mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-07-27 00:05:44 +02:00
Update to 2022-08-09 13:00
This commit is contained in:
@@ -1,12 +1,62 @@
|
||||
---
|
||||
|
||||
- name: Deploy consul configuration
|
||||
template:
|
||||
src: consul.hcl.j2
|
||||
dest: "{{ consul_root_dir }}/etc/consul.hcl"
|
||||
owner: root
|
||||
group: "{{ consul_user }}"
|
||||
mode: 0640
|
||||
validate: consul validate -config-format=hcl %s
|
||||
notify: restart consul
|
||||
block:
|
||||
- name: Deploy consul configuration
|
||||
template:
|
||||
src: consul.hcl.j2
|
||||
dest: "{{ consul_root_dir }}/etc/consul.hcl"
|
||||
owner: root
|
||||
group: "{{ consul_user }}"
|
||||
mode: 0640
|
||||
backup: True
|
||||
register: consul_main_conf
|
||||
notify: restart consul
|
||||
|
||||
- name: Deploy consul reloadable configuration
|
||||
template:
|
||||
src: reload.hcl.j2
|
||||
dest: "{{ consul_root_dir }}/etc/reload.hcl"
|
||||
owner: root
|
||||
group: "{{ consul_user }}"
|
||||
mode: 0640
|
||||
backup: True
|
||||
register: consul_reload_conf
|
||||
notify: reload consul
|
||||
|
||||
- name: Validate configuration
|
||||
command: consul validate {{ consul_root_dir }}/etc
|
||||
changed_when: False
|
||||
become_user: "{{ consul_user }}"
|
||||
register: consul_conf_validation
|
||||
|
||||
rescue:
|
||||
- block:
|
||||
- name: Restore main configuration
|
||||
copy:
|
||||
src: "{{ consul_main_conf.backup_file }}"
|
||||
dest: "{{ consul_root_dir }}/etc/consul.hcl"
|
||||
remote_src: True
|
||||
owner: root
|
||||
group: "{{ consul_user }}"
|
||||
mode: 0640
|
||||
when: consul_main_conf.backup_file is defined
|
||||
|
||||
- name: Restore reloadable configuration
|
||||
copy:
|
||||
src: "{{ consul_reload_conf.backup_file }}"
|
||||
dest: "{{ consul_root_dir }}/etc/reload.hcl"
|
||||
remote_src: True
|
||||
owner: root
|
||||
group: "{{ consul_user }}"
|
||||
mode: 0640
|
||||
when: consul_reload_conf.backup_file is defined
|
||||
|
||||
tags: consul
|
||||
|
||||
- name: Fail if configuration validation failed
|
||||
fail:
|
||||
msg: "Failed to validate configuration: {{ consul_conf_validation.stdout }}"
|
||||
when: consul_conf_validation.rc != 0
|
||||
tags: consul
|
||||
|
||||
|
Reference in New Issue
Block a user