upgrade_nodes.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ---
  2. - name: Drain and upgrade nodes
  3. hosts: oo_nodes_to_upgrade:!oo_masters_to_config
  4. # This var must be set with -e on invocation, as it is not a per-host inventory var
  5. # and is evaluated early. Values such as "20%" can also be used.
  6. serial: "{{ openshift_upgrade_nodes_serial | default(1) }}"
  7. max_fail_percentage: "{{ openshift_upgrade_nodes_max_fail_percentage | default(0) }}"
  8. pre_tasks:
  9. - name: Load lib_openshift modules
  10. include_role:
  11. name: lib_openshift
  12. # TODO: To better handle re-trying failed upgrades, it would be nice to check if the node
  13. # or docker actually needs an upgrade before proceeding. Perhaps best to save this until
  14. # we merge upgrade functionality into the base roles and a normal config.yml playbook run.
  15. - name: Mark node unschedulable
  16. oc_adm_manage_node:
  17. node: "{{ openshift.node.nodename | lower }}"
  18. schedulable: False
  19. delegate_to: "{{ groups.oo_first_master.0 }}"
  20. retries: 10
  21. delay: 5
  22. register: node_unschedulable
  23. until: node_unschedulable|succeeded
  24. - name: Drain Node for Kubelet upgrade
  25. command: >
  26. {{ hostvars[groups.oo_first_master.0].openshift.common.admin_binary }} drain {{ openshift.node.nodename | lower }} --force --delete-local-data --ignore-daemonsets
  27. delegate_to: "{{ groups.oo_first_master.0 }}"
  28. roles:
  29. - lib_openshift
  30. - openshift_facts
  31. - docker
  32. - openshift_node_dnsmasq
  33. - openshift_node_upgrade
  34. - role: openshift_excluder
  35. r_openshift_excluder_action: enable
  36. r_openshift_excluder_service_type: "{{ openshift.common.service_type }}"
  37. post_tasks:
  38. - name: Set node schedulability
  39. oc_adm_manage_node:
  40. node: "{{ openshift.node.nodename | lower }}"
  41. schedulable: True
  42. delegate_to: "{{ groups.oo_first_master.0 }}"
  43. retries: 10
  44. delay: 5
  45. register: node_schedulable
  46. until: node_schedulable|succeeded
  47. when: node_unschedulable|changed