AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Gather VMware ESX/ESXi Host Info with Ansible — Video Tutorial
Discover how to gather info about VMware ESX/ESXi hosts in a cluster using Ansible. Follow our live Playbook and simple code examples to get started.
What You'll Learn
- How to Gather Info about all VMware ESX/ESXi Hosts in a given Cluster with Ansible?
- Ansible Gather Info about all VMware ESX/ESXi Hosts in given Cluster
- Parameters
- Links
- code
- execution
- Conclusion
- Related Articles
Full Tutorial Content
How to Gather Info about all VMware ESX/ESXi Hosts in a given Cluster with Ansible?
I’m going to show you a live Playbook and some simple Ansible code.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot
Ansible Gather Info about all VMware ESX/ESXi Hosts in given Cluster
- `community.vmware.vmware_host_config_info`
- Gathers info about an ESXi host’s advanced configuration information
Let’s talk about the Ansible module `vmware_host_config_info`.
The full name is `community.vmware.vmware_host_config_info`, which means that is part of the collection of modules to interact with VMware, community-supported.
The module's purpose is to gather info about an ESXi host’s advanced configuration information.
Parameters
- `hostname` string / port integer / username string / password string / datacenter string / validate_certs boolean — connection details
- `cluster_name` string — Name of the cluster from which the ESXi host belongs to.
- `esxi_hostname` string — ESXi hostname to gather information from.
The following parameters are useful in order to Gather Info about all VMware ESX/ESXi Hosts in the given Cluster using the module `vmware_host_config_info`.
First of all, we need to establish the connection with VMware vSphere or VMware vCenter using a plethora of self-explicative parameters: `hostname`, `port`, `username`, `password`, `datacenter` and `validate_certs`.
Once the connection is successfully established you could specify the full `esxi_hostname`, the ESX/ESXi hostname, or list all the hostnames in the current cluster `cluster_name`.
Links
- [`community.vmware.vmware_host_config_info`](https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_cluster_info_module.html)
## Playbook
How to Gather Info about all VMware ESX/ESXi Hosts in given Cluster with Ansible.
I’m going to show you how to Gather Information on all the ESX/ESXi Host in the current VMware “production” cluster using Ansible Playbook.
code
- host_info_cluser.yml
```yaml
---
- name: host in cluster info Playbook
hosts: localhost
become: false
gather_facts: false
collections:
- community.vmware
pre_tasks:
- include_vars: vars.yml
tasks:
- name: Gather info about all ESXi Host in given Cluster
community.vmware.vmware_host_config_info:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: "{{ vcenter_validate_certs }}"
cluster_name: "{{ cluster_name }}"
register: cluster_info
- name: print cluster info
ansible.builtin.debug:
var: cluster_info
```
- vars.yml
```yaml
---
vcenter_hostname: "vmware.example.com"
vcenter_datacenter: "vmwaredatacenter"
vcenter_validate_certs: false
vcenter_username: "username@vsphere.local"
vcenter_password: "MySecretPassword123"
cluster_name: "production"
```
execution
```bash
$ ansible-playbook cluster_info.yml
PLAY [cluster info Playbook] ****
About This Tutorial
- Author: Luca Berton
- Difficulty: Advanced
- Read time: 14 min
- Category: installation
Read the full written article: Gather VMware ESX/ESXi Host Info with Ansible