uninstall.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. # This deletes *ALL* Origin, Atomic Enterprise Platform and OpenShift
  2. # Enterprise content installed by ansible. This includes:
  3. #
  4. # configuration
  5. # containers
  6. # example templates and imagestreams
  7. # images
  8. # RPMs
  9. ---
  10. - hosts: OSEv3:children
  11. become: yes
  12. tasks:
  13. - name: Detecting Operating System
  14. shell: ls /run/ostree-booted
  15. ignore_errors: yes
  16. failed_when: false
  17. register: ostree_output
  18. # Since we're not calling openshift_facts we'll do this for now
  19. - set_fact:
  20. is_atomic: "{{ ostree_output.rc == 0 }}"
  21. - set_fact:
  22. is_containerized: "{{ is_atomic or containerized | default(false) | bool }}"
  23. # Stop services on all hosts prior to removing files.
  24. - hosts: nodes
  25. become: yes
  26. tasks:
  27. - name: Stop services
  28. service: name={{ item }} state=stopped
  29. with_items:
  30. - atomic-enterprise-node
  31. - atomic-openshift-node
  32. - openshift-node
  33. - openvswitch
  34. - origin-node
  35. failed_when: false
  36. - hosts: masters
  37. become: yes
  38. tasks:
  39. - name: Stop services
  40. service: name={{ item }} state=stopped
  41. with_items:
  42. - atomic-enterprise-master
  43. - atomic-openshift-master
  44. - atomic-openshift-master-api
  45. - atomic-openshift-master-controllers
  46. - openshift-master
  47. - openshift-master-api
  48. - openshift-master-controllers
  49. - origin-master
  50. - origin-master-api
  51. - origin-master-controllers
  52. - pcsd
  53. failed_when: false
  54. - hosts: etcd
  55. become: yes
  56. tasks:
  57. - name: Stop services
  58. service: name={{ item }} state=stopped
  59. with_items:
  60. - etcd
  61. failed_when: false
  62. - hosts: lb
  63. become: yes
  64. tasks:
  65. - name: Stop services
  66. service: name={{ item }} state=stopped
  67. with_items:
  68. - haproxy
  69. failed_when: false
  70. - hosts: nodes
  71. become: yes
  72. vars:
  73. node_dirs:
  74. - "/etc/origin"
  75. - "/var/lib/origin"
  76. tasks:
  77. - name: unmask services
  78. command: systemctl unmask "{{ item }}"
  79. changed_when: False
  80. failed_when: False
  81. with_items:
  82. - firewalld
  83. - block:
  84. - block:
  85. - name: Remove packages
  86. package: name={{ item }} state=absent
  87. with_items:
  88. - atomic-enterprise
  89. - atomic-enterprise-node
  90. - atomic-enterprise-sdn-ovs
  91. - atomic-openshift
  92. - atomic-openshift-clients
  93. - atomic-openshift-excluder
  94. - atomic-openshift-docker-excluder
  95. - atomic-openshift-node
  96. - atomic-openshift-sdn-ovs
  97. - cockpit-bridge
  98. - cockpit-docker
  99. - cockpit-shell
  100. - cockpit-ws
  101. - kubernetes-client
  102. - openshift
  103. - openshift-node
  104. - openshift-sdn
  105. - openshift-sdn-ovs
  106. - openvswitch
  107. - origin
  108. - origin-excluder
  109. - origin-docker-excluder
  110. - origin-clients
  111. - origin-node
  112. - origin-sdn-ovs
  113. - tuned-profiles-atomic-enterprise-node
  114. - tuned-profiles-atomic-openshift-node
  115. - tuned-profiles-openshift-node
  116. - tuned-profiles-origin-node
  117. - name: Remove flannel package
  118. package: name=flannel state=absent
  119. when: openshift_use_flannel | default(false) | bool
  120. when: "{{ not is_atomic | bool }}"
  121. - shell: systemctl reset-failed
  122. changed_when: False
  123. - shell: systemctl daemon-reload
  124. changed_when: False
  125. - name: Remove br0 interface
  126. shell: ovs-vsctl del-br br0
  127. changed_when: False
  128. failed_when: False
  129. - name: Remove linux interfaces
  130. shell: ip link del "{{ item }}"
  131. changed_when: False
  132. failed_when: False
  133. with_items:
  134. - lbr0
  135. - vlinuxbr
  136. - vovsbr
  137. when: "{{ openshift_remove_all | default(true) | bool }}"
  138. - shell: find /var/lib/origin/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  139. changed_when: False
  140. - shell: find /var/lib/atomic-enterprise/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  141. changed_when: False
  142. - shell: find /var/lib/openshift/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  143. changed_when: False
  144. - shell: docker rm -f "{{ item }}"-master "{{ item }}"-node
  145. changed_when: False
  146. failed_when: False
  147. with_items:
  148. - openshift-enterprise
  149. - atomic-enterprise
  150. - origin
  151. - shell: docker ps -a | grep Exited | egrep "{{ item }}" | awk '{print $1}'
  152. changed_when: False
  153. failed_when: False
  154. register: exited_containers_to_delete
  155. with_items:
  156. - aep3.*/aep
  157. - aep3.*/node
  158. - aep3.*/openvswitch
  159. - openshift3/ose
  160. - openshift3/node
  161. - openshift3/openvswitch
  162. - openshift/origin
  163. - shell: "docker rm {{ item.stdout_lines | join(' ') }}"
  164. changed_when: False
  165. failed_when: False
  166. with_items: "{{ exited_containers_to_delete.results }}"
  167. - block:
  168. - block:
  169. - shell: docker images | egrep {{ item }} | awk '{ print $3 }'
  170. changed_when: False
  171. failed_when: False
  172. register: images_to_delete
  173. with_items:
  174. - registry\.access\..*redhat\.com/openshift3
  175. - registry\.access\..*redhat\.com/aep3
  176. - registry\.qe\.openshift\.com/.*
  177. - registry\.access\..*redhat\.com/rhel7/etcd
  178. - docker.io/openshift
  179. - shell: "docker rmi -f {{ item.stdout_lines | join(' ') }}"
  180. changed_when: False
  181. failed_when: False
  182. with_items: "{{ images_to_delete.results }}"
  183. when: "{{ openshift_uninstall_images | default(True) | bool }}"
  184. - name: remove sdn drop files
  185. file:
  186. path: /run/openshift-sdn
  187. state: absent
  188. - name: Remove files owned by RPMs
  189. file: path={{ item }} state=absent
  190. with_items:
  191. - /etc/sysconfig/openshift-node
  192. - /etc/sysconfig/openvswitch
  193. - /run/openshift-sdn
  194. when: "{{ openshift_remove_all | default(True) | bool }}"
  195. - find: path={{ item }} file_type=file
  196. register: files
  197. with_items:
  198. - "{{ node_dirs }}"
  199. - find: path={{ item }} file_type=directory
  200. register: directories
  201. with_items:
  202. - "{{ node_dirs }}"
  203. - file: path={{ item.1.path }} state=absent
  204. with_subelements:
  205. - "{{ files.results | default([]) }}"
  206. - files
  207. - file: path={{ item.1.path }} state=absent
  208. with_subelements:
  209. - "{{ directories.results | default([]) }}"
  210. - files
  211. - name: Remove remaining files
  212. file: path={{ item }} state=absent
  213. with_items:
  214. - /etc/ansible/facts.d/openshift.fact
  215. - /etc/atomic-enterprise
  216. - /etc/dnsmasq.d/origin-dns.conf
  217. - /etc/dnsmasq.d/origin-upstream-dns.conf
  218. - /etc/NetworkManager/dispatcher.d/99-origin-dns.sh
  219. - /etc/openshift
  220. - /etc/openshift-sdn
  221. - /etc/sysconfig/atomic-enterprise-node
  222. - /etc/sysconfig/atomic-openshift-node
  223. - /etc/sysconfig/atomic-openshift-node-dep
  224. - /etc/sysconfig/openshift-node-dep
  225. - /etc/sysconfig/origin-node
  226. - /etc/sysconfig/origin-node
  227. - /etc/sysconfig/origin-node-dep
  228. - /etc/systemd/system/atomic-openshift-node-dep.service
  229. - /etc/systemd/system/atomic-openshift-node.service
  230. - /etc/systemd/system/atomic-openshift-node.service.wants
  231. - /etc/systemd/system/docker.service.d/docker-sdn-ovs.conf
  232. - /etc/systemd/system/openvswitch.service
  233. - /etc/systemd/system/origin-node-dep.service
  234. - /etc/systemd/system/origin-node.service
  235. - /etc/systemd/system/origin-node.service.wants
  236. - /var/lib/atomic-enterprise
  237. - /var/lib/openshift
  238. - name: restart docker
  239. service: name=docker state=restarted
  240. - name: restart NetworkManager
  241. service: name=NetworkManager state=restarted
  242. - hosts: masters
  243. become: yes
  244. vars:
  245. master_dirs:
  246. - "/etc/origin"
  247. - "/var/lib/origin"
  248. tasks:
  249. - name: unmask services
  250. command: systemctl unmask "{{ item }}"
  251. changed_when: False
  252. failed_when: False
  253. with_items:
  254. - firewalld
  255. - atomic-openshift-master
  256. - name: Remove packages
  257. package: name={{ item }} state=absent
  258. when: not is_atomic | bool and openshift_remove_all | default(True) | bool
  259. with_items:
  260. - atomic-enterprise
  261. - atomic-enterprise-master
  262. - atomic-openshift
  263. - atomic-openshift-clients
  264. - atomic-openshift-excluder
  265. - atomic-openshift-docker-excluder
  266. - atomic-openshift-master
  267. - cockpit-bridge
  268. - cockpit-docker
  269. - cockpit-shell
  270. - cockpit-ws
  271. - corosync
  272. - kubernetes-client
  273. - openshift
  274. - openshift-master
  275. - origin
  276. - origin-clients
  277. - origin-excluder
  278. - origin-docker-excluder
  279. - origin-master
  280. - pacemaker
  281. - pcs
  282. - shell: systemctl reset-failed
  283. changed_when: False
  284. - shell: systemctl daemon-reload
  285. changed_when: False
  286. - name: Remove files owned by RPMs
  287. file: path={{ item }} state=absent
  288. when: openshift_remove_all | default(True) | bool
  289. with_items:
  290. - /etc/sysconfig/atomic-openshift-master
  291. - /etc/sysconfig/openvswitch
  292. - find: path={{ item }} file_type=file
  293. register: files
  294. with_items:
  295. - "{{ master_dirs }}"
  296. - find: path={{ item }} file_type=directory
  297. register: directories
  298. with_items:
  299. - "{{ master_dirs }}"
  300. - file: path={{ item.1.path }} state=absent
  301. with_subelements:
  302. - "{{ files.results | default([]) }}"
  303. - files
  304. - file: path={{ item.1.path }} state=absent
  305. with_subelements:
  306. - "{{ directories.results | default([]) }}"
  307. - files
  308. - name: Remove remaining files
  309. file: path={{ item }} state=absent
  310. with_items:
  311. - "~{{ ansible_ssh_user }}/.kube"
  312. - /etc/ansible/facts.d/openshift.fact
  313. - /etc/atomic-enterprise
  314. - /etc/corosync
  315. - /etc/openshift
  316. - /etc/openshift-sdn
  317. - /etc/systemd/system/atomic-openshift-master.service
  318. - /etc/systemd/system/atomic-openshift-master-api.service
  319. - /etc/systemd/system/atomic-openshift-master-controllers.service
  320. - /etc/systemd/system/origin-master.service
  321. - /etc/systemd/system/origin-master-api.service
  322. - /etc/systemd/system/origin-master-controllers.service
  323. - /etc/systemd/system/openvswitch.service
  324. - /etc/sysconfig/atomic-enterprise-master
  325. - /etc/sysconfig/atomic-enterprise-master-api
  326. - /etc/sysconfig/atomic-enterprise-master-controllers
  327. - /etc/sysconfig/atomic-openshift-master-api
  328. - /etc/sysconfig/atomic-openshift-master-controllers
  329. - /etc/sysconfig/origin-master
  330. - /etc/sysconfig/origin-master-api
  331. - /etc/sysconfig/origin-master-controllers
  332. - /etc/sysconfig/openshift-master
  333. - /etc/sysconfig/origin-master
  334. - /etc/sysconfig/origin-master-api
  335. - /etc/sysconfig/origin-master-controllers
  336. - /root/.kube
  337. - /usr/share/openshift/examples
  338. - /var/lib/atomic-enterprise
  339. - /var/lib/openshift
  340. - /var/lib/pacemaker
  341. - /var/lib/pcsd
  342. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  343. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  344. - /usr/lib/systemd/system/origin-master-api.service
  345. - /usr/lib/systemd/system/origin-master-controllers.service
  346. - /usr/local/bin/openshift
  347. - /usr/local/bin/oadm
  348. - /usr/local/bin/oc
  349. - /usr/local/bin/kubectl
  350. - /etc/flannel
  351. # Since we are potentially removing the systemd unit files for separated
  352. # master-api and master-controllers services, so we need to reload the
  353. # systemd configuration manager
  354. - name: Reload systemd manager configuration
  355. command: systemctl daemon-reload
  356. - hosts: etcd
  357. become: yes
  358. vars:
  359. etcd_dirs:
  360. - "/etc/etcd"
  361. - "/var/lib/etcd"
  362. tasks:
  363. - name: unmask services
  364. command: systemctl unmask "{{ item }}"
  365. changed_when: False
  366. failed_when: False
  367. with_items:
  368. - etcd
  369. - etcd3
  370. - firewalld
  371. - name: Stop additional atomic services
  372. service: name={{ item }} state=stopped
  373. when: is_containerized | bool
  374. with_items:
  375. - etcd_container
  376. failed_when: false
  377. - name: Remove packages
  378. package: name={{ item }} state=absent
  379. when: not is_atomic | bool and openshift_remove_all | default(True) | bool
  380. with_items:
  381. - etcd
  382. - etcd3
  383. - shell: systemctl reset-failed
  384. changed_when: False
  385. - shell: systemctl daemon-reload
  386. changed_when: False
  387. - find: path={{ item }} file_type=file
  388. register: files
  389. with_items:
  390. - "{{ etcd_dirs }}"
  391. - find: path={{ item }} file_type=directory
  392. register: directories
  393. with_items:
  394. - "{{ etcd_dirs }}"
  395. - file: path={{ item.1.path }} state=absent
  396. with_subelements:
  397. - "{{ files.results | default([]) }}"
  398. - files
  399. - file: path={{ item.1.path }} state=absent
  400. with_subelements:
  401. - "{{ directories.results | default([]) }}"
  402. - files
  403. # Intenationally using rm command over file module because if someone had mounted a filesystem
  404. # at /var/lib/etcd then the contents was not removed correctly
  405. - name: Remove etcd data
  406. shell: rm -rf /var/lib/etcd/*
  407. args:
  408. warn: no
  409. failed_when: false
  410. - name: Remove remaining files
  411. file: path={{ item }} state=absent
  412. with_items:
  413. - /etc/ansible/facts.d/openshift.fact
  414. - /etc/systemd/system/etcd_container.service
  415. - /etc/profile.d/etcdctl.sh
  416. - hosts: lb
  417. become: yes
  418. tasks:
  419. - name: unmask services
  420. command: systemctl unmask "{{ item }}"
  421. changed_when: False
  422. failed_when: False
  423. with_items:
  424. - firewalld
  425. - name: Remove packages
  426. package: name={{ item }} state=absent
  427. when: not is_atomic | bool and openshift_remove_all | default(True) | bool
  428. with_items:
  429. - haproxy
  430. - shell: systemctl reset-failed
  431. changed_when: False
  432. - shell: systemctl daemon-reload
  433. changed_when: False
  434. - name: Remove remaining files
  435. file: path={{ item }} state=absent
  436. with_items:
  437. - /etc/ansible/facts.d/openshift.fact
  438. - /var/lib/haproxy/stats