blob: bf8d28a9b769afdbb75eed093137206f47aa1f0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
---
- name: Check for CA indicator files
stat:
path: "{{ item.0 }}"
delegate_to: "{{ item.1 }}"
with_nested:
- - /etc/etcd/ca
- /etc/etcd/generated_certs
- "{{ groups[etcd_ca_host_group] }}"
register: __etcd_ca_host_stat
run_once: true
# Collect ansible_host (inventory hostname) of hosts with /etc/etcd/ca
# and /etc/etcd/generated_certs directories.
- set_fact:
__etcd_ca_dir_hosts: "{{ __etcd_ca_host_stat.results
| lib_utils_oo_collect('_ansible_delegated_vars.ansible_host',
filters={'stat.path':'/etc/etcd/ca','stat.exists':True}) }}"
__etcd_generated_certs_dir_hosts: "{{ __etcd_ca_host_stat.results
| lib_utils_oo_collect('_ansible_delegated_vars.ansible_host',
filters={'stat.path':'/etc/etcd/generated_certs','stat.exists':True}) }}"
run_once: true
# __etcd_ca_hosts is the intersection of hosts which have /etc/etcd/ca
# and /etc/etcd/generated_certs directories.
- set_fact:
__etcd_ca_hosts: "{{ __etcd_ca_dir_hosts | intersect(__etcd_generated_certs_dir_hosts) }}"
run_once: true
# __etcd_ca_hosts should only contain one host. If more than one host
# is able to be an etcd CA host then we will use the first.
- set_fact:
etcd_ca_host: "{{ __etcd_ca_hosts[0] }}"
when:
- __etcd_ca_hosts | length > 0
- etcd_ca_host is not defined
# No etcd_ca_host was found in __etcd_ca_hosts. This is probably a
# fresh installation so we will default to the first member of the
# etcd host group.
- set_fact:
etcd_ca_host: "{{ groups[etcd_ca_host_group].0 }}"
when:
- etcd_ca_host is not defined
|