generated from the-liberated-edge/wikijs
i-8 Implements image creation and publishing in playbook (#22)
# Issue This PR implements the-liberated-edge/test_linux_containers#8 # Acceptance criteria - [x] The existing playbook has been amended, so that it creates and publishes container images to an incus server running locally. - [x] Container image name has been parameterised and provided as an Ansible variable. Co-authored-by: Emil <emil@theliberatededge.org> Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
@@ -3,17 +3,35 @@
|
||||
ansible.builtin.command: incus ls {{ lte_container_name }}
|
||||
register: container_state
|
||||
changed_when: false
|
||||
- name: Stop running container
|
||||
ansible.builtin.command: incus stop {{ lte_container_name }}
|
||||
when: >
|
||||
lte_container_state in ['absent', 'stopped'] and
|
||||
'results' in container_state and
|
||||
container_state.results[0].rc == 0 and
|
||||
'RUNNING' in container_state.results[0].stdout
|
||||
- name: Remove stopped container
|
||||
ansible.builtin.command: 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: (container_state.rc == 1) or ("RUNNING" not in container_state.stdout)
|
||||
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: |-
|
||||
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
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user