i-8 Implements image creation and publishing in playbook #22

Merged
emil merged 8 commits from i-8-add-image-publishing-to-playbook into main 2024-03-07 01:41:39 +00:00
3 changed files with 18 additions and 19 deletions
Showing only changes of commit e529037269 - Show all commits

View File

@ -1,18 +1,14 @@
---
- name: Create
- name: Destroy testing resources
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
- name: Stop and remove the test container
ansible.builtin.include_role:
name: >-
theliberatededge.test_linux_containers.linux_container
vars:
lte_container_state: absent
lte_container_name: '{{ item.name }}-container'
with_items: '{{ molecule_yml.platforms }}'

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"