correct play

This commit is contained in:
2024-07-11 00:29:11 +02:00
parent ac5136f265
commit 6929da916e
2 changed files with 12 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
---
- name: List VMs, Templates, and Clone Ubuntu server on Proxmox
hosts: proxmox.localdomain
gather_facts: no
gather_facts: false
vars:
api_host: "192.168.1.162"
api_user: "root@pam"
@@ -11,7 +11,7 @@
vars_prompt:
- name: new_vm_name
prompt: "Enter the name for the new VM"
private: no
private: false
tasks:
- name: List all VMs and templates
community.general.proxmox_vm_info:
@@ -19,22 +19,22 @@
api_user: "{{ api_user }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
validate_certs: no
validate_certs: false
register: vms_info
- name: Print VM and template names and states
debug:
ansible.builtin.debug:
msg: "{{ item.name }} - {{ item.status }}"
loop: "{{ vms_info.proxmox_vms }}"
- name: Find VMID based on VM name
set_fact:
ansible.builtin.set_fact:
source_vmid: "{{ item.vmid }}"
loop: "{{ vms_info.proxmox_vms }}"
when: item.name == "ubu-srv01"
- name: Debug source VMID
debug:
ansible.builtin.debug:
msg: "Source VMID: {{ source_vmid }}"
- name: Clone VM to create new Ubuntu server
@@ -50,7 +50,7 @@
format: "qcow2"
full: true
timeout: 240
validate_certs: no
validate_certs: false
- name: List all VMs and templates after cloning
community.general.proxmox_vm_info:
@@ -58,11 +58,11 @@
api_user: "{{ api_user }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
validate_certs: no
validate_certs: false
register: vms_info_after_clone
- name: Print VM and template names and states after cloning
debug:
ansible.builtin.debug:
msg: "{{ item.name }} - {{ item.status }}"
loop: "{{ vms_info_after_clone.proxmox_vms }}"