legacy_upgrade.yml 3.8 KB

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