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.

340 lines
8.3 KiB

7 years ago
7 years ago
7 years ago
6 years ago
Fixes for CentOS 8 (#5213) * Fix python3-libselinux installation for RHEL/CentOS 8 In bootstrap-centos.yml we haven't gathered the facts, so #5127 couldn't work Minimum ansible version to run kubespray is 2.7.8, so ansible_distribution_major_version is defined an there is no need to default it Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * Restart NetworkManager for RHEL/CentOS 8 network.service doesn't exist anymore # systemctl status network Unit network.service could not be found. Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * Add module_hotfixes=True to docker / containerd yum repo config https://bugzilla.redhat.com/show_bug.cgi?id=1734081 https://bugzilla.redhat.com/show_bug.cgi?id=1756473 Without this setting you end up with the following error: # yum install docker-ce Failed to set locale, defaulting to C Last metadata expiration check: 0:03:21 ago on Thu Sep 26 22:00:05 2019. Error: Problem: package docker-ce-3:19.03.2-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed - cannot install the best candidate for the job - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded - package containerd.io-1.2.2-3.el7.x86_64 is excluded - package containerd.io-1.2.4-3.1.el7.x86_64 is excluded - package containerd.io-1.2.5-3.1.el7.x86_64 is excluded - package containerd.io-1.2.6-3.3.el7.x86_64 is excluded (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
5 years ago
Fixes for CentOS 8 (#5213) * Fix python3-libselinux installation for RHEL/CentOS 8 In bootstrap-centos.yml we haven't gathered the facts, so #5127 couldn't work Minimum ansible version to run kubespray is 2.7.8, so ansible_distribution_major_version is defined an there is no need to default it Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * Restart NetworkManager for RHEL/CentOS 8 network.service doesn't exist anymore # systemctl status network Unit network.service could not be found. Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> * Add module_hotfixes=True to docker / containerd yum repo config https://bugzilla.redhat.com/show_bug.cgi?id=1734081 https://bugzilla.redhat.com/show_bug.cgi?id=1756473 Without this setting you end up with the following error: # yum install docker-ce Failed to set locale, defaulting to C Last metadata expiration check: 0:03:21 ago on Thu Sep 26 22:00:05 2019. Error: Problem: package docker-ce-3:19.03.2-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed - cannot install the best candidate for the job - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded - package containerd.io-1.2.2-3.el7.x86_64 is excluded - package containerd.io-1.2.4-3.1.el7.x86_64 is excluded - package containerd.io-1.2.5-3.1.el7.x86_64 is excluded - package containerd.io-1.2.6-3.3.el7.x86_64 is excluded (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
5 years ago
  1. ---
  2. - name: reset | stop services
  3. service:
  4. name: "{{ item }}"
  5. state: stopped
  6. with_items:
  7. - kubelet
  8. - vault
  9. failed_when: false
  10. tags:
  11. - services
  12. - name: reset | remove services
  13. file:
  14. path: "/etc/systemd/system/{{ item }}"
  15. state: absent
  16. with_items:
  17. - kubelet.service
  18. - vault.service
  19. - calico-node.service
  20. - containerd.service.d/http-proxy.conf
  21. - crio.service.d/http-proxy.conf
  22. - vault.service.d/http-proxy.conf
  23. register: services_removed
  24. tags:
  25. - services
  26. - containerd
  27. - crio
  28. - name: reset | remove docker dropins
  29. file:
  30. path: "/etc/systemd/system/docker.service.d/{{ item }}"
  31. state: absent
  32. with_items:
  33. - docker-dns.conf
  34. - docker-options.conf
  35. - http-proxy.conf
  36. - docker-orphan-cleanup.conf
  37. register: docker_dropins_removed
  38. tags:
  39. - docker
  40. - name: reset | systemctl daemon-reload # noqa 503
  41. systemd:
  42. daemon_reload: true
  43. when: services_removed.changed or docker_dropins_removed.changed
  44. - name: reset | remove all containers
  45. shell: "set -o pipefail && {{ docker_bin_dir }}/docker ps -aq | xargs -r docker rm -fv"
  46. args:
  47. executable: /bin/bash
  48. register: remove_all_containers
  49. retries: 4
  50. until: remove_all_containers.rc == 0
  51. delay: 5
  52. when: container_manager == "docker"
  53. tags:
  54. - docker
  55. - name: reset | restart docker if needed # noqa 503
  56. service:
  57. name: docker
  58. state: restarted
  59. when: docker_dropins_removed.changed and container_manager == "docker"
  60. tags:
  61. - docker
  62. - name: reset | check if crictl is present
  63. stat:
  64. path: "{{ bin_dir }}/crictl"
  65. register: crictl
  66. - name: reset | stop all cri containers
  67. shell: "set -o pipefail && {{ bin_dir }}/crictl ps -q | xargs -r {{ bin_dir }}/crictl -t 60s stop"
  68. args:
  69. executable: /bin/bash
  70. register: remove_all_cri_containers
  71. retries: 5
  72. until: remove_all_cri_containers.rc == 0
  73. delay: 5
  74. tags:
  75. - crio
  76. - containerd
  77. when:
  78. - crictl.stat.exists
  79. - container_manager in ["crio", "containerd"]
  80. ignore_errors: true
  81. - name: reset | force remove all cri containers
  82. command: "{{ bin_dir }}/crictl rm -a -f"
  83. register: remove_all_cri_containers
  84. retries: 5
  85. until: remove_all_cri_containers.rc == 0
  86. delay: 5
  87. tags:
  88. - crio
  89. - containerd
  90. when:
  91. - crictl.stat.exists
  92. - container_manager in ["crio", "containerd"]
  93. - deploy_container_engine|default(true)
  94. - name: reset | stop and disable crio service
  95. service:
  96. name: crio
  97. state: stopped
  98. enabled: false
  99. failed_when: false
  100. tags: [ crio ]
  101. when: container_manager == "crio"
  102. - name: reset | forcefully wipe CRI-O's container and image storage
  103. command: "crio wipe -f"
  104. failed_when: false
  105. tags: [ crio ]
  106. when: container_manager == "crio"
  107. - name: reset | stop all cri pods
  108. shell: "set -o pipefail && {{ bin_dir }}/crictl pods -q | xargs -r {{ bin_dir }}/crictl -t 60s stopp"
  109. args:
  110. executable: /bin/bash
  111. register: remove_all_cri_containers
  112. retries: 5
  113. until: remove_all_cri_containers.rc == 0
  114. delay: 5
  115. tags: [ containerd ]
  116. when:
  117. - crictl.stat.exists
  118. - container_manager == "containerd"
  119. ignore_errors: true
  120. - name: reset | force remove all cri pods
  121. command: "{{ bin_dir }}/crictl rmp -a -f"
  122. register: remove_all_cri_containers
  123. retries: 5
  124. until: remove_all_cri_containers.rc == 0
  125. delay: 5
  126. tags: [ containerd ]
  127. when:
  128. - crictl.stat.exists
  129. - container_manager == "containerd"
  130. - name: reset | stop etcd services
  131. service:
  132. name: "{{ item }}"
  133. state: stopped
  134. with_items:
  135. - etcd
  136. - etcd-events
  137. failed_when: false
  138. tags:
  139. - services
  140. - name: reset | remove etcd services
  141. file:
  142. path: "/etc/systemd/system/{{ item }}.service"
  143. state: absent
  144. with_items:
  145. - etcd
  146. - etcd-events
  147. register: services_removed
  148. tags:
  149. - services
  150. - name: reset | gather mounted kubelet dirs # noqa 301
  151. shell: set -o pipefail && mount | grep /var/lib/kubelet/ | awk '{print $3}' | tac
  152. args:
  153. executable: /bin/bash
  154. warn: false
  155. check_mode: no
  156. register: mounted_dirs
  157. failed_when: false
  158. tags:
  159. - mounts
  160. - name: reset | unmount kubelet dirs # noqa 301
  161. command: umount -f {{ item }}
  162. with_items: "{{ mounted_dirs.stdout_lines }}"
  163. register: umount_dir
  164. when: mounted_dirs
  165. retries: 4
  166. until: umount_dir.rc == 0
  167. delay: 5
  168. tags:
  169. - mounts
  170. - name: flush iptables
  171. iptables:
  172. table: "{{ item }}"
  173. flush: yes
  174. with_items:
  175. - filter
  176. - nat
  177. - mangle
  178. when: flush_iptables|bool
  179. tags:
  180. - iptables
  181. - name: Clear IPVS virtual server table
  182. command: "ipvsadm -C"
  183. when:
  184. - kube_proxy_mode == 'ipvs' and inventory_hostname in groups['k8s-cluster']
  185. - name: reset | check kube-ipvs0 network device
  186. stat:
  187. path: /sys/class/net/kube-ipvs0
  188. register: kube_ipvs0
  189. - name: reset | Remove kube-ipvs0
  190. command: "ip link del kube-ipvs0"
  191. when:
  192. - kube_proxy_mode == 'ipvs'
  193. - kube_ipvs0.stat.exists
  194. - name: reset | check nodelocaldns network device
  195. stat:
  196. path: /sys/class/net/nodelocaldns
  197. register: nodelocaldns_device
  198. - name: reset | Remove nodelocaldns
  199. command: "ip link del nodelocaldns"
  200. when:
  201. - enable_nodelocaldns|default(false)|bool
  202. - nodelocaldns_device.stat.exists
  203. - name: reset | delete some files and directories
  204. file:
  205. path: "{{ item }}"
  206. state: absent
  207. with_items:
  208. - "{{ kube_config_dir }}"
  209. - /var/lib/kubelet
  210. - "{{ ansible_env.HOME | default('/root') }}/.kube"
  211. - "{{ ansible_env.HOME | default('/root') }}/.helm"
  212. - "{{ etcd_data_dir }}"
  213. - "{{ etcd_events_data_dir }}"
  214. - "{{ etcd_config_dir }}"
  215. - /var/log/calico
  216. - /etc/cni
  217. - "{{ nginx_config_dir }}"
  218. - /etc/dnsmasq.d
  219. - /etc/dnsmasq.conf
  220. - /etc/dnsmasq.d-available
  221. - /etc/etcd.env
  222. - /etc/calico
  223. - /etc/weave.env
  224. - /opt/cni
  225. - /etc/dhcp/dhclient.d/zdnsupdate.sh
  226. - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
  227. - /run/flannel
  228. - /etc/flannel
  229. - /run/kubernetes
  230. - /usr/local/share/ca-certificates/etcd-ca.crt
  231. - /usr/local/share/ca-certificates/kube-ca.crt
  232. - /usr/local/share/ca-certificates/vault-ca.crt
  233. - /etc/ssl/certs/etcd-ca.pem
  234. - /etc/ssl/certs/kube-ca.pem
  235. - /etc/ssl/certs/vault-ca.crt
  236. - /etc/pki/ca-trust/source/anchors/etcd-ca.crt
  237. - /etc/pki/ca-trust/source/anchors/kube-ca.crt
  238. - /etc/pki/ca-trust/source/anchors/vault-ca.crt
  239. - /etc/vault
  240. - /var/log/pods/
  241. - "{{ bin_dir }}/kubelet"
  242. - "{{ bin_dir }}/etcd-scripts"
  243. - "{{ bin_dir }}/etcd"
  244. - "{{ bin_dir }}/etcd-events"
  245. - "{{ bin_dir }}/etcdctl"
  246. - "{{ bin_dir }}/kubernetes-scripts"
  247. - "{{ bin_dir }}/kubectl"
  248. - "{{ bin_dir }}/kubeadm"
  249. - "{{ bin_dir }}/helm"
  250. - "{{ bin_dir }}/calicoctl"
  251. - "{{ bin_dir }}/calicoctl.sh"
  252. - "{{ bin_dir }}/calico-upgrade"
  253. - "{{ bin_dir }}/weave"
  254. - "{{ bin_dir }}/crictl"
  255. - "{{ bin_dir }}/netctl"
  256. - /var/lib/cni
  257. - /etc/vault
  258. - /etc/openvswitch
  259. - /run/openvswitch
  260. - /var/lib/kube-router
  261. - /var/lib/calico
  262. - /etc/cilium
  263. - /run/calico
  264. ignore_errors: yes
  265. tags:
  266. - files
  267. - name: reset | remove dns settings from dhclient.conf
  268. blockinfile:
  269. path: "{{ item }}"
  270. state: absent
  271. marker: "# Ansible entries {mark}"
  272. failed_when: false
  273. with_items:
  274. - /etc/dhclient.conf
  275. - /etc/dhcp/dhclient.conf
  276. tags:
  277. - files
  278. - dns
  279. - name: reset | remove host entries from /etc/hosts
  280. blockinfile:
  281. path: "/etc/hosts"
  282. state: absent
  283. marker: "# Ansible inventory hosts {mark}"
  284. tags:
  285. - files
  286. - dns
  287. - name: reset | include file with reset tasks specific to the network_plugin if exists
  288. include_tasks: "{{ (role_path + '/../network_plugin/' + kube_network_plugin + '/tasks/reset.yml') | realpath }}"
  289. when:
  290. - kube_network_plugin in ['flannel', 'cilium', 'kube-router', 'calico']
  291. tags:
  292. - network
  293. - name: reset | Restart network
  294. service:
  295. name: >-
  296. {% if ansible_os_family == "RedHat" -%}
  297. {%- if ansible_distribution_major_version|int == 8 -%}
  298. NetworkManager
  299. {%- else -%}
  300. network
  301. {%- endif -%}
  302. {%- elif ansible_distribution == "Ubuntu" and ansible_distribution_release in ["bionic", "focal"] -%}
  303. systemd-networkd
  304. {%- elif ansible_os_family == "Debian" -%}
  305. networking
  306. {%- endif %}
  307. state: restarted
  308. when:
  309. - ansible_os_family not in ["Flatcar Container Linux by Kinvolk"]
  310. - reset_restart_network
  311. tags:
  312. - services
  313. - network