Add VxRail Linux inventory playbook to enable easy gathering of Linux VM details from vCenter for management and automation purposes.
💘 Generated with Crush Co-Authored-By: Crush <crush@charm.land>
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
- name: Gather Linux VM inventory from VxRail vCenter
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
vcenter_hostname: "your_vcenter_ip" # Replace with your vCenter IP or hostname
|
||||||
|
vcenter_username: "administrator@vsphere.local" # Replace with your vCenter username
|
||||||
|
vcenter_password: "your_password" # Replace with your vCenter password (use ansible-vault for security)
|
||||||
|
validate_certs: false # Set to true if you have valid certs
|
||||||
|
cluster_name: "your_cluster_name" # Optional: Specify the VxRail cluster name if needed
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Gather information about all VMs in vCenter
|
||||||
|
community.vmware.vmware_vm_info:
|
||||||
|
hostname: "{{ vcenter_hostname }}"
|
||||||
|
username: "{{ vcenter_username }}"
|
||||||
|
password: "{{ vcenter_password }}"
|
||||||
|
validate_certs: "{{ validate_certs }}"
|
||||||
|
cluster: "{{ cluster_name }}" # Optional: Filter by cluster
|
||||||
|
register: vm_info
|
||||||
|
|
||||||
|
- name: Filter Linux VMs
|
||||||
|
set_fact:
|
||||||
|
linux_vms: "{{ vm_info.virtual_machines | selectattr('guest_full_name', 'contains', 'Linux') | list }}"
|
||||||
|
|
||||||
|
- name: Display the Linux VM inventory
|
||||||
|
debug:
|
||||||
|
var: linux_vms
|
||||||
|
|
||||||
|
- name: Save Linux VM inventory to file
|
||||||
|
copy:
|
||||||
|
content: "{{ linux_vms | to_nice_json }}"
|
||||||
|
dest: /root/vxrail_linux_vm_inventory.json
|
||||||
|
|
||||||
|
# Notes:
|
||||||
|
# - Install the community.vmware collection: ansible-galaxy collection install community.vmware
|
||||||
|
# - Ensure pyvmomi is installed on the control machine: pip install pyvmomi
|
||||||
|
# - For production, secure passwords with ansible-vault or use environment variables.
|
||||||
|
# - This playbook assumes connection to vCenter managing the VxRail cluster.
|
||||||
Reference in New Issue
Block a user