uninstall.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. - openshift-master
  39. - openshift-master-api
  40. - openshift-master-controllers
  41. - openshift-node
  42. - openvswitch
  43. - origin-master
  44. - origin-master-api
  45. - origin-master-controllers
  46. - origin-node
  47. - pcsd
  48. failed_when: false
  49. - name: Remove packages
  50. action: "{{ ansible_pkg_mgr }} name={{ item }} state=absent"
  51. when: not is_atomic | bool
  52. with_items:
  53. - atomic-enterprise
  54. - atomic-enterprise-master
  55. - atomic-enterprise-node
  56. - atomic-enterprise-sdn-ovs
  57. - atomic-openshift
  58. - atomic-openshift-clients
  59. - atomic-openshift-master
  60. - atomic-openshift-node
  61. - atomic-openshift-sdn-ovs
  62. - corosync
  63. - etcd
  64. - openshift
  65. - openshift-master
  66. - openshift-node
  67. - openshift-sdn
  68. - openshift-sdn-ovs
  69. - openvswitch
  70. - origin
  71. - origin-clients
  72. - origin-master
  73. - origin-node
  74. - origin-sdn-ovs
  75. - pacemaker
  76. - pcs
  77. - tuned-profiles-atomic-enterprise-node
  78. - tuned-profiles-atomic-openshift-node
  79. - tuned-profiles-openshift-node
  80. - tuned-profiles-origin-node
  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: systemctl reset-failed
  90. changed_when: False
  91. - shell: systemctl daemon-reload
  92. changed_when: False
  93. - shell: find /var/lib/origin/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  94. changed_when: False
  95. - shell: find /var/lib/atomic-enterprise/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  96. changed_when: False
  97. - shell: find /var/lib/openshift/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
  98. changed_when: False
  99. - shell: docker rm -f "{{ item }}"-master "{{ item }}"-node
  100. changed_when: False
  101. failed_when: False
  102. with_items:
  103. - openshift-enterprise
  104. - atomic-enterprise
  105. - origin
  106. - shell: docker ps -a | grep Exited | egrep "{{ item }}" | awk '{print $1}'
  107. changed_when: False
  108. failed_when: False
  109. register: exited_containers_to_delete
  110. with_items:
  111. - aep3.*/aep
  112. - openshift3/ose
  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\.access\..*redhat\.com/rhel7/etcd
  126. - docker.io/openshift
  127. - shell: "docker rmi -f {{ item.stdout_lines | join(' ') }}"
  128. changed_when: False
  129. failed_when: False
  130. with_items: "{{ images_to_delete.results }}"
  131. - name: Remove sdn drop files
  132. file:
  133. path: /run/openshift-sdn
  134. state: absent
  135. - name: restart docker
  136. service:
  137. name: docker
  138. state: restarted
  139. - name: Remove remaining files
  140. file: path={{ item }} state=absent
  141. with_items:
  142. - "~{{ ansible_ssh_user }}/.kube"
  143. - /etc/ansible/facts.d/openshift.fact
  144. - /etc/atomic-enterprise
  145. - /etc/corosync
  146. - /etc/etcd
  147. - /etc/openshift
  148. - /etc/openshift-sdn
  149. - /etc/origin
  150. - /etc/systemd/system/atomic-openshift-master.service
  151. - /etc/systemd/system/atomic-openshift-master-api.service
  152. - /etc/systemd/system/atomic-openshift-master-controllers.service
  153. - /etc/systemd/system/atomic-openshift-node.service
  154. - /etc/systemd/system/etcd_container.service
  155. - /etc/systemd/system/openvswitch.service
  156. - /etc/sysconfig/atomic-enterprise-master
  157. - /etc/sysconfig/atomic-enterprise-master-api
  158. - /etc/sysconfig/atomic-enterprise-master-controllers
  159. - /etc/sysconfig/atomic-enterprise-node
  160. - /etc/sysconfig/atomic-openshift-master
  161. - /etc/sysconfig/atomic-openshift-master-api
  162. - /etc/sysconfig/atomic-openshift-master-controllers
  163. - /etc/sysconfig/atomic-openshift-node
  164. - /etc/sysconfig/openshift-master
  165. - /etc/sysconfig/openshift-node
  166. - /etc/sysconfig/origin-master
  167. - /etc/sysconfig/origin-master-api
  168. - /etc/sysconfig/origin-master-controllers
  169. - /etc/sysconfig/origin-node
  170. - /etc/systemd/system/atomic-openshift-node.service.wants
  171. - /root/.kube
  172. - /run/openshift-sdn
  173. - /usr/share/openshift/examples
  174. - /var/lib/atomic-enterprise
  175. - /var/lib/etcd
  176. - /var/lib/openshift
  177. - /var/lib/origin
  178. - /var/lib/pacemaker
  179. - /usr/lib/systemd/system/atomic-openshift-master-api.service
  180. - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
  181. - /usr/lib/systemd/system/origin-master-api.service
  182. - /usr/lib/systemd/system/origin-master-controllers.service
  183. # Since we are potentially removing the systemd unit files for separated
  184. # master-api and master-controllers services, so we need to reload the
  185. # systemd configuration manager
  186. - name: Reload systemd manager configuration
  187. command: systemctl daemon-reload
  188. - hosts: nodes
  189. sudo: yes
  190. tasks:
  191. - name: restart docker
  192. service: name=docker state=restarted