#--------------------------------------------------------------------------- # Copyright IBM Corp. 2015, 2015 All Rights Reserved # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # Limitations under the License. #--------------------------------------------------------------------------- - stat: path=/usr/bin/docker register: st - name: Stop all running containers shell: docker ps -a -q register: docker when: st.stat.exists - shell: docker stop {{ docker.stdout_lines[0] }} when: st.stat.exists and docker is defined and stdout_lines in docker - name: Delete all running containers shell: docker rm "{{ docker.stdout_lines[0] }}" when: st.stat.exists and docker is defined and stdout_lines in docker - name: stop the docker service service: name=docker state=stopped when: st.stat.exists - name: uninstall docker apt: name=lxc-docker state=absent purge=yes when: st.stat.exists - name: make sure all docker stuff is removed shell: apt-get -y autoremove when: st.stat.exists - name: cleanup docker runtime stat: path="{{ docker_device }}/docker" register: p - shell: rm -fr "{{ docker_device }}"/docker when: p.stat.exists ignore_errors: yes - stat: path=/var/lib/docker register: p - shell: rm -fr /var/lib/docker when: p.stat.exists - name: cleanup conf files stat: path=/etc/default/docker register: p - shell: rm -f /etc/default/docker when: p.stat.exists - stat: path=/etc/init/docker.conf register: p - shell: rm -f /etc/init/docker.conf when: p.stat.exists - stat: path=/etc/init.d/docker register: p - shell: rm -f /etc/init.d/docker when: p.stat.exists