Files
Kamino/roles/pve_lxc/tasks/create.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

26 lines
1.1 KiB
YAML

---
- name: Create LXC if it does not exist
# No root password: root gets only the keys in pve_lxc_pubkey.
no_log: true # defence in depth: the module already masks the API token secret
delegate_to: localhost
community.proxmox.proxmox:
vmid: "{{ pve_lxc_vmid }}"
node: "{{ pve_lxc_node }}"
hostname: "{{ inventory_hostname }}"
ostemplate: "{{ pve_lxc_ostemplate }}"
disk: "{{ pve_lxc_disk }}"
memory: "{{ pve_lxc_memory }}"
cores: "{{ pve_lxc_cores | default(omit) }}"
swap: "{{ pve_lxc_swap | default(omit) }}"
nameserver: "{{ pve_lxc_nameserver | default(omit) }}"
netif:
net0: >-
{{ (['name=' ~ pve_lxc_net_interface, 'bridge=' ~ pve_lxc_net.bridge,
'ip=' ~ ansible_host ~ '/' ~ pve_lxc_net_prefix, 'gw=' ~ pve_lxc_net.gw,
'tag=' ~ pve_lxc_net.tag] + (['firewall=1'] if pve_lxc_firewall | bool else []))
| join(',') }}
pubkey: "{{ pve_lxc_pubkey }}"
features: "{{ pve_lxc_features if (pve_lxc_features | length > 0) else omit }}"
onboot: "{{ __pve_lxc_effective_onboot }}"
state: present