This gist describes how to run systemd within a container (podman or docker) created by the ansible testing framework molecule.
The files in this gist need to be placed into the following structure:
📂 .
├── 📂 molecule
│ ├── 📂 default
│ │ ├── 🗒 converge.yml
│ │ └── 🗒 molecule.yml
│ └── 🗒 requirements.txt
├── 🗒 ansible-lint.yml
└── 🗒 yamllint.yml
Molecule prefers running containers with podman. To configure the prefered container runtime set the environment variable MOLECULE_CONTAINERS_BACKEND=podman,docker
.
python3 -m venv --copies molecule
source molecule/bin/activate
# Updating all python packages within the venv
python3 -m pip list --outdated --format=json | jq -r '.[] | "\(.name)==\(.latest_version)"' | xargs --no-run-if-empty -n1 python3 -m pip install -U
# Installing molecule and dependencies
python3 -m pip install -r molecule/requirements.txt
MOLECULE_CONTAINERS_BACKEND=docker molecule create
# or
MOLECULE_CONTAINERS_BACKEND=podman molecule create
molecule lint
molecule converge
molecule login -h instance-1
molecule idempotence
molecule destroy
molecule test