2024-03-06 01:48:51 +01:00

19 lines
614 B
YAML

---
- name: Create
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: find current container state
ansible.builtin.command: incus ls "{{ item.name }}-container"
register: state
changed_when: false
with_items: '{{ molecule_yml.platforms }}'
- name: stop and remove running containers
ansible.builtin.shell:
cmd: |
incus stop "{{ item.name }}-container" && \
incus rm "{{ item.name }}-container"
when: state.results[0].rc == 0 and "RUNNING" in state.results[0].stdout
with_items: '{{ molecule_yml.platforms }}'