FEATURE: adds idempotency to vm creation in roles/deploy_vm_on_proxmox/tasks/main.yaml
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
---
|
||||
- name: Create a new VM with minimal options
|
||||
|
||||
- name: Check if VM already exists
|
||||
community.proxmox.proxmox_kvm:
|
||||
validate_certs: false
|
||||
node: proxmox-server
|
||||
api_user: root@pam
|
||||
api_host: 192.168.0.2
|
||||
api_token_id: ansible
|
||||
api_token_secret: "{{ proxmox_token_secret }}"
|
||||
|
||||
name: "{{ vm_hostname }}"
|
||||
state: current
|
||||
ignore_errors: true
|
||||
register: vm_status
|
||||
|
||||
|
||||
- name: Create a new VM with minimal options only if it doesn't exist
|
||||
when: vm_status is failed or 'does not exist in cluster' in vm_status.msg
|
||||
become: false
|
||||
community.proxmox.proxmox_kvm:
|
||||
validate_certs: false
|
||||
@@ -77,7 +94,7 @@
|
||||
name: "{{ vm_hostname }}"
|
||||
state: started
|
||||
|
||||
- name: Sleep for 2 minutes to make sure that VM has started and cloud init has done its thing
|
||||
- name: Sleep for 120 seconds just to make sure that all settings are applied
|
||||
become: false
|
||||
ansible.builtin.wait_for:
|
||||
timeout: 120
|
||||
|
||||
Reference in New Issue
Block a user