uninstall.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. - openshift3/ose
  121. - openshift/origin
  122. - shell: "docker rm {{ item.stdout_lines | join(' ') }}"
  123. changed_when: False
  124. failed_when: False
  125. with_items: "{{ exited_containers_to_delete.results }}"
  126. - shell: docker images | egrep {{ item }} | awk '{ print $3 }'
  127. changed_when: False
  128. failed_when: False
  129. register: images_to_delete
  130. with_items:
  131. - registry\.access\..*redhat\.com/openshift3
  132. - registry\.access\..*redhat\.com/aep3
  133. - registry\.access\..*redhat\.com/rhel7/etcd
  134. - docker.io/openshift
  135. - shell: "docker rmi -f {{ item.stdout_lines | join(' ') }}"
  136. changed_when: False
  137. failed_when: False
  138. with_items: "{{ images_to_delete.results }}"
  139. - name: Remove sdn drop files
  140. file:
  141. path: /run/openshift-sdn
  142. state: absent
  143. - name: restart docker
  144. service:
  145. name: docker
  146. state: restarted
  147. - name: Remove remaining files
  148. file: path={{ item }} state=absent
  149. with_items:
  150. - "~{{ ansible_ssh_user }}/.kube"
  151. - /etc/ansible/facts.d/openshift.fact
  152. - /etc/atomic-enterprise
  153. - /etc/corosync
  154. - /etc/etcd
  155. - /etc/openshift
  156. - /etc/openshift-sdn
  157. - /etc/origin
  158. - /etc/systemd/system/atomic-openshift-master.service
  159. - /etc/systemd/system/atomic-openshift-master-api.service
  160. - /etc/systemd/system/atomic-openshift-master-controllers.service
  161. - /etc/systemd/system/atomic-openshift-node.service
  162. - /etc/systemd/system/etcd_container.service
  163. - /etc/systemd/system/openvswitch.service
  164. - /etc/sysconfig/atomic-enterprise-master
  165. - /etc/sysconfig/atomic-enterprise-master-api
  166. - /etc/sysconfig/atomic-enterprise-master-controllers
  167. - /etc/sysconfig/atomic-enterprise-node
  168. - /etc/sysconfig/atomic-openshift-master
  169. - /etc/sysconfig/atomic-openshift-master-api
  170. - /etc/sysconfig/atomic-openshift-master-controllers
  171. - /etc/sysconfig/atomic-openshift-node
  172. - /etc/sysconfig/openshift-master
  173. - /etc/sysconfig/openshift-node
  174. - /etc/sysconfig/origin-master
  175. - /etc/sysconfig/origin-master-api
  176. - /etc/sysconfig/origin-master-controllers
  177. - /etc/sysconfig/origin-node
  178. - /etc/systemd/system/atomic-openshift-node.service.wants
  179. - /root/.kube
  180. - /run/openshift-sdn
  181. - /usr/share/openshift/examples
  182. - /var/lib/atomic-enterprise
  183. - /var/lib/etcd
  184. - /var/lib/openshift
  185. - /var/lib/origin
  186. - /var/lib/pacemaker
  187. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  188. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  189. - /usr/lib/systemd/system/origin-master-api.service
  190. - /usr/lib/systemd/system/origin-master-controllers.service
  191. - /usr/local/bin/openshift
  192. - /usr/local/bin/oadm
  193. - /usr/local/bin/oc
  194. - /usr/local/bin/kubectl
  195. # Since we are potentially removing the systemd unit files for separated
  196. # master-api and master-controllers services, so we need to reload the
  197. # systemd configuration manager
  198. - name: Reload systemd manager configuration
  199. command: systemctl daemon-reload
  200. - hosts: nodes
  201. sudo: yes
  202. tasks:
  203. - name: restart docker
  204. service: name=docker state=restarted