--- # ============================================================================= # Libvirt/KVM Dynamic Inventory Configuration # ============================================================================= # Configuration for community.libvirt.libvirt dynamic inventory plugin # Documentation: ansible-doc -t inventory community.libvirt.libvirt # ============================================================================= plugin: community.libvirt.libvirt # Hypervisor Connection # ----------------------------------------------------------------------------- # URI to connect to libvirt hypervisor # Local system: qemu:///system # Remote SSH: qemu+ssh://user@host/system uri: 'qemu:///system' # Inventory Hostname Format # ----------------------------------------------------------------------------- # How to register VMs as inventory hostnames # Options: 'name' (use VM name) or 'uuid' (use UUID) inventory_hostname: name # Grouping Configuration # ----------------------------------------------------------------------------- # Automatically create groups based on VM characteristics compose: # Set ansible_host from libvirt network IP if available ansible_host: ansible_libvirt_ip_address | default(omit) groups: # Group by VM state running_vms: ansible_libvirt_state == 'running' stopped_vms: ansible_libvirt_state != 'running' # Group by resource allocation small_vms: ansible_libvirt_memory_mb <= 2048 medium_vms: ansible_libvirt_memory_mb > 2048 and ansible_libvirt_memory_mb <= 8192 large_vms: ansible_libvirt_memory_mb > 8192 # Keyed Groups # ----------------------------------------------------------------------------- # Create dynamic groups based on host variables keyed_groups: - key: ansible_libvirt_state prefix: state separator: "_" - key: ansible_libvirt_network prefix: network separator: "_" # Filters # ----------------------------------------------------------------------------- # Set strict mode for error handling strict: false