community.vmware.vmware_guest_serial_port 模块 – 管理现有虚拟机上的串行端口
注意
此模块是 community.vmware 集合(版本 5.2.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.vmware
。
要在 playbook 中使用它,请指定:community.vmware.vmware_guest_serial_port
。
概要
此模块可用于管理现有虚拟机上的串行端口
参数
参数 |
注释 |
---|---|
串行端口的后备列表。
|
|
要添加、重新配置或删除的串行端口的后备类型是必需的。 |
|
串行设备的绝对路径。 当 |
|
此后备中使用的宿主机文件的文件路径。需要完全限定的路径,例如 <datastore_name>/<file_name>。 当 |
|
宿主机管道的管道名称。 当 |
|
标识一个 vSPC 代理服务,该服务提供对 如果您指定代理 URI,虚拟机将发起与代理服务的连接,并将 serviceURI 和 direction 转发到代理。 当设置 |
|
根据 如果您将虚拟机用作服务器,则 URI 标识虚拟机运行所在的宿主机。 在这种情况下,URI 的主机名部分应为空,或者应指定本地主机的地址。 如果您将虚拟机用作客户端,则 URI 标识网络上的远程系统。 当 |
|
需要 如果 如果 如果要修改或移除现有的串行端口,则需要 选项
|
|
启用 CPU 让步行为。 选项
|
|
vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。 如果在任务中未指定该值,则将使用环境变量 |
|
vSphere vCenter 或 ESXi 服务器的密码。 如果在任务中未指定该值,则将使用环境变量 |
|
将接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。 如果在任务中未指定该值,则将使用环境变量 |
|
是否使用 VMware 实例 UUID 而不是 BIOS UUID。 选项
|
|
vSphere vCenter 或 ESXi 服务器的用户名。 如果在任务中未指定该值,则将使用环境变量 |
|
当 SSL 证书无效时允许连接。当证书不受信任时,设置为 如果在任务中未指定该值,则将使用环境变量 选项
|
注释
注意
所有模块都需要 API 写入权限,因此在免费 ESXi 许可上不受支持。
所有变量和 VMware 对象名称都区分大小写。
示例
# 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
# 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
# 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
返回值
常见的返回值记录在此处,以下是此模块特有的字段
键 |
描述 |
---|---|
有关管理后虚拟机串行端口的元数据 已返回: 始终 示例: |