correct play
This commit is contained in:
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"ansible.python.interpreterPath": "/bin/python3",
|
||||
"yaml.schemas": {
|
||||
"file:///home/alex/.vscode/extensions/docsmsft.docs-yaml-1.0.1/dist/toc.schema.json": "/toc\\.yml/i",
|
||||
"https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible.json#/$defs/playbook": [
|
||||
"file:///home/alex/git/ansible/shutdown_windows.yml",
|
||||
"file:///home/alex/ansible/ansible/shutdown_windows.yml"
|
||||
]
|
||||
],
|
||||
"https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible.json#/$defs/tasks": "file:///home/alex/git/ansible/install_zabbix_agent.yml"
|
||||
},
|
||||
"ansible.lightspeed.enabled": true
|
||||
}
|
||||
@@ -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 }}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user