You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
5.8 KiB

Upgrade ansible (#10190) * project: update all dependencies including ansible Upgrade to ansible 7.x and ansible-core 2.14.x. There seems to be issue with ansible 8/ansible-core 2.15 so we remain on those versions for now. It's quite a big bump already anyway. Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * tests: install aws galaxy collection Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * ansible-lint: disable various rules after ansible upgrade Temporarily disable a bunch of linting action following ansible upgrade. Those should be taken care of separately. Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve deprecated-module ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve no-free-form ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve schema[meta] ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve schema[playbook] ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve schema[tasks] ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve risky-file-permissions ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve risky-shell-pipe ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: remove deprecated warn args Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: use fqcn for non builtin tasks Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve syntax-check[missing-file] for contrib playbook Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: use arithmetic inside jinja to fix ansible 6 upgrade Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> --------- Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch>
1 year ago
Upgrade ansible (#10190) * project: update all dependencies including ansible Upgrade to ansible 7.x and ansible-core 2.14.x. There seems to be issue with ansible 8/ansible-core 2.15 so we remain on those versions for now. It's quite a big bump already anyway. Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * tests: install aws galaxy collection Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * ansible-lint: disable various rules after ansible upgrade Temporarily disable a bunch of linting action following ansible upgrade. Those should be taken care of separately. Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve deprecated-module ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve no-free-form ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve schema[meta] ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve schema[playbook] ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve schema[tasks] ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve risky-file-permissions ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve risky-shell-pipe ansible-lint error Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: remove deprecated warn args Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: use fqcn for non builtin tasks Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: resolve syntax-check[missing-file] for contrib playbook Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> * project: use arithmetic inside jinja to fix ansible 6 upgrade Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch> --------- Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch>
1 year ago
  1. ---
  2. - name: Gen_certs | create etcd cert dir
  3. file:
  4. path: "{{ etcd_cert_dir }}"
  5. group: "{{ etcd_cert_group }}"
  6. state: directory
  7. owner: "{{ etcd_owner }}"
  8. mode: "{{ etcd_cert_dir_mode }}"
  9. recurse: yes
  10. - name: "Gen_certs | create etcd script dir (on {{ groups['etcd'][0] }})"
  11. file:
  12. path: "{{ etcd_script_dir }}"
  13. state: directory
  14. owner: root
  15. mode: 0700
  16. run_once: yes
  17. when: inventory_hostname == groups['etcd'][0]
  18. - name: Gen_certs | write openssl config
  19. template:
  20. src: "openssl.conf.j2"
  21. dest: "{{ etcd_config_dir }}/openssl.conf"
  22. mode: 0640
  23. run_once: yes
  24. delegate_to: "{{ groups['etcd'][0] }}"
  25. when:
  26. - gen_certs | default(false)
  27. - inventory_hostname == groups['etcd'][0]
  28. - name: Gen_certs | copy certs generation script
  29. template:
  30. src: "make-ssl-etcd.sh.j2"
  31. dest: "{{ etcd_script_dir }}/make-ssl-etcd.sh"
  32. mode: 0700
  33. run_once: yes
  34. when:
  35. - gen_certs | default(false)
  36. - inventory_hostname == groups['etcd'][0]
  37. - name: Gen_certs | run cert generation script for etcd and kube control plane nodes
  38. command: "bash -x {{ etcd_script_dir }}/make-ssl-etcd.sh -f {{ etcd_config_dir }}/openssl.conf -d {{ etcd_cert_dir }}"
  39. environment:
  40. MASTERS: |-
  41. {% for m in groups['etcd'] %}
  42. {% if gen_master_certs[m] %}
  43. {{ m }}
  44. {% endif %}
  45. {% endfor %}
  46. HOSTS: |-
  47. {% for h in groups['kube_control_plane'] %}
  48. {% if gen_node_certs[h] %}
  49. {{ h }}
  50. {% endif %}
  51. {% endfor %}
  52. run_once: yes
  53. delegate_to: "{{ groups['etcd'][0] }}"
  54. when: gen_certs | default(false)
  55. notify: Set etcd_secret_changed
  56. - name: Gen_certs | run cert generation script for all clients
  57. command: "bash -x {{ etcd_script_dir }}/make-ssl-etcd.sh -f {{ etcd_config_dir }}/openssl.conf -d {{ etcd_cert_dir }}"
  58. environment:
  59. HOSTS: |-
  60. {% for h in groups['k8s_cluster'] %}
  61. {% if gen_node_certs[h] %}
  62. {{ h }}
  63. {% endif %}
  64. {% endfor %}
  65. run_once: yes
  66. delegate_to: "{{ groups['etcd'][0] }}"
  67. when:
  68. - kube_network_plugin in ["calico", "flannel", "cilium"] or cilium_deploy_additionally | default(false) | bool
  69. - kube_network_plugin != "calico" or calico_datastore == "etcd"
  70. - gen_certs | default(false)
  71. notify: Set etcd_secret_changed
  72. - name: Gen_certs | Gather etcd member/admin and kube_control_plane client certs from first etcd node
  73. slurp:
  74. src: "{{ item }}"
  75. register: etcd_master_certs
  76. with_items:
  77. - "{{ etcd_cert_dir }}/ca.pem"
  78. - "{{ etcd_cert_dir }}/ca-key.pem"
  79. - "[{% for node in groups['etcd'] %}
  80. '{{ etcd_cert_dir }}/admin-{{ node }}.pem',
  81. '{{ etcd_cert_dir }}/admin-{{ node }}-key.pem',
  82. '{{ etcd_cert_dir }}/member-{{ node }}.pem',
  83. '{{ etcd_cert_dir }}/member-{{ node }}-key.pem',
  84. {% endfor %}]"
  85. - "[{% for node in (groups['kube_control_plane']) %}
  86. '{{ etcd_cert_dir }}/node-{{ node }}.pem',
  87. '{{ etcd_cert_dir }}/node-{{ node }}-key.pem',
  88. {% endfor %}]"
  89. delegate_to: "{{ groups['etcd'][0] }}"
  90. when:
  91. - inventory_hostname in groups['etcd']
  92. - sync_certs | default(false)
  93. - inventory_hostname != groups['etcd'][0]
  94. notify: Set etcd_secret_changed
  95. - name: Gen_certs | Write etcd member/admin and kube_control_plane client certs to other etcd nodes
  96. copy:
  97. dest: "{{ item.item }}"
  98. content: "{{ item.content | b64decode }}"
  99. group: "{{ etcd_cert_group }}"
  100. owner: "{{ etcd_owner }}"
  101. mode: 0640
  102. with_items: "{{ etcd_master_certs.results }}"
  103. when:
  104. - inventory_hostname in groups['etcd']
  105. - sync_certs | default(false)
  106. - inventory_hostname != groups['etcd'][0]
  107. loop_control:
  108. label: "{{ item.item }}"
  109. - name: Gen_certs | Gather node certs from first etcd node
  110. slurp:
  111. src: "{{ item }}"
  112. register: etcd_master_node_certs
  113. with_items:
  114. - "[{% for node in groups['k8s_cluster'] %}
  115. '{{ etcd_cert_dir }}/node-{{ node }}.pem',
  116. '{{ etcd_cert_dir }}/node-{{ node }}-key.pem',
  117. {% endfor %}]"
  118. delegate_to: "{{ groups['etcd'][0] }}"
  119. when:
  120. - inventory_hostname in groups['etcd']
  121. - inventory_hostname != groups['etcd'][0]
  122. - kube_network_plugin in ["calico", "flannel", "cilium"] or cilium_deploy_additionally | default(false) | bool
  123. - kube_network_plugin != "calico" or calico_datastore == "etcd"
  124. notify: Set etcd_secret_changed
  125. - name: Gen_certs | Write node certs to other etcd nodes
  126. copy:
  127. dest: "{{ item.item }}"
  128. content: "{{ item.content | b64decode }}"
  129. group: "{{ etcd_cert_group }}"
  130. owner: "{{ etcd_owner }}"
  131. mode: 0640
  132. with_items: "{{ etcd_master_node_certs.results }}"
  133. when:
  134. - inventory_hostname in groups['etcd']
  135. - inventory_hostname != groups['etcd'][0]
  136. - kube_network_plugin in ["calico", "flannel", "cilium"] or cilium_deploy_additionally | default(false) | bool
  137. - kube_network_plugin != "calico" or calico_datastore == "etcd"
  138. loop_control:
  139. label: "{{ item.item }}"
  140. - name: Gen_certs | Generate etcd certs
  141. include_tasks: gen_nodes_certs_script.yml
  142. when:
  143. - inventory_hostname in groups['kube_control_plane'] and
  144. sync_certs | default(false) and inventory_hostname not in groups['etcd']
  145. - name: Gen_certs | Generate etcd certs on nodes if needed
  146. include_tasks: gen_nodes_certs_script.yml
  147. when:
  148. - kube_network_plugin in ["calico", "flannel", "cilium"] or cilium_deploy_additionally | default(false) | bool
  149. - kube_network_plugin != "calico" or calico_datastore == "etcd"
  150. - inventory_hostname in groups['k8s_cluster'] and
  151. sync_certs | default(false) and inventory_hostname not in groups['etcd']
  152. - name: Gen_certs | check certificate permissions
  153. file:
  154. path: "{{ etcd_cert_dir }}"
  155. group: "{{ etcd_cert_group }}"
  156. state: directory
  157. owner: "{{ etcd_owner }}"
  158. mode: "{{ etcd_cert_dir_mode }}"
  159. recurse: yes