uninstall.yml 10 KB

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