Update .gitignore and refactor Ubuntu template playbook to use role for Proxmox template management
This commit is contained in:
39
ansible/roles/proxmox_provision/tasks/main.yml
Normal file
39
ansible/roles/proxmox_provision/tasks/main.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- name: Provision VM from Template
|
||||
community.general.proxmox_kvm:
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_password: "{{ proxmox_api_password }}"
|
||||
# Use remote host verification if you have valid certs, else ignore
|
||||
validate_certs: false
|
||||
|
||||
node: "{{ proxmox_node }}"
|
||||
vmid: "{{ vmid if vmid | int > 0 else omit }}"
|
||||
name: "{{ vm_name }}"
|
||||
|
||||
clone: "{{ template_name }}"
|
||||
full: true # Full clone
|
||||
|
||||
cores: "{{ vm_cores }}"
|
||||
memory: "{{ vm_memory }}"
|
||||
|
||||
storage: "{{ vm_storage }}"
|
||||
net:
|
||||
net0: "virtio,bridge={{ vm_net_bridge }}"
|
||||
|
||||
# Cloud Init
|
||||
ciuser: "{{ ci_user }}"
|
||||
sshkeys: "{{ ssh_keys | join('\n') }}"
|
||||
ipconfig:
|
||||
ipconfig0: "ip=dhcp"
|
||||
|
||||
state: "{{ vm_state }}"
|
||||
register: vm_provision_result
|
||||
|
||||
- name: Debug Provision Result
|
||||
debug:
|
||||
var: vm_provision_result
|
||||
|
||||
# Note: Waiting for SSH requires knowing the IP.
|
||||
# If qemu-guest-agent is installed in the template, we can fetch it.
|
||||
# Otherwise, we might need a fixed IP or DNS check.
|
||||
Reference in New Issue
Block a user