ansible-consul icon indicating copy to clipboard operation
ansible-consul copied to clipboard

Don't delete non declared services when using consul_services

Open rgarrigue opened this issue 3 years ago • 1 comments

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 ?

rgarrigue avatar Sep 10 '20 15:09 rgarrigue

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 }}"

sandipb avatar Sep 13 '21 13:09 sandipb