Note
This plugin is part of the community.vmware collection.
To install it use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vmware_host_facts
.
hostname
.hostname
and esxi_hostname
is not specified, then the module will throw an error.The below requirements are needed on the host that executes this module.
Parameter | Choices/Defaults | Comments |
---|---|---|
esxi_hostname string | ESXi hostname. Host facts about the specified ESXi server will be returned. By specifying this option, you can select which ESXi hostsystem is returned if connecting to a vCenter. | |
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. | |
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. |
properties list / elements=string | Specify the properties to retrieve. If not specified, all properties are retrieved (deeply). Results are returned in a structure identical to the vsphere API. Example: properties: [ "hardware.memorySize", "hardware.cpuInfo.numCpuCores", "config.product.apiVersion", "overallStatus" ] Only valid when schema is vsphere . | |
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. | |
schema string |
| Specify the output schema desired. The 'summary' output schema is the legacy output from the module The 'vsphere' output schema is the vSphere API class definition which requires pyvmomi>6.7.1 |
show_tag boolean |
| Tags related to Host are shown if set to True . |
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 | |
validate_certs boolean |
| 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 yes , please make sure Python >= 2.7.9 is installed on the given machine. |
- name: Gather vmware host facts community.vmware.vmware_host_facts: hostname: "{{ esxi_server }}" username: "{{ esxi_username }}" password: "{{ esxi_password }}" register: host_facts delegate_to: localhost - name: Gather vmware host facts from vCenter community.vmware.vmware_host_facts: hostname: "{{ vcenter_server }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" esxi_hostname: "{{ esxi_hostname }}" register: host_facts delegate_to: localhost - name: Gather vmware host facts from vCenter with tag information community.vmware.vmware_host_facts: hostname: "{{ vcenter_server }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" esxi_hostname: "{{ esxi_hostname }}" show_tag: True register: host_facts_tag delegate_to: localhost - name: Get VSAN Cluster UUID from host facts community.vmware.vmware_host_facts: hostname: "{{ esxi_server }}" username: "{{ esxi_username }}" password: "{{ esxi_password }}" register: host_facts - set_fact: cluster_uuid: "{{ host_facts['ansible_facts']['vsan_cluster_uuid'] }}" - name: Gather some info from a host using the vSphere API output schema community.vmware.vmware_host_facts: hostname: "{{ vcenter_server }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" esxi_hostname: "{{ esxi_hostname }}" schema: vsphere properties: - hardware.memorySize - hardware.cpuInfo.numCpuCores - config.product.apiVersion - overallStatus register: host_facts - name: Gather information about powerstate and connection state community.vmware.vmware_host_facts: hostname: "{{ vcenter_server }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" esxi_hostname: "{{ esxi_hostname }}" schema: vsphere properties: - runtime.connectionState - runtime.powerState - name: How to retrieve Product, Version, Build, Update info for ESXi from vCenter block: - name: Gather product version info for ESXi from vCenter community.vmware.vmware_host_facts: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_user }}" password: "{{ vcenter_pass }}" validate_certs: no esxi_hostname: "{{ esxi_hostname }}" schema: vsphere properties: - config.product - config.option register: gather_host_facts_result - name: Extract update level info from option properties set_fact: update_level_info: "{{ item.value }}" loop: "{{ gather_host_facts_result.ansible_facts.config.option }}" when: - item.key == 'Misc.HostAgentUpdateLevel' - name: The output of Product, Version, Build, Update info for ESXi debug: msg: - "Product : {{ gather_host_facts_result.ansible_facts.config.product.name }}" - "Version : {{ gather_host_facts_result.ansible_facts.config.product.version }}" - "Build : {{ gather_host_facts_result.ansible_facts.config.product.build }}" - "Update : {{ update_level_info }}"
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/community/vmware/vmware_host_facts_module.html