Commit Graph
17 Commits
Author SHA1 Message Date
patrick 77723f8ef7 fix(proxmox_lxc_provision): wait for container config file before editing it
The proxmox create task can return before pmxcfs has flushed the .conf, so the
first delegated lineinfile hit 'Destination /etc/pve/lxc/<vmid>.conf does not
exist'. Poll for the file with wait_for (up to 30s) before applying idmaps/GPU
config, which continues as soon as it appears rather than eating a fixed sleep.
2026-07-27 19:06:22 -04:00
patrick 7a617de315 fix(proxmox_lxc_provision): drop self-referential lxc_vmid default in edit-config include
lxc_vmid: {{ lxc_result.vmid | default(lxc_vmid) }} defined the var in terms of
itself, causing infinite templating recursion. Mirror start.yml and use
lxc_result.vmid directly, which is always registered by the clone or create path.
2026-07-27 18:02:17 -04:00
patrick aae89f5f5e fix(proxmox_lxc_provision): apply idmaps/GPU config via lineinfile, wire into flow
edit-config.yml was never included by the role, so lxc_id_mappings and GPU
passthrough were silently ignored. It also used blockinfile, whose comment
markers are incompatible with Proxmox hoisting all comments to the top of the
.conf on every write -- which orphans the markers and empties the managed block.

Rewrite edit-config.yml to manage raw lxc.* lines with lineinfile (keyed on each
exact line, churn-free, immune to comment hoisting), delegated to the Proxmox
host. Include it from main.yml after clone/create but before start.yml, while the
container is stopped, since ID mappings can't change on a running container.
2026-07-27 17:58:15 -04:00
patrick 1e3ab88304 fix(proxmox_lxc_provision): use literal module-name keys in module_defaults
The previous commit (d5cf6f6) used 'module_defaults: "{{ _proxmox_module_defaults }}"'
to template the entire defaults dict. Ansible rejects this because
module_defaults keys must be static action/module/group names at parse
time — only values may be templated.

Expose _proxmox_api_args as a flat dict of API parameters in
defaults/main.yml, and in each task file's module_defaults block use
the literal community.proxmox.proxmox and community.proxmox.proxmox_vm_info
keys with templated values pointing at the var.
2026-06-28 13:46:16 -04:00
patrick d5cf6f656e refactor(proxmox_lxc_provision): centralize module_defaults so tasks_from works without setup
Previously the community.proxmox.proxmox / proxmox_vm_info module_defaults
were defined inline on the outer block in main.yml. Invoking individual
task files via 'tasks_from: stop' (or delete/convert/etc.) bypassed
main.yml, leaving the API parameters unset and producing
'missing required arguments: api_host, api_user' errors. The README
worked around this by telling callers to repeat the module_defaults
block at the play level — easy to forget, and duplicated config.

Extract the defaults dict into _proxmox_module_defaults in
defaults/main.yml (using a YAML anchor to share between the two
modules), and wrap every task file that calls a Proxmox module in a
block that references it. Callers only need the proxmox_* connection
vars in scope (typically group_vars/all/) — both 'roles:' and
'tasks_from:' invocations now configure the API consistently.

Files wrapped: check-exists, create, clone, update, start, stop,
delete, convert. wait/post-clone/edit-config don't call Proxmox modules
and are unchanged. main.yml's now-redundant outer module_defaults is
removed.

README updated to drop the 'Using Standalone Tasks' workaround
boilerplate.
2026-06-28 13:42:41 -04:00
patrick 3b6f59a029 fix(proxmox_lxc_provision): post-clone privilege escalation and SSH key regen var name
The user-module tasks in post-clone.yml were running without become, so
modifying /etc/passwd failed with 'usermod: Permission denied' when the
connection user (e.g. admin) was non-root. Add become: true to both
password tasks. Block-level become is avoided because the known_hosts
task in the same file is delegate_to: localhost and should not sudo on
the controller.

Also fix the variable name passed to the system_setup ssh tasks_from:
post-clone.yml was setting 'regenerate_ssh_keys', but ssh.yml gates on
'regenerate_ssh_host_keys'. The mismatch caused cloned containers to
silently keep the source template's SSH host keys.
2026-06-27 23:19:26 -04:00
patrick 4f09e886c2 feat(proxmox_lxc_provision): support custom bridge, interface name, and VLAN tag
The bridge (vmbr0) and interface name (eth0) were previously hardcoded
in the netif string, and there was no way to set an 802.1Q VLAN tag.
Expose lxc_bridge, lxc_iface_name, and lxc_vlan_tag (optional) so
containers can be attached to non-default bridges or tagged into a VLAN
without forking the role.

Also drop the misleading 'lxc_ipv6 | default(omit)' filter — default(omit)
does not produce omission inside a string context, and lxc_ipv6 always
has a default of 'auto' in defaults/main.yml.
2026-06-27 21:23:14 -04:00
patrick 51c1c5b611 refactor(proxmox_lxc_provision): rename password vars and parameterize user name
Rename lxc_password to lxc_root_password for consistency with the new
lxc_user_password (replaces the previously bare 'password' variable in
post-clone.yml, which silently collided with any same-named caller var).
Add lxc_user_name (default: admin) so the non-root account managed in
post-clone.yml is no longer hardcoded. Apply default(omit) to the root
password in create.yml so it is genuinely optional as documented.

BREAKING CHANGE: callers passing lxc_password or a bare 'password' var
must rename to lxc_root_password and lxc_user_password respectively.
2026-06-27 21:11:13 -04:00
patrick 27924cf55c docs(proxmox_lxc_provision): document missing task files and optional variables
Add post-clone.yml and edit-config.yml to the task list, and document
the previously undocumented optional variables (lxc_unprivileged,
lxc_mounts, lxc_onboot, lxc_startup, lxc_timezone, lxc_nvidia_gpu_mount,
gpu_device_id, uvm_device_id, lxc_id_mappings).
2026-06-27 21:09:27 -04:00
patrick 5fbc4e9928 add proxmox_delegate_host variable and update check-exists documentation
- Document proxmox_delegate_host for delegating pct commands to inventory host
- Update check-exists.yml description to reflect vmid or hostname checking
- Document lxc_exists fact set by idempotency check
2026-04-15 19:24:05 -04:00
patrick 441b9fa824 refactor: Update check-exists.yml to check by vmid or hostname 2026-04-14 19:08:28 -04:00
patrick 9d7f702f2a refactor: add variable for delegating to proxmox host 2026-04-14 18:43:43 -04:00
patrick 6e6bed6a40 fix: change proxmox info module to proxmox_vm_info from proxmox_lxc_info 2026-04-14 17:52:24 -04:00
patrick 3a2b4b8775 chore: migrate proxmox module from community.general.proxmox to community.proxmox 2026-04-14 17:40:03 -04:00
patrick 479996612e refactor: use module_defaults for proxmox API connection
- Replace YAML merge keys (<<:) with module_defaults block in main.yml
- Simplify connection variables to individual vars instead of dictionary
- Remove redundant connection params from individual task files
- Document standalone task usage requires play-level module_defaults
- Update README examples with new variable pattern
2026-04-14 17:18:18 -04:00
patrick 570eba84e7 fix: add execute permissions to task 2026-04-14 15:25:16 -04:00
patrick 62f4a3ea73 fix: rename roles to use underscores instead of hyphens which was causing the roles not to be found 2026-04-14 15:19:21 -04:00