uninstall.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  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: atomic uninstall "{{ item }}"-master-api
  139. changed_when: False
  140. failed_when: False
  141. with_items:
  142. - openshift-enterprise
  143. - atomic-enterprise
  144. - origin
  145. - shell: atomic uninstall "{{ item }}"-master-controllers
  146. changed_when: False
  147. failed_when: False
  148. with_items:
  149. - openshift-enterprise
  150. - atomic-enterprise
  151. - origin
  152. - shell: atomic uninstall "{{ item }}"-master
  153. changed_when: False
  154. failed_when: False
  155. with_items:
  156. - openshift-enterprise
  157. - atomic-enterprise
  158. - origin
  159. - shell: atomic uninstall "{{ item }}"-node
  160. changed_when: False
  161. failed_when: False
  162. with_items:
  163. - openshift-enterprise
  164. - atomic-enterprise
  165. - origin
  166. - shell: atomic uninstall "{{ item }}"
  167. changed_when: False
  168. failed_when: False
  169. with_items:
  170. - etcd
  171. - openvswitch
  172. - shell: find /var/lib/origin/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  173. changed_when: False
  174. - shell: find /var/lib/atomic-enterprise/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  175. changed_when: False
  176. - shell: find /var/lib/openshift/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  177. changed_when: False
  178. - shell: docker rm -f "{{ item }}"-master "{{ item }}"-node
  179. changed_when: False
  180. failed_when: False
  181. with_items:
  182. - openshift-enterprise
  183. - atomic-enterprise
  184. - origin
  185. - shell: docker ps -a | grep Exited | egrep "{{ item }}" | awk '{print $1}'
  186. changed_when: False
  187. failed_when: False
  188. register: exited_containers_to_delete
  189. with_items:
  190. - aep3.*/aep
  191. - aep3.*/node
  192. - aep3.*/openvswitch
  193. - openshift3/ose
  194. - openshift3/node
  195. - openshift3/openvswitch
  196. - openshift/origin
  197. - shell: "docker rm {{ item.stdout_lines | join(' ') }}"
  198. changed_when: False
  199. failed_when: False
  200. with_items: "{{ exited_containers_to_delete.results }}"
  201. - block:
  202. - block:
  203. - shell: docker images | egrep {{ item }} | awk '{ print $3 }'
  204. changed_when: False
  205. failed_when: False
  206. register: images_to_delete
  207. with_items:
  208. - registry\.access\..*redhat\.com/openshift3
  209. - registry\.access\..*redhat\.com/aep3
  210. - registry\.qe\.openshift\.com/.*
  211. - registry\.access\..*redhat\.com/rhel7/etcd
  212. - docker.io/openshift
  213. - shell: "docker rmi -f {{ item.stdout_lines | join(' ') }}"
  214. changed_when: False
  215. failed_when: False
  216. with_items: "{{ images_to_delete.results }}"
  217. when: openshift_uninstall_images | default(True) | bool
  218. - name: remove sdn drop files
  219. file:
  220. path: /run/openshift-sdn
  221. state: absent
  222. - name: Remove files owned by RPMs
  223. file: path={{ item }} state=absent
  224. with_items:
  225. - /etc/sysconfig/openshift-node
  226. - /etc/sysconfig/openvswitch
  227. - /run/openshift-sdn
  228. when: openshift_remove_all | default(True) | bool
  229. - find: path={{ item }} file_type=file
  230. register: files
  231. with_items:
  232. - "{{ node_dirs }}"
  233. - find: path={{ item }} file_type=directory
  234. register: directories
  235. with_items:
  236. - "{{ node_dirs }}"
  237. - file: path={{ item.1.path }} state=absent
  238. with_subelements:
  239. - "{{ files.results | default([]) }}"
  240. - files
  241. - file: path={{ item.1.path }} state=absent
  242. with_subelements:
  243. - "{{ directories.results | default([]) }}"
  244. - files
  245. - name: Remove remaining files
  246. file: path={{ item }} state=absent
  247. with_items:
  248. - /etc/ansible/facts.d/openshift.fact
  249. - /etc/atomic-enterprise
  250. - /etc/dnsmasq.d/origin-dns.conf
  251. - /etc/dnsmasq.d/origin-upstream-dns.conf
  252. - /etc/NetworkManager/dispatcher.d/99-origin-dns.sh
  253. - /etc/openshift
  254. - /etc/openshift-sdn
  255. - /etc/sysconfig/atomic-enterprise-node
  256. - /etc/sysconfig/atomic-openshift-node
  257. - /etc/sysconfig/atomic-openshift-node-dep
  258. - /etc/sysconfig/openshift-node-dep
  259. - /etc/sysconfig/origin-node
  260. - /etc/sysconfig/origin-node
  261. - /etc/sysconfig/origin-node-dep
  262. - /etc/systemd/system/atomic-openshift-node-dep.service
  263. - /etc/systemd/system/atomic-openshift-node.service
  264. - /etc/systemd/system/atomic-openshift-node.service.wants
  265. - /etc/systemd/system/docker.service.d/docker-sdn-ovs.conf
  266. - /etc/systemd/system/openvswitch.service
  267. - /etc/systemd/system/origin-node-dep.service
  268. - /etc/systemd/system/origin-node.service
  269. - /etc/systemd/system/origin-node.service.wants
  270. - /var/lib/atomic-enterprise
  271. - /var/lib/openshift
  272. - shell: systemctl daemon-reload
  273. changed_when: False
  274. - name: restart docker
  275. service: name=docker state=restarted
  276. - name: restart NetworkManager
  277. service: name=NetworkManager state=restarted
  278. - hosts: masters
  279. become: yes
  280. vars:
  281. master_dirs:
  282. - "/etc/origin"
  283. - "/var/lib/origin"
  284. tasks:
  285. - name: unmask services
  286. command: systemctl unmask "{{ item }}"
  287. changed_when: False
  288. failed_when: False
  289. with_items:
  290. - firewalld
  291. - atomic-openshift-master
  292. - name: Remove packages
  293. package: name={{ item }} state=absent
  294. when: not is_atomic | bool and openshift_remove_all | default(True) | bool
  295. with_items:
  296. - atomic-enterprise
  297. - atomic-enterprise-master
  298. - atomic-openshift
  299. - atomic-openshift-clients
  300. - atomic-openshift-excluder
  301. - atomic-openshift-docker-excluder
  302. - atomic-openshift-master
  303. - cockpit-bridge
  304. - cockpit-docker
  305. - cockpit-shell
  306. - cockpit-ws
  307. - corosync
  308. - kubernetes-client
  309. - openshift
  310. - openshift-master
  311. - origin
  312. - origin-clients
  313. - origin-excluder
  314. - origin-docker-excluder
  315. - origin-master
  316. - pacemaker
  317. - pcs
  318. - shell: systemctl reset-failed
  319. changed_when: False
  320. - shell: systemctl daemon-reload
  321. changed_when: False
  322. - name: Remove files owned by RPMs
  323. file: path={{ item }} state=absent
  324. when: openshift_remove_all | default(True) | bool
  325. with_items:
  326. - /etc/sysconfig/atomic-openshift-master
  327. - /etc/sysconfig/openvswitch
  328. - find: path={{ item }} file_type=file
  329. register: files
  330. with_items:
  331. - "{{ master_dirs }}"
  332. - find: path={{ item }} file_type=directory
  333. register: directories
  334. with_items:
  335. - "{{ master_dirs }}"
  336. - file: path={{ item.1.path }} state=absent
  337. with_subelements:
  338. - "{{ files.results | default([]) }}"
  339. - files
  340. - file: path={{ item.1.path }} state=absent
  341. with_subelements:
  342. - "{{ directories.results | default([]) }}"
  343. - files
  344. - name: Remove remaining files
  345. file: path={{ item }} state=absent
  346. with_items:
  347. - "~{{ ansible_ssh_user }}/.kube"
  348. - /etc/ansible/facts.d/openshift.fact
  349. - /etc/atomic-enterprise
  350. - /etc/corosync
  351. - /etc/openshift
  352. - /etc/openshift-sdn
  353. - /etc/systemd/system/atomic-openshift-master.service
  354. - /etc/systemd/system/atomic-openshift-master-api.service
  355. - /etc/systemd/system/atomic-openshift-master-controllers.service
  356. - /etc/systemd/system/origin-master.service
  357. - /etc/systemd/system/origin-master-api.service
  358. - /etc/systemd/system/origin-master-controllers.service
  359. - /etc/systemd/system/openvswitch.service
  360. - /etc/sysconfig/atomic-enterprise-master
  361. - /etc/sysconfig/atomic-enterprise-master-api
  362. - /etc/sysconfig/atomic-enterprise-master-controllers
  363. - /etc/sysconfig/atomic-openshift-master-api
  364. - /etc/sysconfig/atomic-openshift-master-controllers
  365. - /etc/sysconfig/origin-master
  366. - /etc/sysconfig/origin-master-api
  367. - /etc/sysconfig/origin-master-controllers
  368. - /etc/sysconfig/openshift-master
  369. - /etc/sysconfig/origin-master
  370. - /etc/sysconfig/origin-master-api
  371. - /etc/sysconfig/origin-master-controllers
  372. - /root/.kube
  373. - /usr/share/openshift/examples
  374. - /var/lib/atomic-enterprise
  375. - /var/lib/openshift
  376. - /var/lib/pacemaker
  377. - /var/lib/pcsd
  378. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  379. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  380. - /usr/lib/systemd/system/origin-master-api.service
  381. - /usr/lib/systemd/system/origin-master-controllers.service
  382. - /usr/local/bin/openshift
  383. - /usr/local/bin/oadm
  384. - /usr/local/bin/oc
  385. - /usr/local/bin/kubectl
  386. - /etc/flannel
  387. # Since we are potentially removing the systemd unit files for separated
  388. # master-api and master-controllers services, so we need to reload the
  389. # systemd configuration manager
  390. - name: Reload systemd manager configuration
  391. command: systemctl daemon-reload
  392. - hosts: etcd
  393. become: yes
  394. vars:
  395. etcd_dirs:
  396. - "/etc/etcd"
  397. - "/var/lib/etcd"
  398. tasks:
  399. - name: unmask services
  400. command: systemctl unmask "{{ item }}"
  401. changed_when: False
  402. failed_when: False
  403. with_items:
  404. - etcd
  405. - etcd3
  406. - firewalld
  407. - name: Stop additional atomic services
  408. service: name={{ item }} state=stopped
  409. when: is_containerized | bool
  410. with_items:
  411. - etcd_container
  412. failed_when: false
  413. - name: Remove packages
  414. package: name={{ item }} state=absent
  415. when: not is_atomic | bool and openshift_remove_all | default(True) | bool
  416. with_items:
  417. - etcd
  418. - etcd3
  419. - shell: systemctl reset-failed
  420. changed_when: False
  421. - shell: systemctl daemon-reload
  422. changed_when: False
  423. - find: path={{ item }} file_type=file
  424. register: files
  425. with_items:
  426. - "{{ etcd_dirs }}"
  427. - find: path={{ item }} file_type=directory
  428. register: directories
  429. with_items:
  430. - "{{ etcd_dirs }}"
  431. - file: path={{ item.1.path }} state=absent
  432. with_subelements:
  433. - "{{ files.results | default([]) }}"
  434. - files
  435. - file: path={{ item.1.path }} state=absent
  436. with_subelements:
  437. - "{{ directories.results | default([]) }}"
  438. - files
  439. # Intenationally using rm command over file module because if someone had mounted a filesystem
  440. # at /var/lib/etcd then the contents was not removed correctly
  441. - name: Remove etcd data
  442. shell: rm -rf /var/lib/etcd/*
  443. args:
  444. warn: no
  445. failed_when: false
  446. - name: Remove remaining files
  447. file: path={{ item }} state=absent
  448. with_items:
  449. - /etc/ansible/facts.d/openshift.fact
  450. - /etc/systemd/system/etcd_container.service
  451. - /etc/profile.d/etcdctl.sh
  452. - hosts: lb
  453. become: yes
  454. tasks:
  455. - name: unmask services
  456. command: systemctl unmask "{{ item }}"
  457. changed_when: False
  458. failed_when: False
  459. with_items:
  460. - firewalld
  461. - name: Remove packages
  462. package: name={{ item }} state=absent
  463. when: not is_atomic | bool and openshift_remove_all | default(True) | bool
  464. with_items:
  465. - haproxy
  466. - shell: systemctl reset-failed
  467. changed_when: False
  468. - shell: systemctl daemon-reload
  469. changed_when: False
  470. - name: Remove remaining files
  471. file: path={{ item }} state=absent
  472. with_items:
  473. - /etc/ansible/facts.d/openshift.fact
  474. - /var/lib/haproxy/stats