uninstall.yml 11 KB

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