|
|
|
@ -10,7 +10,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
|
---
|
|
|
|
|
module: ovirt_vms
|
|
|
|
|
module: ovirt_vm
|
|
|
|
|
short_description: Module to manage Virtual Machines in oVirt/RHV
|
|
|
|
|
version_added: "2.2"
|
|
|
|
|
author:
|
|
|
|
@ -46,6 +46,7 @@ options:
|
|
|
|
|
allow_partial_import:
|
|
|
|
|
description:
|
|
|
|
|
- Boolean indication whether to allow partial registration of Virtual Machine when C(state) is registered.
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.4"
|
|
|
|
|
vnic_profile_mappings:
|
|
|
|
|
description:
|
|
|
|
@ -105,6 +106,7 @@ options:
|
|
|
|
|
reassign_bad_macs:
|
|
|
|
|
description:
|
|
|
|
|
- "Boolean indication whether to reassign bad macs when C(state) is registered."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
template:
|
|
|
|
|
description:
|
|
|
|
@ -186,47 +188,13 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- Operating system of the Virtual Machine.
|
|
|
|
|
- Default value is set by oVirt/RHV engine.
|
|
|
|
|
choices:
|
|
|
|
|
- debian_7
|
|
|
|
|
- freebsd
|
|
|
|
|
- freebsdx64
|
|
|
|
|
- other
|
|
|
|
|
- other_linux
|
|
|
|
|
- other_linux_ppc64
|
|
|
|
|
- other_ppc64
|
|
|
|
|
- rhel_3
|
|
|
|
|
- rhel_4
|
|
|
|
|
- rhel_4x64
|
|
|
|
|
- rhel_5
|
|
|
|
|
- rhel_5x64
|
|
|
|
|
- rhel_6
|
|
|
|
|
- rhel_6x64
|
|
|
|
|
- rhel_6_ppc64
|
|
|
|
|
- rhel_7x64
|
|
|
|
|
- rhel_7_ppc64
|
|
|
|
|
- sles_11
|
|
|
|
|
- sles_11_ppc64
|
|
|
|
|
- ubuntu_12_04
|
|
|
|
|
- ubuntu_12_10
|
|
|
|
|
- ubuntu_13_04
|
|
|
|
|
- ubuntu_13_10
|
|
|
|
|
- ubuntu_14_04
|
|
|
|
|
- ubuntu_14_04_ppc64
|
|
|
|
|
- windows_10
|
|
|
|
|
- windows_10x64
|
|
|
|
|
- windows_2003
|
|
|
|
|
- windows_2003x64
|
|
|
|
|
- windows_2008
|
|
|
|
|
- windows_2008x64
|
|
|
|
|
- windows_2008r2x64
|
|
|
|
|
- windows_2008R2x64
|
|
|
|
|
- windows_2012x64
|
|
|
|
|
- windows_2012R2x64
|
|
|
|
|
- windows_7
|
|
|
|
|
- windows_7x64
|
|
|
|
|
- windows_8
|
|
|
|
|
- windows_8x64
|
|
|
|
|
- windows_xp
|
|
|
|
|
- "Possible values: debian_7, freebsd, freebsdx64, other, other_linux,
|
|
|
|
|
other_linux_ppc64, other_ppc64, rhel_3, rhel_4, rhel_4x64, rhel_5, rhel_5x64,
|
|
|
|
|
rhel_6, rhel_6x64, rhel_6_ppc64, rhel_7x64, rhel_7_ppc64, sles_11, sles_11_ppc64,
|
|
|
|
|
ubuntu_12_04, ubuntu_12_10, ubuntu_13_04, ubuntu_13_10, ubuntu_14_04, ubuntu_14_04_ppc64,
|
|
|
|
|
windows_10, windows_10x64, windows_2003, windows_2003x64, windows_2008, windows_2008x64,
|
|
|
|
|
windows_2008r2x64, windows_2008R2x64, windows_2012x64, windows_2012R2x64, windows_7,
|
|
|
|
|
windows_7x64, windows_8, windows_8x64, windows_xp"
|
|
|
|
|
boot_devices:
|
|
|
|
|
description:
|
|
|
|
|
- List of boot devices which should be used to boot. For example C([ cdrom, hd ]).
|
|
|
|
@ -235,18 +203,22 @@ options:
|
|
|
|
|
boot_menu:
|
|
|
|
|
description:
|
|
|
|
|
- "I(True) enable menu to select boot device, I(False) to disable it. By default is chosen by oVirt/RHV engine."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
usb_support:
|
|
|
|
|
description:
|
|
|
|
|
- "I(True) enable USB support, I(False) to disable it. By default is chosen by oVirt/RHV engine."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
serial_console:
|
|
|
|
|
description:
|
|
|
|
|
- "I(True) enable VirtIO serial console, I(False) to disable it. By default is chosen by oVirt/RHV engine."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
sso:
|
|
|
|
|
description:
|
|
|
|
|
- "I(True) enable Single Sign On by Guest Agent, I(False) to disable it. By default is chosen by oVirt/RHV engine."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
host:
|
|
|
|
|
description:
|
|
|
|
@ -282,11 +254,13 @@ options:
|
|
|
|
|
- If I(yes) Virtual Machine will be set as delete protected.
|
|
|
|
|
- If I(no) Virtual Machine won't be set as delete protected.
|
|
|
|
|
- If no value is passed, default value is set by oVirt/RHV engine.
|
|
|
|
|
type: bool
|
|
|
|
|
stateless:
|
|
|
|
|
description:
|
|
|
|
|
- If I(yes) Virtual Machine will be set as stateless.
|
|
|
|
|
- If I(no) Virtual Machine will be unset as stateless.
|
|
|
|
|
- If no value is passed, default value is set by oVirt/RHV engine.
|
|
|
|
|
type: bool
|
|
|
|
|
clone:
|
|
|
|
|
description:
|
|
|
|
|
- If I(yes) then the disks of the created virtual machine will be cloned and independent of the template.
|
|
|
|
@ -382,6 +356,7 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- "If I(true) the C(cloud_init) or C(sysprep) parameters will be saved for the virtual machine
|
|
|
|
|
and won't be virtual machine won't be started as run-once."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
aliases: [ 'sysprep_persist' ]
|
|
|
|
|
kernel_path:
|
|
|
|
@ -423,6 +398,7 @@ options:
|
|
|
|
|
- C(vm) - Sets the Virtual Machine's UUID as its serial number.
|
|
|
|
|
- C(host) - Sets the host's UUID as the Virtual Machine's serial number.
|
|
|
|
|
- C(custom) - Allows you to specify a custom serial number in C(serial_policy_value).
|
|
|
|
|
choices: ['vm', 'host', 'custom']
|
|
|
|
|
version_added: "2.3"
|
|
|
|
|
serial_policy_value:
|
|
|
|
|
description:
|
|
|
|
@ -499,6 +475,7 @@ options:
|
|
|
|
|
- "If I(true), in addition return I(remote_vv_file) inside I(vm) dictionary, which contains compatible
|
|
|
|
|
content for remote-viewer application. Works only C(state) is I(running)."
|
|
|
|
|
version_added: "2.7"
|
|
|
|
|
type: bool
|
|
|
|
|
cpu_pinning:
|
|
|
|
|
description:
|
|
|
|
|
- "CPU Pinning topology to map virtual machine CPU to host CPU."
|
|
|
|
@ -509,10 +486,12 @@ options:
|
|
|
|
|
soundcard_enabled:
|
|
|
|
|
description:
|
|
|
|
|
- "If I(true), the sound card is added to the virtual machine."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
smartcard_enabled:
|
|
|
|
|
description:
|
|
|
|
|
- "If I(true), use smart card authentication."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
io_threads:
|
|
|
|
|
description:
|
|
|
|
@ -523,12 +502,14 @@ options:
|
|
|
|
|
- "If I(true), use memory ballooning."
|
|
|
|
|
- "Memory balloon is a guest device, which may be used to re-distribute / reclaim the host memory
|
|
|
|
|
based on VM needs in a dynamic way. In this way it's possible to create memory over commitment states."
|
|
|
|
|
type: bool
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
numa_tune_mode:
|
|
|
|
|
description:
|
|
|
|
|
- "Set how the memory allocation for NUMA nodes of this VM is applied (relevant if NUMA nodes are set for this VM)."
|
|
|
|
|
- "It can be one of the following: I(interleave), I(preferred) or I(strict)."
|
|
|
|
|
- "If no value is passed, default value is set by oVirt/RHV engine."
|
|
|
|
|
choices: ['interleave', 'preferred', 'strict']
|
|
|
|
|
version_added: "2.6"
|
|
|
|
|
numa_nodes:
|
|
|
|
|
description:
|
|
|
|
@ -592,28 +573,28 @@ EXAMPLES = '''
|
|
|
|
|
# look at ovirt_auth module to see how to reuse authentication:
|
|
|
|
|
|
|
|
|
|
- name: Creates a new Virtual Machine from template named 'rhel7_template'
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: present
|
|
|
|
|
name: myvm
|
|
|
|
|
template: rhel7_template
|
|
|
|
|
cluster: mycluster
|
|
|
|
|
|
|
|
|
|
- name: Register VM
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: registered
|
|
|
|
|
storage_domain: mystorage
|
|
|
|
|
cluster: mycluster
|
|
|
|
|
name: myvm
|
|
|
|
|
|
|
|
|
|
- name: Register VM using id
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: registered
|
|
|
|
|
storage_domain: mystorage
|
|
|
|
|
cluster: mycluster
|
|
|
|
|
id: 1111-1111-1111-1111
|
|
|
|
|
|
|
|
|
|
- name: Register VM, allowing partial import
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: registered
|
|
|
|
|
storage_domain: mystorage
|
|
|
|
|
allow_partial_import: "True"
|
|
|
|
@ -621,7 +602,7 @@ EXAMPLES = '''
|
|
|
|
|
id: 1111-1111-1111-1111
|
|
|
|
|
|
|
|
|
|
- name: Register VM with vnic profile mappings and reassign bad macs
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: registered
|
|
|
|
|
storage_domain: mystorage
|
|
|
|
|
cluster: mycluster
|
|
|
|
@ -636,7 +617,7 @@ EXAMPLES = '''
|
|
|
|
|
reassign_bad_macs: "True"
|
|
|
|
|
|
|
|
|
|
- name: Register VM with mappings
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: registered
|
|
|
|
|
storage_domain: mystorage
|
|
|
|
|
cluster: mycluster
|
|
|
|
@ -671,7 +652,7 @@ EXAMPLES = '''
|
|
|
|
|
dest_name: cluster_B
|
|
|
|
|
|
|
|
|
|
- name: Creates a stateless VM which will always use latest template version
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
template: rhel7
|
|
|
|
|
cluster: mycluster
|
|
|
|
@ -680,7 +661,7 @@ EXAMPLES = '''
|
|
|
|
|
# Creates a new server rhel7 Virtual Machine from Blank template
|
|
|
|
|
# on brq01 cluster with 2GiB memory and 2 vcpu cores/sockets
|
|
|
|
|
# and attach bootable disk with name rhel7_disk and attach virtio NIC
|
|
|
|
|
- ovirt_vms:
|
|
|
|
|
- ovirt_vm:
|
|
|
|
|
state: present
|
|
|
|
|
cluster: brq01
|
|
|
|
|
name: myvm
|
|
|
|
@ -697,7 +678,7 @@ EXAMPLES = '''
|
|
|
|
|
- name: nic1
|
|
|
|
|
|
|
|
|
|
- name: Run VM with cloud init
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: rhel7
|
|
|
|
|
template: rhel7
|
|
|
|
|
cluster: Default
|
|
|
|
@ -722,7 +703,7 @@ EXAMPLES = '''
|
|
|
|
|
root_password: super_password
|
|
|
|
|
|
|
|
|
|
- name: Run VM with cloud init, with multiple network interfaces
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: rhel7_4
|
|
|
|
|
template: rhel7
|
|
|
|
|
cluster: mycluster
|
|
|
|
@ -738,7 +719,7 @@ EXAMPLES = '''
|
|
|
|
|
nic_on_boot: true
|
|
|
|
|
|
|
|
|
|
- name: Run VM with sysprep
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: windows2012R2_AD
|
|
|
|
|
template: windows2012R2
|
|
|
|
|
cluster: Default
|
|
|
|
@ -750,47 +731,47 @@ EXAMPLES = '''
|
|
|
|
|
root_password: SuperPassword123
|
|
|
|
|
|
|
|
|
|
- name: Migrate/Run VM to/on host named 'host1'
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: running
|
|
|
|
|
name: myvm
|
|
|
|
|
host: host1
|
|
|
|
|
|
|
|
|
|
- name: Change VMs CD
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
cd_iso: drivers.iso
|
|
|
|
|
|
|
|
|
|
- name: Eject VMs CD
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
cd_iso: ''
|
|
|
|
|
|
|
|
|
|
- name: Boot VM from CD
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
cd_iso: centos7_x64.iso
|
|
|
|
|
boot_devices:
|
|
|
|
|
- cdrom
|
|
|
|
|
|
|
|
|
|
- name: Stop vm
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: stopped
|
|
|
|
|
name: myvm
|
|
|
|
|
|
|
|
|
|
- name: Upgrade memory to already created VM
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
memory: 4GiB
|
|
|
|
|
|
|
|
|
|
- name: Hot plug memory to already created and running VM (VM won't be restarted)
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
memory: 4GiB
|
|
|
|
|
|
|
|
|
|
# Create/update a VM to run with two vNUMA nodes and pin them to physical NUMA nodes as follows:
|
|
|
|
|
# vnuma index 0-> numa index 0, vnuma index 1-> numa index 1
|
|
|
|
|
- name: Create a VM to run with two vNUMA nodes
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
cluster: mycluster
|
|
|
|
|
numa_tune_mode: "interleave"
|
|
|
|
@ -805,7 +786,7 @@ EXAMPLES = '''
|
|
|
|
|
numa_node_pins: [1]
|
|
|
|
|
|
|
|
|
|
- name: Update an existing VM to run without previously created vNUMA nodes (i.e. remove all vNUMA nodes+NUMA pinning setting)
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
cluster: mycluster
|
|
|
|
|
state: "present"
|
|
|
|
@ -816,14 +797,14 @@ EXAMPLES = '''
|
|
|
|
|
# When change on the VM needs restart of the VM, use next_run state,
|
|
|
|
|
# The VM will be updated and rebooted if there are any changes.
|
|
|
|
|
# If present state would be used, VM won't be restarted.
|
|
|
|
|
- ovirt_vms:
|
|
|
|
|
- ovirt_vm:
|
|
|
|
|
state: next_run
|
|
|
|
|
name: myvm
|
|
|
|
|
boot_devices:
|
|
|
|
|
- network
|
|
|
|
|
|
|
|
|
|
- name: Import virtual machine from VMware
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: stopped
|
|
|
|
|
cluster: mycluster
|
|
|
|
|
name: vmware_win10
|
|
|
|
@ -837,7 +818,7 @@ EXAMPLES = '''
|
|
|
|
|
password: password
|
|
|
|
|
|
|
|
|
|
- name: Create vm from template and create all disks on specific storage domain
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: vm_test
|
|
|
|
|
cluster: mycluster
|
|
|
|
|
template: mytemplate
|
|
|
|
@ -846,7 +827,7 @@ EXAMPLES = '''
|
|
|
|
|
- name: nic1
|
|
|
|
|
|
|
|
|
|
- name: Remove VM, if VM is running it will be stopped
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
state: absent
|
|
|
|
|
name: myvm
|
|
|
|
|
|
|
|
|
@ -855,7 +836,7 @@ EXAMPLES = '''
|
|
|
|
|
- ovirt_quotas_facts:
|
|
|
|
|
data_center: Default
|
|
|
|
|
name: myquota
|
|
|
|
|
- ovirt_vms:
|
|
|
|
|
- ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
sso: False
|
|
|
|
|
boot_menu: True
|
|
|
|
@ -864,7 +845,7 @@ EXAMPLES = '''
|
|
|
|
|
quota_id: "{{ ovirt_quotas[0]['id'] }}"
|
|
|
|
|
|
|
|
|
|
- name: Create a VM that has the console configured for both Spice and VNC
|
|
|
|
|
ovirt_vms:
|
|
|
|
|
ovirt_vm:
|
|
|
|
|
name: myvm
|
|
|
|
|
template: mytemplate
|
|
|
|
|
cluster: mycluster
|
|
|
|
@ -1849,7 +1830,7 @@ def control_state(vm, vms_service, module):
|
|
|
|
|
vm.status == otypes.VmStatus.UNKNOWN
|
|
|
|
|
):
|
|
|
|
|
# Invalid states:
|
|
|
|
|
module.fail_json(msg="Not possible to control VM, if it's in '{}' status".format(vm.status))
|
|
|
|
|
module.fail_json(msg="Not possible to control VM, if it's in '{0}' status".format(vm.status))
|
|
|
|
|
elif vm.status == otypes.VmStatus.POWERING_DOWN:
|
|
|
|
|
if (force and state == 'stopped') or state == 'absent':
|
|
|
|
|
vm_service.stop()
|
|
|
|
@ -1890,7 +1871,7 @@ def main():
|
|
|
|
|
type=dict(type='str', choices=['server', 'desktop', 'high_performance']),
|
|
|
|
|
operating_system=dict(type='str'),
|
|
|
|
|
cd_iso=dict(type='str'),
|
|
|
|
|
boot_devices=dict(type='list'),
|
|
|
|
|
boot_devices=dict(type='list', choices=['cdrom', 'hd', 'network']),
|
|
|
|
|
vnic_profile_mappings=dict(default=[], type='list'),
|
|
|
|
|
cluster_mappings=dict(default=[], type='list'),
|
|
|
|
|
role_mappings=dict(default=[], type='list'),
|
|
|
|
@ -1951,6 +1932,10 @@ def main():
|
|
|
|
|
supports_check_mode=True,
|
|
|
|
|
required_one_of=[['id', 'name']],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if module._name == 'ovirt_vms':
|
|
|
|
|
module.deprecate("The 'ovirt_vms' module is being renamed 'ovirt_vm'", version=2.8)
|
|
|
|
|
|
|
|
|
|
check_sdk(module)
|
|
|
|
|
check_params(module)
|
|
|
|
|
|