- name: Install consul deps apt: name: "{{ consul_deps_packages }}" update_cache: yes - name: Add gpg keys for consul ansible.builtin.apt_key: url: "{{ item.url }}" keyring: "{{ item.keyring }}" when: consul_install_official_repo loop: "{{ consul_apt_key }}" - name: Add Hashicorp repository apt_repository: repo: "{{ item.repo }}" state: present filename: "{{ item.filename }}" update_cache: yes when: consul_install_official_repo loop: "{{ consul_apt_repository }}" - name: Gather packages package_facts: manager: auto - name: Set fact about Consul package set_fact: consul_installed_package: "{{ ansible_facts.packages[consul_package_name][0]['name'] }}" when: consul_package_name in ansible_facts.packages - name: Mask Consul before install ansible.builtin.systemd: name: "{{ consul_package_name }}" masked: yes when: consul_package_name not in ansible_facts.packages or ansible_facts.packages[consul_package_name][0]['version'] != (consul_version|string + "-" + consul_version_build|string) - name: "Install {{ consul_package_name }}-{{ consul_version }}-{{ consul_version_build }}" apt: name: "{{ consul_package }}-{{ consul_version_build }}" update_cache: yes register: consul_setup when: consul_package_name not in ansible_facts.packages - name: "Update {{ consul_package_name }}-{{ consul_version }}-{{ consul_version_build }}" apt: name: "{{ consul_package }}-{{ consul_version_build }}" update_cache: yes register: consul_setup notify: Restart consul when: - consul_package_name in ansible_facts.packages - ansible_facts.packages[consul_package_name][0]['version'] != (consul_version|string + "-" + consul_version_build|string) - name: Fix "/etc/consul.d/consul.env" copy: content: "" dest: /etc/consul.d/consul.env owner: consul group: consul