Don't delete non declared services when using consul_services
rgarrigue opened this issue · 1 comments
rgarrigue commented
Hi there
I just discovered consul_services. Why not. Tried using it, it wiped all services files as defined here. That's not documented. And that's definitively not possible for anyone with services files coming from multiples sources.
Would you mind adding a dedicated flag to prevent that ?
sandipb commented
There might be a workaround for this. You can find out the list of the files in consul.d and set a variable managed_files
to that while running this module. It will not remove those files.
- name: Find All files in consul.d
find:
paths: /etc/consul.d
patterns: "*.json"
register: consul_d_json
tags: ["consul_services"]
no_log: true
- name: Install consul
ansible.builtin.import_role:
name: ansible-consul
vars:
managed_files: "{{ consul_d_json.files | map(attribute='path') | list }}"