Skip to content

Commit

Permalink
Modified the role: soft-reset v4
Browse files Browse the repository at this point in the history
- remove images, volumes and containers together
  • Loading branch information
d80ep08th committed Sep 7, 2022
1 parent b50d256 commit cc2f27b
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions roles/soft-reset/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,15 @@
- name: Tear down existing services
community.docker.docker_compose:
project_src: /etc/uptane/
remove_images: all
remove_volumes: yes
state: absent
register: output

- ansible.builtin.debug:
var: output

- name: Make sure the directory ota-ce-gen is deleted
file:
state: absent
path: /etc/uptane/ota-ce-gen


- name: Make sure all docker containers are removed
ansible.builtin.shell: docker container ls -a
failed_when: false
register: output
changed_when: false

- name: Remove containers if they arent removed
become: true
ansible.builtin.shell: docker container ls -a | awk '{if (NR!=1) {print $1}}'| xargs -n1 docker container rm
when: output.rc != 0

- name: Make sure all docker images are removed
ansible.builtin.shell: docker image ls | awk '{if (NR!=1) {print $3}}'| xargs -n1 docker image rm

- name: Make sure all docker volumes are removed
ansible.builtin.shell: docker volume ls | awk '{if (NR!=1) {print $2}}'| xargs -n1 docker volume rm

0 comments on commit cc2f27b

Please sign in to comment.