ansible-consul/tasks/main.yml
2022-03-12 11:17:02 +01:00

35 lines
793 B
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: ensure service is started
systemd:
name: "{{ consul_service_name }}"
state: started
enabled: True