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.

395 lines
9.8 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.service
  8. - cri-dockerd.service
  9. - cri-dockerd.socket
  10. failed_when: false
  11. tags:
  12. - services
  13. - name: reset | remove services
  14. file:
  15. path: "/etc/systemd/system/{{ item }}"
  16. state: absent
  17. with_items:
  18. - kubelet.service
  19. - cri-dockerd.service
  20. - cri-dockerd.socket
  21. - calico-node.service
  22. - containerd.service.d/http-proxy.conf
  23. - crio.service.d/http-proxy.conf
  24. - k8s-certs-renew.service
  25. - k8s-certs-renew.timer
  26. register: services_removed
  27. tags:
  28. - services
  29. - containerd
  30. - crio
  31. - name: reset | Remove Docker
  32. include_role:
  33. name: container-engine/docker
  34. tasks_from: reset
  35. when: container_manager == 'docker'
  36. tags:
  37. - docker
  38. - name: reset | systemctl daemon-reload # noqa 503
  39. systemd:
  40. daemon_reload: true
  41. when: services_removed.changed
  42. - name: reset | check if crictl is present
  43. stat:
  44. path: "{{ bin_dir }}/crictl"
  45. get_attributes: no
  46. get_checksum: no
  47. get_mime: no
  48. register: crictl
  49. - name: reset | stop all cri containers
  50. shell: "set -o pipefail && {{ bin_dir }}/crictl ps -q | xargs -r {{ bin_dir }}/crictl -t 60s stop"
  51. args:
  52. executable: /bin/bash
  53. register: remove_all_cri_containers
  54. retries: 5
  55. until: remove_all_cri_containers.rc == 0
  56. delay: 5
  57. tags:
  58. - crio
  59. - containerd
  60. when:
  61. - crictl.stat.exists
  62. - container_manager in ["crio", "containerd"]
  63. ignore_errors: true # noqa ignore-errors
  64. - name: reset | force remove all cri containers
  65. command: "{{ bin_dir }}/crictl rm -a -f"
  66. register: remove_all_cri_containers
  67. retries: 5
  68. until: remove_all_cri_containers.rc == 0
  69. delay: 5
  70. tags:
  71. - crio
  72. - containerd
  73. when:
  74. - crictl.stat.exists
  75. - container_manager in ["crio", "containerd"]
  76. - deploy_container_engine
  77. ignore_errors: true # noqa ignore-errors
  78. - name: reset | stop and disable crio service
  79. service:
  80. name: crio
  81. state: stopped
  82. enabled: false
  83. failed_when: false
  84. tags: [ crio ]
  85. when: container_manager == "crio"
  86. - name: reset | forcefully wipe CRI-O's container and image storage
  87. command: "crio wipe -f"
  88. failed_when: false
  89. tags: [ crio ]
  90. when: container_manager == "crio"
  91. - name: reset | stop all cri pods
  92. shell: "set -o pipefail && {{ bin_dir }}/crictl pods -q | xargs -r {{ bin_dir }}/crictl -t 60s stopp"
  93. args:
  94. executable: /bin/bash
  95. register: remove_all_cri_containers
  96. retries: 5
  97. until: remove_all_cri_containers.rc == 0
  98. delay: 5
  99. tags: [ containerd ]
  100. when:
  101. - crictl.stat.exists
  102. - container_manager == "containerd"
  103. ignore_errors: true # noqa ignore-errors
  104. - block:
  105. - name: reset | force remove all cri pods
  106. command: "{{ bin_dir }}/crictl rmp -a -f"
  107. register: remove_all_cri_containers
  108. retries: 5
  109. until: remove_all_cri_containers.rc == 0
  110. delay: 5
  111. tags: [ containerd ]
  112. when:
  113. - crictl.stat.exists
  114. - container_manager == "containerd"
  115. rescue:
  116. - name: reset | force remove all cri pods (rescue)
  117. shell: "ip netns list | cut -d' ' -f 1 | xargs -n1 ip netns delete && {{ bin_dir }}/crictl rmp -a -f"
  118. ignore_errors: true # noqa ignore-errors
  119. changed_when: true
  120. - name: reset | stop etcd services
  121. service:
  122. name: "{{ item }}"
  123. state: stopped
  124. with_items:
  125. - etcd
  126. - etcd-events
  127. failed_when: false
  128. tags:
  129. - services
  130. - name: reset | remove etcd services
  131. file:
  132. path: "/etc/systemd/system/{{ item }}.service"
  133. state: absent
  134. with_items:
  135. - etcd
  136. - etcd-events
  137. register: services_removed
  138. tags:
  139. - services
  140. - name: reset | remove containerd
  141. when: container_manager == 'containerd'
  142. block:
  143. - name: reset | stop containerd service
  144. service:
  145. name: containerd
  146. state: stopped
  147. failed_when: false
  148. tags:
  149. - services
  150. - name: reset | remove containerd service
  151. file:
  152. path: /etc/systemd/system/containerd.service
  153. state: absent
  154. register: services_removed
  155. tags:
  156. - services
  157. - name: reset | gather mounted kubelet dirs # noqa 301
  158. shell: set -o pipefail && mount | grep /var/lib/kubelet/ | awk '{print $3}' | tac
  159. args:
  160. executable: /bin/bash
  161. warn: false
  162. check_mode: no
  163. register: mounted_dirs
  164. failed_when: false
  165. tags:
  166. - mounts
  167. - name: reset | unmount kubelet dirs # noqa 301
  168. command: umount -f {{ item }}
  169. with_items: "{{ mounted_dirs.stdout_lines }}"
  170. register: umount_dir
  171. when: mounted_dirs
  172. retries: 4
  173. until: umount_dir.rc == 0
  174. delay: 5
  175. tags:
  176. - mounts
  177. - name: flush iptables
  178. iptables:
  179. table: "{{ item }}"
  180. flush: yes
  181. with_items:
  182. - filter
  183. - nat
  184. - mangle
  185. - raw
  186. when: flush_iptables|bool
  187. tags:
  188. - iptables
  189. - name: Clear IPVS virtual server table
  190. command: "ipvsadm -C"
  191. ignore_errors: true # noqa ignore-errors
  192. when:
  193. - kube_proxy_mode == 'ipvs' and inventory_hostname in groups['k8s_cluster']
  194. - name: reset | check kube-ipvs0 network device
  195. stat:
  196. path: /sys/class/net/kube-ipvs0
  197. get_attributes: no
  198. get_checksum: no
  199. get_mime: no
  200. register: kube_ipvs0
  201. - name: reset | Remove kube-ipvs0
  202. command: "ip link del kube-ipvs0"
  203. when:
  204. - kube_proxy_mode == 'ipvs'
  205. - kube_ipvs0.stat.exists
  206. - name: reset | check nodelocaldns network device
  207. stat:
  208. path: /sys/class/net/nodelocaldns
  209. get_attributes: no
  210. get_checksum: no
  211. get_mime: no
  212. register: nodelocaldns_device
  213. - name: reset | Remove nodelocaldns
  214. command: "ip link del nodelocaldns"
  215. when:
  216. - enable_nodelocaldns|default(false)|bool
  217. - nodelocaldns_device.stat.exists
  218. - name: reset | delete some files and directories
  219. file:
  220. path: "{{ item }}"
  221. state: absent
  222. with_items:
  223. - "{{ kube_config_dir }}"
  224. - /var/lib/kubelet
  225. - "{{ containerd_storage_dir }}"
  226. - "{{ ansible_env.HOME | default('/root') }}/.kube"
  227. - "{{ ansible_env.HOME | default('/root') }}/.helm"
  228. - "{{ etcd_data_dir }}"
  229. - "{{ etcd_events_data_dir }}"
  230. - "{{ etcd_config_dir }}"
  231. - /var/log/calico
  232. - /etc/cni
  233. - /etc/nerdctl
  234. - "{{ nginx_config_dir }}"
  235. - /etc/dnsmasq.d
  236. - /etc/dnsmasq.conf
  237. - /etc/dnsmasq.d-available
  238. - /etc/etcd.env
  239. - /etc/calico
  240. - /etc/NetworkManager/conf.d/calico.conf
  241. - /etc/NetworkManager/conf.d/k8s.conf
  242. - /etc/weave.env
  243. - /opt/cni
  244. - /etc/dhcp/dhclient.d/zdnsupdate.sh
  245. - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
  246. - /run/flannel
  247. - /etc/flannel
  248. - /run/kubernetes
  249. - /usr/local/share/ca-certificates/etcd-ca.crt
  250. - /usr/local/share/ca-certificates/kube-ca.crt
  251. - /etc/ssl/certs/etcd-ca.pem
  252. - /etc/ssl/certs/kube-ca.pem
  253. - /etc/pki/ca-trust/source/anchors/etcd-ca.crt
  254. - /etc/pki/ca-trust/source/anchors/kube-ca.crt
  255. - /var/log/pods/
  256. - "{{ bin_dir }}/kubelet"
  257. - "{{ bin_dir }}/cri-dockerd"
  258. - "{{ bin_dir }}/etcd-scripts"
  259. - "{{ bin_dir }}/etcd"
  260. - "{{ bin_dir }}/etcd-events"
  261. - "{{ bin_dir }}/etcdctl"
  262. - "{{ bin_dir }}/etcdctl.sh"
  263. - "{{ bin_dir }}/kubernetes-scripts"
  264. - "{{ bin_dir }}/kubectl"
  265. - "{{ bin_dir }}/kubeadm"
  266. - "{{ bin_dir }}/helm"
  267. - "{{ bin_dir }}/calicoctl"
  268. - "{{ bin_dir }}/calicoctl.sh"
  269. - "{{ bin_dir }}/calico-upgrade"
  270. - "{{ bin_dir }}/weave"
  271. - "{{ bin_dir }}/crictl"
  272. - "{{ bin_dir }}/nerdctl"
  273. - "{{ bin_dir }}/netctl"
  274. - "{{ bin_dir }}/k8s-certs-renew.sh"
  275. - /var/lib/cni
  276. - /etc/openvswitch
  277. - /run/openvswitch
  278. - /var/lib/kube-router
  279. - /var/lib/calico
  280. - /etc/cilium
  281. - /run/calico
  282. - /etc/bash_completion.d/kubectl.sh
  283. - /etc/bash_completion.d/crictl
  284. - /etc/bash_completion.d/nerdctl
  285. - /etc/bash_completion.d/krew
  286. - /etc/bash_completion.d/krew.sh
  287. - "{{ krew_root_dir }}"
  288. - /etc/modules-load.d/kube_proxy-ipvs.conf
  289. - /etc/modules-load.d/kubespray-br_netfilter.conf
  290. - /etc/modules-load.d/kubespray-kata-containers.conf
  291. - /usr/libexec/kubernetes
  292. - /etc/origin/openvswitch
  293. - /etc/origin/ovn
  294. - "{{ sysctl_file_path }}"
  295. - /etc/crictl.yaml
  296. ignore_errors: true # noqa ignore-errors
  297. tags:
  298. - files
  299. - name: reset | remove containerd binary files
  300. file:
  301. path: "{{ containerd_bin_dir }}/{{ item }}"
  302. state: absent
  303. with_items:
  304. - containerd
  305. - containerd-shim
  306. - containerd-shim-runc-v1
  307. - containerd-shim-runc-v2
  308. - containerd-stress
  309. - crictl
  310. - critest
  311. - ctd-decoder
  312. - ctr
  313. - runc
  314. ignore_errors: true # noqa ignore-errors
  315. when: container_manager == 'containerd'
  316. tags:
  317. - files
  318. - name: reset | remove dns settings from dhclient.conf
  319. blockinfile:
  320. path: "{{ item }}"
  321. state: absent
  322. marker: "# Ansible entries {mark}"
  323. failed_when: false
  324. with_items:
  325. - /etc/dhclient.conf
  326. - /etc/dhcp/dhclient.conf
  327. tags:
  328. - files
  329. - dns
  330. - name: reset | remove host entries from /etc/hosts
  331. blockinfile:
  332. path: "/etc/hosts"
  333. state: absent
  334. marker: "# Ansible inventory hosts {mark}"
  335. tags:
  336. - files
  337. - dns
  338. - name: reset | include file with reset tasks specific to the network_plugin if exists
  339. include_role:
  340. name: "network_plugin/{{ kube_network_plugin }}"
  341. tasks_from: reset
  342. when:
  343. - kube_network_plugin in ['flannel', 'cilium', 'kube-router', 'calico']
  344. tags:
  345. - network
  346. - name: reset | Restart network
  347. service:
  348. name: >-
  349. {% if ansible_os_family == "RedHat" -%}
  350. {%- if ansible_distribution_major_version|int == 8 or is_fedora_coreos or ansible_distribution == "Fedora" -%}
  351. NetworkManager
  352. {%- else -%}
  353. network
  354. {%- endif -%}
  355. {%- elif ansible_distribution == "Ubuntu" and ansible_distribution_release in ["hirsute","bionic", "focal"] -%}
  356. systemd-networkd
  357. {%- elif ansible_os_family == "Debian" -%}
  358. networking
  359. {%- endif %}
  360. state: restarted
  361. when:
  362. - ansible_os_family not in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
  363. - reset_restart_network
  364. tags:
  365. - services
  366. - network