generated from the-liberated-edge/wikijs
Introduces LTE_IMAGE_NAME variable.
This commit is contained in:
parent
c8878ad28b
commit
4dcdf45a12
28
README.md
28
README.md
@ -33,23 +33,27 @@ ansible-galaxy collection install -U --force \
|
||||
## Run the launch_linux_container playbook
|
||||
|
||||
Substitute the missing variable valuess and run the playbook
|
||||
for launching Debian Bookworm linux containers.
|
||||
for creating and publishing Debian Bookworm linux container images
|
||||
to a locally running incus image server.
|
||||
|
||||
Variables
|
||||
- `lte_container_name` stands for the desired container name that
|
||||
will be visible when running `incus ls`.
|
||||
- `lte_image_name` stands for the desired Linux container image.
|
||||
- `lte_container_root_pwd` is the password that will be set for
|
||||
the `root` user in the container named `lte_container_name`.
|
||||
the `root` user in the containers created out of the `lte_image_name`
|
||||
Linux container image.
|
||||
|
||||
```
|
||||
LC_ALL=C.UTF-8 ansible-playbook \
|
||||
theliberatededge.test_linux_containers.launch_linux_container \
|
||||
-e "lte_container_name=<container name> lte_container_root_pwd=<password>"
|
||||
theliberatededge.test_linux_containers.image_published_locally \
|
||||
-e "lte_image_name=<image name> lte_container_root_pwd=<password>"
|
||||
```
|
||||
|
||||
Once the playbook finishes execution, you should be able to
|
||||
connect to the newly launched container as user `root` via
|
||||
ssh.
|
||||
launch new containers refering to the newly published image name.
|
||||
|
||||
```
|
||||
incus launch <image_name> <container_name>
|
||||
```
|
||||
|
||||
## Include playbook or role from the collection
|
||||
|
||||
@ -62,15 +66,15 @@ assign the missing values to the variables first.
|
||||
|
||||
```
|
||||
---
|
||||
- name: Launch Linux Container
|
||||
- name: Create and publish locally container image
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
- name: imports and executes the playbook under test
|
||||
- name: Imports and executes the playbook
|
||||
ansible.builtin.import_playbook:
|
||||
theliberatededge.test_linux_containers.launch_linux_container.yml
|
||||
theliberatededge.test_linux_containers.image_publlished_locally.yml
|
||||
vars:
|
||||
lte_debian_version: bookworm
|
||||
lte_container_name: <container name>
|
||||
lte_image_name: <image name>
|
||||
lte_container_root_pwd: <password>
|
||||
```
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ tasks:
|
||||
cmds:
|
||||
- |
|
||||
LC_ALL=C.UTF-8 \
|
||||
LTE_CONTAINER_NAME={{ .LTE_CONTAINER_NAME }} \
|
||||
LTE_IMAGE_NAME={{ .LTE_IMAGE_NAME }} \
|
||||
LTE_CONTAINER_ROOT_PWD={{ .LTE_CONTAINER_ROOT_PWD }} \
|
||||
molecule test --all
|
||||
vars:
|
||||
LTE_CONTAINER_NAME:
|
||||
LTE_IMAGE_NAME:
|
||||
sh: cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1
|
||||
|
||||
@ -7,6 +7,6 @@
|
||||
theliberatededge.test_linux_containers.image_published_locally.yml
|
||||
vars:
|
||||
lte_debian_version: bookworm
|
||||
lte_container_name: '{{ molecule_yml.platforms[0].name }}'
|
||||
lte_image_name: '{{ molecule_yml.platforms[0].name }}'
|
||||
lte_container_root_pwd: |-
|
||||
'{{ lookup("ansible.builtin.env", "LTE_CONTAINER_ROOT_PWD") }}'
|
||||
|
||||
@ -5,14 +5,14 @@
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: find current container state
|
||||
ansible.builtin.command: incus ls {{ item.name }}
|
||||
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 }} && \
|
||||
incus rm {{ item.name }}
|
||||
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 }}'
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
dependency:
|
||||
name: galaxy
|
||||
platforms:
|
||||
- name: ${LTE_CONTAINER_NAME}
|
||||
- name: ${LTE_IMAGE_NAME}
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
- name: Create and publish Linux container image to a local image server
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
- lte_container_name: '{{ lte_image_name }}-container'
|
||||
tasks:
|
||||
- name: Create a test container image template
|
||||
- name: Create a test container
|
||||
ansible.builtin.import_role:
|
||||
name: linux_container
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user