Files
Kamino/roles/pve_lxc/molecule/default/molecule.yml
T
Defame1297 cf2286b7a7 test(roles): run molecule's check step before and after converge
Every role scenario with a converge now runs check right before it (a
fresh host) and right after it (a configured host), and a script test
fails a scenario without both. pihole and pve_lxc move their second
check from after idempotence to after converge to match.

The roles that failed under --check on a fresh host get the two allowed
guards: cloudflared, docker, gitea, gitea_runner, traefik and
user_management. ufw and fail2ban preview only a host where their
package is installed, as their READMEs now say.

Closes #134

Assisted-by: Claude Code
2026-11-26 10:11:54 +00:00

74 lines
2.7 KiB
YAML

---
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404 image
# (MOLECULE_IMAGE, the pin in .gitea/workflows/molecule.yml). The container stands in for the
# Proxmox node: the role's node-side task files (raw config reconcile, guest firewall file) and
# its input validation run against it. Nothing calls the Proxmox API (README, Tests).
# The container runs systemd as PID 1 with a writable cgroup; no privileged mode.
driver:
name: docker
platforms:
- name: ${KAMINO_RUN_ID:-local}-pve-lxc-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE}
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
# One source for every play, so the converge and the negative tests in verify.yml start from
# the same valid input.
inventory:
group_vars:
all:
pve_lxc_node: "{{ inventory_hostname }}"
pve_lxc_vmid: 9100
# The docker connection sets no ansible_host, from which the role defaults the API address;
# argument validation templates that default, so main would fail on it instead.
pve_lxc_api_host: 192.0.2.1
# Valid inputs for validate.yml; a negative case empties the one under test.
pve_lxc_api_user: molecule
pve_lxc_api_token_secret: not-a-secret
pve_lxc_net_prefix: 24
# stopped: the role never restarts a stopped container, so the raw config change makes
# no API call.
pve_lxc_state: stopped
pve_lxc_raw_config:
- "lxc.cgroup2.devices.allow: c 226:0 rwm"
- "lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir 0 0"
- "lxc.mount.entry: /srv/data srv/data none bind,create=dir 0 0"
pve_lxc_firewall: true
# not the defaults, so verify proves the variables reach the file
pve_lxc_firewall_policy_in: REJECT
pve_lxc_firewall_policy_out: ACCEPT
pve_lxc_firewall_rules:
- IN ACCEPT -source 192.0.2.10 -p tcp -dport 22
- OUT DROP -dest 198.51.100.0/24
verifier:
name: ansible
scenario:
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
# container as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
# plus a check before the converge (fresh host) and one after it (configured host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
- cleanup