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.
This commit is contained in:
@@ -5,10 +5,9 @@ proxmox_api_validate_certs: false
|
|||||||
# Host to delegate pct commands to (use inventory hostname for become_password to work)
|
# Host to delegate pct commands to (use inventory hostname for become_password to work)
|
||||||
proxmox_delegate_host: "{{ proxmox_api_host }}"
|
proxmox_delegate_host: "{{ proxmox_api_host }}"
|
||||||
|
|
||||||
# Shared module_defaults applied by every task file that calls the Proxmox API.
|
# Shared Proxmox API args referenced by each task file's module_defaults block.
|
||||||
# Override the underlying proxmox_* vars (e.g. from group_vars/all/) to customize.
|
# Override the underlying proxmox_* vars (e.g. from group_vars/all/) to customize.
|
||||||
_proxmox_module_defaults:
|
_proxmox_api_args:
|
||||||
community.proxmox.proxmox: &_proxmox_api_args
|
|
||||||
api_host: "{{ proxmox_api_host }}"
|
api_host: "{{ proxmox_api_host }}"
|
||||||
api_port: "{{ proxmox_api_port }}"
|
api_port: "{{ proxmox_api_port }}"
|
||||||
api_user: "{{ proxmox_api_user }}"
|
api_user: "{{ proxmox_api_user }}"
|
||||||
@@ -16,7 +15,6 @@ _proxmox_module_defaults:
|
|||||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||||
validate_certs: "{{ proxmox_api_validate_certs }}"
|
validate_certs: "{{ proxmox_api_validate_certs }}"
|
||||||
node: "{{ proxmox_node }}"
|
node: "{{ proxmox_node }}"
|
||||||
community.proxmox.proxmox_vm_info: *_proxmox_api_args
|
|
||||||
|
|
||||||
# LXC defaults
|
# LXC defaults
|
||||||
lxc_template: "local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst"
|
lxc_template: "local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst"
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Check if LXC exists
|
- name: Check if LXC exists
|
||||||
module_defaults: "{{ _proxmox_module_defaults }}"
|
module_defaults:
|
||||||
|
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
|
||||||
|
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
|
||||||
block:
|
block:
|
||||||
- name: Query Proxmox for existing LXCs
|
- name: Query Proxmox for existing LXCs
|
||||||
community.proxmox.proxmox_vm_info:
|
community.proxmox.proxmox_vm_info:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Clone LXC container
|
- name: Clone LXC container
|
||||||
module_defaults: "{{ _proxmox_module_defaults }}"
|
module_defaults:
|
||||||
|
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
|
||||||
|
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
|
||||||
block:
|
block:
|
||||||
- name: Create a full clone of the container
|
- name: Create a full clone of the container
|
||||||
community.proxmox.proxmox:
|
community.proxmox.proxmox:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Convert LXC container to template
|
- name: Convert LXC container to template
|
||||||
module_defaults: "{{ _proxmox_module_defaults }}"
|
module_defaults:
|
||||||
|
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
|
||||||
|
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
|
||||||
block:
|
block:
|
||||||
- ansible.builtin.include_tasks: stop.yml
|
- ansible.builtin.include_tasks: stop.yml
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Create LXC container
|
- name: Create LXC container
|
||||||
module_defaults: "{{ _proxmox_module_defaults }}"
|
module_defaults:
|
||||||
|
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
|
||||||
|
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
|
||||||
block:
|
block:
|
||||||
- name: Create an LXC container
|
- name: Create an LXC container
|
||||||
community.proxmox.proxmox:
|
community.proxmox.proxmox:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Delete LXC container
|
- name: Delete LXC container
|
||||||
module_defaults: "{{ _proxmox_module_defaults }}"
|
module_defaults:
|
||||||
|
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
|
||||||
|
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
|
||||||
block:
|
block:
|
||||||
- ansible.builtin.include_tasks: stop.yml
|
- ansible.builtin.include_tasks: stop.yml
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Start LXC container
|
- name: Start LXC container
|
||||||
module_defaults: "{{ _proxmox_module_defaults }}"
|
module_defaults:
|
||||||
|
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
|
||||||
|
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
|
||||||
block:
|
block:
|
||||||
- name: Start the LXC container
|
- name: Start the LXC container
|
||||||
community.proxmox.proxmox:
|
community.proxmox.proxmox:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Stop LXC container
|
- name: Stop LXC container
|
||||||
module_defaults: "{{ _proxmox_module_defaults }}"
|
module_defaults:
|
||||||
|
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
|
||||||
|
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
|
||||||
block:
|
block:
|
||||||
- name: Stop container if it is running
|
- name: Stop container if it is running
|
||||||
community.proxmox.proxmox:
|
community.proxmox.proxmox:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Update LXC container
|
- name: Update LXC container
|
||||||
module_defaults: "{{ _proxmox_module_defaults }}"
|
module_defaults:
|
||||||
|
community.proxmox.proxmox: "{{ _proxmox_api_args }}"
|
||||||
|
community.proxmox.proxmox_vm_info: "{{ _proxmox_api_args }}"
|
||||||
block:
|
block:
|
||||||
- name: Update an LXC container
|
- name: Update an LXC container
|
||||||
community.proxmox.proxmox:
|
community.proxmox.proxmox:
|
||||||
|
|||||||
Reference in New Issue
Block a user