community.vmware.vmware_deploy_ovf 模块 – 从文件系统或 HTTP 服务器上的 OVF 或 OVA 文件部署 VMware 虚拟机

注意

此模块是 community.vmware 集合 (版本 5.2.0) 的一部分。

如果您使用的是 ansible 包,则您可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install community.vmware

要在 playbook 中使用它,请指定: community.vmware.vmware_deploy_ovf

概要

  • 此模块可用于从文件系统或 HTTP 服务器上的 OVF 或 OVA 文件部署 VMware 虚拟机。

参数

参数

注释

allow_duplicates

布尔值

是否允许重复的虚拟机名称。ESXi 允许重复,vCenter 可能不允许。

选项

  • false

  • true ← (默认)

cluster

字符串

要部署到的集群。

如果未设置 esxi_hostname 并且 hostname 设置为 vCenter 服务器,则此参数为必填参数。

esxi_hostnamecluster 是互斥参数。

datacenter

字符串

要部署到的数据中心。

默认值: "ha-datacenter"

datastore

字符串

要部署到的数据存储。

默认值: "datastore1"

deployment_option

字符串

所选部署选项的键。

disk_provisioning

字符串

磁盘配置类型。

选项

  • "flat"

  • "eagerZeroedThick"

  • "monolithicSparse"

  • "twoGbMaxExtentSparse"

  • "twoGbMaxExtentFlat"

  • "thin" ← (默认)

  • "sparse"

  • "thick"

  • "seSparse"

  • "monolithicFlat"

enable_hidden_properties

布尔值

在 community.vmware 3.11.0 中添加

启用标记为 ovf:userConfigurable=false 的源属性。

选项

  • false ← (默认)

  • true

esxi_hostname

字符串

虚拟机将运行在其上的 ESXi 主机名。

如果未在任务中指定此参数,则将改用环境变量 VMWARE_HOST 的值。

esxi_hostnamecluster 是互斥参数。

fail_on_spec_warnings

布尔值

使模块将 OVF 导入规范警告视为错误。

选项

  • false ← (默认)

  • true

folder

字符串

放置虚拟机的文件夹的绝对路径。

如果未指定,则默认为 datacenter.vmFolder 的值。

示例

folder: /ha-datacenter/vm

folder: ha-datacenter/vm

folder: /datacenter1/vm

folder: datacenter1/vm

folder: /datacenter1/vm/folder1

folder: datacenter1/vm/folder1

folder: /folder1/datacenter1/vm

folder: folder1/datacenter1/vm

folder: /folder1/datacenter1/vm/folder2

hostname

字符串

vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。

如果在任务中未指定此值,则将改用环境变量 VMWARE_HOST 的值。

inject_ovf_env

布尔值

强制将给定的属性插入 OVF 环境并通过 VMware Tools 注入。

选项

  • false ← (默认)

  • true

name

字符串

要使用的虚拟机的名称。

vCenter 中的虚拟机名称不一定是唯一的,这可能会有问题。

networks

字典

key: value OVF 网络名称与 vCenter 网络名称的映射。

默认值: {"VM Network": "VM Network"}

ovf

别名:ova

path

要部署的 OVF 或 OVA 文件的路径。

如果未设置 url,则为必填参数。

ovfurl 是互斥参数。

密码

别名:pass,pwd

字符串

vSphere vCenter 或 ESXi 服务器的密码。

如果任务中未指定此值,则将使用环境变量VMWARE_PASSWORD的值。

端口

整数

vSphere vCenter 或 ESXi 服务器的端口号。

如果任务中未指定此值,则将使用环境变量VMWARE_PORT的值。

默认值: 443

power_on

布尔值

创建虚拟机后是否启动。

选项

  • false

  • true ← (默认)

属性

字典

将值分配给 OVF 中找到的属性,采用键值对的形式。

proxy_host

字符串

将接收所有 HTTPS 请求并转发它们的代理的地址。

格式为主机名或 IP 地址。

如果任务中未指定此值,则将使用环境变量VMWARE_PROXY_HOST的值。

proxy_port

整数

将接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。

如果任务中未指定此值,则将使用环境变量VMWARE_PROXY_PORT的值。

资源池

字符串

要部署到的资源池。

默认值: "Resources"

url

字符串

在 community.vmware 3.9.0 中添加

要部署的 OVA 文件的 URL。

如果未设置ovf,则需要此参数。

urlovf 是互斥参数。

用户名

别名:admin,user

字符串

vSphere vCenter 或 ESXi 服务器的用户名。

如果任务中未指定此值,则将使用环境变量VMWARE_USER的值。

validate_certs

布尔值

允许在 SSL 证书无效时连接。当证书不受信任时,将其设置为false

如果任务中未指定此值,则将使用环境变量VMWARE_VALIDATE_CERTS的值。

选项

  • false

  • true ← (默认)

wait

布尔值

等待主机启动。

选项

  • false

  • true ← (默认)

wait_for_ip_address

布尔值

等待 vCenter 检测到虚拟机的 IP 地址。

这需要 vmware-tools (vmtoolsd) 在创建后才能正常工作。

选项

  • false ← (默认)

  • true

备注

注意

  • 如需使用 https 作为源,需要在防火墙中启用 443 端口的入站访问。

  • 所有模块都需要 API 写入权限,因此不受免费 ESXi 许可证的支持。

  • 所有变量和 VMware 对象名称都区分大小写。

示例

- community.vmware.vmware_deploy_ovf:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    ovf: /path/to/ubuntu-16.04-amd64.ovf
    wait_for_ip_address: true
  delegate_to: localhost

# Deploys a new VM named 'NewVM' in specific datacenter/cluster, with network mapping taken from variable and using ova template from an absolute path
- community.vmware.vmware_deploy_ovf:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: Datacenter1
    cluster: Cluster1
    datastore: vsandatastore
    name: NewVM
    networks: "{u'VM Network':u'{{ ProvisioningNetworkLabel }}'}"
    power_on: false
    ovf: /absolute/path/to/template/mytemplate.ova
  delegate_to: localhost

- community.vmware.vmware_deploy_ovf:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    datacenter: Datacenter1
    esxi_hostname: test-server
    datastore: test-datastore
    ovf: /path/to/ubuntu-16.04-amd64.ovf
  delegate_to: localhost

- community.vmware.vmware_deploy_ovf:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    url: https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64.ova
    wait_for_ip_address: true
  delegate_to: localhost

返回值

常用返回值已在此处记录,以下是此模块特有的字段

描述

实例

字典

有关新虚拟机的元数据

返回:始终

示例: "None"

作者

  • Alexander Nikitin (@ihumster)

  • Matt Martz (@sivel)