consul/tasks/Debian/main.yaml

46 lines
1.1 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
ansible.builtin.apt_key:
url: "{{ item.url }}"
keyring: "{{ item.keyring }}"
loop: "{{ consul_apt_key }}"
- name: Add Hashicorp repository
apt_repository:
repo: "{{ item.repo }}"
state: present
filename: "{{ item.filename }}"
update_cache: yes
loop: "{{ consul_apt_repository }}"
- name: Check if Consul is installed
ansible.builtin.shell: dpkg-query -l {{ consul_package_name }} 2>&1 | grep {{ consul_version }}
ignore_errors: True
register: is_consul
changed_when: is_consul.rc != 0
failed_when: False
- name: Mask Consul before install
ansible.builtin.systemd:
name: "{{ consul_package_name }}"
masked: yes
when: is_consul.rc != 0
- name: "Install {{ consul_package_name }}-{{ consul_version }}"
apt:
name: "{{ consul_package }}"
update_cache: yes
register: consul_setup
when: is_consul.rc != 0
- name: Fix "/etc/consul.d/consul.env"
copy:
content: ""
dest: /etc/consul.d/consul.env
owner: consul
group: consul