52 lines
1.2 KiB
YAML
52 lines
1.2 KiB
YAML
---
|
|
- name: Include OS-specific variables
|
|
include_vars: "{{ item }}"
|
|
with_first_found:
|
|
- files:
|
|
- "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
|
|
- "{{ ansible_os_family }}.yml"
|
|
|
|
- name: install package
|
|
package:
|
|
name: "{{ consul_os_package }}"
|
|
state: present
|
|
|
|
- name: encure data dir exist
|
|
file:
|
|
state: directory
|
|
owner: consul
|
|
path: "{{ consul_data_dir }}"
|
|
mode: 0755
|
|
|
|
- name: apply config template
|
|
block:
|
|
- name: server template
|
|
template:
|
|
src: config.hcl.j2
|
|
dest: /etc/consul.d/config.hcl
|
|
owner: consul
|
|
mode: 0644
|
|
notify: reload consul configuration
|
|
|
|
- name: configure backup
|
|
block:
|
|
- name: copy backup script
|
|
copy:
|
|
dest: "{{ consul_data_dir }}/cs-backup.sh"
|
|
mode: 0744
|
|
owner: consul
|
|
src: cs-backup.sh
|
|
- name: consul snaphot cron.d
|
|
cron:
|
|
name: consul backup
|
|
user: consul
|
|
state: present
|
|
job: "{{ consul_data_dir }}/cs-backup.sh {{ consul_backup_location }}"
|
|
hour: "{{consul_cron_hour}}"
|
|
when: consul_snapshot
|
|
- name: ensure service is started
|
|
systemd:
|
|
name: "{{ consul_service_name }}"
|
|
state: started
|
|
enabled: True
|