refactor: Update check-exists.yml to check by vmid or hostname

This commit is contained in:
2026-04-14 19:08:28 -04:00
parent 9d7f702f2a
commit 441b9fa824
2 changed files with 7 additions and 11 deletions

View File

@@ -4,12 +4,11 @@
type: lxc
register: proxmox_lxcs
- name: Check if LXC with hostname already exists
- name: Check if LXC already exists
ansible.builtin.set_fact:
lxc_exists: >-
{{
proxmox_lxcs.proxmox_vms
| selectattr('name', 'equalto', lxc_hostname)
| list
| length > 0
(lxc_vmid is defined and lxc_vmid | int in (proxmox_lxcs.proxmox_vms | map(attribute='vmid') | list))
or
(lxc_hostname is defined and (proxmox_lxcs.proxmox_vms | selectattr('name', 'equalto', lxc_hostname) | list | length > 0))
}}