scale_computing.hypercore.vm module – Create, update or delete a VM.
Note
This module is part of the scale_computing.hypercore collection (version 1.6.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install scale_computing.hypercore
.
To use it in a playbook, specify: scale_computing.hypercore.vm
.
New in scale_computing.hypercore 1.0.0
Synopsis
Use this module to create, update or delete a VM. When creating or updating a VM, setting the disks, network nics and boot order is possible.
Module tries to remove disks from a running VM. If disk cannot be removed from running VM, then VM will be shutdown, disk will be removed, and VM is started back.
VM has
shutdown_timeout
time to respond to shutdown request. If VM is not shutoff within shutdown_timeout, then a force shutdown will be issued ifforce_reboot=True
.
Parameters
Parameter |
Comments |
---|---|
If supported by operating system, create an extra device to attach the Scale Guest OS tools ISO. Supported by operating_system=os_windows_server_2012. Choices:
|
|
Ordered list of boot devices (disks and nics) you want to set |
|
If setting the boot device order of disk, that is type=virtio_disk, type=ide_disk, type=scsi_disk, type=ide_floppy or type=nvram disk_slot is required. If setting the boot device order of CD-ROM, that is type=ide_cdrom, at least one of iso_name or disk_slot is required. If type=nic, disk_slot is not relevant. At least one of disk_slot, nic_vlan and iso_name is required to identify the VM device to which we’re setting the boot order. |
|
The name of ISO image that CD-ROM device is attached to. Only relevant if type=ide_cdrom. If type=cdrom, at least one of iso_name or disk_slot is required to identify CD-ROM device. Otherwise, iso_name is not relevant. At least one of disk_slot, nic_vlan and i(iso_name) is required to identify the vm device to which we’re setting the boot order. |
|
Nic’s vlan. If type=nic, nic_vlan is required. Otherwise, nic_vlan is not relevant. At least one of disk_slot, nic_vlan and iso_name is required to identify the vm device to which we’re setting the boot order. |
|
The type of device we want to set the boot order to. If setting the boot order for nic, type should be equal to nic. If setting the boot order for disk, type should be equal to one of the specific types, listed below. Choices:
|
|
Configuration to be used by cloud-init (Linux) or cloudbase-init (Windows). When non-empty will create an extra ISO device attached to VirDomain as a NoCloud datasource. There has to be cloud-config comment present at the beginning of cloud_init file or raw yaml. Default: |
|
Configuration meta-data to be used by cloud-init (Linux) or cloudbase-init (Windows). Valid YAML syntax. |
|
Configuration user-data to be used by cloud-init (Linux) or cloudbase-init (Windows). Valid YAML syntax. |
|
Scale Computing HyperCore instance information. |
|
Select login method. If not set, the value of the Value local - username/password is verified by the HyperCore server (the local users). Value oidc - username/password is verified by the configured OIDC provider. Choices:
|
|
The HyperCore instance URL. If not set, the value of the For example “https://10.1.2.3:443”. |
|
Password used for authentication. If not set, the value of the |
|
Timeout in seconds for the connection with the Scale Computing HyperCore API instance. If not set, the value of the |
|
Username used for authentication. If not set, the value of the |
|
VM’s description. Only relevant if state=present. value. |
|
List of disks we want to create. Required if state=present. |
|
The cache mode the VM will use. Choices:
|
|
Virtual slot the drive will occupy. |
|
The name of the ISO image we want to attach to the CD-ROM. Required if type=ide_cdrom Only relevant if type=ide_cdrom. |
|
Logical size of the device in bytes. |
|
The bus type the VM will use. If type=ide_cdrom, it’s assumed you want to attach ISO image to cdrom disk. In that case, field iso_name is required. Choices:
|
|
Can VM be forced to power off and on. Only used when modifications to the VM require it to be powered off and VM does not respond to a shutdown request within shutdown_timeout limit. Before this is utilized, a shutdown request is sent. Choices:
|
|
Scale Hardware version. Required if creating a new VM. Only relevant when creating the VM. This property cannot be modified. HyperCore needs to support requested machine_type. BIOS and UEFI - available since 9.1. vTPM+UEFI - available since 9.2. vTPM+UEFI-compatible - available since 9.3. Choices:
|
|
VM’s physical memory in bytes. Required if state=present. Irrelevant if state=absent. |
|
List of network interfaces we want to create. Required if state=present. |
|
Is network interface connected or not. Choices:
|
|
Mac address of the network interface. |
|
Defines type of the network interface. Choices:
|
|
Network interface virtual LAN. Default: |
|
Operating system name. Used to select drivers package Choices:
|
|
Desired VM state. States Note that - shutdown will trigger a graceful ACPI shutdown. - reboot will trigger a graceful ACPI reboot. - stop will trigger an abrupt shutdown (force power off). VM might loose data, and filesystem might be corrupted afterwards. - reset will trigger an abrupt reset (force power reset). VM might loose data, and filesystem might be corrupted afterwards. Choices:
|
|
How long does ansible controller wait for VMs response to a shutdown request. In seconds. Default: |
|
The name of an existing snapshot_schedule to assign to VM. VM can have 0 or 1 snapshot schedules assigned. |
|
Desired state of the VM. Choices:
|
|
Tags of the VM. The first tag determines the group that the VM is going to belong. |
|
Number of Central processing units on the VM. Required if state=present. If state=absent, vcpu is not relevant. |
|
Virtual machine name. Used to identify selected virtual machine by name. |
|
Use it to rename a VM. If the VM already exists, VM’s new name. Only relevant if state=present. |
Notes
Note
The
record
return value will be changed from list (containing a single item) to dict. There will be no release where both old and new variant work at the same time. The change will happen with release 3.0.0. To ease migration, the only change between last 1.x or 2.x release and 3.0.0 release will be changing therecord
return value. List of deprecation changes includes examples to help with transition.check_mode
is not supported.
See Also
See also
- scale_computing.hypercore.vm_info
Retrieve information about the VMs.
- scale_computing.hypercore.vm_params
Manage VM’s parameters.
- scale_computing.hypercore.vm_boot_devices
Manage HyperCore VM’s boot devices.
- scale_computing.hypercore.vm_disk
Manage VM’s disks.
- scale_computing.hypercore.vm_nic
Handles actions over network interfaces.
- scale_computing.hypercore.vm_node_affinity
Update virtual machine’s node affinity.
- scale_computing.hypercore.vm_replication
Handles VM replications.
- scale_computing.hypercore.vm_clone
Handles cloning of the VM.
- scale_computing.hypercore.vm_import
Handles import of the virtual machine.
- scale_computing.hypercore.vm_export
Handles export of the virtual machine.
Examples
- name: Create and start the VM with disks, nics and boot devices set. Attach ISO onto the VM. Add cloud init data
scale_computing.hypercore.vm:
vm_name: vm-integration-test-vm
description: Demo VM
state: present
tags:
- my-group
- mytag1
- mytag2
memory: "{{ '512 MB' | human_to_bytes }}"
vcpu: 2
attach_guest_tools_iso: true
power_state: start
force_reboot: true
shutdown_timeout: "{{ '5minutes' | community.general.to_time_unit('seconds') }}"
disks:
- type: virtio_disk
disk_slot: 0
size: "{{ '10.1 GB' | human_to_bytes }}"
- type: ide_cdrom
disk_slot: 0
iso_name: TinyCore-current.iso
nics:
- vlan: 0
type: RTL8139
boot_devices:
- type: virtio_disk
disk_slot: 0
- type: nic
nic_vlan: 0
cloud_init:
user_data: "{{ lookup('file', 'cloud-init-user-data-example.yml') }}"
meta_data: |
# Content for cloud-init meta-data (or user-data) can be inline too.
register: result
- name: Delete the VM
scale_computing.hypercore.vm:
vm_name: demo-VM
state: absent
register: result
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Created VM, if creating the record. If deleting the record, none is returned. Returned: success |
|
Bootable disks or nics, in the order that they will boot Returned: success Sample: |
|
Human-readable description Returned: success Sample: |
|
Attached virtual block devices Returned: success Sample: |
|
Attached virtual network devices Returned: success Sample: |
|
VM’s node affinity strategy Returned: success Sample: |
|
VM’s power state Returned: success Sample: |
|
UUID of source VM if this VM is a replicated VM. Empty string is returned if this VM is not replicated. Returned: success Sample: |
|
Name identifier of a snapshot schedule for automated snapshots Returned: success Sample: |
|
User-modifiable words for organizing a group of VMs Returned: success Sample: |
|
Unique identifier Returned: success Sample: |
|
Number of allotted virtual CPUs Returned: success Sample: |
|
Human-readable virtual machine name Returned: success Sample: |
|
Info if reboot of the VM was performed. Returned: success Sample: |