refactor(vars): remove legacy variable inputs
This commit is contained in:
2
main.yml
2
main.yml
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
- role: environment
|
- role: environment
|
||||||
vars:
|
vars:
|
||||||
ansible_connection: "{{ 'vmware_tools' if hypervisor == 'vmware' else 'ssh' }}"
|
ansible_connection: "{{ 'vmware_tools' if hypervisor_type == 'vmware' else 'ssh' }}"
|
||||||
|
|
||||||
- role: partitioning
|
- role: partitioning
|
||||||
vars:
|
vars:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Remove Archiso and cloud-init disks
|
- name: Remove Archiso and cloud-init disks
|
||||||
when: hypervisor == "libvirt"
|
when: hypervisor_type == "libvirt"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
block:
|
block:
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
---
|
---
|
||||||
- name: Setup Cleanup
|
- name: Setup Cleanup
|
||||||
when: hypervisor == "proxmox"
|
when: hypervisor_type == "proxmox"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
block:
|
block:
|
||||||
- name: Cleanup Setup Disks
|
- name: Cleanup Setup Disks
|
||||||
community.proxmox.proxmox_disk:
|
community.proxmox.proxmox_disk:
|
||||||
api_host: "{{ hypervisor_url }}"
|
api_host: "{{ hypervisor_cfg.url }}"
|
||||||
api_user: "{{ hypervisor_username }}"
|
api_user: "{{ hypervisor_cfg.username }}"
|
||||||
api_password: "{{ hypervisor_password }}"
|
api_password: "{{ hypervisor_cfg.password }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
vmid: "{{ system_cfg.id }}"
|
vmid: "{{ system_cfg.id }}"
|
||||||
disk: "{{ item }}"
|
disk: "{{ item }}"
|
||||||
@@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
- name: Start the VM
|
- name: Start the VM
|
||||||
community.proxmox.proxmox_kvm:
|
community.proxmox.proxmox_kvm:
|
||||||
api_host: "{{ hypervisor_url }}"
|
api_host: "{{ hypervisor_cfg.url }}"
|
||||||
api_user: "{{ hypervisor_username }}"
|
api_user: "{{ hypervisor_cfg.username }}"
|
||||||
api_password: "{{ hypervisor_password }}"
|
api_password: "{{ hypervisor_cfg.password }}"
|
||||||
node: "{{ hypervisor_node }}"
|
node: "{{ hypervisor_cfg.node }}"
|
||||||
vmid: "{{ system_cfg.id }}"
|
vmid: "{{ system_cfg.id }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
- name: Remove VM for libvirt
|
- name: Remove VM for libvirt
|
||||||
when:
|
when:
|
||||||
- hypervisor == "libvirt"
|
- hypervisor_type == "libvirt"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
- name: Undefine VM for libvirt
|
- name: Undefine VM for libvirt
|
||||||
when:
|
when:
|
||||||
- hypervisor == "libvirt"
|
- hypervisor_type == "libvirt"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
- name: Remove VM disk for libvirt
|
- name: Remove VM disk for libvirt
|
||||||
when:
|
when:
|
||||||
- hypervisor == "libvirt"
|
- hypervisor_type == "libvirt"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
|
|
||||||
- name: Remove cloud-init disk for libvirt
|
- name: Remove cloud-init disk for libvirt
|
||||||
when:
|
when:
|
||||||
- hypervisor == "libvirt"
|
- hypervisor_type == "libvirt"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
@@ -106,30 +106,30 @@
|
|||||||
|
|
||||||
- name: Remove VM for proxmox
|
- name: Remove VM for proxmox
|
||||||
when:
|
when:
|
||||||
- hypervisor == "proxmox"
|
- hypervisor_type == "proxmox"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
community.proxmox.proxmox_kvm:
|
community.proxmox.proxmox_kvm:
|
||||||
api_host: "{{ hypervisor_url }}"
|
api_host: "{{ hypervisor_cfg.url }}"
|
||||||
api_user: "{{ hypervisor_username }}"
|
api_user: "{{ hypervisor_cfg.username }}"
|
||||||
api_password: "{{ hypervisor_password }}"
|
api_password: "{{ hypervisor_cfg.password }}"
|
||||||
node: "{{ hypervisor_node }}"
|
node: "{{ hypervisor_cfg.node }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
vmid: "{{ system_cfg.id }}"
|
vmid: "{{ system_cfg.id }}"
|
||||||
state: stopped
|
state: stopped
|
||||||
|
|
||||||
- name: Delete VM for proxmox
|
- name: Delete VM for proxmox
|
||||||
when:
|
when:
|
||||||
- hypervisor == "proxmox"
|
- hypervisor_type == "proxmox"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
community.proxmox.proxmox_kvm:
|
community.proxmox.proxmox_kvm:
|
||||||
api_host: "{{ hypervisor_url }}"
|
api_host: "{{ hypervisor_cfg.url }}"
|
||||||
api_user: "{{ hypervisor_username }}"
|
api_user: "{{ hypervisor_cfg.username }}"
|
||||||
api_password: "{{ hypervisor_password }}"
|
api_password: "{{ hypervisor_cfg.password }}"
|
||||||
node: "{{ hypervisor_node }}"
|
node: "{{ hypervisor_cfg.node }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
vmid: "{{ system_cfg.id }}"
|
vmid: "{{ system_cfg.id }}"
|
||||||
state: absent
|
state: absent
|
||||||
@@ -137,37 +137,37 @@
|
|||||||
|
|
||||||
- name: Remove VM for VMware
|
- name: Remove VM for VMware
|
||||||
when:
|
when:
|
||||||
- hypervisor == "vmware"
|
- hypervisor_type == "vmware"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
community.vmware.vmware_guest:
|
community.vmware.vmware_guest:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_cfg.url }}"
|
||||||
username: "{{ hypervisor_username }}"
|
username: "{{ hypervisor_cfg.username }}"
|
||||||
password: "{{ hypervisor_password }}"
|
password: "{{ hypervisor_cfg.password }}"
|
||||||
validate_certs: "{{ hypervisor_validate_certs }}"
|
validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
folder: "{{ system_cfg.path | default('/') }}"
|
folder: "{{ system_cfg.path | default('/') }}"
|
||||||
state: poweredoff
|
state: poweredoff
|
||||||
|
|
||||||
- name: Delete VM for VMware
|
- name: Delete VM for VMware
|
||||||
when:
|
when:
|
||||||
- hypervisor == "vmware"
|
- hypervisor_type == "vmware"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
community.vmware.vmware_guest:
|
community.vmware.vmware_guest:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_cfg.url }}"
|
||||||
username: "{{ hypervisor_username }}"
|
username: "{{ hypervisor_cfg.username }}"
|
||||||
password: "{{ hypervisor_password }}"
|
password: "{{ hypervisor_cfg.password }}"
|
||||||
validate_certs: "{{ hypervisor_validate_certs }}"
|
validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
folder: "{{ system_cfg.path | default('/') }}"
|
folder: "{{ system_cfg.path | default('/') }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Destroy Xen VM if running
|
- name: Destroy Xen VM if running
|
||||||
when:
|
when:
|
||||||
- hypervisor == "xen"
|
- hypervisor_type == "xen"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
|
|
||||||
- name: Remove Xen VM disk
|
- name: Remove Xen VM disk
|
||||||
when:
|
when:
|
||||||
- hypervisor == "xen"
|
- hypervisor_type == "xen"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
@@ -195,7 +195,7 @@
|
|||||||
|
|
||||||
- name: Remove Xen VM config file
|
- name: Remove Xen VM config file
|
||||||
when:
|
when:
|
||||||
- hypervisor == "xen"
|
- hypervisor_type == "xen"
|
||||||
- virtualization_vm_created_in_run | default(false) | bool
|
- virtualization_vm_created_in_run | default(false) | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
---
|
---
|
||||||
- name: Clean vCenter VM
|
- name: Clean vCenter VM
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor_type == "vmware"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
block:
|
block:
|
||||||
- name: Remove CD-ROM from VM in vCenter
|
- name: Remove CD-ROM from VM in vCenter
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor_type == "vmware"
|
||||||
community.vmware.vmware_guest:
|
community.vmware.vmware_guest:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_cfg.url }}"
|
||||||
username: "{{ hypervisor_username }}"
|
username: "{{ hypervisor_cfg.username }}"
|
||||||
password: "{{ hypervisor_password }}"
|
password: "{{ hypervisor_cfg.password }}"
|
||||||
validate_certs: "{{ hypervisor_validate_certs }}"
|
validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}"
|
||||||
datacenter: "{{ hypervisor_datacenter }}"
|
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
cdrom:
|
cdrom:
|
||||||
- controller_number: 0
|
- controller_number: 0
|
||||||
@@ -29,12 +29,12 @@
|
|||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
- name: Start VM in vCenter
|
- name: Start VM in vCenter
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor_type == "vmware"
|
||||||
vmware.vmware.vm_powerstate:
|
vmware.vmware.vm_powerstate:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_cfg.url }}"
|
||||||
username: "{{ hypervisor_username }}"
|
username: "{{ hypervisor_cfg.username }}"
|
||||||
password: "{{ hypervisor_password }}"
|
password: "{{ hypervisor_cfg.password }}"
|
||||||
validate_certs: "{{ hypervisor_validate_certs }}"
|
validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}"
|
||||||
datacenter: "{{ hypervisor_datacenter }}"
|
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
state: powered-on
|
state: powered-on
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Cleanup Xen installer media
|
- name: Cleanup Xen installer media
|
||||||
when: hypervisor == "xen"
|
when: hypervisor_type == "xen"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
block:
|
block:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
configuration_fstab_dvd_line: >-
|
configuration_fstab_dvd_line: >-
|
||||||
{{
|
{{
|
||||||
'/usr/local/install/redhat/rhel.iso /usr/local/install/redhat/dvd iso9660 loop,nofail 0 0'
|
'/usr/local/install/redhat/rhel.iso /usr/local/install/redhat/dvd iso9660 loop,nofail 0 0'
|
||||||
if hypervisor == 'vmware'
|
if hypervisor_type == 'vmware'
|
||||||
else '/dev/sr0 /usr/local/install/redhat/dvd iso9660 ro,relatime,nojoliet,check=s,map=n,nofail 0 0'
|
else '/dev/sr0 /usr/local/install/redhat/dvd iso9660 ro,relatime,nojoliet,check=s,map=n,nofail 0 0'
|
||||||
}}
|
}}
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Write image from RHEL ISO to the target machine
|
- name: Write image from RHEL ISO to the target machine
|
||||||
when: os == "rhel" and hypervisor == 'vmware'
|
when: os == "rhel" and hypervisor_type == 'vmware'
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
argv:
|
argv:
|
||||||
- dd
|
- dd
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Configure work environment
|
- name: Configure work environment
|
||||||
become: "{{ hypervisor != 'vmware' }}"
|
become: "{{ hypervisor_type != 'vmware' }}"
|
||||||
block:
|
block:
|
||||||
- name: Wait for connection
|
- name: Wait for connection
|
||||||
ansible.builtin.wait_for_connection:
|
ansible.builtin.wait_for_connection:
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
msg: This host is not booted from the Arch install media!
|
msg: This host is not booted from the Arch install media!
|
||||||
|
|
||||||
- name: Select primary Network Interface
|
- name: Select primary Network Interface
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor_type == "vmware"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
environment_interface_name: >-
|
environment_interface_name: >-
|
||||||
{{
|
{{
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
|
|
||||||
- name: Set IP-Address
|
- name: Set IP-Address
|
||||||
when:
|
when:
|
||||||
- hypervisor == "vmware"
|
- hypervisor_type == "vmware"
|
||||||
- system_cfg.ip is defined and system_cfg.ip | string | length > 0
|
- system_cfg.ip is defined and system_cfg.ip | string | length > 0
|
||||||
ansible.builtin.command: >-
|
ansible.builtin.command: >-
|
||||||
ip addr replace {{ system_cfg.ip }}/{{ system_cfg.prefix }}
|
ip addr replace {{ system_cfg.ip }}/{{ system_cfg.prefix }}
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
|
|
||||||
- name: Set Default Gateway
|
- name: Set Default Gateway
|
||||||
when:
|
when:
|
||||||
- hypervisor == "vmware"
|
- hypervisor_type == "vmware"
|
||||||
- system_cfg.gateway is defined and system_cfg.gateway | string | length > 0
|
- system_cfg.gateway is defined and system_cfg.gateway | string | length > 0
|
||||||
- system_cfg.ip is defined and system_cfg.ip | string | length > 0
|
- system_cfg.ip is defined and system_cfg.ip | string | length > 0
|
||||||
ansible.builtin.command: "ip route replace default via {{ system_cfg.gateway }}"
|
ansible.builtin.command: "ip route replace default via {{ system_cfg.gateway }}"
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Configure SSH for root login
|
- name: Configure SSH for root login
|
||||||
when: hypervisor == "vmware" and vmware_ssh | bool
|
when: hypervisor_type == "vmware" and vmware_ssh | bool
|
||||||
block:
|
block:
|
||||||
- name: Allow login
|
- name: Allow login
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
environment_rhel_iso_device: >-
|
environment_rhel_iso_device: >-
|
||||||
{{
|
{{
|
||||||
'/dev/sr2'
|
'/dev/sr2'
|
||||||
if hypervisor == 'libvirt'
|
if hypervisor_type == 'libvirt'
|
||||||
else '/dev/sr1'
|
else '/dev/sr1'
|
||||||
}}
|
}}
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
hypervisor: "none"
|
# User input. Normalized into hypervisor_cfg + hypervisor_type.
|
||||||
|
hypervisor:
|
||||||
|
type: "none"
|
||||||
hypervisor_defaults:
|
hypervisor_defaults:
|
||||||
type: "none"
|
type: "none"
|
||||||
url: ""
|
url: ""
|
||||||
|
|||||||
@@ -1,42 +1,26 @@
|
|||||||
---
|
---
|
||||||
- name: Validate hypervisor dict input
|
- name: Ensure hypervisor input is a dictionary
|
||||||
when: hypervisor is mapping
|
ansible.builtin.set_fact:
|
||||||
|
hypervisor: "{{ hypervisor | default({}) }}"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Validate hypervisor input
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
|
- hypervisor is mapping
|
||||||
- hypervisor.type is defined
|
- hypervisor.type is defined
|
||||||
- hypervisor.type | string | length > 0
|
- hypervisor.type | string | length > 0
|
||||||
fail_msg: "hypervisor.type is required when hypervisor is a dictionary"
|
fail_msg: "hypervisor must be a dictionary and hypervisor.type must be set (e.g. libvirt|proxmox|vmware|xen|none)."
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Normalize hypervisor configuration
|
- name: Normalize hypervisor configuration
|
||||||
vars:
|
vars:
|
||||||
hypervisor_input: "{{ hypervisor if hypervisor is mapping else {} }}"
|
|
||||||
hypervisor_type_legacy: "{{ (hypervisor | default('none')) if hypervisor is string else '' }}"
|
|
||||||
hypervisor_legacy_cfg:
|
|
||||||
type: "{{ hypervisor_type_legacy }}"
|
|
||||||
url: "{{ hypervisor_url | default('') }}"
|
|
||||||
username: "{{ hypervisor_username | default('') }}"
|
|
||||||
password: "{{ hypervisor_password | default('') }}"
|
|
||||||
node: "{{ hypervisor_node | default('') }}"
|
|
||||||
storage: "{{ hypervisor_storage | default('') }}"
|
|
||||||
datacenter: "{{ hypervisor_datacenter | default('') }}"
|
|
||||||
cluster: "{{ hypervisor_cluster | default('') }}"
|
|
||||||
validate_certs: "{{ hypervisor_validate_certs | default(false) | bool }}"
|
|
||||||
hypervisor_cfg_effective: >-
|
hypervisor_cfg_effective: >-
|
||||||
{{
|
{{
|
||||||
hypervisor_defaults
|
hypervisor_defaults
|
||||||
| combine(hypervisor_legacy_cfg, recursive=True)
|
| combine(hypervisor, recursive=True)
|
||||||
| combine(hypervisor_input, recursive=True)
|
|
||||||
}}
|
}}
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
hypervisor_cfg: "{{ hypervisor_cfg_effective }}"
|
hypervisor_cfg: "{{ hypervisor_cfg_effective }}"
|
||||||
hypervisor: "{{ hypervisor_cfg_effective.type | string | lower }}"
|
hypervisor_type: "{{ hypervisor_cfg_effective.type | string | lower }}"
|
||||||
hypervisor_url: "{{ hypervisor_cfg_effective.url }}"
|
|
||||||
hypervisor_username: "{{ hypervisor_cfg_effective.username }}"
|
|
||||||
hypervisor_password: "{{ hypervisor_cfg_effective.password }}"
|
|
||||||
hypervisor_node: "{{ hypervisor_cfg_effective.node }}"
|
|
||||||
hypervisor_storage: "{{ hypervisor_cfg_effective.storage }}"
|
|
||||||
hypervisor_datacenter: "{{ hypervisor_cfg_effective.datacenter }}"
|
|
||||||
hypervisor_cluster: "{{ hypervisor_cfg_effective.cluster }}"
|
|
||||||
hypervisor_validate_certs: "{{ hypervisor_cfg_effective.validate_certs | bool }}"
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
- name: Set SSH access
|
- name: Set SSH access
|
||||||
when:
|
when:
|
||||||
- install_type == "virtual"
|
- install_type == "virtual"
|
||||||
- hypervisor != "vmware"
|
- hypervisor_type != "vmware"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
ansible_user: "{{ user_name }}"
|
ansible_user: "{{ user_name }}"
|
||||||
ansible_password: "{{ user_password }}"
|
ansible_password: "{{ user_password }}"
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Set connection for VMware
|
- name: Set connection for VMware
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor_type == "vmware"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
ansible_connection: vmware_tools
|
ansible_connection: vmware_tools
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|||||||
@@ -17,87 +17,79 @@
|
|||||||
{{
|
{{
|
||||||
system.name
|
system.name
|
||||||
if system.name is defined and (system.name | string | length) > 0
|
if system.name is defined and (system.name | string | length) > 0
|
||||||
else (
|
else inventory_hostname
|
||||||
hostname
|
|
||||||
if hostname is defined and (hostname | string | length) > 0
|
|
||||||
else inventory_hostname
|
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
system_id_effective: >-
|
system_id_effective: >-
|
||||||
{{
|
{{
|
||||||
system.id
|
system.id
|
||||||
if system.id is defined and (system.id | string | length) > 0
|
if system.id is defined and (system.id | string | length) > 0
|
||||||
else (vm_id | default(''))
|
else ''
|
||||||
}}
|
}}
|
||||||
system_cpus_effective: >-
|
system_cpus_effective: >-
|
||||||
{{
|
{{
|
||||||
system.cpus
|
system.cpus
|
||||||
if system.cpus is defined and (system.cpus | int) > 0
|
if system.cpus is defined and (system.cpus | int) > 0
|
||||||
else (vm_cpus | default(0))
|
else 0
|
||||||
}}
|
}}
|
||||||
system_memory_mb_effective: >-
|
system_memory_mb_effective: >-
|
||||||
{{
|
{{
|
||||||
system.memory_mb
|
system.memory_mb
|
||||||
if system.memory_mb is defined and (system.memory_mb | int) > 0
|
if system.memory_mb is defined and (system.memory_mb | int) > 0
|
||||||
else (vm_memory | default(0))
|
else 0
|
||||||
}}
|
}}
|
||||||
system_balloon_mb_effective: >-
|
system_balloon_mb_effective: >-
|
||||||
{{
|
{{
|
||||||
system.balloon_mb
|
system.balloon_mb
|
||||||
if system.balloon_mb is defined and (system.balloon_mb | int) > 0
|
if system.balloon_mb is defined and (system.balloon_mb | int) > 0
|
||||||
else (vm_ballo | default(''))
|
else 0
|
||||||
}}
|
}}
|
||||||
system_network_effective: >-
|
system_network_effective: >-
|
||||||
{{
|
{{
|
||||||
system.network
|
system.network
|
||||||
if system.network is defined and (system.network | string | length) > 0
|
if system.network is defined and (system.network | string | length) > 0
|
||||||
else (vm_nif | default(''))
|
else ''
|
||||||
}}
|
}}
|
||||||
system_vlan_effective: >-
|
system_vlan_effective: >-
|
||||||
{{
|
{{
|
||||||
system.vlan
|
system.vlan
|
||||||
if system.vlan is defined and (system.vlan | string | length) > 0
|
if system.vlan is defined and (system.vlan | string | length) > 0
|
||||||
else (vlan_name | default(''))
|
else ''
|
||||||
}}
|
}}
|
||||||
system_ip_effective: >-
|
system_ip_effective: >-
|
||||||
{{
|
{{
|
||||||
system.ip
|
system.ip
|
||||||
if system.ip is defined and (system.ip | string | length) > 0
|
if system.ip is defined and (system.ip | string | length) > 0
|
||||||
else (vm_ip | default(''))
|
else ''
|
||||||
}}
|
}}
|
||||||
system_prefix_effective: >-
|
system_prefix_effective: >-
|
||||||
{{
|
{{
|
||||||
system.prefix
|
system.prefix
|
||||||
if system.prefix is defined and (system.prefix | int) > 0
|
if system.prefix is defined and (system.prefix | int) > 0
|
||||||
else (vm_nms | default(''))
|
else ''
|
||||||
}}
|
}}
|
||||||
system_gateway_effective: >-
|
system_gateway_effective: >-
|
||||||
{{
|
{{
|
||||||
system.gateway
|
system.gateway
|
||||||
if system.gateway is defined and (system.gateway | string | length) > 0
|
if system.gateway is defined and (system.gateway | string | length) > 0
|
||||||
else (vm_gw | default(''))
|
else ''
|
||||||
}}
|
}}
|
||||||
system_dns_servers_effective: >-
|
system_dns_servers_effective: >-
|
||||||
{{
|
{{
|
||||||
system.dns_servers
|
system.dns_servers
|
||||||
if system.dns_servers is defined
|
if system.dns_servers is defined
|
||||||
else (vm_dns | default([]))
|
else []
|
||||||
}}
|
}}
|
||||||
system_dns_search_effective: >-
|
system_dns_search_effective: >-
|
||||||
{{
|
{{
|
||||||
system.dns_search
|
system.dns_search
|
||||||
if system.dns_search is defined
|
if system.dns_search is defined
|
||||||
else (vm_dns_search | default([]))
|
else []
|
||||||
}}
|
}}
|
||||||
system_path_effective: >-
|
system_path_effective: >-
|
||||||
{{
|
{{
|
||||||
system.path
|
system.path
|
||||||
if system.path is defined and (system.path | string | length) > 0
|
if system.path is defined and (system.path | string | length) > 0
|
||||||
else (
|
else ''
|
||||||
system.hypervisor_path
|
|
||||||
if system.hypervisor_path is defined and (system.hypervisor_path | string | length) > 0
|
|
||||||
else (vm_path | default(''))
|
|
||||||
)
|
|
||||||
}}
|
}}
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
hostname: "{{ system_name_effective }}"
|
hostname: "{{ system_name_effective }}"
|
||||||
@@ -141,29 +133,21 @@
|
|||||||
if system_cfg.disks is defined
|
if system_cfg.disks is defined
|
||||||
else []
|
else []
|
||||||
}}
|
}}
|
||||||
system_disks_legacy: >-
|
|
||||||
{{
|
|
||||||
[ {'size': vm_size} ]
|
|
||||||
if (system_disks_raw | length) == 0 and (vm_size is defined and (vm_size | float) > 0)
|
|
||||||
else []
|
|
||||||
}}
|
|
||||||
system_disks_effective: >-
|
system_disks_effective: >-
|
||||||
{{
|
{{
|
||||||
system_disks_raw
|
system_disks_raw
|
||||||
if (system_disks_raw | length) > 0
|
|
||||||
else system_disks_legacy
|
|
||||||
}}
|
}}
|
||||||
system_disk_device_prefix: >-
|
system_disk_device_prefix: >-
|
||||||
{{
|
{{
|
||||||
'/dev/vd'
|
'/dev/vd'
|
||||||
if (install_type | default('')) == 'virtual' and (hypervisor | default('')) == 'libvirt'
|
if (install_type | default('')) == 'virtual' and (hypervisor_type | default('')) == 'libvirt'
|
||||||
else (
|
else (
|
||||||
'/dev/xvd'
|
'/dev/xvd'
|
||||||
if (install_type | default('')) == 'virtual' and (hypervisor | default('')) == 'xen'
|
if (install_type | default('')) == 'virtual' and (hypervisor_type | default('')) == 'xen'
|
||||||
else (
|
else (
|
||||||
'/dev/sd'
|
'/dev/sd'
|
||||||
if (install_type | default('')) == 'virtual'
|
if (install_type | default('')) == 'virtual'
|
||||||
and (hypervisor | default('')) in ['proxmox', 'vmware']
|
and (hypervisor_type | default('')) in ['proxmox', 'vmware']
|
||||||
else ''
|
else ''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -272,20 +256,3 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
install_drive: "{{ system_disks_cfg[0].device }}"
|
install_drive: "{{ system_disks_cfg[0].device }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Set legacy vm_* aliases (compat)
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
vm_id: "{{ system_cfg.id }}"
|
|
||||||
vm_cpus: "{{ system_cfg.cpus }}"
|
|
||||||
vm_memory: "{{ system_cfg.memory_mb }}"
|
|
||||||
vm_ballo: "{{ system_cfg.balloon_mb }}"
|
|
||||||
vm_nif: "{{ system_cfg.network }}"
|
|
||||||
vlan_name: "{{ system_cfg.vlan }}"
|
|
||||||
vm_ip: "{{ system_cfg.ip }}"
|
|
||||||
vm_nms: "{{ system_cfg.prefix }}"
|
|
||||||
vm_gw: "{{ system_cfg.gateway }}"
|
|
||||||
vm_dns: "{{ system_cfg.dns_servers }}"
|
|
||||||
vm_dns_search: "{{ system_cfg.dns_search }}"
|
|
||||||
vm_path: "{{ system_cfg.path }}"
|
|
||||||
vm_size: "{{ (system_cfg.disks | default([]) | first | default({})).size | default(0) }}"
|
|
||||||
changed_when: false
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
that:
|
that:
|
||||||
- install_type is defined
|
- install_type is defined
|
||||||
- install_type in ["virtual", "physical"]
|
- install_type in ["virtual", "physical"]
|
||||||
- hypervisor is defined
|
- hypervisor_cfg is defined
|
||||||
- hypervisor in ["libvirt", "proxmox", "vmware", "xen", "none"]
|
- hypervisor_cfg is mapping
|
||||||
|
- hypervisor_type is defined
|
||||||
|
- hypervisor_type in ["libvirt", "proxmox", "vmware", "xen", "none"]
|
||||||
- filesystem is defined
|
- filesystem is defined
|
||||||
- filesystem in ["btrfs", "ext4", "xfs"]
|
- filesystem in ["btrfs", "ext4", "xfs"]
|
||||||
- install_drive is defined
|
- install_drive is defined
|
||||||
@@ -18,7 +20,7 @@
|
|||||||
- name: Validate install_type/hypervisor relationship
|
- name: Validate install_type/hypervisor relationship
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install_type == "physical" or hypervisor in ["libvirt", "proxmox", "vmware", "xen"]
|
- install_type == "physical" or hypervisor_type in ["libvirt", "proxmox", "vmware", "xen"]
|
||||||
fail_msg: "hypervisor must be one of: libvirt, proxmox, vmware, xen when install_type=virtual."
|
fail_msg: "hypervisor must be one of: libvirt, proxmox, vmware, xen when install_type=virtual."
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
@@ -58,7 +60,7 @@
|
|||||||
- name: Validate Proxmox hypervisor inputs
|
- name: Validate Proxmox hypervisor inputs
|
||||||
when:
|
when:
|
||||||
- install_type == "virtual"
|
- install_type == "virtual"
|
||||||
- hypervisor == "proxmox"
|
- hypervisor_type == "proxmox"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- hypervisor_cfg.url | string | length > 0
|
- hypervisor_cfg.url | string | length > 0
|
||||||
@@ -74,7 +76,7 @@
|
|||||||
- name: Validate VMware hypervisor inputs
|
- name: Validate VMware hypervisor inputs
|
||||||
when:
|
when:
|
||||||
- install_type == "virtual"
|
- install_type == "virtual"
|
||||||
- hypervisor == "vmware"
|
- hypervisor_type == "vmware"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- hypervisor_cfg.url | string | length > 0
|
- hypervisor_cfg.url | string | length > 0
|
||||||
@@ -90,7 +92,7 @@
|
|||||||
- name: Validate Xen hypervisor inputs
|
- name: Validate Xen hypervisor inputs
|
||||||
when:
|
when:
|
||||||
- install_type == "virtual"
|
- install_type == "virtual"
|
||||||
- hypervisor == "xen"
|
- hypervisor_type == "xen"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- system_cfg.network | string | length > 0
|
- system_cfg.network | string | length > 0
|
||||||
@@ -125,7 +127,7 @@
|
|||||||
that:
|
that:
|
||||||
- system_cfg is defined
|
- system_cfg is defined
|
||||||
- system_cfg is mapping
|
- system_cfg is mapping
|
||||||
fail_msg: "system configuration is missing. Define system: {...} or legacy vm_* variables."
|
fail_msg: "system configuration is missing. Define system: {...}."
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Validate virtual system sizing
|
- name: Validate virtual system sizing
|
||||||
|
|||||||
@@ -119,7 +119,13 @@ partitioning_vm_size_effective: >-
|
|||||||
(
|
(
|
||||||
partitioning_vm_size
|
partitioning_vm_size
|
||||||
if (partitioning_vm_size is defined and (partitioning_vm_size | float) > 0)
|
if (partitioning_vm_size is defined and (partitioning_vm_size | float) > 0)
|
||||||
else (vm_size if vm_size is defined else 0)
|
else (
|
||||||
|
(
|
||||||
|
(system_cfg.disks | default([]) | first | default({})).size
|
||||||
|
if system_cfg is defined
|
||||||
|
else 0
|
||||||
|
) | default(0)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
| float
|
| float
|
||||||
}}
|
}}
|
||||||
@@ -128,7 +134,10 @@ partitioning_vm_memory_effective: >-
|
|||||||
(
|
(
|
||||||
partitioning_vm_memory
|
partitioning_vm_memory
|
||||||
if (partitioning_vm_memory is defined and (partitioning_vm_memory | float) > 0)
|
if (partitioning_vm_memory is defined and (partitioning_vm_memory | float) > 0)
|
||||||
else (vm_memory if vm_memory is defined else 0)
|
else (
|
||||||
|
(system_cfg.memory_mb if system_cfg is defined else 0)
|
||||||
|
| default(0)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
| float
|
| float
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
when:
|
when:
|
||||||
- swap_enabled | bool
|
- swap_enabled | bool
|
||||||
- partitioning_vm_memory is not defined or (partitioning_vm_memory | float) <= 0
|
- partitioning_vm_memory is not defined or (partitioning_vm_memory | float) <= 0
|
||||||
- vm_memory is not defined or (vm_memory | float) <= 0
|
- system_cfg is not defined or (system_cfg.memory_mb | default(0) | float) <= 0
|
||||||
block:
|
block:
|
||||||
- name: Read system memory
|
- name: Read system memory
|
||||||
ansible.builtin.command: awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo
|
ansible.builtin.command: awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
when:
|
when:
|
||||||
- install_type == "physical"
|
- install_type == "physical"
|
||||||
- partitioning_vm_size is not defined or (partitioning_vm_size | float) <= 0
|
- partitioning_vm_size is not defined or (partitioning_vm_size | float) <= 0
|
||||||
- vm_size is not defined or (vm_size | float) <= 0
|
|
||||||
- install_drive | length > 0
|
- install_drive | length > 0
|
||||||
block:
|
block:
|
||||||
- name: Detect install drive size
|
- name: Detect install drive size
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
when: install_type == "virtual"
|
when: install_type == "virtual"
|
||||||
block:
|
block:
|
||||||
- name: Check if VM already exists on libvirt
|
- name: Check if VM already exists on libvirt
|
||||||
when: hypervisor == "libvirt"
|
when: hypervisor_type == "libvirt"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
community.libvirt.virt:
|
community.libvirt.virt:
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
- name: Abort if VM already exists on libvirt
|
- name: Abort if VM already exists on libvirt
|
||||||
when: hypervisor == "libvirt"
|
when: hypervisor_type == "libvirt"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- hostname not in system_check_libvirt_existing_vms.domains | default([])
|
- hostname not in system_check_libvirt_existing_vms.domains | default([])
|
||||||
@@ -103,14 +103,14 @@
|
|||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Check if VM already exists on Proxmox
|
- name: Check if VM already exists on Proxmox
|
||||||
when: hypervisor == "proxmox"
|
when: hypervisor_type == "proxmox"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
community.proxmox.proxmox_vm_info:
|
community.proxmox.proxmox_vm_info:
|
||||||
api_host: "{{ hypervisor_url }}"
|
api_host: "{{ hypervisor_cfg.url }}"
|
||||||
api_user: "{{ hypervisor_username }}"
|
api_user: "{{ hypervisor_cfg.username }}"
|
||||||
api_password: "{{ hypervisor_password }}"
|
api_password: "{{ hypervisor_cfg.password }}"
|
||||||
node: "{{ hypervisor_node }}"
|
node: "{{ hypervisor_cfg.node }}"
|
||||||
vmid: "{{ system_cfg.id }}"
|
vmid: "{{ system_cfg.id }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
type: qemu
|
type: qemu
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Abort if VM already exists on Proxmox
|
- name: Abort if VM already exists on Proxmox
|
||||||
when: hypervisor == "proxmox"
|
when: hypervisor_type == "proxmox"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- system_check_proxmox_check_result.proxmox_vms | default([]) | length == 0
|
- system_check_proxmox_check_result.proxmox_vms | default([]) | length == 0
|
||||||
@@ -129,14 +129,14 @@
|
|||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Check if VM already exists in vCenter
|
- name: Check if VM already exists in vCenter
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor_type == "vmware"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
community.vmware.vmware_guest_info:
|
community.vmware.vmware_guest_info:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_cfg.url }}"
|
||||||
username: "{{ hypervisor_username }}"
|
username: "{{ hypervisor_cfg.username }}"
|
||||||
password: "{{ hypervisor_password }}"
|
password: "{{ hypervisor_cfg.password }}"
|
||||||
validate_certs: "{{ hypervisor_validate_certs }}"
|
validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}"
|
||||||
datacenter: "{{ hypervisor_datacenter }}"
|
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
folder: "{{ system_cfg.path if system_cfg.path | length > 0 else omit }}"
|
folder: "{{ system_cfg.path if system_cfg.path | length > 0 else omit }}"
|
||||||
register: system_check_vmware_check_result
|
register: system_check_vmware_check_result
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Fail if vCenter lookup failed unexpectedly
|
- name: Fail if vCenter lookup failed unexpectedly
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor_type == "vmware"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- not system_check_vmware_check_result.failed
|
- not system_check_vmware_check_result.failed
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Abort if VM already exists in vCenter
|
- name: Abort if VM already exists in vCenter
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor_type == "vmware"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- system_check_vmware_check_result.instance is not defined
|
- system_check_vmware_check_result.instance is not defined
|
||||||
@@ -166,7 +166,7 @@
|
|||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
- name: Check if VM already exists on Xen
|
- name: Check if VM already exists on Xen
|
||||||
when: hypervisor == "xen"
|
when: hypervisor_type == "xen"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
argv:
|
argv:
|
||||||
@@ -177,7 +177,7 @@
|
|||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
- name: Abort if VM already exists on Xen
|
- name: Abort if VM already exists on Xen
|
||||||
when: hypervisor == "xen"
|
when: hypervisor_type == "xen"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- hostname not in system_check_xen_existing_vms.stdout | default('')
|
- hostname not in system_check_xen_existing_vms.stdout | default('')
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
- name: Create Virtual Machine
|
- name: Create Virtual Machine
|
||||||
ansible.builtin.include_tasks: "{{ hypervisor }}.yml"
|
ansible.builtin.include_tasks: "{{ hypervisor_type }}.yml"
|
||||||
|
|||||||
@@ -23,17 +23,17 @@
|
|||||||
virtualization_proxmox_scsi: >-
|
virtualization_proxmox_scsi: >-
|
||||||
{%- set out = {} -%}
|
{%- set out = {} -%}
|
||||||
{%- for disk in system_cfg.disks -%}
|
{%- for disk in system_cfg.disks -%}
|
||||||
{%- set _ = out.update({ 'scsi' ~ loop.index0: hypervisor_storage ~ ':' ~ (disk.size | int) }) -%}
|
{%- set _ = out.update({ 'scsi' ~ loop.index0: hypervisor_cfg.storage ~ ':' ~ (disk.size | int) }) -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{{ out }}
|
{{ out }}
|
||||||
community.proxmox.proxmox_kvm:
|
community.proxmox.proxmox_kvm:
|
||||||
api_host: "{{ hypervisor_url }}"
|
api_host: "{{ hypervisor_cfg.url }}"
|
||||||
api_user: "{{ hypervisor_username }}"
|
api_user: "{{ hypervisor_cfg.username }}"
|
||||||
api_password: "{{ hypervisor_password }}"
|
api_password: "{{ hypervisor_cfg.password }}"
|
||||||
ciuser: "{{ user_name }}"
|
ciuser: "{{ user_name }}"
|
||||||
cipassword: "{{ user_password }}"
|
cipassword: "{{ user_password }}"
|
||||||
ciupgrade: false
|
ciupgrade: false
|
||||||
node: "{{ hypervisor_node }}"
|
node: "{{ hypervisor_cfg.node }}"
|
||||||
vmid: "{{ system_cfg.id }}"
|
vmid: "{{ system_cfg.id }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
cpu: host
|
cpu: host
|
||||||
@@ -53,17 +53,17 @@
|
|||||||
efitype: 4m
|
efitype: 4m
|
||||||
format: raw
|
format: raw
|
||||||
pre_enrolled_keys: false
|
pre_enrolled_keys: false
|
||||||
storage: "{{ hypervisor_storage }}"
|
storage: "{{ hypervisor_cfg.storage }}"
|
||||||
tpmstate0: >-
|
tpmstate0: >-
|
||||||
{{
|
{{
|
||||||
{'storage': hypervisor_storage, 'version': '2.0'}
|
{'storage': hypervisor_cfg.storage, 'version': '2.0'}
|
||||||
if virtualization_tpm2_enabled | bool
|
if virtualization_tpm2_enabled | bool
|
||||||
else omit
|
else omit
|
||||||
}}
|
}}
|
||||||
ide:
|
ide:
|
||||||
ide0: "{{ boot_iso }},media=cdrom"
|
ide0: "{{ boot_iso }},media=cdrom"
|
||||||
ide1: "{{ rhel_iso + ',media=cdrom' if rhel_iso is defined and rhel_iso | length > 0 else omit }}"
|
ide1: "{{ rhel_iso + ',media=cdrom' if rhel_iso is defined and rhel_iso | length > 0 else omit }}"
|
||||||
ide2: "{{ hypervisor_storage }}:cloudinit"
|
ide2: "{{ hypervisor_cfg.storage }}:cloudinit"
|
||||||
net:
|
net:
|
||||||
net0: >-
|
net0: >-
|
||||||
virtio,bridge={{ system_cfg.network }}{% if system_cfg.vlan is defined and system_cfg.vlan | string | length > 0 %},tag={{ system_cfg.vlan }}{% endif %}
|
virtio,bridge={{ system_cfg.network }}{% if system_cfg.vlan is defined and system_cfg.vlan | string | length > 0 %},tag={{ system_cfg.vlan }}{% endif %}
|
||||||
@@ -83,10 +83,10 @@
|
|||||||
- name: Start VM on Proxmox
|
- name: Start VM on Proxmox
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
community.proxmox.proxmox_kvm:
|
community.proxmox.proxmox_kvm:
|
||||||
api_host: "{{ hypervisor_url }}"
|
api_host: "{{ hypervisor_cfg.url }}"
|
||||||
api_user: "{{ hypervisor_username }}"
|
api_user: "{{ hypervisor_cfg.username }}"
|
||||||
api_password: "{{ hypervisor_password }}"
|
api_password: "{{ hypervisor_cfg.password }}"
|
||||||
node: "{{ hypervisor_node }}"
|
node: "{{ hypervisor_cfg.node }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
vmid: "{{ system_cfg.id }}"
|
vmid: "{{ system_cfg.id }}"
|
||||||
state: started
|
state: started
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
virtualization_vmware_disk_cfg:
|
virtualization_vmware_disk_cfg:
|
||||||
size_gb: "{{ item.size | int }}"
|
size_gb: "{{ item.size | int }}"
|
||||||
type: thin
|
type: thin
|
||||||
datastore: "{{ hypervisor_storage }}"
|
datastore: "{{ hypervisor_cfg.storage }}"
|
||||||
loop: "{{ system_cfg.disks }}"
|
loop: "{{ system_cfg.disks }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item | to_json }}"
|
label: "{{ item | to_json }}"
|
||||||
@@ -15,12 +15,12 @@
|
|||||||
- name: Create VM in vCenter
|
- name: Create VM in vCenter
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
community.vmware.vmware_guest:
|
community.vmware.vmware_guest:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_cfg.url }}"
|
||||||
username: "{{ hypervisor_username }}"
|
username: "{{ hypervisor_cfg.username }}"
|
||||||
password: "{{ hypervisor_password }}"
|
password: "{{ hypervisor_cfg.password }}"
|
||||||
validate_certs: "{{ hypervisor_validate_certs }}"
|
validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}"
|
||||||
datacenter: "{{ hypervisor_datacenter }}"
|
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||||
cluster: "{{ hypervisor_cluster }}"
|
cluster: "{{ hypervisor_cfg.cluster }}"
|
||||||
folder: "{{ system_cfg.path if system_cfg.path | string | length > 0 else omit }}"
|
folder: "{{ system_cfg.path if system_cfg.path | string | length > 0 else omit }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
guest_id: otherLinux64Guest
|
guest_id: otherLinux64Guest
|
||||||
@@ -71,11 +71,11 @@
|
|||||||
when: virtualization_tpm2_enabled | bool
|
when: virtualization_tpm2_enabled | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
community.vmware.vmware_guest_tpm:
|
community.vmware.vmware_guest_tpm:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_cfg.url }}"
|
||||||
username: "{{ hypervisor_username }}"
|
username: "{{ hypervisor_cfg.username }}"
|
||||||
password: "{{ hypervisor_password }}"
|
password: "{{ hypervisor_cfg.password }}"
|
||||||
validate_certs: "{{ hypervisor_validate_certs }}"
|
validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}"
|
||||||
datacenter: "{{ hypervisor_datacenter }}"
|
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||||
folder: "{{ system_cfg.path if system_cfg.path | string | length > 0 else omit }}"
|
folder: "{{ system_cfg.path if system_cfg.path | string | length > 0 else omit }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
state: present
|
state: present
|
||||||
@@ -84,11 +84,11 @@
|
|||||||
when: virtualization_tpm2_enabled | bool
|
when: virtualization_tpm2_enabled | bool
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
vmware.vmware.vm_powerstate:
|
vmware.vmware.vm_powerstate:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_cfg.url }}"
|
||||||
username: "{{ hypervisor_username }}"
|
username: "{{ hypervisor_cfg.username }}"
|
||||||
password: "{{ hypervisor_password }}"
|
password: "{{ hypervisor_cfg.password }}"
|
||||||
validate_certs: "{{ hypervisor_validate_certs }}"
|
validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}"
|
||||||
datacenter: "{{ hypervisor_datacenter }}"
|
datacenter: "{{ hypervisor_cfg.datacenter }}"
|
||||||
name: "{{ hostname }}"
|
name: "{{ hostname }}"
|
||||||
state: powered-on
|
state: powered-on
|
||||||
register: virtualization_vmware_start_result
|
register: virtualization_vmware_start_result
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ hypervisor:
|
|||||||
cluster: "cluster01"
|
cluster: "cluster01"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
|
||||||
# Legacy (still supported): hypervisor_url, hypervisor_username, hypervisor_password, hypervisor_node, hypervisor_storage,
|
|
||||||
# hypervisor_datacenter, hypervisor_cluster, hypervisor_validate_certs.
|
|
||||||
|
|
||||||
# VMware (only needed when hypervisor: vmware)
|
# VMware (only needed when hypervisor: vmware)
|
||||||
# system:
|
# system:
|
||||||
# path: "/Folder" # Optional folder path segment in vCenter.
|
# path: "/Folder" # Optional folder path segment in vCenter.
|
||||||
|
|||||||
Reference in New Issue
Block a user