Adds basic container state managementto linux_container role

This commit is contained in:
Emil
2024-03-06 02:35:07 +01:00
parent 8daf94c1be
commit e529037269
3 changed files with 18 additions and 19 deletions

View File

@@ -9,9 +9,10 @@
incus stop {{ lte_container_name }} && \
incus rm {{ lte_container_name }}
when: >
lte_container_state == "absent" and
state.results[0].rc == 0 and
"RUNNING" in state.results[0].stdout
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: |
@@ -19,14 +20,14 @@
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
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"
when: lte_container_state == 'present'
changed_when: false

View File

@@ -1,4 +1,6 @@
---
- ansible.builtin.include_tasks: container.yml
- ansible.builtin.include_tasks: ume.yml
when: lte_container_state == "present"
- ansible.builtin.include_tasks: openssh-server.yml
when: lte_container_state == "present"