diff --git a/defaults/main.yaml b/defaults/main.yaml index 9906f29..5c89899 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -1,4 +1,4 @@ -consul_version: "1.12.9" +consul_version: "1.14.5" consul_config_path: "/etc/consul.d" consul_data_path: "/opt/consul" consul_user: "consul" diff --git a/tasks/Debian/main.yaml b/tasks/Debian/main.yaml index 0877259..3bcf440 100644 --- a/tasks/Debian/main.yaml +++ b/tasks/Debian/main.yaml @@ -1,26 +1,23 @@ -- name: Add gpg package +- name: Install consul deps apt: - name: gpg + name: "{{ consul_deps_packages }}" + update_cache: yes - name: Add gpg keys for consul - environment: - http_proxy: "{{ consul_install_http_proxy | default(omit) }}" - https_proxy: "{{ consul_install_https_proxy | default(omit) }}" ansible.builtin.apt_key: url: "{{ item.url }}" keyring: "{{ item.keyring }}" + when: consul_install_repo loop: "{{ consul_apt_key }}" - name: Add Hashicorp repository - environment: - http_proxy: "{{ consul_install_http_proxy | default(omit) }}" - https_proxy: "{{ consul_install_https_proxy | default(omit) }}" apt_repository: repo: "{{ item.repo }}" state: present filename: "{{ item.filename }}" update_cache: yes - loop: "{{ consul_apt_repository }}" + when: consul_install_repo + loop: "{{ consul_apt_repository }}" - name: Gather packages package_facts: @@ -35,30 +32,24 @@ 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 + "-" + consul_version_build) + 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 }}" - environment: - http_proxy: "{{ consul_install_http_proxy | default(omit) }}" - https_proxy: "{{ consul_install_https_proxy | default(omit) }}" apt: name: "{{ consul_package }}-{{ consul_version_build }}" update_cache: yes register: consul_setup - when: consul_package_name not in ansible_facts.packages + when: consul_package_name not in ansible_facts.packages - name: "Update {{ consul_package_name }}-{{ consul_version }}-{{ consul_version_build }}" - environment: - http_proxy: "{{ consul_install_http_proxy | default(omit) }}" - https_proxy: "{{ consul_install_https_proxy | default(omit) }}" 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 + "-" + consul_version_build) + 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: @@ -66,4 +57,3 @@ dest: /etc/consul.d/consul.env owner: consul group: consul - diff --git a/tasks/RedHat/main.yaml b/tasks/RedHat/main.yaml index 31dfcbe..ce2f014 100644 --- a/tasks/RedHat/main.yaml +++ b/tasks/RedHat/main.yaml @@ -10,9 +10,6 @@ when: consul_install_repo - name: "Install {{ consul_package_name }}-{{ consul_version }} from official repository" - environment: - http_proxy: "{{ consul_install_http_proxy | default(omit) }}" - https_proxy: "{{ consul_install_https_proxy | default(omit) }}" dnf: name: "{{ consul_package }}" state: present @@ -24,9 +21,6 @@ when: consul_install_repo - name: "Install {{ consul_package_name }}-{{ consul_version }}" - environment: - http_proxy: "{{ consul_install_http_proxy | default(omit) }}" - https_proxy: "{{ consul_install_https_proxy | default(omit) }}" dnf: name: "{{ consul_package }}" state: present diff --git a/vars/Debian.yaml b/vars/Debian.yaml index e471aa2..9692cb0 100644 --- a/vars/Debian.yaml +++ b/vars/Debian.yaml @@ -6,6 +6,10 @@ consul_apt_key: consul_apt_repository: - repo: deb [arch=amd64] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main filename: hashicorp + +consul_deps_packages: + - gnupg2 + consul_version_build: "1" consul_package_name_regex: "{{ consul_package_name }}-{{ consul_version }}-{{ consul_version_build }}" consul_ssl_update_ca_command: "update-ca-certificates --fresh"