diff options
author | Scott Dodson <sdodson@redhat.com> | 2018-02-08 19:44:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-08 19:44:21 -0500 |
commit | 3489d4f75fd2773f5fa5a684b82bf8ca44f1fa02 (patch) | |
tree | 77fc852e5bd7aa2d346b3cdd0a178d5b65f7146b /roles | |
parent | 0217c03b15bbf5ffcd5491f789de65ecb6e22ddd (diff) | |
parent | e4f4204c4dcb5d9d300a2e2cca9cabe4b7afcf94 (diff) | |
download | openshift-3489d4f75fd2773f5fa5a684b82bf8ca44f1fa02.tar.gz openshift-3489d4f75fd2773f5fa5a684b82bf8ca44f1fa02.tar.bz2 openshift-3489d4f75fd2773f5fa5a684b82bf8ca44f1fa02.tar.xz openshift-3489d4f75fd2773f5fa5a684b82bf8ca44f1fa02.zip |
Merge pull request #6926 from abutcher/etcd-ca-host
Determine which host is the etcd CA host
Diffstat (limited to 'roles')
-rw-r--r-- | roles/lib_utils/filter_plugins/oo_filters.py | 2 | ||||
-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 |
4 files changed, 48 insertions, 1 deletions
diff --git a/roles/lib_utils/filter_plugins/oo_filters.py b/roles/lib_utils/filter_plugins/oo_filters.py index 574743ff1..c355115b5 100644 --- a/roles/lib_utils/filter_plugins/oo_filters.py +++ b/roles/lib_utils/filter_plugins/oo_filters.py @@ -126,7 +126,7 @@ def lib_utils_oo_collect(data_list, attribute=None, filters=None): raise errors.AnsibleFilterError( "lib_utils_oo_collect expects filter to be a dict") retval.extend([get_attr(d, attribute) for d in data if ( - all([d.get(key, None) == filters[key] for key in filters]))]) + all([get_attr(d, key) == filters[key] for key in filters]))]) else: retval.extend([get_attr(d, attribute) for d in data]) 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 |