mirror of
https://gitea.0xace.cc/ansible-galaxy/consul.git
synced 2024-11-25 06:37:18 +00:00
43 lines
1.2 KiB
YAML
43 lines
1.2 KiB
YAML
|
- name: Make sure handlers are flushed immediately
|
||
|
meta: flush_handlers
|
||
|
|
||
|
- name: Load a variable file based on the OS type
|
||
|
include_vars: "{{ lookup('first_found', params) }}"
|
||
|
vars:
|
||
|
params:
|
||
|
files:
|
||
|
- "{{ ansible_facts['distribution'] }}.yaml"
|
||
|
- "{{ ansible_facts['os_family'] }}.yaml"
|
||
|
paths:
|
||
|
- "vars"
|
||
|
|
||
|
- name: Consul cluster pre-check
|
||
|
include_tasks: pre_check.yaml
|
||
|
when: inventory_hostname in groups[consul_server_group]
|
||
|
|
||
|
- name: "Install Consul for {{ ansible_facts['os_family'] }}"
|
||
|
include_tasks: "{{ ansible_facts['os_family'] }}/main.yaml"
|
||
|
|
||
|
- name: Bootstrap Consul
|
||
|
include_tasks: bootstrap.yaml
|
||
|
when: inventory_hostname in groups[consul_server_group]
|
||
|
|
||
|
- name: Create Consul configuration
|
||
|
import_tasks: config.yaml
|
||
|
|
||
|
- name: Enable and start Consul
|
||
|
systemd:
|
||
|
daemon_reload: true
|
||
|
name: consul
|
||
|
enabled: true
|
||
|
state: started
|
||
|
masked: no
|
||
|
tags: consul, consul_start
|
||
|
|
||
|
- name: Join new server node to cluster
|
||
|
import_tasks: join.yaml
|
||
|
when:
|
||
|
- hostvars[inventory_hostname]['ansible_host'] not in cluster_node_list
|
||
|
- cluster_node_list | length != 0
|
||
|
- inventory_hostname in groups[consul_server_group]
|