update consul

This commit is contained in:
ace 2023-03-28 22:14:08 +03:00
parent 7eab49a6d2
commit 2eee7d69d3
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
4 changed files with 16 additions and 28 deletions

View File

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

View File

@ -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

View File

@ -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

View File

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