upgrade_nodes.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. any_errors_fatal: true
  8. pre_tasks:
  9. # TODO: To better handle re-trying failed upgrades, it would be nice to check if the node
  10. # or docker actually needs an upgrade before proceeding. Perhaps best to save this until
  11. # we merge upgrade functionality into the base roles and a normal config.yml playbook run.
  12. - name: Determine if node is currently scheduleable
  13. command: >
  14. {{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} get node {{ openshift.node.nodename | lower }} -o json
  15. register: node_output
  16. delegate_to: "{{ groups.oo_first_master.0 }}"
  17. changed_when: false
  18. - set_fact:
  19. was_schedulable: "{{ 'unschedulable' not in (node_output.stdout | from_json).spec }}"
  20. - name: Mark node unschedulable
  21. command: >
  22. {{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} adm manage-node {{ openshift.node.nodename | lower }} --schedulable=false
  23. delegate_to: "{{ groups.oo_first_master.0 }}"
  24. # NOTE: There is a transient "object has been modified" error here, allow a couple
  25. # retries for a more reliable upgrade.
  26. register: node_unsched
  27. until: node_unsched.rc == 0
  28. retries: 3
  29. delay: 1
  30. - name: Drain Node for Kubelet upgrade
  31. command: >
  32. {{ hostvars[groups.oo_first_master.0].openshift.common.admin_binary }} drain {{ openshift.node.nodename | lower }} --force --delete-local-data
  33. delegate_to: "{{ groups.oo_first_master.0 }}"
  34. roles:
  35. - openshift_facts
  36. - docker
  37. - openshift_node_upgrade
  38. post_tasks:
  39. - name: Set node schedulability
  40. command: >
  41. {{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} adm manage-node {{ openshift.node.nodename | lower }} --schedulable=true
  42. delegate_to: "{{ groups.oo_first_master.0 }}"
  43. when: was_schedulable | bool
  44. register: node_sched
  45. until: node_sched.rc == 0
  46. retries: 3
  47. delay: 1
  48. - include: ../reset_excluder.yml
  49. tags:
  50. - always