--- - name: Create Ansible Controller VM on Proxmox hosts: localhost connection: local gather_facts: false vars: # Proxmox connection (store credentials in vault) proxmox_host: "{{ vault_proxmox_host }}" proxmox_user: "{{ vault_proxmox_user }}" proxmox_node: "{{ vault_proxmox_node | default('pve') }}" # VM specs matching your current setup vm_name: "ansible-control" vm_id: 110 vm_memory: 8192 # 8GB (match current working setup) vm_cores: 2 # 2 cores vm_sockets: 1 vm_disk_size: "32G" # Bigger than current 8G vm_storage: "local-lvm" vm_network_bridge: "vmbr0" # Ubuntu Server 24.04 LTS vm_iso: "ubuntu-24.04-live-server-amd64.iso" vm_iso_storage: "local" # User configuration vm_ciuser: "master" vm_ssh_keys: - "{{ vault_ssh_public_key }}" # Your SSH public key vm_ip_config: "dhcp" # or set static: "10.0.10.110/24,gw=10.0.10.1" vm_start_after_create: true pre_tasks: - name: Check if VM already exists community.general.proxmox_kvm: api_host: "{{ proxmox_host }}" api_user: "{{ proxmox_user }}" api_password: "{{ vault_proxmox_password }}" vmid: "{{ vm_id }}" state: current register: vm_check failed_when: false - name: Display VM status ansible.builtin.debug: msg: | VM {{ vm_name }} ({{ vm_id }}): {{ 'Already exists' if vm_check.status is defined else 'Will be created' }} roles: - {role: proxmox_vm, when: vm_check.status is not defined} post_tasks: - name: Wait for VM to be accessible via SSH ansible.builtin.wait_for: host: "{{ vm_ip_config.split('/')[0] if '/' in vm_ip_config else 'ansible-control.local' }}" port: 22 timeout: 300 when: - vm_check.status is not defined - vm_start_after_create | bool - vm_ip_config != "dhcp" - name: Display next steps ansible.builtin.debug: msg: | 🎉 Ansible Controller VM Created Successfully! Next steps: 1. The VM should be starting up now 2. Wait a few minutes for Ubuntu installation to complete 3. SSH to the VM: ssh {{ vm_ciuser }}@[VM-IP] 4. Run the local-playbook.yml to set it up as an Ansible controller To find the VM IP (if using DHCP): - Check Proxmox web interface - Or run: qm guest cmd {{ vm_id }} network-get-interfaces