Files
ansible-collection-infrastr…/roles/proxmox_lxc_provision/tasks/create.yml
T
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

30 lines
1.3 KiB
YAML
Executable File

---
- name: Create LXC container
module_defaults:
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
block:
- name: Create an LXC container
community.proxmox.proxmox:
vmid: "{{ lxc_vmid | default(omit) }}"
hostname: "{{ lxc_hostname }}"
password: "{{ lxc_root_password | default(omit) }}"
ostemplate: "{{ lxc_template }}"
cores: "{{ lxc_cores }}"
memory: "{{ lxc_memory }}"
swap: "{{ lxc_swap }}"
disk: "{{ lxc_disk }}"
mounts: "{{ lxc_mounts | default(omit) }}"
netif: >-
{"net0": "name={{ lxc_iface_name }},bridge={{ lxc_bridge }},ip={{ lxc_ipv4 }},gw={{ lxc_gateway }},ip6={{ lxc_ipv6 }}{% if lxc_vlan_tag is defined %},tag={{ lxc_vlan_tag }}{% endif %}"}
pubkey: "{{ lookup('file', lxc_pubkey_file) | default(omit) }}"
onboot: "{{ lxc_onboot | default(false) }}"
startup: "{{ lxc_startup | default(omit) }}"
unprivileged: "{{ lxc_unprivileged | default(true) }}"
features: "{{ lxc_features | default(omit) }}"
timezone: "{{ lxc_timezone | default(omit) }}"
nameserver: "{{ lxc_nameserver | default(omit) }}"
state: present
tags: "{{ lxc_tags | default(omit) }}"
register: lxc_result