legacy_upgrade.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. ---
  2. - name: Calico Upgrade | Validate
  3. hosts: nodes
  4. tasks:
  5. - name: Check legacy upgrade exists
  6. stat:
  7. path: /lib/systemd/system/calico.service
  8. register: sym
  9. - fail:
  10. msg: No service to upgrade
  11. when: not sym.stat.exists
  12. - include_tasks: upgrade_versions.yml
  13. - import_playbook: ../../init/evaluate_groups.yml
  14. - import_playbook: ../../init/basic_facts.yml
  15. - import_playbook: ../../init/cluster_facts.yml
  16. - name: Calico Upgrade | Gather Facts
  17. hosts: oo_first_master
  18. gather_facts: no
  19. pre_tasks:
  20. - set_fact:
  21. openshift_master_etcd_hosts: "{{ hostvars
  22. | lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  23. | lib_utils_oo_collect('openshift.common.hostname')
  24. | default(none, true) }}"
  25. openshift_master_etcd_port: "{{ (etcd_client_port | default('2379')) if (groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config) else none }}"
  26. roles:
  27. - role: openshift_facts
  28. - role: openshift_master_facts
  29. - role: lib_openshift
  30. tasks:
  31. - include_tasks: ../roles/calico_master/tasks/certs.yml
  32. - name: Calico Upgrade | Prepare Nodes
  33. hosts: nodes
  34. gather_facts: no
  35. tasks:
  36. - name: Prepull Images
  37. command: "docker pull {{ calico_node_image }}"
  38. - name: Calico Upgrade | Initiate
  39. hosts: oo_first_master
  40. roles:
  41. - role: openshift_facts
  42. tasks:
  43. - name: Calico Master | Create temp directory
  44. command: mktemp -d /tmp/openshift-ansible-XXXXXXX
  45. register: mktemp
  46. changed_when: False
  47. - name: Calico Master | Write Calico install yaml
  48. template:
  49. dest: "{{ mktemp.stdout }}/calico.yml"
  50. src: ../roles/calico_master/templates/calico.yml.j2
  51. - name: Calico Master | oc adm policy add-scc-to-user privileged system:serviceaccount:kube-system:calico-node
  52. oc_adm_policy_user:
  53. user: system:serviceaccount:kube-system:calico-node
  54. resource_kind: scc
  55. resource_name: privileged
  56. state: present
  57. - name: Calico Master | oc adm policy add-scc-to-user privileged system:serviceaccount:kube-system:calico-kube-controllers
  58. oc_adm_policy_user:
  59. user: system:serviceaccount:kube-system:calico-kube-controllers
  60. resource_kind: scc
  61. resource_name: privileged
  62. state: present
  63. - name: Apply Calico manifest
  64. command: >
  65. {{ openshift_client_binary }} apply
  66. -f {{ mktemp.stdout }}/calico.yml
  67. --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  68. register: calico_create_output
  69. failed_when: "('already exists' not in calico_create_output.stderr) and ('created' not in calico_create_output.stdout) and calico_create_output.rc != 0"
  70. changed_when: ('created' in calico_create_output.stdout)
  71. - name: Delete old policy controller
  72. oc_obj:
  73. name: calico-policy-controller
  74. kind: deployment
  75. state: absent
  76. namespace: kube-system
  77. - name: Calico Upgrade | Upgrade nodes
  78. hosts: nodes
  79. serial: 1
  80. any_errors_fatal: true
  81. tasks:
  82. - name: Stop legacy service
  83. become: yes
  84. systemd:
  85. name: calico
  86. state: stopped
  87. - name: Apply node label
  88. delegate_to: "{{ groups.oo_first_master.0 }}"
  89. command: >
  90. {{ openshift_client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig label node {{ openshift.node.nodename | lower }} --overwrite projectcalico.org/ds-ready=true
  91. - name: Wait for node running
  92. uri:
  93. url: http://localhost:9099/readiness
  94. status_code: 204
  95. delay: 3
  96. retries: 10
  97. register: result
  98. until: result.status == 204
  99. - name: Disable legacy service
  100. become: yes
  101. systemd:
  102. name: calico
  103. enabled: no
  104. - name: Rename legacy service
  105. command: mv /lib/systemd/system/calico.service /lib/systemd/system/calico-legacy.service.bak