34 lines
1.1 KiB
YAML

---
- name: find current container state
ansible.builtin.command: incus ls {{ lte_container_name }}
register: container_state
changed_when: false
- name: stop and remove running container
ansible.builtin.shell:
cmd: |
incus stop {{ lte_container_name }} && \
incus rm {{ lte_container_name }}
when: >
lte_container_state == 'absent' and
'results' in container_state and
container_state.results[0].rc == 0 and
'RUNNING' in container_state.results[0].stdout
- name: launch debian bookworm linux container
ansible.builtin.shell:
cmd: |
incus launch \
images:debian/{{ lte_debian_version }}/cloud \
{{ lte_container_name }}
when: >
lte_container_state == 'present' and
(container_state.rc == 1) or
("RUNNING" not in container_state.stdout)
- name: update apt cache and upgrade system packages
ansible.builtin.shell:
cmd: |-
incus exec {{ lte_container_name }} -- \
bash -c \
'/usr/bin/apt update && /usr/bin/apt upgrade -y'
when: lte_container_state == 'present'
changed_when: false