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.

310 lines
7.6 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>
4 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>
4 years ago
  1. ---
  2. - name: reset | include file with pre-reset tasks specific to the network_plugin if exists
  3. include_tasks: "{{ (role_path + '/../network_plugin/' + kube_network_plugin + '/tasks/pre-reset.yml') | realpath }}"
  4. when:
  5. - kube_network_plugin in ['contiv']
  6. tags:
  7. - network
  8. - name: reset | stop services
  9. service:
  10. name: "{{ item }}"
  11. state: stopped
  12. with_items:
  13. - kubelet
  14. - vault
  15. failed_when: false
  16. tags:
  17. - services
  18. - name: reset | remove services
  19. file:
  20. path: "/etc/systemd/system/{{ item }}.service"
  21. state: absent
  22. with_items:
  23. - kubelet
  24. - vault
  25. - calico-node
  26. register: services_removed
  27. tags:
  28. - services
  29. - name: reset | remove docker dropins
  30. file:
  31. path: "/etc/systemd/system/docker.service.d/{{ item }}"
  32. state: absent
  33. with_items:
  34. - docker-dns.conf
  35. - docker-options.conf
  36. - http-proxy.conf
  37. register: docker_dropins_removed
  38. tags:
  39. - docker
  40. - name: reset | systemctl daemon-reload
  41. systemd:
  42. daemon_reload: true
  43. when: services_removed.changed or docker_dropins_removed.changed
  44. - name: reset | remove all containers
  45. shell: "{{ docker_bin_dir }}/docker ps -aq | xargs -r docker rm -fv"
  46. register: remove_all_containers
  47. retries: 4
  48. until: remove_all_containers.rc == 0
  49. delay: 5
  50. when: container_manager == "docker"
  51. tags:
  52. - docker
  53. - name: reset | restart docker if needed
  54. service:
  55. name: docker
  56. state: restarted
  57. when: docker_dropins_removed.changed and container_manager == "docker"
  58. tags:
  59. - docker
  60. - name: reset | stop all cri containers
  61. shell: "crictl ps -aq | xargs -r crictl -t 60s stop"
  62. register: remove_all_cri_containers
  63. retries: 5
  64. until: remove_all_cri_containers.rc == 0
  65. delay: 5
  66. tags:
  67. - crio
  68. - containerd
  69. when: container_manager in ["crio", "containerd"]
  70. - name: reset | remove all cri containers
  71. shell: "crictl ps -aq | xargs -r crictl -t 60s rm"
  72. register: remove_all_cri_containers
  73. retries: 5
  74. until: remove_all_cri_containers.rc == 0
  75. delay: 5
  76. tags:
  77. - crio
  78. - containerd
  79. when: container_manager in ["crio", "containerd"] and deploy_container_engine|default(true)
  80. - name: reset | stop all cri pods
  81. shell: "crictl pods -q | xargs -r crictl -t 60s stopp"
  82. register: remove_all_cri_containers
  83. retries: 5
  84. until: remove_all_cri_containers.rc == 0
  85. delay: 5
  86. tags:
  87. - crio
  88. - containerd
  89. when: container_manager in ["crio", "containerd"]
  90. - name: reset | remove all cri pods
  91. shell: "crictl pods -q | xargs -r crictl -t 60s rmp"
  92. register: remove_all_cri_containers
  93. retries: 5
  94. until: remove_all_cri_containers.rc == 0
  95. delay: 5
  96. tags:
  97. - crio
  98. - containerd
  99. when: container_manager in ["crio", "containerd"]
  100. - name: reset | stop etcd services
  101. service:
  102. name: "{{ item }}"
  103. state: stopped
  104. with_items:
  105. - etcd
  106. - etcd-events
  107. failed_when: false
  108. tags:
  109. - services
  110. - name: reset | remove etcd services
  111. file:
  112. path: "/etc/systemd/system/{{ item }}.service"
  113. state: absent
  114. with_items:
  115. - etcd
  116. - etcd-events
  117. register: services_removed
  118. tags:
  119. - services
  120. - name: reset | gather mounted kubelet dirs
  121. shell: mount | grep /var/lib/kubelet/ | awk '{print $3}' | tac
  122. args:
  123. warn: false
  124. check_mode: no
  125. register: mounted_dirs
  126. tags:
  127. - mounts
  128. - name: reset | unmount kubelet dirs
  129. command: umount -f {{ item }}
  130. with_items: '{{ mounted_dirs.stdout_lines }}'
  131. register: umount_dir
  132. retries: 4
  133. until: umount_dir.rc == 0
  134. delay: 5
  135. tags:
  136. - mounts
  137. - name: flush iptables
  138. iptables:
  139. table: "{{ item }}"
  140. flush: yes
  141. with_items:
  142. - filter
  143. - nat
  144. - mangle
  145. when: flush_iptables|bool
  146. tags:
  147. - iptables
  148. - name: Clear IPVS virtual server table
  149. shell: "ipvsadm -C"
  150. when:
  151. - kube_proxy_mode == 'ipvs' and inventory_hostname in groups['k8s-cluster']
  152. - name: reset | check kube-ipvs0 network device
  153. stat:
  154. path: /sys/class/net/kube-ipvs0
  155. register: kube_ipvs0
  156. - name: reset | Remove kube-ipvs0
  157. command: "ip link del kube-ipvs0"
  158. when:
  159. - kube_proxy_mode == 'ipvs'
  160. - kube_ipvs0.stat.exists
  161. - name: reset | check nodelocaldns network device
  162. stat:
  163. path: /sys/class/net/nodelocaldns
  164. register: nodelocaldns_device
  165. - name: reset | Remove nodelocaldns
  166. command: "ip link del nodelocaldns"
  167. when:
  168. - enable_nodelocaldns|default(false)|bool
  169. - nodelocaldns_device.stat.exists
  170. - name: reset | delete some files and directories
  171. file:
  172. path: "{{ item }}"
  173. state: absent
  174. with_items:
  175. - "{{ kube_config_dir }}"
  176. - /var/lib/kubelet
  177. - "{{ ansible_env.HOME | default('/root') }}/.kube"
  178. - "{{ ansible_env.HOME | default('/root') }}/.helm"
  179. - "{{ etcd_data_dir }}"
  180. - /var/lib/etcd-events
  181. - /etc/ssl/etcd
  182. - /var/log/calico
  183. - /etc/cni
  184. - "{{ nginx_config_dir }}"
  185. - /etc/dnsmasq.d
  186. - /etc/dnsmasq.conf
  187. - /etc/dnsmasq.d-available
  188. - /etc/etcd.env
  189. - /etc/calico
  190. - /etc/weave.env
  191. - /opt/cni
  192. - /etc/dhcp/dhclient.d/zdnsupdate.sh
  193. - /etc/dhcp/dhclient-exit-hooks.d/zdnsupdate
  194. - /run/flannel
  195. - /etc/flannel
  196. - /run/kubernetes
  197. - /usr/local/share/ca-certificates/etcd-ca.crt
  198. - /usr/local/share/ca-certificates/kube-ca.crt
  199. - /usr/local/share/ca-certificates/vault-ca.crt
  200. - /etc/ssl/certs/etcd-ca.pem
  201. - /etc/ssl/certs/kube-ca.pem
  202. - /etc/ssl/certs/vault-ca.crt
  203. - /etc/pki/ca-trust/source/anchors/etcd-ca.crt
  204. - /etc/pki/ca-trust/source/anchors/kube-ca.crt
  205. - /etc/pki/ca-trust/source/anchors/vault-ca.crt
  206. - /etc/vault
  207. - /var/log/pods/
  208. - "{{ bin_dir }}/kubelet"
  209. - "{{ bin_dir }}/etcd-scripts"
  210. - "{{ bin_dir }}/etcd"
  211. - "{{ bin_dir }}/etcd-events"
  212. - "{{ bin_dir }}/etcdctl"
  213. - "{{ bin_dir }}/kubernetes-scripts"
  214. - "{{ bin_dir }}/kubectl"
  215. - "{{ bin_dir }}/kubeadm"
  216. - "{{ bin_dir }}/hyperkube"
  217. - "{{ bin_dir }}/helm"
  218. - "{{ bin_dir }}/calicoctl"
  219. - "{{ bin_dir }}/calicoctl.sh"
  220. - "{{ bin_dir }}/calico-upgrade"
  221. - "{{ bin_dir }}/weave"
  222. - "{{ bin_dir }}/crictl"
  223. - "{{ bin_dir }}/netctl"
  224. - /var/lib/cni
  225. - /etc/vault
  226. - /etc/contiv
  227. - /var/contiv
  228. - /run/contiv
  229. - /etc/openvswitch
  230. - /run/openvswitch
  231. - /var/lib/kube-router
  232. - /var/lib/calico
  233. - /etc/cilium
  234. - /run/calico
  235. ignore_errors: yes
  236. tags:
  237. - files
  238. - name: reset | remove dns settings from dhclient.conf
  239. blockinfile:
  240. path: "{{ item }}"
  241. state: absent
  242. marker: "# Ansible entries {mark}"
  243. failed_when: false
  244. with_items:
  245. - /etc/dhclient.conf
  246. - /etc/dhcp/dhclient.conf
  247. tags:
  248. - files
  249. - dns
  250. - name: reset | remove host entries from /etc/hosts
  251. blockinfile:
  252. path: "/etc/hosts"
  253. state: absent
  254. marker: "# Ansible inventory hosts {mark}"
  255. tags:
  256. - files
  257. - dns
  258. - name: reset | include file with reset tasks specific to the network_plugin if exists
  259. include_tasks: "{{ (role_path + '/../network_plugin/' + kube_network_plugin + '/tasks/reset.yml') | realpath }}"
  260. when:
  261. - kube_network_plugin in ['flannel', 'cilium', 'contiv', 'kube-router', 'calico']
  262. tags:
  263. - network
  264. - name: reset | Restart network
  265. service:
  266. name: >-
  267. {% if ansible_os_family == "RedHat" -%}
  268. {%- if ansible_distribution_major_version|int == 8 -%}
  269. NetworkManager
  270. {%- else -%}
  271. network
  272. {%- endif -%}
  273. {%- elif ansible_distribution == "Ubuntu" and ansible_distribution_release == "bionic" -%}
  274. systemd-networkd
  275. {%- elif ansible_os_family == "Debian" -%}
  276. networking
  277. {%- endif %}
  278. state: restarted
  279. when:
  280. - ansible_os_family not in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"]
  281. - reset_restart_network
  282. tags:
  283. - services
  284. - network