38 lines
1.3 KiB
YAML
38 lines
1.3 KiB
YAML
---
|
|
- name: Create VM ID from IP address for Proxmox hosts
|
|
hosts: all
|
|
gather_facts: false
|
|
|
|
tasks:
|
|
- name: Create Proxmox VMs
|
|
delegate_to: "localhost"
|
|
when: platform is defined and platform == "proxmox"
|
|
block:
|
|
- name: Create VM ID from IP address
|
|
ansible.builtin.set_fact:
|
|
vm_id: "{{ ip_address.split('.')[-2] }}{{ '%03d' % (ip_address.split('.')[-1] | int) }}"
|
|
|
|
- name: Create new VM with minimal options and given vmid
|
|
community.proxmox.proxmox_kvm:
|
|
api_user: "{{ proxmox_user }}"
|
|
api_password: "{{ proxmox_password }}"
|
|
api_host: "{{ proxmox_host }}"
|
|
name: "{{ inventory_hostname }}"
|
|
node: "{{ proxmox_target_node }}"
|
|
vmid: "{{ vm_id }}"
|
|
cores: "{{ vm_cpus }}"
|
|
memory: "{{ vm_memory }}"
|
|
bios: ovmf
|
|
efidisk0:
|
|
storage: "{{ vm_storage }}"
|
|
format: raw
|
|
efitype: 4m
|
|
pre_enrolled_keys: false
|
|
scsihw: virtio-scsi-single
|
|
scsi:
|
|
scsi0: "{{ vm_storage }}:{{ vm_disk_size }},format=raw,aio=native" # VMs_LVM:10,format=raw
|
|
net:
|
|
net0: "virtio,bridge={{ vm_net_bridge }}{{ vm_net_vlan }}"
|
|
onboot: "true"
|
|
# update: "true"
|