Files
Kamino/roles/pve_lxc/molecule/default/molecule.yml
T
Defame1297 318229bdb3
Build / build (pull_request) Successful in 48s
Lint / lint (pull_request) Failing after 3m17s
Molecule / molecule (pull_request) Failing after 4m2s
feat(pve_lxc): add the pve_lxc role
Add pve_lxc, which manages the lifecycle of a Proxmox VE LXC container
through the Proxmox API (community.proxmox), reconciles the raw lxc.*
lines of its config on the node and, opt-in, writes its guest firewall
file. It keeps the pve_lxc_* interface and carries no legacy-name guard.
The input asserts run from tasks/validate.yml before any change, and the
API token secret has no default.

The molecule scenario runs the validation and the node-side task files
against a container standing in for the node; the API lifecycle is not
exercised. Debian trixie is declared, untested.

Refs #386

Assisted-by: Claude Code:claude-opus-5-5
2026-11-25 22:55:25 +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 two check steps: one before the converge (first-run preview), one after the idempotence run.
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- idempotence
- check
- side_effect
- verify
- cleanup