diff options
author | Devan Goodwin <dgoodwin@redhat.com> | 2016-09-19 14:57:13 -0300 |
---|---|---|
committer | Devan Goodwin <dgoodwin@redhat.com> | 2016-09-29 10:26:01 -0300 |
commit | 0e7e7f6b45ace8a3a9516c8800e5cf84d7aa14fa (patch) | |
tree | 44b6aaf5d466d584194ffaf3c14ba8402a89aca9 /playbooks/common/openshift-cluster/upgrades/initialize_nodes_to_upgrade.yml | |
parent | 67fbf22ec96d07b8646de701b60e2718a4d6bef3 (diff) | |
download | openshift-0e7e7f6b45ace8a3a9516c8800e5cf84d7aa14fa.tar.gz openshift-0e7e7f6b45ace8a3a9516c8800e5cf84d7aa14fa.tar.bz2 openshift-0e7e7f6b45ace8a3a9516c8800e5cf84d7aa14fa.tar.xz openshift-0e7e7f6b45ace8a3a9516c8800e5cf84d7aa14fa.zip |
Allow filtering nodes to upgrade by label.
Diffstat (limited to 'playbooks/common/openshift-cluster/upgrades/initialize_nodes_to_upgrade.yml')
-rw-r--r-- | playbooks/common/openshift-cluster/upgrades/initialize_nodes_to_upgrade.yml | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/playbooks/common/openshift-cluster/upgrades/initialize_nodes_to_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/initialize_nodes_to_upgrade.yml new file mode 100644 index 000000000..4e375ac26 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/initialize_nodes_to_upgrade.yml @@ -0,0 +1,40 @@ +--- +- name: Filter list of nodes to be upgraded if necessary + hosts: oo_first_master + tasks: + - name: Retrieve list of openshift nodes matching upgrade label + command: > + {{ openshift.common.client_binary }} + get nodes + --config={{ openshift.common.config_base }}/master/admin.kubeconfig + --selector={{ openshift_upgrade_nodes_label }} + -o jsonpath='{.items[*].metadata.name}' + register: matching_nodes + changed_when: false + when: openshift_upgrade_nodes_label is defined + + - set_fact: + nodes_to_upgrade: "{{ matching_nodes.stdout.split(' ') }}" + when: openshift_upgrade_nodes_label is defined + + # We got a list of nodes with the label, now we need to match these with inventory hosts + # using their openshift.common.hostname fact. + - name: Map labelled nodes to inventory hosts + add_host: + name: "{{ item }}" + groups: temp_nodes_to_upgrade + ansible_ssh_user: "{{ g_ssh_user | default(omit) }}" + ansible_become: "{{ g_sudo | default(omit) }}" + with_items: " {{ groups['oo_nodes_to_config'] }}" + when: openshift_upgrade_nodes_label is defined and hostvars[item].openshift.common.hostname in nodes_to_upgrade + changed_when: false + + # Build up the oo_nodes_to_upgrade group, use the list filtered by label if + # present, otherwise hit all nodes: + - name: Evaluate oo_nodes_to_upgrade + add_host: + name: "{{ item }}" + groups: oo_nodes_to_upgrade + ansible_ssh_user: "{{ g_ssh_user | default(omit) }}" + ansible_become: "{{ g_sudo | default(omit) }}" + with_items: "{{ groups['temp_nodes_to_upgrade'] | default(groups['oo_nodes_to_config']) }}" |