refactor: Update check-exists.yml to check by vmid or hostname
This commit is contained in:
@@ -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))
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user