docker_upgrade.yml 2.6 KB

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