From 7f232159717b9fdb13cbbea550623ed61aad5ac7 Mon Sep 17 00:00:00 2001 From: Russell Teague Date: Fri, 17 Feb 2017 13:21:26 -0500 Subject: Updating node playbooks to use oc_obj --- playbooks/common/openshift-node/restart.yml | 20 ++++++++++++---- roles/openshift_node_upgrade/tasks/main.yml | 37 ++++++++++++++++------------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/playbooks/common/openshift-node/restart.yml b/playbooks/common/openshift-node/restart.yml index 6e9b1cca3..5e1df951c 100644 --- a/playbooks/common/openshift-node/restart.yml +++ b/playbooks/common/openshift-node/restart.yml @@ -2,16 +2,24 @@ - name: Restart nodes hosts: oo_nodes_to_config serial: "{{ openshift_restart_nodes_serial | default(1) }}" + + roles: + - lib_openshift + tasks: - name: Restart docker - service: name=docker state=restarted + service: + name: docker + state: restarted - name: Update docker facts openshift_facts: role: docker - name: Restart containerized services - service: name={{ item }} state=started + service: + name: "{{ item }}" + state: started with_items: - etcd_container - openvswitch @@ -36,12 +44,14 @@ state: restarted - name: Wait for node to be ready - command: > - {{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} get node {{ openshift.common.hostname | lower }} --no-headers + oc_obj: + state: list + kind: node + name: "{{ openshift.common.hostname | lower }}" register: node_output delegate_to: "{{ groups.oo_first_master.0 }}" when: inventory_hostname in groups.oo_nodes_to_config - until: "{{ node_output.stdout.split()[1].startswith('Ready')}}" + until: node_output.results.results[0].status.conditions | selectattr('type', 'equalto', 'Ready') | map(attribute='status') | join | bool == True # Give the node two minutes to come back online. retries: 24 delay: 5 diff --git a/roles/openshift_node_upgrade/tasks/main.yml b/roles/openshift_node_upgrade/tasks/main.yml index 609ca2a6e..96e296a3b 100644 --- a/roles/openshift_node_upgrade/tasks/main.yml +++ b/roles/openshift_node_upgrade/tasks/main.yml @@ -13,7 +13,10 @@ vars: # We will restart Docker ourselves after everything is ready: skip_docker_restart: True - when: l_docker_upgrade is defined and l_docker_upgrade | bool and not openshift.common.is_atomic | bool + when: + - l_docker_upgrade is defined + - l_docker_upgrade | bool + - not openshift.common.is_containerized | bool - include: "{{ node_config_hook }}" when: node_config_hook is defined @@ -25,14 +28,19 @@ when: not openshift.common.is_containerized | bool - name: Remove obsolete docker-sdn-ovs.conf - file: path=/etc/systemd/system/docker.service.d/docker-sdn-ovs.conf state=absent - when: (deployment_type == 'openshift-enterprise' and openshift_release | version_compare('3.4', '>=')) or (deployment_type == 'origin' and openshift_release | version_compare('1.4', '>=')) + file: + path: "/etc/systemd/system/docker.service.d/docker-sdn-ovs.conf" + state: absent + when: (deployment_type == 'openshift-enterprise' and openshift_release | version_compare('3.4', '>=')) + or (deployment_type == 'origin' and openshift_release | version_compare('1.4', '>=')) - include: containerized_node_upgrade.yml when: openshift.common.is_containerized | bool - name: Ensure containerized services stopped before Docker restart - service: name={{ item }} state=stopped + service: + name: "{{ item }}" + state: stopped with_items: - etcd_container - openvswitch @@ -62,22 +70,19 @@ - include: docker/restart.yml - name: Restart rpm node service - service: name="{{ openshift.common.service_type }}-node" state=restarted + service: + name: "{{ openshift.common.service_type }}-node" + state: restarted when: not openshift.common.is_containerized | bool - name: Wait for node to be ready - command: > - {{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} get node {{ openshift.common.hostname | lower }} --no-headers + oc_obj: + state: list + kind: node + name: "{{ openshift.common.hostname | lower }}" register: node_output delegate_to: "{{ groups.oo_first_master.0 }}" - until: "{{ node_output.stdout.split()[1].startswith('Ready')}}" - # Give the node two minutes to come back online. Note that we pre-pull images now - # so containerized services should restart quickly as well. + until: node_output.results.results[0].status.conditions | selectattr('type', 'equalto', 'Ready') | map(attribute='status') | join | bool == True + # Give the node two minutes to come back online. retries: 24 delay: 5 - # AUDIT:changed_when: `false` because we are only inspecting the - # state of the node, we aren't changing anything (we changed node - # service state in the previous task). You could say we shouldn't - # override this because something will be changing (the state of a - # service), but that should be part of the last task. - changed_when: false -- cgit v1.2.1