From 5fbc4e9928827eb702f3d33d69892c13cfcf86c4 Mon Sep 17 00:00:00 2001 From: patrick Date: Wed, 15 Apr 2026 19:24:05 -0400 Subject: [PATCH] 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 --- roles/proxmox_lxc_provision/README.md | 6 ++++-- roles/proxmox_lxc_provision/defaults/main.yml | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/roles/proxmox_lxc_provision/README.md b/roles/proxmox_lxc_provision/README.md index f7bcaea..100f0c9 100755 --- a/roles/proxmox_lxc_provision/README.md +++ b/roles/proxmox_lxc_provision/README.md @@ -13,7 +13,7 @@ It also includes tasks which may be used individually: - `stop.yml`: Stops an LXC container - `update.yml`: Updates an existing LXC container - `wait.yml`: Waits for SSH to be available on the container -- `check-exists.yml`: Checks the existence of the LXC with the given hostname +- `check-exists.yml`: Checks if an LXC exists by `lxc_vmid` or `lxc_hostname` ## Requirements @@ -41,6 +41,7 @@ It also includes tasks which may be used individually: |----------|-------------|---------| | `proxmox_api_port` | The port on which the Proxmox API is listening | `8006` | | `proxmox_api_validate_certs` | Whether to validate SSL certificates | `false` | +| `proxmox_delegate_host` | Inventory hostname for delegated tasks (pct commands). Use this to inherit `ansible_become_password` from inventory. | `{{ proxmox_api_host }}` | ### Required Container Variables @@ -88,6 +89,7 @@ proxmox_api_token_id: "mytoken" proxmox_api_token_secret: "{{ vault_proxmox_token }}" proxmox_api_validate_certs: false proxmox_node: "pve01" +proxmox_delegate_host: "proxmox_server" # inventory hostname for become_password ``` ### Creating a new LXC from template @@ -122,7 +124,7 @@ proxmox_node: "pve01" ### Idempotent Behavior -The role includes idempotency checking. If a container with the specified `lxc_vmid` already exists, the role will skip provisioning and exit gracefully. +The role includes idempotency checking. If a container with the specified `lxc_vmid` or `lxc_hostname` already exists, the role will skip provisioning and exit gracefully. Sets `lxc_exists` fact for use in subsequent tasks. ### Using Standalone Tasks diff --git a/roles/proxmox_lxc_provision/defaults/main.yml b/roles/proxmox_lxc_provision/defaults/main.yml index 39ff794..1833ea8 100755 --- a/roles/proxmox_lxc_provision/defaults/main.yml +++ b/roles/proxmox_lxc_provision/defaults/main.yml @@ -2,6 +2,8 @@ # Proxmox API connection defaults (optional) proxmox_api_port: 8006 proxmox_api_validate_certs: false +# Host to delegate pct commands to (use inventory hostname for become_password to work) +proxmox_delegate_host: "{{ proxmox_api_host }}" # LXC defaults lxc_template: "local:vztmpl/debian-12-standard_12.12-1_amd64.tar.zst"