102 lines
3.2 KiB
YAML
102 lines
3.2 KiB
YAML
---
|
|
# Create a Proxmox VM for Single Node OpenShift.
|
|
# Uses q35 machine type with UEFI (required for SNO / RHCOS).
|
|
# An empty ide2 CD-ROM slot is created for the agent installer ISO.
|
|
|
|
- name: Build net0 string
|
|
ansible.builtin.set_fact:
|
|
__sno_deploy_net0: >-
|
|
virtio{{
|
|
'=' + sno_mac if sno_mac | length > 0 else ''
|
|
}},bridge={{ sno_vnet }}
|
|
|
|
- name: Build net1 (storage) string
|
|
ansible.builtin.set_fact:
|
|
__sno_deploy_net1: >-
|
|
virtio{{
|
|
'=' + sno_storage_mac if sno_storage_mac | length > 0 else ''
|
|
}},bridge={{ sno_storage_vnet }}
|
|
|
|
- name: Create SNO VM in Proxmox
|
|
community.proxmox.proxmox_kvm:
|
|
api_host: "{{ hostvars['proxmox_api']['ansible_host'] }}"
|
|
api_user: "{{ proxmox_api_user }}"
|
|
api_port: "{{ hostvars['proxmox_api']['ansible_port'] }}"
|
|
api_token_id: "{{ proxmox_api_token_id }}"
|
|
api_token_secret: "{{ proxmox_api_token_secret }}"
|
|
validate_certs: "{{ proxmox_validate_certs }}"
|
|
node: "{{ proxmox_node }}"
|
|
vmid: "{{ sno_vm_id | default(omit, true) }}"
|
|
name: "{{ sno_vm_name }}"
|
|
cores: "{{ sno_cpu }}"
|
|
memory: "{{ sno_memory_mb }}"
|
|
cpu: host
|
|
numa_enabled: true
|
|
machine: q35
|
|
bios: ovmf
|
|
efidisk0:
|
|
storage: "{{ proxmox_storage }}"
|
|
format: raw
|
|
efitype: 4m
|
|
pre_enrolled_keys: false
|
|
scsi:
|
|
scsi0: "{{ proxmox_storage }}:{{ sno_disk_gb }},format=raw,iothread=1,cache=writeback"
|
|
scsi1: "{{ proxmox_storage }}:{{ sno_pvc_disk_gb }},format=raw,iothread=1,cache=writeback"
|
|
scsihw: virtio-scsi-single
|
|
ide:
|
|
ide2: none,media=cdrom
|
|
net:
|
|
net0: "{{ __sno_deploy_net0 }}"
|
|
net1: "{{ __sno_deploy_net1 }}"
|
|
boot: "order=scsi0;ide2"
|
|
onboot: true
|
|
state: present
|
|
register: __sno_deploy_vm_result
|
|
|
|
- name: Retrieve VM info
|
|
community.proxmox.proxmox_vm_info:
|
|
api_host: "{{ hostvars['proxmox_api']['ansible_host'] }}"
|
|
api_user: "{{ proxmox_api_user }}"
|
|
api_port: "{{ hostvars['proxmox_api']['ansible_port'] }}"
|
|
api_token_id: "{{ proxmox_api_token_id }}"
|
|
api_token_secret: "{{ proxmox_api_token_secret }}"
|
|
validate_certs: "{{ proxmox_validate_certs }}"
|
|
node: "{{ proxmox_node }}"
|
|
name: "{{ sno_vm_name }}"
|
|
type: qemu
|
|
config: current
|
|
register: __sno_deploy_vm_info
|
|
retries: 5
|
|
|
|
- name: Set VM ID fact for subsequent plays
|
|
ansible.builtin.set_fact:
|
|
sno_vm_id: "{{ __sno_deploy_vm_info.proxmox_vms[0].vmid }}"
|
|
cacheable: true
|
|
|
|
- name: Extract MAC address from VM config
|
|
ansible.builtin.set_fact:
|
|
sno_mac: >-
|
|
{{ __sno_deploy_vm_info.proxmox_vms[0].config.net0
|
|
| regex_search('([0-9A-Fa-f]{2}(?::[0-9A-Fa-f]{2}){5})', '\1')
|
|
| first }}
|
|
cacheable: true
|
|
when: sno_mac | length == 0
|
|
|
|
- name: Extract storage MAC address from VM config
|
|
ansible.builtin.set_fact:
|
|
sno_storage_mac: >-
|
|
{{ __sno_deploy_vm_info.proxmox_vms[0].config.net1
|
|
| regex_search('([0-9A-Fa-f]{2}(?::[0-9A-Fa-f]{2}){5})', '\1')
|
|
| first }}
|
|
cacheable: true
|
|
when: sno_storage_mac | length == 0
|
|
|
|
- name: Display VM details
|
|
ansible.builtin.debug:
|
|
msg:
|
|
- "VM Name : {{ sno_vm_name }}"
|
|
- "VM ID : {{ sno_vm_id }}"
|
|
- "MAC (net0) : {{ sno_mac }}"
|
|
- "MAC (net1) : {{ sno_storage_mac }}"
|
|
verbosity: 1
|