consul/tasks/main.yaml

54 lines
1.6 KiB
YAML
Raw Normal View History

2022-07-28 14:14:26 +00:00
- 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"
2023-02-17 15:13:34 +00:00
- name: Set facts about needed vars
set_fact:
consul_version_build: "{{ consul_version_build }}"
when: ansible_os_family == 'Debian'
2023-02-10 14:40:44 +00:00
2022-07-28 14:14:26 +00:00
- 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"
2022-09-06 12:59:08 +00:00
- name: SSL certificates generation
2024-05-16 14:57:54 +00:00
#import_tasks: cacert.yaml
2024-03-19 10:56:23 +00:00
import_tasks: ssl/main.yaml
2022-09-06 12:59:08 +00:00
when: consul_ssl
2022-07-28 14:14:26 +00:00
- 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
2022-09-06 12:59:08 +00:00
register: consul_enable_and_start
2022-07-28 14:14:26 +00:00
tags: consul, consul_start
- name: Join new server node to cluster
import_tasks: join.yaml
when:
2023-02-07 20:11:11 +00:00
- (hostvars[inventory_hostname]['ansible_host'] is defined and hostvars[inventory_hostname]['ansible_host'] not in cluster_node_list) or hostvars[inventory_hostname]['ansible_default_ipv4']['address'] not in cluster_node_list
2022-07-28 14:14:26 +00:00
- cluster_node_list | length != 0
- inventory_hostname in groups[consul_server_group]