consul/tasks/Debian/main.yaml

70 lines
2.3 KiB
YAML
Raw Normal View History

2022-07-28 14:14:26 +00:00
- name: Add gpg package
apt:
name: gpg
- name: Add gpg keys for consul
2023-02-09 20:14:16 +00:00
environment:
http_proxy: "{{ consul_install_http_proxy | default(omit) }}"
https_proxy: "{{ consul_install_https_proxy | default(omit) }}"
2022-07-28 14:14:26 +00:00
ansible.builtin.apt_key:
url: "{{ item.url }}"
keyring: "{{ item.keyring }}"
loop: "{{ consul_apt_key }}"
- name: Add Hashicorp repository
2023-02-09 20:14:16 +00:00
environment:
http_proxy: "{{ consul_install_http_proxy | default(omit) }}"
https_proxy: "{{ consul_install_https_proxy | default(omit) }}"
2022-07-28 14:14:26 +00:00
apt_repository:
repo: "{{ item.repo }}"
state: present
filename: "{{ item.filename }}"
update_cache: yes
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
2022-07-28 14:14:26 +00:00
- 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 + "-" + consul_version_build)
2022-07-28 14:14:26 +00:00
2023-02-07 20:11:11 +00:00
- name: "Install {{ consul_package_name }}-{{ consul_version }}-{{ consul_version_build }}"
2023-02-09 20:14:16 +00:00
environment:
http_proxy: "{{ consul_install_http_proxy | default(omit) }}"
https_proxy: "{{ consul_install_https_proxy | default(omit) }}"
2022-07-28 14:14:26 +00:00
apt:
2023-02-07 20:11:11 +00:00
name: "{{ consul_package }}-{{ consul_version_build }}"
2022-07-28 14:14:26 +00:00
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 }}"
2023-02-09 20:14:16 +00:00
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_update
notify: Restart consul
when:
- consul_package_name in ansible_facts.packages
- ansible_facts.packages[consul_package_name][0]['version'] != (consul_version + "-" + consul_version_build)
2022-07-28 14:14:26 +00:00
- name: Fix "/etc/consul.d/consul.env"
copy:
content: ""
dest: /etc/consul.d/consul.env
owner: consul
group: consul