emo 0fb9c88890 i-1 Introduces an Ansible playbook for linux-container with SSH access
# Issue

This PR implements the following [issue](the-liberated-edge/test-linux-containers#1).

# Acceptance criteria

- [x] A playbook for launching LXD Debian container with parameterized container name and OS version has been implemented.
- [x] The newly launched Linux containers can be connected to and administered via SSH.
- [x] The playbook has been part of an Ansible collection named theliberatededge.test_linux_containers.
- [x] Setup and getting started technical documentation has been added to README.md.

Co-authored-by: emo <esimeonov@gmail.com>
Reviewed-on: #2
2024-01-07 00:48:19 +00:00

20 lines
653 B
YAML

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