community.vmware.vmware_guest_serial_port – Manage serial ports on an existing VM

Note

This plugin is part of the community.vmware collection (version 1.9.0).

To install it use: ansible-galaxy collection install community.vmware.

To use it in a playbook, specify: community.vmware.vmware_guest_serial_port.

Synopsis

  • This module can be used to manage serial ports on an existing VM

Parameters

Parameter Choices/Defaults Comments
backings
list / elements=dictionary / required
A list of backings for serial ports.
backing_type (str): is required to add or reconfigure or remove an existing serial port.
backing_type
string / required
Backing type is required for the serial ports to be added or reconfigured or removed.

aliases: type
device_name
string
Serial device absolutely path.
Required when backing_type=device.
direction
string
    Choices:
  • client ←
  • server
The direction of the connection.
Required when backing_type=network.
endpoint
string
    Choices:
  • client ←
  • server
When you use serial port pipe backing to connect a virtual machine to another process, you must define the endpoints.
Required when backing_type=pipe.
file_path
string
File path for the host file used in this backing. Fully qualified path is required, like <datastore_name>/<file_name>.
Required when backing_type=file.
no_rx_loss
boolean
    Choices:
  • no ←
  • yes
Enables optimized data transfer over the pipe.
Required when backing_type=pipe.
pipe_name
string
Pipe name for the host pipe.
Required when backing_type=pipe.
service_uri
string
Identifies the local host or a system on the network, depending on the value of direction.
If you use the virtual machine as a server, the URI identifies the host on which the virtual machine runs.
In this case, the host name part of the URI should be empty, or it should specify the address of the local host.
If you use the virtual machine as a client, the URI identifies the remote system on the network.
Required when backing_type=network.
state
string
    Choices:
  • present ←
  • absent
state is required to identify whether we are adding, modifying or removing the serial port.
If state is set to present, a serial port will be added or modified.
If state is set to absent, an existing serial port will be removed.
If an existing serial port to modify or remove, backing_type and either of service_uri or pipe_name or device_name or file_path are required.
yield_on_poll
boolean
    Choices:
  • no
  • yes ←
Enables CPU yield behavior.
hostname
string
The hostname or IP address of the vSphere vCenter or ESXi server.
If the value is not specified in the task, the value of environment variable VMWARE_HOST will be used instead.
Environment variable support added in Ansible 2.6.
moid
string
Managed Object ID of the instance to manage if known, this is a unique identifier only within a single vCenter instance.
This is required if name or uuid is not supplied.
name
string
Name of the virtual machine.
This is a required parameter, if parameter uuid or moid is not supplied.
password
string
The password of the vSphere vCenter or ESXi server.
If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.
Environment variable support added in Ansible 2.6.

aliases: pass, pwd
port
integer
Default:
443
The port number of the vSphere vCenter or ESXi server.
If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.
Environment variable support added in Ansible 2.6.
proxy_host
string
Address of a proxy that will receive all HTTPS requests and relay them.
The format is a hostname or a IP.
If the value is not specified in the task, the value of environment variable VMWARE_PROXY_HOST will be used instead.
This feature depends on a version of pyvmomi greater than v6.7.1.2018.12
proxy_port
integer
Port of the HTTP proxy that will receive all HTTPS requests and relay them.
If the value is not specified in the task, the value of environment variable VMWARE_PROXY_PORT will be used instead.
use_instance_uuid
boolean
    Choices:
  • no ←
  • yes
Whether to use the VMware instance UUID rather than the BIOS UUID.
username
string
The username of the vSphere vCenter or ESXi server.
If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.
Environment variable support added in Ansible 2.6.

aliases: admin, user
uuid
string
UUID of the instance to manage the serial ports, this is VMware's unique identifier.
This is a required parameter, if parameter name or moid is not supplied.
validate_certs
boolean
    Choices:
  • no
  • yes ←
Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted.
If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.
Environment variable support added in Ansible 2.6.
If set to true, please make sure Python >= 2.7.9 is installed on the given machine.

Examples

# Create serial ports
- name: Create multiple serial ports with Backing type - network, pipe, device and file
  community.vmware.vmware_guest_serial_port:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: "test_vm1"
    backings:
    - type: 'network'
      direction: 'client'
      service_uri: 'tcp://6000'
      yield_on_poll: True
    - type: 'pipe'
      pipe_name: 'serial_pipe'
      endpoint: 'client'
    - type: 'device'
      device_name: '/dev/char/serial/uart0'
    - type: 'file'
      file_path: '[datastore1]/file1'
      yield_on_poll:  True
    register: create_multiple_ports

# Modify existing serial port
- name: Modify Network backing type
  community.vmware.vmware_guest_serial_port:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    name: '{{ name }}'
    backings:
    - type: 'network'
      state: 'present'
      direction: 'server'
      service_uri: 'tcp://6000'
  delegate_to: localhost

# Remove serial port
- name: Remove pipe backing type
  community.vmware.vmware_guest_serial_port:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    name: '{{ name }}'
    backings:
    - type: 'pipe'
      state: 'absent'
  delegate_to: localhost

Return Values

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

Key Returned Description
serial_port_data
dictionary
always
metadata about the virtual machine's serial ports after managing them

Sample:
[{'backing_type': 'network', 'direction': 'client', 'service_uri': 'tcp://6000'}, {'backing_type': 'pipe', 'direction': 'server', 'pipe_name': 'serial pipe'}]


Authors

  • Anusha Hegde (@anusha94)