-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Inventory Integration to Hypervisors #2709
Comments
I found a work-around and you might get some value for adding it to your documentation for Ansible Semaphore, because I can see more people being interested in adding VMware as a dynamic inventory. The guide is as follows: ansible - vmware inventorythis guide will help set up a dynamic inventory file in yaml format, where it uses the Ansible collection module community.vmware, the python packages pyVmomi, requests and vSphere Automation SDK.
pip install \
ansible \
requests \
pyVmomi \
git+https://github.com/vmware/vsphere-automation-sdk-python.git
ansible collection install \
community.vmware
[inventory]
enable_plugins = vmware_vm_inventory
plugin: vmware_vm_inventory
strict: false
hostname: vcenter01.domain.com
username: vmware-api-user
password: !vault |
$ANSIBLE_VAULT;1.1;AES256
3932.....
validate_certs: false
with_tags: false
groups:
VMs: true You can use a clear-text-password, but I recommend using an Ansible encrypted string. To create encrypted string, use the command below, and the output can then be added to ansible-vault encrypt_string 'PUT YOUR PASSWORD HERE'
ansible-inventory -i vmware.yml --list --ask-vault-pass If it all goes well, you should see a list of hosts, it might seem like it's stuck, but that could be that you have alot of VM's or slow connection. Don't worry, simply wait. Now you are done. Bonus tipYou can add the inventory to Ansible Semaphore, just make sure you have created a secret for the encrypted string. This assumes you have setup an Repository in Semaphore, where This guide is made on Ansible Semaphore version v2.11.2, things might be subject to change in newer versions.
Set the following:
Click on the
Set the following:
You can use |
Related to
Other
Impact
major improvement to user experience
Missing Feature
AWX and AAP offer integration capabilities with various hypervisors, such as VMware, through an API provided by the hypervisor. This integration enables the creation of a dynamic inventory.
As a result, the inventory is automatically updated based on the hosts in VMware or other hypervisors, eliminating the need for manual updates to the inventory file. This ensures that the inventory remains current without relying on others to manage updates, providing an always-up-to-date reflection of the hosts in VMware or another hypervisor.
Implementation
Utilize the API provided by the various hypervisors to retrieve hostnames, which can then undergo a validation process to ensure proper formatting. Once validated, an inventory can be generated and made available for use in Ansible Semaphore. The inventory can be set to update automatically on an hourly basis, or an option can be provided to manually trigger an inventory update as needed.
Design
Although I don't have programming experience, I believe that utilizing an API from a hypervisor to retrieve hostnames may require authentication. This would likely involve setting up a user or API key to allow access to the hypervisor and pull the necessary hostnames. Once retrieved, Semaphore could then format the data and generate the inventory.
Given that different hypervisors have distinct API request structures and formats, I assume that separate integrations would need to be developed for each. It might be beneficial to begin with the most commonly used hypervisors, such as VMware and Proxmox.
The text was updated successfully, but these errors were encountered: