Searches for template names instead of ids
This commit is contained in:
@@ -16,6 +16,23 @@
|
||||
ansible.builtin.debug:
|
||||
msg: "Target node {{ target_node }} will use storage: {{ target_storage }}"
|
||||
|
||||
- name: Get list of LXC containers on target node
|
||||
ansible.builtin.uri:
|
||||
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ target_node }}/lxc"
|
||||
method: GET
|
||||
headers:
|
||||
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||
validate_certs: false
|
||||
register: lxc_list
|
||||
|
||||
- name: Find template VMID by name
|
||||
ansible.builtin.set_fact:
|
||||
lxc_template_id: "{{ (lxc_list.json.data | selectattr('name', 'equalto', lxc_template_name) | first).vmid }}"
|
||||
|
||||
- name: Display found template
|
||||
ansible.builtin.debug:
|
||||
msg: "Found template '{{ lxc_template_name }}' with VMID {{ lxc_template_id }} on {{ target_node }}"
|
||||
|
||||
- name: Clone LXC from template on target node
|
||||
community.proxmox.proxmox:
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
|
||||
Reference in New Issue
Block a user