diff options
author | Andrew Butcher <abutcher@redhat.com> | 2018-01-29 15:29:33 -0500 |
---|---|---|
committer | Andrew Butcher <abutcher@redhat.com> | 2018-02-01 16:57:43 -0500 |
commit | 76bbd06963b474237925b97893c2403b3feba496 (patch) | |
tree | 35b2409dbc6753270a0f595f4b2c79fbbfe3ea8f /roles/openshift_etcd_facts | |
parent | 6ee7a3baa0d46c3ab29050b61fea92ffb350ee35 (diff) | |
download | openshift-76bbd06963b474237925b97893c2403b3feba496.tar.gz openshift-76bbd06963b474237925b97893c2403b3feba496.tar.bz2 openshift-76bbd06963b474237925b97893c2403b3feba496.tar.xz openshift-76bbd06963b474237925b97893c2403b3feba496.zip |
Determine which etcd host is the etcd_ca_host rather than assume it is the first host in the etcd host group.
Diffstat (limited to 'roles/openshift_etcd_facts')
-rw-r--r-- | roles/openshift_etcd_facts/defaults/main.yml | 2 | ||||
-rw-r--r-- | roles/openshift_etcd_facts/tasks/main.yml | 1 | ||||
-rw-r--r-- | roles/openshift_etcd_facts/tasks/set_etcd_ca_host.yml | 44 |
3 files changed, 47 insertions, 0 deletions
diff --git a/roles/openshift_etcd_facts/defaults/main.yml b/roles/openshift_etcd_facts/defaults/main.yml new file mode 100644 index 000000000..d13e7c912 --- /dev/null +++ b/roles/openshift_etcd_facts/defaults/main.yml @@ -0,0 +1,2 @@ +--- +etcd_ca_host_group: "oo_etcd_to_config" diff --git a/roles/openshift_etcd_facts/tasks/main.yml b/roles/openshift_etcd_facts/tasks/main.yml index ed97d539c..86546f4e3 100644 --- a/roles/openshift_etcd_facts/tasks/main.yml +++ b/roles/openshift_etcd_facts/tasks/main.yml @@ -1 +1,2 @@ --- +- import_tasks: set_etcd_ca_host.yml diff --git a/roles/openshift_etcd_facts/tasks/set_etcd_ca_host.yml b/roles/openshift_etcd_facts/tasks/set_etcd_ca_host.yml new file mode 100644 index 000000000..bf8d28a9b --- /dev/null +++ b/roles/openshift_etcd_facts/tasks/set_etcd_ca_host.yml @@ -0,0 +1,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 |