uninstall.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. tasks:
  73. - name: unmask services
  74. command: systemctl unmask "{{ item }}"
  75. changed_when: False
  76. failed_when: False
  77. with_items:
  78. - firewalld
  79. - name: Remove packages
  80. package: name={{ item }} state=absent
  81. when: not is_atomic | bool
  82. with_items:
  83. - atomic-enterprise
  84. - atomic-enterprise-node
  85. - atomic-enterprise-sdn-ovs
  86. - atomic-openshift
  87. - atomic-openshift-clients
  88. - atomic-openshift-node
  89. - atomic-openshift-sdn-ovs
  90. - cockpit-bridge
  91. - cockpit-docker
  92. - cockpit-shell
  93. - cockpit-ws
  94. - kubernetes-client
  95. - openshift
  96. - openshift-node
  97. - openshift-sdn
  98. - openshift-sdn-ovs
  99. - openvswitch
  100. - origin
  101. - origin-clients
  102. - origin-node
  103. - origin-sdn-ovs
  104. - tuned-profiles-atomic-enterprise-node
  105. - tuned-profiles-atomic-openshift-node
  106. - tuned-profiles-openshift-node
  107. - tuned-profiles-origin-node
  108. - name: Remove flannel package
  109. package: name=flannel state=absent
  110. when: openshift_use_flannel | default(false) | bool and not is_atomic | bool
  111. - shell: systemctl reset-failed
  112. changed_when: False
  113. - shell: systemctl daemon-reload
  114. changed_when: False
  115. - name: Remove br0 interface
  116. shell: ovs-vsctl del-br br0
  117. changed_when: False
  118. failed_when: False
  119. - name: Remove linux interfaces
  120. shell: ip link del "{{ item }}"
  121. changed_when: False
  122. failed_when: False
  123. with_items:
  124. - lbr0
  125. - vlinuxbr
  126. - vovsbr
  127. - shell: find /var/lib/origin/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  128. changed_when: False
  129. - shell: find /var/lib/atomic-enterprise/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  130. changed_when: False
  131. - shell: find /var/lib/openshift/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  132. changed_when: False
  133. - shell: docker rm -f "{{ item }}"-master "{{ item }}"-node
  134. changed_when: False
  135. failed_when: False
  136. with_items:
  137. - openshift-enterprise
  138. - atomic-enterprise
  139. - origin
  140. - shell: docker ps -a | grep Exited | egrep "{{ item }}" | awk '{print $1}'
  141. changed_when: False
  142. failed_when: False
  143. register: exited_containers_to_delete
  144. with_items:
  145. - aep3.*/aep
  146. - aep3.*/node
  147. - aep3.*/openvswitch
  148. - openshift3/ose
  149. - openshift3/node
  150. - openshift3/openvswitch
  151. - openshift/origin
  152. - shell: "docker rm {{ item.stdout_lines | join(' ') }}"
  153. changed_when: False
  154. failed_when: False
  155. with_items: "{{ exited_containers_to_delete.results }}"
  156. - shell: docker images | egrep {{ item }} | awk '{ print $3 }'
  157. changed_when: False
  158. failed_when: False
  159. register: images_to_delete
  160. with_items:
  161. - registry\.access\..*redhat\.com/openshift3
  162. - registry\.access\..*redhat\.com/aep3
  163. - registry\.qe\.openshift\.com/.*
  164. - registry\.access\..*redhat\.com/rhel7/etcd
  165. - docker.io/openshift
  166. when: openshift_uninstall_images | default(True) | bool
  167. - shell: "docker rmi -f {{ item.stdout_lines | join(' ') }}"
  168. changed_when: False
  169. failed_when: False
  170. with_items: "{{ images_to_delete.results }}"
  171. when: openshift_uninstall_images | default(True) | bool
  172. - name: Remove sdn drop files
  173. file:
  174. path: /run/openshift-sdn
  175. state: absent
  176. - name: Remove remaining files
  177. file: path={{ item }} state=absent
  178. with_items:
  179. - /etc/ansible/facts.d/openshift.fact
  180. - /etc/atomic-enterprise
  181. - /etc/dnsmasq.d/origin-dns.conf
  182. - /etc/dnsmasq.d/origin-upstream-dns.conf
  183. - /etc/NetworkManager/dispatcher.d/99-origin-dns.sh
  184. - /etc/openshift
  185. - /etc/openshift-sdn
  186. - /etc/origin
  187. - /etc/sysconfig/atomic-enterprise-node
  188. - /etc/sysconfig/atomic-openshift-node
  189. - /etc/sysconfig/atomic-openshift-node-dep
  190. - /etc/sysconfig/openshift-node
  191. - /etc/sysconfig/openshift-node-dep
  192. - /etc/sysconfig/openvswitch
  193. - /etc/sysconfig/origin-node
  194. - /etc/sysconfig/origin-node
  195. - /etc/sysconfig/origin-node-dep
  196. - /etc/systemd/system/atomic-openshift-node-dep.service
  197. - /etc/systemd/system/atomic-openshift-node.service
  198. - /etc/systemd/system/atomic-openshift-node.service.wants
  199. - /etc/systemd/system/docker.service.d/docker-sdn-ovs.conf
  200. - /etc/systemd/system/openvswitch.service
  201. - /etc/systemd/system/origin-node-dep.service
  202. - /etc/systemd/system/origin-node.service
  203. - /etc/systemd/system/origin-node.service.wants
  204. - /run/openshift-sdn
  205. - /var/lib/atomic-enterprise
  206. - /var/lib/openshift
  207. - /var/lib/origin
  208. - name: restart docker
  209. service: name=docker state=restarted
  210. - name: restart NetworkManager
  211. service: name=NetworkManager state=restarted
  212. - hosts: masters
  213. become: yes
  214. tasks:
  215. - name: unmask services
  216. command: systemctl unmask "{{ item }}"
  217. changed_when: False
  218. failed_when: False
  219. with_items:
  220. - firewalld
  221. - atomic-openshift-master
  222. - name: Remove packages
  223. package: name={{ item }} state=absent
  224. when: not is_atomic | bool
  225. with_items:
  226. - atomic-enterprise
  227. - atomic-enterprise-master
  228. - atomic-openshift
  229. - atomic-openshift-clients
  230. - atomic-openshift-master
  231. - cockpit-bridge
  232. - cockpit-docker
  233. - cockpit-shell
  234. - cockpit-ws
  235. - corosync
  236. - kubernetes-client
  237. - openshift
  238. - openshift-master
  239. - origin
  240. - origin-clients
  241. - origin-master
  242. - pacemaker
  243. - pcs
  244. - shell: systemctl reset-failed
  245. changed_when: False
  246. - shell: systemctl daemon-reload
  247. changed_when: False
  248. - name: Remove remaining files
  249. file: path={{ item }} state=absent
  250. with_items:
  251. - "~{{ ansible_ssh_user }}/.kube"
  252. - /etc/ansible/facts.d/openshift.fact
  253. - /etc/atomic-enterprise
  254. - /etc/corosync
  255. - /etc/openshift
  256. - /etc/openshift-sdn
  257. - /etc/origin
  258. - /etc/systemd/system/atomic-openshift-master.service
  259. - /etc/systemd/system/atomic-openshift-master-api.service
  260. - /etc/systemd/system/atomic-openshift-master-controllers.service
  261. - /etc/systemd/system/origin-master.service
  262. - /etc/systemd/system/origin-master-api.service
  263. - /etc/systemd/system/origin-master-controllers.service
  264. - /etc/systemd/system/openvswitch.service
  265. - /etc/sysconfig/atomic-enterprise-master
  266. - /etc/sysconfig/atomic-enterprise-master-api
  267. - /etc/sysconfig/atomic-enterprise-master-controllers
  268. - /etc/sysconfig/atomic-openshift-master
  269. - /etc/sysconfig/atomic-openshift-master-api
  270. - /etc/sysconfig/atomic-openshift-master-controllers
  271. - /etc/sysconfig/origin-master
  272. - /etc/sysconfig/origin-master-api
  273. - /etc/sysconfig/origin-master-controllers
  274. - /etc/sysconfig/openshift-master
  275. - /etc/sysconfig/openvswitch
  276. - /etc/sysconfig/origin-master
  277. - /etc/sysconfig/origin-master-api
  278. - /etc/sysconfig/origin-master-controllers
  279. - /root/.kube
  280. - /usr/share/openshift/examples
  281. - /var/lib/atomic-enterprise
  282. - /var/lib/openshift
  283. - /var/lib/origin
  284. - /var/lib/pacemaker
  285. - /var/lib/pcsd
  286. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  287. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  288. - /usr/lib/systemd/system/origin-master-api.service
  289. - /usr/lib/systemd/system/origin-master-controllers.service
  290. - /usr/local/bin/openshift
  291. - /usr/local/bin/oadm
  292. - /usr/local/bin/oc
  293. - /usr/local/bin/kubectl
  294. - /etc/flannel
  295. # Since we are potentially removing the systemd unit files for separated
  296. # master-api and master-controllers services, so we need to reload the
  297. # systemd configuration manager
  298. - name: Reload systemd manager configuration
  299. command: systemctl daemon-reload
  300. - hosts: etcd
  301. become: yes
  302. tasks:
  303. - name: unmask services
  304. command: systemctl unmask "{{ item }}"
  305. changed_when: False
  306. failed_when: False
  307. with_items:
  308. - etcd
  309. - etcd3
  310. - firewalld
  311. - name: Stop additional atomic services
  312. service: name={{ item }} state=stopped
  313. when: is_containerized | bool
  314. with_items:
  315. - etcd_container
  316. failed_when: false
  317. - name: Remove packages
  318. package: name={{ item }} state=absent
  319. when: not is_atomic | bool
  320. with_items:
  321. - etcd
  322. - etcd3
  323. - shell: systemctl reset-failed
  324. changed_when: False
  325. - shell: systemctl daemon-reload
  326. changed_when: False
  327. - name: Remove remaining files
  328. file: path={{ item }} state=absent
  329. with_items:
  330. - /etc/ansible/facts.d/openshift.fact
  331. - /etc/etcd
  332. - /etc/systemd/system/etcd_container.service
  333. - /etc/profile.d/etcdctl.sh
  334. # Intenationally using rm command over file module because if someone had mounted a filesystem
  335. # at /var/lib/etcd then the contents was not removed correctly
  336. - name: Remove etcd data
  337. shell: rm -rf /var/lib/etcd/*
  338. args:
  339. warn: no
  340. failed_when: false
  341. - hosts: lb
  342. become: yes
  343. tasks:
  344. - name: unmask services
  345. command: systemctl unmask "{{ item }}"
  346. changed_when: False
  347. failed_when: False
  348. with_items:
  349. - firewalld
  350. - name: Remove packages
  351. package: name={{ item }} state=absent
  352. when: not is_atomic | bool
  353. with_items:
  354. - haproxy
  355. - shell: systemctl reset-failed
  356. changed_when: False
  357. - shell: systemctl daemon-reload
  358. changed_when: False
  359. - name: Remove remaining files
  360. file: path={{ item }} state=absent
  361. with_items:
  362. - /etc/ansible/facts.d/openshift.fact
  363. - /var/lib/haproxy