Files
homelab/ansible/playbooks/proxmox_start_vm.yml
2025-11-19 09:36:59 -08:00

41 lines
1.3 KiB
YAML
Executable File

---
- name: Create VM ID from IP address for Proxmox hosts
hosts: all
gather_facts: false
tasks:
- name: Start Proxmox VM
delegate_to: "localhost"
when: platform is defined and platform == "proxmox"
community.proxmox.proxmox_kvm:
api_user: "{{ proxmox_user }}"
api_password: "{{ proxmox_password }}"
api_host: "{{ proxmox_host }}"
name: "{{ inventory_hostname }}"
node: "{{ proxmox_clone_node }}"
state: started
- name: Wait for SSH service to be ready
delegate_to: "localhost"
when: platform is defined and platform == "proxmox"
ansible.builtin.wait_for:
port: 22
host: "{{ inventory_hostname }}"
search_regex: OpenSSH
timeout: 300
msg: "Waiting for SSH service to be ready on {{ inventory_hostname }}"
- name: Wait for VM to be fully booted and responsive
delegate_to: "localhost"
when: platform is defined and platform == "proxmox"
ansible.builtin.wait_for_connection:
connect_timeout: 10
sleep: 5
timeout: 300
- name: Display VM startup completion
delegate_to: "localhost"
when: platform is defined and platform == "proxmox"
ansible.builtin.debug:
msg: "✅ {{ inventory_hostname }} is now running and accessible via SSH"