community.vmware.vmware_guest_serial_port (4.2.0) — module

Manage serial ports on an existing VM

Authors: Anusha Hegde (@anusha94)

Install collection

Install with ansible-galaxy collection install community.vmware:==4.2.0


Add to requirements.yml

  collections:
    - name: community.vmware
      version: 4.2.0

Description

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

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Create vSPC port
- name: Create network serial port with vSPC
  community.vmware.vmware_guest_serial_port:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: "test_vm1"
    backings:
    - type: 'network'
      direction: 'server'
      service_uri: 'vSPC.py'
      proxy_uri: 'telnets://<host>:<port>'
      yield_on_poll: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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

Inputs

    
moid:
    description:
    - 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 O(name) or O(uuid) is not supplied.
    type: str

name:
    description:
    - Name of the virtual machine.
    - This is a required parameter, if parameter O(uuid) or O(moid) is not supplied.
    type: str

port:
    default: 443
    description:
    - The port number of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PORT)
      will be used instead.
    type: int

uuid:
    description:
    - UUID of the instance to manage the serial ports, this is VMware's unique identifier.
    - This is a required parameter, if parameter O(name) or O(moid) is not supplied.
    type: str

backings:
    description:
    - A list of backings for serial ports.
    - O(backings.backing_type) is required to add or reconfigure or remove an existing
      serial port.
    elements: dict
    required: true
    suboptions:
      backing_type:
        aliases:
        - type
        description:
        - Backing type is required for the serial ports to be added or reconfigured or
          removed.
        required: true
        type: str
      device_name:
        description:
        - Serial device absolutely path.
        - Required when O(backings.backing_type=device).
        type: str
      direction:
        choices:
        - client
        - server
        default: client
        description:
        - The direction of the connection.
        - Required when O(backings.backing_type=network).
        type: str
      endpoint:
        choices:
        - client
        - server
        default: client
        description:
        - When you use serial port pipe backing to connect a virtual machine to another
          process, you must define the endpoints.
        - Required when O(backings.backing_type=pipe).
        type: str
      file_path:
        description:
        - File path for the host file used in this backing. Fully qualified path is required,
          like <datastore_name>/<file_name>.
        - Required when O(backings.backing_type=file).
        type: str
      no_rx_loss:
        default: false
        description:
        - Enables optimized data transfer over the pipe.
        - Required when O(backings.backing_type=pipe).
        type: bool
      pipe_name:
        description:
        - Pipe name for the host pipe.
        - Required when O(backings.backing_type=pipe).
        type: str
      proxy_uri:
        description:
        - Identifies a vSPC proxy service that provides network access to the O(backings.service_uri).
        - If you specify a proxy URI, the virtual machine initiates a connection with
          the proxy service and forwards the serviceURI and direction to the proxy.
        - The C(Use Virtual Serial Port Concentrator) option is automatically enabled
          when O(backings.proxy_uri) is set.
        type: str
        version_added: 3.7.0
        version_added_collection: community.vmware
      service_uri:
        description:
        - Identifies the local host or a system on the network, depending on the value
          of O(backings.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 O(backings.backing_type=pipe).
        type: str
      state:
        choices:
        - present
        - absent
        default: present
        description:
        - O(backings.state) is required to identify whether we are adding, modifying or
          removing the serial port.
        - If V(present), a serial port will be added or modified.
        - If V(absent), an existing serial port will be removed.
        - If an existing serial port to modify or remove, O(backings.backing_type) and
          either of O(backings.service_uri) or O(backings.pipe_name) or O(backings.device_name)
          or O(backings.file_path) are required.
        type: str
      yield_on_poll:
        default: true
        description:
        - Enables CPU yield behavior.
        type: bool
    type: list

hostname:
    description:
    - 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 E(VMWARE_HOST)
      will be used instead.
    type: str

password:
    aliases:
    - pass
    - pwd
    description:
    - The password of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PASSWORD)
      will be used instead.
    type: str

username:
    aliases:
    - admin
    - user
    description:
    - The username of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_USER)
      will be used instead.
    type: str

proxy_host:
    description:
    - 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 E(VMWARE_PROXY_HOST)
      will be used instead.
    required: false
    type: str

proxy_port:
    description:
    - 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 E(VMWARE_PROXY_PORT)
      will be used instead.
    required: false
    type: int

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid. Set to V(false) when certificates
      are not trusted.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_VALIDATE_CERTS)
      will be used instead.
    type: bool

use_instance_uuid:
    default: false
    description:
    - Whether to use the VMware instance UUID rather than the BIOS UUID.
    type: bool

Outputs

serial_port_data:
  description: metadata about the virtual machine's serial ports after managing them
  returned: always
  sample:
  - backing_type: network
    direction: client
    service_uri: tcp://6000
  - backing_type: pipe
    direction: server
    pipe_name: serial pipe
  type: dict