Files
max cdfcc844e0
Deploy new config to the Ansible server / trigger-webhook (pull_request) Successful in 26s
FIX: encloses the variable name with brackets and double quotes
2026-08-24 14:20:24 +05:00

26 lines
730 B
YAML

---
- name: Check if VM already exists
community.proxmox.proxmox_kvm:
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: "{{ proxmox_1_host }}"
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
ansible.builtin.include_tasks: create_vm.yaml
- name: Start the VM only if needed
when: '"does not exist in cluster" in vm_status.msg or vm_status.status != "running"'
ansible.builtin.include_tasks: start_vm.yaml