38 lines
1.5 KiB
YAML
38 lines
1.5 KiB
YAML
---
|
|
- name: Gather VM inventory from Red Hat Virtualization (RHV)
|
|
hosts: localhost
|
|
gather_facts: false
|
|
vars:
|
|
rhv_url: "https://your_rhv_manager_fqdn/ovirt-engine/api" # Replace with your RHV Manager URL
|
|
rhv_username: "admin@internal" # Replace with your RHV username
|
|
rhv_password: "your_password" # Replace with your RHV password (use ansible-vault for security)
|
|
rhv_insecure: true # Set to false if you have valid certs
|
|
rhv_ca_file: "/path/to/ca.crt" # Optional: Path to CA certificate file
|
|
|
|
tasks:
|
|
- name: Gather information about all VMs in RHV
|
|
ovirt.ovirt.ovirt_vm_info:
|
|
auth:
|
|
url: "{{ rhv_url }}"
|
|
username: "{{ rhv_username }}"
|
|
password: "{{ rhv_password }}"
|
|
insecure: "{{ rhv_insecure }}"
|
|
ca_file: "{{ rhv_ca_file | default(omit) }}"
|
|
pattern: "name=*"
|
|
register: vm_info
|
|
|
|
- name: Display the VM inventory
|
|
debug:
|
|
var: vm_info
|
|
|
|
- name: Save VM inventory to file
|
|
copy:
|
|
content: "{{ vm_info | to_nice_json }}"
|
|
dest: /root/rhv_vm_inventory.json
|
|
|
|
# Notes:
|
|
# - Install the ovirt.ovirt collection: ansible-galaxy collection install ovirt.ovirt
|
|
# - Ensure required Python libraries are installed: pip install ovirt-engine-sdk-python
|
|
# - For production, secure passwords with ansible-vault or use environment variables.
|
|
# - This assumes you have access to the RHV Manager API.
|