scale_computing.hypercore.vm_nic module – Handles actions over network interfaces

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

New in scale_computing.hypercore 1.0.0

Synopsis

  • Use vm_nics to perform actions over network interfaces (NIC) on a specified virtual machine.

  • Can create, update or delete specified network interfaces.

  • A single NIC can be identified by - type and vlan, or - type and mac

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.

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

List of network interfaces.

Default: []

connected

boolean

Is network interface connected or not.

Choices:

  • false

  • true ← (default)

mac

string

Mac address of the network interface.

mac_new

string

Used to change mac address on the network interface.

type

string

Defines type of the network interface.

Choices:

  • "virtio" ← (default)

  • "RTL8139"

  • "INTEL_E1000"

vlan

integer

Network interface virtual LAN.

Default: 0

vlan_new

integer

Used to swap network interface to a different virtual LAN.

shutdown_timeout

float

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

In seconds.

Default: 300.0

state

string / required

State defines which operation should plugin do over selected network interfaces.

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 NIC interface
  scale_computing.hypercore.vm_nic:
    vm_name: XLAB-demo-vm
    force_reboot: true
    shutdown_timeout: "{{ '5minutes' | community.general.to_time_unit('seconds') }}"
    items:
      - vlan: 0
        type: RTL8139
    state: set

- name: Remove all nic interfces
  scale_computing.hypercore.vm_nic:
    vm_name: XLAB-demo-vm
    items: []
    state: set

- name: Add/Update NICs interface
  scale_computing.hypercore.vm_nic:
    vm_name: XLAB-demo-vm
    items:
      - vlan: 1
        type: virtio
      - vlan: 2
        type: RTL8139
    state: present

- name: Remove one NIC interface
  scale_computing.hypercore.vm_nic:
    vm_name: XLAB-demo-vm
    items:
      - vlan: 1
        type: virtio
    state: absent

- name: Change VLAN on NIC
  scale_computing.hypercore.vm_nic:
    vm_name: XLAB-demo-vm
    items:
      - vlan: 1
        vlan_new: 10
    state: set

- name: Set NIC interfaces on multiple virtual machines
  scale_computing.hypercore.vm_nic:
    vm_name: "{{ item }}"
    items:
      - vlan: 0
        type: RTL8139
    state: present
  loop:
    - XLAB-demo-vm
    - XLAB-POST-TEST
    - XLAB-us11-example6

- name: Change mac on NIC
  scale_computing.hypercore.vm_nic:
    vm_name: XLAB-demo-vm
    items:
      - vlan: 1
        mac_new: 7C:4C:58:01:23:45
    state: set

Return Values

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

Key

Description

records

list / elements=dictionary

The created or changed record for nic on a specified virtual machine.

Returned: success

connected

boolean

Enabled and can make connections

Returned: success

Sample: true

ipv4_addresses

list / elements=string

IPv4 addresses registered with this device

Returned: success

Sample: ["192.0.2.1"]

mac

string

MAC address of the virtual network device

Returned: success

Sample: "12-34-56-78-AB"

type

string

Virtualized network device types

Returned: success

Sample: "virtio"

uuid

string

Unique identifier

Returned: success

Sample: "07a2a68a-0afa-4718-9c6f-00a39d08b67e"

vlan

integer

VLAN tag of the interface

Returned: success

Sample: 15

vm_rebooted

boolean

Info if reboot of the VM was performed.

Returned: success

Sample: true

Authors

  • Domen Dobnikar (@domen_dobnikar)