scale_computing.hypercore.vm_boot_devices module – Manage HyperCore VM’s boot devices

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_boot_devices.

New in scale_computing.hypercore 1.0.0

Synopsis

  • Use this module to reconfigure VM boot devices.

  • VM boot devices can be set exactly to provided list, or provided list can be inserted before or after current VM boot devices.

Parameters

Parameter

Comments

cluster_instance

dictionary

Scale Computing HyperCore instance information.

auth_method

string

Select login method. If not set, the value of the SC_AUTH_METHOD environment variable will be used.

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:

  • "local" ← (default)

  • "oidc"

host

string / required

The HyperCore instance URL.

If not set, the value of the SC_HOST environment variable will be used.

For example “https://10.1.2.3:443”.

password

string / required

Password used for authentication.

If not set, the value of the SC_PASSWORD environment variable will be used.

timeout

float

Timeout in seconds for the connection with the Scale Computing HyperCore API instance.

If not set, the value of the SC_TIMEOUT environment variable will be used.

username

string / required

Username used for authentication.

If not set, the value of the SC_USERNAME environment variable will be used.

first

boolean

Only relevant if state=present.

If you want to assign the device the first order, set the value of first to 1.

Choices:

  • false ← (default)

  • true

force_reboot

boolean

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:

  • false ← (default)

  • true

items

list / elements=dictionary

The boot devices items we want to change.

Default: []

disk_slot

integer

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 to be specified.

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.

iso_name

string

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 iso_name is required to identify the VM device to which we’re setting the boot order.

nic_vlan

integer

NIC’s vlan.

If type=nic, nic_vlan is required.

Otherwise, nic_vlan is not relevant.

At least one of disk_slot, nic_vlan or iso_name is required to identify the VM device to which we’re setting the boot order.

type

string / required

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 disk types, listed below.

Choices:

  • "nic"

  • "ide_cdrom"

  • "virtio_disk"

  • "ide_disk"

  • "scsi_disk"

  • "ide_floppy"

  • "nvram"

shutdown_timeout

float

How long does ansible controller wait for VMs response to a shutdown request.

In seconds.

Default: 300.0

state

string / required

The desired state of the boot devices specified by items.

If state=present devices specified by items will be added to list of boot devices.

If state=absent devices specified by items will be removed from the list of boot devices.

If state=set VM boot devices will be set exactly to devices specified by items.

Choices:

  • "present"

  • "absent"

  • "set"

vm_name

string / required

Virtual machine name.

Used to identify selected virtual machine by name.

Notes

Note

  • check_mode is not supported.

Examples

- name: Set exact boot order
  scale_computing.hypercore.vm_boot_devices:
    vm_name: name-of-desired-vm
    items:
      - type: virtio_disk
        disk_slot: 2
      - type: nic
        nic_vlan: 10
    state: set
  register: result

- name: Set device as bootable
  scale_computing.hypercore.vm_boot_devices:
    vm_name: name-of-desired-vm
    items:
      - type: nic
        nic_vlan: 2
    state: present
  register: result

- name: Set device as not bootable
  scale_computing.hypercore.vm_boot_devices:
    vm_name: name-of-desired-vm
    items:
      - type: nic
        nic_vlan: 10
    state: absent
  register: result

- name: Set device as first boot device
  scale_computing.hypercore.vm_boot_devices:
    vm_name: name-of-desired-vm
    force_reboot: true
    shutdown_timeout: "{{ '5minutes' | community.general.to_time_unit('seconds') }}"
    items:
      - type: virtio_disk
        disk_slot: 2
      - type: nic
        nic_vlan: 5
    state: present
    first: true
  register: result

- name: Set ISO as first boot device. Identifying CD-ROM by field iso_name
  scale_computing.hypercore.vm_boot_devices:
    vm_name: name-of-desired-vm
    items:
      - type: ide_cdrom
        iso_name: TinyCore-current.iso  # name of ISO image, but it can be used only if ISO is inside CD-ROM
    state: present
    first: true
  register: result

- name: Set ISO as first boot device. Identifying CD-ROM by field disk_slot
  scale_computing.hypercore.vm_boot_devices:
    vm_name: name-of-desired-vm
    items:
      - type: ide_cdrom
        disk_slot: 2
    state: present
    first: true
  register: result

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

record

dictionary

VM’s device that we’re assigning the boot order to, which can be either disks from the API endpoint /VirDomainBlockDevices, or nics from the API endpoint /VirDomainNetDevices.

Returned: success

cache_mode

string

The cache mode the block device will use

Returned: success

Sample: "writeback"

disable_snapshotting

boolean

Disables the ability to snapshot the drive

Returned: success

Sample: false

disk_slot

integer

Virtual slot the drive will occupy

Returned: success

Sample: 2

iso_name

string

Name of the virtual storage device

Returned: success

Sample: "jc1-disk-0"

mount_points

list / elements=string

Mount points of the drive in the guest OS, populated by the guest-agent

Returned: success

Sample: ["/boot"]

read_only

boolean

When true, this device was created via VirDomainSnapshotBlockDeviceCreate with VirDomainSnapshotBlockDeviceCreateOptions

Returned: success

Sample: false

size

integer

Logical size of the device in bytes, and can be increased on update or clone

Returned: success

Sample: 10737418240

tiering_priority_factor

integer

SSD tiering priority factor for block placement

Returned: success

Sample: 8

type

string

The bus type the block device will use

Returned: success

Sample: "virtio_disk"

uuid

string

Unique Identifier

Returned: success

Sample: "d48847d0-91b1-4edf-ab28-3be864494711"

vm_uuid

string

Identifier of the VirDomain this device is attached to

Returned: success

Sample: "183c5d7c-1e2e-4871-84e8-9ef35bfda5ca"

vm_rebooted

boolean

Info if reboot of the VM was performed.

Returned: success

Sample: true

Authors

  • Tjaž Eržen (@tjazsch)