docker_upgrade.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ---
  2. - import_playbook: ../../../../init/evaluate_groups.yml
  3. vars:
  4. # Do not allow adding hosts during upgrade.
  5. g_new_master_hosts: []
  6. g_new_node_hosts: []
  7. - import_playbook: ../initialize_nodes_to_upgrade.yml
  8. - name: Check for appropriate Docker versions
  9. hosts: oo_masters_to_config:oo_nodes_to_upgrade:oo_etcd_to_config
  10. roles:
  11. - openshift_facts
  12. tasks:
  13. - fail:
  14. msg: Cannot upgrade Docker on Atomic operating systems.
  15. when: openshift_is_atomic | bool
  16. - import_role:
  17. name: container_runtime
  18. tasks_from: docker_upgrade_check.yml
  19. when: docker_upgrade is not defined or docker_upgrade | bool
  20. # If a node fails, halt everything, the admin will need to clean up and we
  21. # don't want to carry on, potentially taking out every node. The playbook can safely be re-run
  22. # and will not take any action on a node already running the requested docker version.
  23. - name: Drain and upgrade nodes
  24. hosts: oo_masters_to_config:oo_nodes_to_upgrade:oo_etcd_to_config
  25. serial: 1
  26. any_errors_fatal: true
  27. roles:
  28. - openshift_facts
  29. - lib_openshift
  30. tasks:
  31. - name: Mark node unschedulable
  32. oc_adm_manage_node:
  33. node: "{{ openshift.node.nodename | lower }}"
  34. schedulable: False
  35. delegate_to: "{{ groups.oo_first_master.0 }}"
  36. retries: 10
  37. delay: 5
  38. register: node_unschedulable
  39. until: node_unschedulable is succeeded
  40. when:
  41. - l_docker_upgrade is defined
  42. - l_docker_upgrade | bool
  43. - inventory_hostname in groups.oo_nodes_to_upgrade
  44. - name: Drain Node for Kubelet upgrade
  45. command: >
  46. {{ openshift_client_binary }} adm drain {{ openshift.node.nodename }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig --force --delete-local-data --ignore-daemonsets
  47. delegate_to: "{{ groups.oo_first_master.0 }}"
  48. when: l_docker_upgrade is defined and l_docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_upgrade
  49. register: l_docker_upgrade_drain_result
  50. until: not (l_docker_upgrade_drain_result is failed)
  51. retries: 60
  52. delay: 60
  53. - include_tasks: tasks/upgrade.yml
  54. when: l_docker_upgrade is defined and l_docker_upgrade | bool
  55. - name: Set node schedulability
  56. oc_adm_manage_node:
  57. node: "{{ openshift.node.nodename | lower }}"
  58. schedulable: True
  59. delegate_to: "{{ groups.oo_first_master.0 }}"
  60. retries: 10
  61. delay: 5
  62. register: node_schedulable
  63. until: node_schedulable is succeeded
  64. when: node_unschedulable is changed