uninstall.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. sudo: 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: Stop additional atomic services
  51. service: name={{ item }} state=stopped
  52. when: is_atomic | bool
  53. with_items:
  54. - etcd_container
  55. failed_when: false
  56. - name: Remove packages
  57. action: "{{ ansible_pkg_mgr }} name={{ item }} state=absent"
  58. when: not is_atomic | bool
  59. with_items:
  60. - atomic-enterprise
  61. - atomic-enterprise-master
  62. - atomic-enterprise-node
  63. - atomic-enterprise-sdn-ovs
  64. - atomic-openshift
  65. - atomic-openshift-clients
  66. - atomic-openshift-master
  67. - atomic-openshift-node
  68. - atomic-openshift-sdn-ovs
  69. - corosync
  70. - etcd
  71. - haproxy
  72. - openshift
  73. - openshift-master
  74. - openshift-node
  75. - openshift-sdn
  76. - openshift-sdn-ovs
  77. - openvswitch
  78. - origin
  79. - origin-clients
  80. - origin-master
  81. - origin-node
  82. - origin-sdn-ovs
  83. - pacemaker
  84. - pcs
  85. - tuned-profiles-atomic-enterprise-node
  86. - tuned-profiles-atomic-openshift-node
  87. - tuned-profiles-openshift-node
  88. - tuned-profiles-origin-node
  89. - name: Remove linux interfaces
  90. shell: ip link del "{{ item }}"
  91. changed_when: False
  92. failed_when: False
  93. with_items:
  94. - lbr0
  95. - vlinuxbr
  96. - vovsbr
  97. - shell: systemctl reset-failed
  98. changed_when: False
  99. - shell: systemctl daemon-reload
  100. changed_when: False
  101. - shell: find /var/lib/origin/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  102. changed_when: False
  103. - shell: find /var/lib/atomic-enterprise/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  104. changed_when: False
  105. - shell: find /var/lib/openshift/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  106. changed_when: False
  107. - shell: docker rm -f "{{ item }}"-master "{{ item }}"-node
  108. changed_when: False
  109. failed_when: False
  110. with_items:
  111. - openshift-enterprise
  112. - atomic-enterprise
  113. - origin
  114. - shell: docker ps -a | grep Exited | egrep "{{ item }}" | awk '{print $1}'
  115. changed_when: False
  116. failed_when: False
  117. register: exited_containers_to_delete
  118. with_items:
  119. - aep3.*/aep
  120. - aep3.*/node
  121. - aep3.*/openvswitch
  122. - openshift3/ose
  123. - openshift3/node
  124. - openshift3/openvswitch
  125. - openshift/origin
  126. - shell: "docker rm {{ item.stdout_lines | join(' ') }}"
  127. changed_when: False
  128. failed_when: False
  129. with_items: "{{ exited_containers_to_delete.results }}"
  130. - shell: docker images | egrep {{ item }} | awk '{ print $3 }'
  131. changed_when: False
  132. failed_when: False
  133. register: images_to_delete
  134. with_items:
  135. - registry\.access\..*redhat\.com/openshift3
  136. - registry\.access\..*redhat\.com/aep3
  137. - registry\.qe\.openshift\.com/.*
  138. - registry\.access\..*redhat\.com/rhel7/etcd
  139. - docker.io/openshift
  140. - shell: "docker rmi -f {{ item.stdout_lines | join(' ') }}"
  141. changed_when: False
  142. failed_when: False
  143. with_items: "{{ images_to_delete.results }}"
  144. - name: Remove sdn drop files
  145. file:
  146. path: /run/openshift-sdn
  147. state: absent
  148. - name: restart docker
  149. service:
  150. name: docker
  151. state: restarted
  152. - name: Remove remaining files
  153. file: path={{ item }} state=absent
  154. with_items:
  155. - "~{{ ansible_ssh_user }}/.kube"
  156. - /etc/ansible/facts.d/openshift.fact
  157. - /etc/atomic-enterprise
  158. - /etc/corosync
  159. - /etc/etcd
  160. - /etc/openshift
  161. - /etc/openshift-sdn
  162. - /etc/origin
  163. - /etc/systemd/system/atomic-openshift-master.service
  164. - /etc/systemd/system/atomic-openshift-master-api.service
  165. - /etc/systemd/system/atomic-openshift-master-controllers.service
  166. - /etc/systemd/system/atomic-openshift-node.service
  167. - /etc/systemd/system/etcd_container.service
  168. - /etc/systemd/system/openvswitch.service
  169. - /etc/sysconfig/atomic-enterprise-master
  170. - /etc/sysconfig/atomic-enterprise-master-api
  171. - /etc/sysconfig/atomic-enterprise-master-controllers
  172. - /etc/sysconfig/atomic-enterprise-node
  173. - /etc/sysconfig/atomic-openshift-master
  174. - /etc/sysconfig/atomic-openshift-master-api
  175. - /etc/sysconfig/atomic-openshift-master-controllers
  176. - /etc/sysconfig/atomic-openshift-node
  177. - /etc/sysconfig/openshift-master
  178. - /etc/sysconfig/openshift-node
  179. - /etc/sysconfig/openvswitch
  180. - /etc/sysconfig/origin-master
  181. - /etc/sysconfig/origin-master-api
  182. - /etc/sysconfig/origin-master-controllers
  183. - /etc/sysconfig/origin-node
  184. - /etc/systemd/system/atomic-openshift-node.service.wants
  185. - /root/.kube
  186. - /run/openshift-sdn
  187. - /usr/share/openshift/examples
  188. - /var/lib/atomic-enterprise
  189. - /var/lib/etcd
  190. - /var/lib/openshift
  191. - /var/lib/origin
  192. - /var/lib/pacemaker
  193. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  194. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  195. - /usr/lib/systemd/system/origin-master-api.service
  196. - /usr/lib/systemd/system/origin-master-controllers.service
  197. - /usr/local/bin/openshift
  198. - /usr/local/bin/oadm
  199. - /usr/local/bin/oc
  200. - /usr/local/bin/kubectl
  201. # Since we are potentially removing the systemd unit files for separated
  202. # master-api and master-controllers services, so we need to reload the
  203. # systemd configuration manager
  204. - name: Reload systemd manager configuration
  205. command: systemctl daemon-reload
  206. - hosts: nodes
  207. sudo: yes
  208. tasks:
  209. - name: restart docker
  210. service: name=docker state=restarted