uninstall.yml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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:
  11. - OSEv3:children
  12. become: yes
  13. tasks:
  14. - name: Detecting Operating System
  15. shell: ls /run/ostree-booted
  16. ignore_errors: yes
  17. failed_when: false
  18. register: ostree_output
  19. # Since we're not calling openshift_facts we'll do this for now
  20. - set_fact:
  21. is_atomic: "{{ ostree_output.rc == 0 }}"
  22. - set_fact:
  23. is_containerized: "{{ is_atomic or containerized | default(false) | bool }}"
  24. - name: Remove br0 interface
  25. shell: ovs-vsctl del-br br0
  26. changed_when: False
  27. failed_when: False
  28. - name: Stop services
  29. service: name={{ item }} state=stopped
  30. with_items:
  31. - atomic-enterprise-master
  32. - atomic-enterprise-node
  33. - atomic-openshift-master
  34. - atomic-openshift-master-api
  35. - atomic-openshift-master-controllers
  36. - atomic-openshift-node
  37. - etcd
  38. - haproxy
  39. - openshift-master
  40. - openshift-master-api
  41. - openshift-master-controllers
  42. - openshift-node
  43. - openvswitch
  44. - origin-master
  45. - origin-master-api
  46. - origin-master-controllers
  47. - origin-node
  48. - pcsd
  49. failed_when: false
  50. - name: unmask services
  51. command: systemctl unmask "{{ item }}"
  52. changed_when: False
  53. failed_when: False
  54. with_items:
  55. - etcd
  56. - firewalld
  57. - name: Stop additional atomic services
  58. service: name={{ item }} state=stopped
  59. when: is_containerized | bool
  60. with_items:
  61. - etcd_container
  62. failed_when: false
  63. - name: Remove packages
  64. action: "{{ ansible_pkg_mgr }} name={{ item }} state=absent"
  65. when: not is_atomic | bool
  66. with_items:
  67. - atomic-enterprise
  68. - atomic-enterprise-master
  69. - atomic-enterprise-node
  70. - atomic-enterprise-sdn-ovs
  71. - atomic-openshift
  72. - atomic-openshift-clients
  73. - atomic-openshift-master
  74. - atomic-openshift-node
  75. - atomic-openshift-sdn-ovs
  76. - cockpit-bridge
  77. - cockpit-docker
  78. - cockpit-shell
  79. - cockpit-ws
  80. - corosync
  81. - etcd
  82. - haproxy
  83. - kubernetes-client
  84. - openshift
  85. - openshift-master
  86. - openshift-node
  87. - openshift-sdn
  88. - openshift-sdn-ovs
  89. - openvswitch
  90. - origin
  91. - origin-clients
  92. - origin-master
  93. - origin-node
  94. - origin-sdn-ovs
  95. - pacemaker
  96. - pcs
  97. - tuned-profiles-atomic-enterprise-node
  98. - tuned-profiles-atomic-openshift-node
  99. - tuned-profiles-openshift-node
  100. - tuned-profiles-origin-node
  101. - name: Remove linux interfaces
  102. shell: ip link del "{{ item }}"
  103. changed_when: False
  104. failed_when: False
  105. with_items:
  106. - lbr0
  107. - vlinuxbr
  108. - vovsbr
  109. - shell: systemctl reset-failed
  110. changed_when: False
  111. - shell: systemctl daemon-reload
  112. changed_when: False
  113. - shell: find /var/lib/origin/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  114. changed_when: False
  115. - shell: find /var/lib/atomic-enterprise/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  116. changed_when: False
  117. - shell: find /var/lib/openshift/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  118. changed_when: False
  119. - shell: docker rm -f "{{ item }}"-master "{{ item }}"-node
  120. changed_when: False
  121. failed_when: False
  122. with_items:
  123. - openshift-enterprise
  124. - atomic-enterprise
  125. - origin
  126. - shell: docker ps -a | grep Exited | egrep "{{ item }}" | awk '{print $1}'
  127. changed_when: False
  128. failed_when: False
  129. register: exited_containers_to_delete
  130. with_items:
  131. - aep3.*/aep
  132. - aep3.*/node
  133. - aep3.*/openvswitch
  134. - openshift3/ose
  135. - openshift3/node
  136. - openshift3/openvswitch
  137. - openshift/origin
  138. - shell: "docker rm {{ item.stdout_lines | join(' ') }}"
  139. changed_when: False
  140. failed_when: False
  141. with_items: "{{ exited_containers_to_delete.results }}"
  142. - shell: docker images | egrep {{ item }} | awk '{ print $3 }'
  143. changed_when: False
  144. failed_when: False
  145. register: images_to_delete
  146. with_items:
  147. - registry\.access\..*redhat\.com/openshift3
  148. - registry\.access\..*redhat\.com/aep3
  149. - registry\.qe\.openshift\.com/.*
  150. - registry\.access\..*redhat\.com/rhel7/etcd
  151. - docker.io/openshift
  152. - shell: "docker rmi -f {{ item.stdout_lines | join(' ') }}"
  153. changed_when: False
  154. failed_when: False
  155. with_items: "{{ images_to_delete.results }}"
  156. - name: Remove sdn drop files
  157. file:
  158. path: /run/openshift-sdn
  159. state: absent
  160. - name: restart docker
  161. service:
  162. name: docker
  163. state: restarted
  164. - name: Remove remaining files
  165. file: path={{ item }} state=absent
  166. with_items:
  167. - "~{{ ansible_ssh_user }}/.kube"
  168. - /etc/ansible/facts.d/openshift.fact
  169. - /etc/atomic-enterprise
  170. - /etc/corosync
  171. - /etc/etcd
  172. - /etc/openshift
  173. - /etc/openshift-sdn
  174. - /etc/origin
  175. - /etc/systemd/system/atomic-openshift-master.service
  176. - /etc/systemd/system/atomic-openshift-master-api.service
  177. - /etc/systemd/system/atomic-openshift-master-controllers.service
  178. - /etc/systemd/system/atomic-openshift-node.service
  179. - /etc/systemd/system/etcd_container.service
  180. - /etc/systemd/system/openvswitch.service
  181. - /etc/sysconfig/atomic-enterprise-master
  182. - /etc/sysconfig/atomic-enterprise-master-api
  183. - /etc/sysconfig/atomic-enterprise-master-controllers
  184. - /etc/sysconfig/atomic-enterprise-node
  185. - /etc/sysconfig/atomic-openshift-master
  186. - /etc/sysconfig/atomic-openshift-master-api
  187. - /etc/sysconfig/atomic-openshift-master-controllers
  188. - /etc/sysconfig/atomic-openshift-node
  189. - /etc/sysconfig/openshift-master
  190. - /etc/sysconfig/openshift-node
  191. - /etc/sysconfig/openvswitch
  192. - /etc/sysconfig/origin-master
  193. - /etc/sysconfig/origin-master-api
  194. - /etc/sysconfig/origin-master-controllers
  195. - /etc/sysconfig/origin-node
  196. - /etc/systemd/system/atomic-openshift-node.service.wants
  197. - /root/.kube
  198. - /run/openshift-sdn
  199. - /usr/share/openshift/examples
  200. - /var/lib/atomic-enterprise
  201. - /var/lib/etcd
  202. - /var/lib/openshift
  203. - /var/lib/origin
  204. - /var/lib/pacemaker
  205. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  206. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  207. - /usr/lib/systemd/system/origin-master-api.service
  208. - /usr/lib/systemd/system/origin-master-controllers.service
  209. - /usr/local/bin/openshift
  210. - /usr/local/bin/oadm
  211. - /usr/local/bin/oc
  212. - /usr/local/bin/kubectl
  213. - /etc/NetworkManager/dispatcher.d/99-origin-dns.sh
  214. - /etc/dnsmasq.d/origin-dns.conf
  215. - /etc/dnsmasq.d/origin-upstream-dns.conf
  216. # Since we are potentially removing the systemd unit files for separated
  217. # master-api and master-controllers services, so we need to reload the
  218. # systemd configuration manager
  219. - name: Reload systemd manager configuration
  220. command: systemctl daemon-reload
  221. - hosts: nodes
  222. become: yes
  223. tasks:
  224. - name: restart docker
  225. service: name=docker state=restarted
  226. - name: restart NetworkManager
  227. service: name=NetworkManager state=restarted