123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- # This deletes *ALL* Origin and OpenShift Enterprise content installed by
- # ansible. This includes:
- #
- # configuration
- # containers
- # example templates and imagestreams
- # images
- # RPMs
- ---
- - hosts: OSEv3:children
- become: yes
- tasks:
- - name: Detecting Operating System
- shell: ls /run/ostree-booted
- ignore_errors: yes
- failed_when: false
- register: ostree_output
- # Since we're not calling openshift_facts we'll do this for now
- - set_fact:
- openshift_is_atomic: "{{ ostree_output.rc == 0 }}"
- openshift_is_containerized: "{{ ostree_output.rc == 0 or containerized | default(false) | bool }}"
- # Stop services on all hosts prior to removing files.
- - hosts: nodes
- become: yes
- tasks:
- - name: Remove dnsmasq dispatcher
- file:
- path: "{{ item }}"
- state: absent
- with_items:
- - /etc/dnsmasq.d/origin-dns.conf
- - /etc/dnsmasq.d/origin-upstream-dns.conf
- - /etc/dnsmasq.d/openshift-ansible.conf
- - /etc/NetworkManager/dispatcher.d/99-origin-dns.sh
- - service:
- name: NetworkManager
- state: restarted
- - name: Stop services
- service: name={{ item }} state=stopped
- with_items:
- - atomic-openshift-node
- - openshift-node
- - openvswitch
- - origin-node
- failed_when: false
- - hosts: masters
- become: yes
- tasks:
- - name: Stop services
- service: name={{ item }} state=stopped
- with_items:
- - atomic-openshift-master
- - atomic-openshift-master-api
- - atomic-openshift-master-controllers
- - openshift-master
- - openshift-master-api
- - openshift-master-controllers
- - origin-master
- - origin-master-api
- - origin-master-controllers
- failed_when: false
- - hosts: etcd
- become: yes
- tasks:
- - name: Stop services
- service: name={{ item }} state=stopped
- with_items:
- - etcd
- failed_when: false
- - hosts: lb
- become: yes
- tasks:
- - name: Stop services
- service: name={{ item }} state=stopped
- with_items:
- - haproxy
- failed_when: false
- - hosts: nodes
- become: yes
- vars:
- node_dirs:
- - "/etc/origin"
- - "/var/lib/origin"
- tasks:
- - name: unmask services
- command: systemctl unmask "{{ item }}"
- changed_when: False
- failed_when: False
- with_items:
- - firewalld
- - block:
- - block:
- - name: Remove packages
- package: name={{ item }} state=absent
- with_items:
- - atomic-openshift
- - atomic-openshift-clients
- - atomic-openshift-excluder
- - atomic-openshift-docker-excluder
- - atomic-openshift-node
- - atomic-openshift-sdn-ovs
- - cockpit-bridge
- - cockpit-docker
- - cockpit-system
- - cockpit-ws
- - kubernetes-client
- - openshift
- - openshift-node
- - openshift-sdn
- - openshift-sdn-ovs
- - openvswitch
- - origin
- - origin-excluder
- - origin-docker-excluder
- - origin-clients
- - origin-node
- - origin-sdn-ovs
- - tuned-profiles-atomic-openshift-node
- - tuned-profiles-origin-node
- register: result
- until: result is succeeded
- - name: Remove flannel package
- package: name=flannel state=absent
- when: openshift_use_flannel | default(false) | bool
- register: result
- until: result is succeeded
- when: not openshift_is_atomic | bool
- - shell: systemctl reset-failed
- changed_when: False
- - shell: systemctl daemon-reload
- changed_when: False
- - name: Remove br0 interface
- shell: ovs-vsctl del-br br0
- changed_when: False
- failed_when: False
- - name: Remove linux interfaces
- shell: ip link del "{{ item }}"
- changed_when: False
- failed_when: False
- with_items:
- - lbr0
- - vlinuxbr
- - vovsbr
- - name: Remove virtual devices
- command: nmcli delete device "{{ item }}"
- failed_when: False
- with_items:
- - tun0
- - docker0
- when: openshift_remove_all | default(true) | bool
- - shell: atomic uninstall "{{ item }}"-master-api
- changed_when: False
- failed_when: False
- with_items:
- - openshift-enterprise
- - origin
- - shell: atomic uninstall "{{ item }}"-master-controllers
- changed_when: False
- failed_when: False
- with_items:
- - openshift-enterprise
- - origin
- - shell: atomic uninstall "{{ item }}"-master
- changed_when: False
- failed_when: False
- with_items:
- - openshift-enterprise
- - origin
- - shell: atomic uninstall "{{ item }}"-node
- changed_when: False
- failed_when: False
- with_items:
- - openshift-enterprise
- - origin
- - shell: atomic uninstall "{{ item }}"
- changed_when: False
- failed_when: False
- with_items:
- - etcd
- - openvswitch
- - shell: find /var/lib/origin/openshift.local.volumes -type d -exec umount {} \; 2>/dev/null || true
- changed_when: False
- - shell: docker rm -f "{{ item }}"-master "{{ item }}"-node
- changed_when: False
- failed_when: False
- with_items:
- - openshift-enterprise
- - origin
- - shell: docker ps -a | grep Exited | egrep "{{ item }}" | awk '{print $1}'
- changed_when: False
- failed_when: False
- register: exited_containers_to_delete
- with_items:
- - openshift3/ose
- - openshift3/node
- - openshift3/openvswitch
- - openshift/origin
- - shell: "docker rm {{ item.stdout_lines | join(' ') }}"
- changed_when: False
- failed_when: False
- with_items: "{{ exited_containers_to_delete.results }}"
- - block:
- - block:
- - shell: docker images | egrep {{ item }} | awk '{ print $3 }'
- changed_when: False
- failed_when: False
- register: images_to_delete
- with_items:
- - registry\.access\..*redhat\.com/openshift3
- - registry\.qe\.openshift\.com/.*
- - registry\.access\..*redhat\.com/rhel7/etcd
- - docker.io/openshift
- - shell: "docker rmi -f {{ item.stdout_lines | join(' ') }}"
- changed_when: False
- failed_when: False
- with_items: "{{ images_to_delete.results }}"
- when: openshift_uninstall_images | default(True) | bool
- - name: remove sdn drop files
- file:
- path: /run/openshift-sdn
- state: absent
- - name: Remove files owned by RPMs
- file: path={{ item }} state=absent
- with_items:
- - /etc/sysconfig/openshift-node
- - /etc/sysconfig/openvswitch
- - /run/openshift-sdn
- when: openshift_remove_all | default(True) | bool
- - find: path={{ item }} file_type=file
- register: files
- with_items:
- - "{{ node_dirs }}"
- - find: path={{ item }} file_type=directory
- register: directories
- with_items:
- - "{{ node_dirs }}"
- - file: path={{ item.1.path }} state=absent
- with_subelements:
- - "{{ files.results | default([]) }}"
- - files
- - file: path={{ item.1.path }} state=absent
- with_subelements:
- - "{{ directories.results | default([]) }}"
- - files
- - shell: systemctl daemon-reload
- changed_when: False
- - name: restart container-engine
- service: name=container-engine state=stopped enabled=no
- failed_when: false
- register: container_engine
- - name: restart docker
- service: name=docker state=stopped enabled=no
- failed_when: false
- when: not (container_engine is changed)
- register: l_docker_restart_docker_in_pb_result
- until: not (l_docker_restart_docker_in_pb_result is failed)
- retries: 3
- delay: 30
- - name: Remove remaining files
- file: path={{ item }} state=absent
- with_items:
- - /etc/ansible/facts.d/openshift.fact
- - /etc/openshift
- - /etc/openshift-sdn
- - /etc/pki/ca-trust/source/anchors/openshift-ca.crt
- - /etc/sysconfig/atomic-openshift-node
- - /etc/sysconfig/atomic-openshift-node-dep
- - /etc/sysconfig/openshift-node-dep
- - /etc/sysconfig/origin-node
- - /etc/sysconfig/origin-node
- - /etc/sysconfig/origin-node-dep
- - /etc/systemd/system/atomic-openshift-node-dep.service
- - /etc/systemd/system/atomic-openshift-node.service
- - /etc/systemd/system/atomic-openshift-node.service.wants
- - /etc/systemd/system/docker.service.d/docker-sdn-ovs.conf
- - /etc/systemd/system/openvswitch.service
- - /etc/systemd/system/origin-node-dep.service
- - /etc/systemd/system/origin-node.service
- - /etc/systemd/system/origin-node.service.wants
- - /var/lib/docker
- - name: Rebuild ca-trust
- command: update-ca-trust
- - name: Reset Docker proxy configuration
- lineinfile:
- state=absent
- dest=/etc/sysconfig/docker
- regexp='(NO_PROXY|HTTP_PROXY|HTTPS_PROXY)=.*'
- - name: Reset Docker registry configuration
- lineinfile:
- state=absent
- dest=/etc/sysconfig/docker
- regexp='(ADD_REGISTRY|BLOCK_REGISTRY|INSECURE_REGISTRY)=.*'
- - name: Detect Docker storage configuration
- shell: vgs -o name | grep docker
- register: docker_vg_name
- failed_when: false
- changed_when: false
- - name: Wipe out Docker storage contents
- command: vgremove -f {{ item }}
- with_items: "{{ docker_vg_name.stdout_lines }}"
- when: docker_vg_name.rc == 0
- - name: Wipe out Docker storage configuration
- file: path=/etc/sysconfig/docker-storage state=absent
- when: docker_vg_name.rc == 0
- - hosts: masters
- become: yes
- vars:
- master_dirs:
- - "/etc/origin"
- - "/var/lib/origin"
- tasks:
- - name: unmask services
- command: systemctl unmask "{{ item }}"
- changed_when: False
- failed_when: False
- with_items:
- - firewalld
- - atomic-openshift-master
- - name: Remove packages
- package: name={{ item }} state=absent
- when: not openshift_is_atomic | bool and openshift_remove_all | default(True) | bool
- with_items:
- - atomic-openshift
- - atomic-openshift-clients
- - atomic-openshift-excluder
- - atomic-openshift-docker-excluder
- - atomic-openshift-master
- - cockpit-bridge
- - cockpit-docker
- - cockpit-system
- - cockpit-ws
- - corosync
- - kubernetes-client
- - openshift
- - openshift-master
- - origin
- - origin-clients
- - origin-excluder
- - origin-docker-excluder
- - origin-master
- register: result
- until: result is succeeded
- - shell: systemctl reset-failed
- changed_when: False
- - shell: systemctl daemon-reload
- changed_when: False
- - name: Remove files owned by RPMs
- file: path={{ item }} state=absent
- when: openshift_remove_all | default(True) | bool
- with_items:
- - /etc/sysconfig/atomic-openshift-master
- - /etc/sysconfig/openvswitch
- - find: path={{ item }} file_type=file
- register: files
- with_items:
- - "{{ master_dirs }}"
- - find: path={{ item }} file_type=directory
- register: directories
- with_items:
- - "{{ master_dirs }}"
- - file: path={{ item.1.path }} state=absent
- with_subelements:
- - "{{ files.results | default([]) }}"
- - files
- - file: path={{ item.1.path }} state=absent
- with_subelements:
- - "{{ directories.results | default([]) }}"
- - files
- - set_fact:
- client_users: "{{ [ansible_ssh_user, 'root'] | unique }}"
- - name: Remove client kubeconfigs
- file:
- path: "~{{ item }}/.kube"
- state: absent
- with_items:
- - "{{ client_users }}"
- - name: Remove remaining files
- file: path={{ item }} state=absent
- with_items:
- - /etc/ansible/facts.d/openshift.fact
- - /etc/corosync
- - /etc/openshift
- - /etc/openshift-sdn
- - /etc/systemd/system/atomic-openshift-master.service
- - /etc/systemd/system/atomic-openshift-master-api.service
- - /etc/systemd/system/atomic-openshift-master-controllers.service
- - /etc/systemd/system/origin-master.service
- - /etc/systemd/system/origin-master-api.service
- - /etc/systemd/system/origin-master-controllers.service
- - /etc/systemd/system/openvswitch.service
- - /etc/sysconfig/atomic-openshift-master-api
- - /etc/sysconfig/atomic-openshift-master-controllers
- - /etc/sysconfig/origin-master
- - /etc/sysconfig/origin-master-api
- - /etc/sysconfig/origin-master-controllers
- - /etc/sysconfig/openshift-master
- - /etc/sysconfig/origin-master
- - /etc/sysconfig/origin-master-api
- - /etc/sysconfig/origin-master-controllers
- - /usr/share/openshift/examples
- - /usr/lib/systemd/system/atomic-openshift-master-api.service
- - /usr/lib/systemd/system/atomic-openshift-master-controllers.service
- - /usr/lib/systemd/system/origin-master-api.service
- - /usr/lib/systemd/system/origin-master-controllers.service
- - /usr/local/bin/openshift
- - /usr/local/bin/oadm
- - /usr/local/bin/oc
- - /usr/local/bin/kubectl
- - /etc/flannel
- # Since we are potentially removing the systemd unit files for separated
- # master-api and master-controllers services, so we need to reload the
- # systemd configuration manager
- - name: Reload systemd manager configuration
- command: systemctl daemon-reload
- - hosts: etcd
- become: yes
- vars:
- etcd_dirs:
- - "/etc/etcd"
- - "/var/lib/etcd"
- tasks:
- - name: unmask services
- command: systemctl unmask "{{ item }}"
- changed_when: False
- failed_when: False
- with_items:
- - etcd
- - etcd3
- - firewalld
- - name: Stop additional atomic services
- service: name={{ item }} state=stopped
- when: openshift_is_containerized | bool
- with_items:
- - etcd_container
- failed_when: false
- - name: Remove packages
- package: name={{ item }} state=absent
- when: not openshift_is_atomic | bool and openshift_remove_all | default(True) | bool
- with_items:
- - etcd
- - etcd3
- register: result
- until: result is succeeded
- - shell: systemctl reset-failed
- changed_when: False
- - shell: systemctl daemon-reload
- changed_when: False
- - find: path={{ item }} file_type=file
- register: files
- with_items:
- - "{{ etcd_dirs }}"
- - find: path={{ item }} file_type=directory
- register: directories
- with_items:
- - "{{ etcd_dirs }}"
- - file: path={{ item.1.path }} state=absent
- with_subelements:
- - "{{ files.results | default([]) }}"
- - files
- - file: path={{ item.1.path }} state=absent
- with_subelements:
- - "{{ directories.results | default([]) }}"
- - files
- # Intenationally using rm command over file module because if someone had mounted a filesystem
- # at /var/lib/etcd then the contents was not removed correctly
- - name: Remove etcd data
- shell: rm -rf /var/lib/etcd/*
- args:
- warn: no
- failed_when: false
- - name: Remove remaining files
- file: path={{ item }} state=absent
- with_items:
- - /etc/ansible/facts.d/openshift.fact
- - /etc/systemd/system/etcd_container.service
- - /etc/profile.d/etcdctl.sh
- - hosts: lb
- become: yes
- tasks:
- - name: unmask services
- command: systemctl unmask "{{ item }}"
- changed_when: False
- failed_when: False
- with_items:
- - firewalld
- - name: Remove packages
- package: name={{ item }} state=absent
- when: not openshift_is_atomic | bool and openshift_remove_all | default(True) | bool
- with_items:
- - haproxy
- register: result
- until: result is succeeded
- - shell: systemctl reset-failed
- changed_when: False
- - shell: systemctl daemon-reload
- changed_when: False
- - name: Remove remaining files
- file: path={{ item }} state=absent
- with_items:
- - /etc/ansible/facts.d/openshift.fact
- - /var/lib/haproxy/stats
- # Here we remove only limits.conf rather than directory, as users may put their files.
- # - /etc/systemd/system/haproxy.service.d
- - /etc/systemd/system/haproxy.service.d/limits.conf
- - /etc/systemd/system/haproxy.service
|