community / community.vmware / 4.2.0 / module / vmware_host_facts Gathers facts about remote ESXi hostsystem Authors: Wei Gao (@woshihaoren)community.vmware.vmware_host_facts (4.2.0) — module
Install with ansible-galaxy collection install community.vmware:==4.2.0
collections: - name: community.vmware version: 4.2.0
This module can be used to gathers facts like CPU, memory, datastore, network and system etc. about ESXi host system.
Please specify hostname or IP address of ESXi host system as O(hostname).
If hostname or IP address of vCenter is provided as O(hostname) and O(esxi_hostname) is not specified, then the module will throw an error.
Please note that when ESXi host connection state is not C(connected), facts returned from vCenter might be stale. Users are recommended to check connection state value and take appropriate decision in the playbook.
- 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_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" 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_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" 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_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" 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_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" 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_username }}" password: "{{ vcenter_password }}" 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 }}"
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 schema: choices: - summary - vsphere default: summary description: - Specify the output schema desired. - The V(summary) output schema is the legacy output from the module - The V(vsphere) output schema is the vSphere API class definition which requires pyvmomi>6.7.1 type: str 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 show_tag: default: false description: - Tags related to Host are shown if set to V(true). required: false type: bool 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 properties: description: - 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 O(schema=vsphere). elements: str required: false type: list 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 esxi_hostname: description: - 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. type: str 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 show_datacenter: default: false description: - Return the related Datacenter if set to V(true). required: false type: bool version_added: 4.2.0 version_added_collection: community.vmware
ansible_facts: description: system info about the host machine returned: always sample: ansible_all_ipv4_addresses: - 10.76.33.200 ansible_bios_date: '2011-01-01T00:00:00+00:00' ansible_bios_version: 0.5.1 ansible_datastore: - free: 11.63 GB name: datastore1 total: 12.50 GB ansible_distribution: VMware ESXi ansible_distribution_build: '4887370' ansible_distribution_version: 6.5.0 ansible_hostname: 10.76.33.100 ansible_in_maintenance_mode: true ansible_interfaces: - vmk0 ansible_memfree_mb: 2702 ansible_memtotal_mb: 4095 ansible_os_type: vmnix-x86 ansible_processor: Intel Xeon E312xx (Sandy Bridge) ansible_processor_cores: 2 ansible_processor_count: 2 ansible_processor_vcpus: 2 ansible_product_name: KVM ansible_product_serial: NA ansible_system_vendor: Red Hat ansible_uptime: 1791680 ansible_uuid: 4c4c4544-0052-3410-804c-b2c04f4e3632 ansible_vmk0: device: vmk0 ipv4: address: 10.76.33.100 netmask: 255.255.255.0 macaddress: 52:54:00:56:7d:59 mtu: 1500 tags: - category_id: urn:vmomi:InventoryServiceCategory:8eb81431-b20d-49f5-af7b-126853aa1189:GLOBAL category_name: host_category_0001 description: '' id: urn:vmomi:InventoryServiceTag:e9398232-46fd-461a-bf84-06128e182a4a:GLOBAL name: host_tag_0001 vsan_cluster_uuid: null vsan_health: unknown vsan_node_uuid: null type: dict