You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.3 KiB
YAML
122 lines
4.3 KiB
YAML
---
|
|
|
|
- name: Check if VM already exists
|
|
community.general.proxmox_vm_info:
|
|
api_host: "{{ create_vm_proxmox_host }}"
|
|
api_user: "{{ create_vm_proxmox_user }}"
|
|
api_password: "{{ create_vm_proxmox_password }}"
|
|
vmid: "{{ create_vm_proxmox_vmid }}"
|
|
register: create_vm_proxmox_check_if_vm_exists
|
|
when:
|
|
- create_vm_proxmox_recreate_vm | bool
|
|
delegate_to: localhost
|
|
|
|
- name: Delete VM if it already exists
|
|
community.general.proxmox_kvm:
|
|
api_host: "{{ create_vm_proxmox_host }}"
|
|
api_user: "{{ create_vm_proxmox_user }}"
|
|
api_password: "{{ create_vm_proxmox_password }}"
|
|
vmid: "{{ create_vm_proxmox_vmid }}"
|
|
name: "{{ create_vm_proxmox_name }}"
|
|
state: absent
|
|
force: true
|
|
when:
|
|
- create_vm_proxmox_check_if_vm_exists.proxmox_vms is defined
|
|
- create_vm_proxmox_check_if_vm_exists.proxmox_vms | length > 0
|
|
- create_vm_proxmox_recreate_vm | bool
|
|
delegate_to: localhost
|
|
|
|
- name: Check if VM already exists
|
|
community.general.proxmox_vm_info:
|
|
api_host: "{{ create_vm_proxmox_host }}"
|
|
api_user: "{{ create_vm_proxmox_user }}"
|
|
api_password: "{{ create_vm_proxmox_password }}"
|
|
vmid: "{{ create_vm_proxmox_vmid }}"
|
|
register: create_vm_proxmox_check_if_vm_exists
|
|
delegate_to: localhost
|
|
|
|
- name: Clone VM in Proxmox
|
|
community.general.proxmox_kvm:
|
|
api_host: "{{ create_vm_proxmox_host }}"
|
|
api_user: "{{ create_vm_proxmox_user }}"
|
|
api_password: "{{ create_vm_proxmox_password }}"
|
|
node: "{{ create_vm_proxmox_host }}"
|
|
newid: "{{ create_vm_proxmox_vmid }}"
|
|
name: "{{ create_vm_proxmox_name }}"
|
|
clone: "{{ create_vm_proxmox_source_vm }}"
|
|
vcpus: "{{ create_vm_proxmox_numb_cpus | default(omit) }}"
|
|
cores: "{{ create_vm_proxmox_numb_cores | default(omit) }}"
|
|
memory: "{{ create_vm_proxmox_memory_mb | default(omit) }}"
|
|
virtio: "{{ create_vm_proxmox_virtio_disks | default(omit) }}"
|
|
net: "{{ create_vm_proxmox_net | default(omit) }}"
|
|
when:
|
|
- create_vm_proxmox_check_if_vm_exists.proxmox_vms | length == 0
|
|
delegate_to: localhost
|
|
|
|
- name: Add cloud-init drive to VM
|
|
community.general.proxmox_kvm:
|
|
api_host: "{{ create_vm_proxmox_host }}"
|
|
api_user: "{{ create_vm_proxmox_user }}"
|
|
api_password: "{{ create_vm_proxmox_password }}"
|
|
node: "{{ create_vm_proxmox_host }}"
|
|
vmid: "{{ create_vm_proxmox_vmid }}"
|
|
name: "{{ create_vm_proxmox_name }}"
|
|
update: true
|
|
update_unsafe: true
|
|
ciuser: "{{ create_vm_proxmox_cloudinit_user }}"
|
|
cipassword: "{{ create_vm_proxmox_cloudinit_user }}"
|
|
sshkeys: "{{ create_vm_proxmox_cloudinit_sshkeys }}"
|
|
ipconfig: "{{ create_vm_proxmox_cloudinit_ipconfig }}"
|
|
nameservers: "{{ create_vm_proxmox_cloudinit_nameservers }}"
|
|
searchdomains: "{{ create_vm_proxmox_cloudinit_searchdomains }}"
|
|
ide:
|
|
ide2: "{{ create_vm_proxmox_cloudinit_storage_pool }}:cloudinit,format=raw"
|
|
when:
|
|
- create_vm_proxmox_check_if_vm_exists.proxmox_vms | length == 0
|
|
- create_vm_proxmox_configure_cloudinit | bool
|
|
delegate_to: localhost
|
|
|
|
- name: Enable QEMU guest agent for VM
|
|
community.general.proxmox_kvm:
|
|
api_host: "{{ create_vm_proxmox_host }}"
|
|
api_user: "{{ create_vm_proxmox_user }}"
|
|
api_password: "{{ create_vm_proxmox_password }}"
|
|
node: "{{ create_vm_proxmox_host }}"
|
|
vmid: "{{ create_vm_proxmox_vmid }}"
|
|
name: "{{ create_vm_proxmox_name }}"
|
|
agent: true
|
|
update: true
|
|
when:
|
|
- create_vm_proxmox_enable_guest_agent | bool
|
|
delegate_to: localhost
|
|
|
|
- name: Set VM to autostart
|
|
community.general.proxmox_kvm:
|
|
api_host: "{{ create_vm_proxmox_host }}"
|
|
api_user: "{{ create_vm_proxmox_user }}"
|
|
api_password: "{{ create_vm_proxmox_password }}"
|
|
node: "{{ create_vm_proxmox_host }}"
|
|
vmid: "{{ create_vm_proxmox_vmid }}"
|
|
name: "{{ create_vm_proxmox_name }}"
|
|
proxmox_default_behavior: no_defaults
|
|
onboot: true
|
|
update: true
|
|
when:
|
|
- create_vm_proxmox_start_vm_onboot | bool
|
|
delegate_to: localhost
|
|
|
|
- name: Start VM
|
|
community.general.proxmox_kvm:
|
|
api_host: "{{ create_vm_proxmox_host }}"
|
|
api_user: "{{ create_vm_proxmox_user }}"
|
|
api_password: "{{ create_vm_proxmox_password }}"
|
|
node: "{{ create_vm_proxmox_host }}"
|
|
vmid: "{{ create_vm_proxmox_vmid }}"
|
|
name: "{{ create_vm_proxmox_name }}"
|
|
state: started
|
|
when:
|
|
- create_vm_proxmox_start_vm
|
|
delegate_to: localhost
|
|
|
|
...
|