ansible-roles/roles/consul/tasks/install.yml

70 lines
1.8 KiB
YAML
Raw Normal View History

2022-07-21 01:00:17 +02:00
---
- name: Install needed tools
package:
name:
- tar
- zstd
- unzip
2022-09-04 14:00:17 +02:00
- acl
2022-07-21 01:00:17 +02:00
tags: consul
- when: consul_install_mode != 'none'
block:
- name: Download consul
get_url:
url: "{{ consul_archive_url }}"
dest: "{{ consul_root_dir }}/tmp"
checksum: sha256:{{ consul_archive_sha256 }}
- name: Extract the archive
unarchive:
src: "{{ consul_root_dir }}/tmp/consul_{{ consul_version }}_linux_amd64.zip"
dest: "{{ consul_root_dir }}/tmp"
remote_src: True
- name: Install consul binary
copy:
src: "{{ consul_root_dir }}/tmp/consul"
dest: "{{ consul_root_dir }}/bin/consul"
remote_src: True
mode: 755
2022-09-21 10:00:09 +02:00
notify: restart consul
2022-07-21 01:00:17 +02:00
- name: Link in /usr/local/bin
file: src={{ consul_root_dir }}/bin/consul dest=/usr/local/bin/consul state=link force=True
tags: consul
- name: Install bash completion support
copy:
content: |
complete -C {{ consul_root_dir }}/bin/consul consul
dest: /etc/bash_completion.d/consul
2022-09-08 18:00:11 +02:00
mode: 0644
2022-07-21 01:00:17 +02:00
tags: consul
- name: Deploy systemd service unit
template: src=consul.service.j2 dest=/etc/systemd/system/consul.service
register: consul_unit
notify: restart consul
tags: consul
2022-09-04 14:00:17 +02:00
- name: Install consul-template unit
template: src=consul-template-consul.service.j2 dest=/etc/systemd/system/consul-template-consul.service
register: consul_template_tpl_unit
notify: restart consul-template-consul
tags: consul
2022-07-21 01:00:17 +02:00
- name: Reload systemd
systemd: daemon_reload=True
2022-09-04 14:00:17 +02:00
when: consul_unit.changed or consul_template_tpl_unit.changed
2022-07-21 01:00:17 +02:00
tags: consul
2022-07-23 14:00:15 +02:00
- name: Install backup hooks
template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/consul mode=755
loop:
- pre
- post
tags: consul