All Projects → mattkeeler → ansible-nutanix-inventory

mattkeeler / ansible-nutanix-inventory

Licence: other
A dynamic inventory script for Ansible that interacts with the Nutanix API

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to ansible-nutanix-inventory

Automation
Centralized Repo for community driven Nutanix automation
Stars: ✭ 50 (+117.39%)
Mutual labels:  nutanix, nutanix-automation
ansible-ssh
Script to connect to managed hosts using Ansible inventory and config.
Stars: ✭ 51 (+121.74%)
Mutual labels:  ansible-inventory
ansible-yaml inventory
Ansible dynamic inventory reading the inventory from YAML file.
Stars: ✭ 19 (-17.39%)
Mutual labels:  ansible-inventory
PowerShell
Nutanix PowerShell.next
Stars: ✭ 23 (+0%)
Mutual labels:  nutanix
ansible-dns-inventory
A dynamic inventory script for Ansible that uses DNS TXT records
Stars: ✭ 20 (-13.04%)
Mutual labels:  ansible-inventory
yaani
Yet another Ansible Netbox inventory
Stars: ✭ 12 (-47.83%)
Mutual labels:  ansible-inventory
simple-ansible-inventory
A simple, clean and easily readable Ansible inventory
Stars: ✭ 25 (+8.7%)
Mutual labels:  ansible-inventory
itop-utilities
Utilities scripts for itop, an open source cmdb. Empowers CMDB by connecting it to other system like Ansible.
Stars: ✭ 38 (+65.22%)
Mutual labels:  ansible-inventory
ansible-pull-example
example skeleton repo for setting up ansible-pull infrastructure
Stars: ✭ 22 (-4.35%)
Mutual labels:  ansible-inventory
Ansible-inventory-file-examples
Examples and counter-examples of Ansible inventory files
Stars: ✭ 25 (+8.7%)
Mutual labels:  ansible-inventory
terraform-provider-nutanix
Terraform Nutanix Provider
Stars: ✭ 53 (+130.43%)
Mutual labels:  nutanix
grafana
Grafana dashboard for Veeam solutions
Stars: ✭ 31 (+34.78%)
Mutual labels:  nutanix

Nutanix external inventory script for Ansible

Overview

This script generates inventory that Ansible can understand by making API requests to one or more Nutanix clusters.

It assumes there is a nutanix.yml file alongside it. To specify a different path to nutanix.yml, define the NUTANIX_YML_PATH environment variable:

export NUTANIX_YML_PATH=/path/to/nutanix.yml

This script requires that all VM names and IP addresses be unique across clusters, and will fail otherwise. This is to prevent VMs with identical names or IP addresses from overwriting each other in the inventory.

Caching is implemented in order to reduce traffic and speed up inventory results. The length of time cache files are kept is determined by max_cache_age in nutanix.yml.

You can also force an update of the cache with the --refresh-cache switch.

For each host, the following variables are registered:

  • acropolisVm
  • clusterUuid
  • consistencyGroupName
  • containerIds - list
  • containerUuids - list
  • controllerVm
  • cpuReservedInHz
  • diskCapacityInBytes
  • displayable
  • fingerPrintOnWrite
  • guestOperatingSystem
  • hostId
  • hostName
  • hostUuid
  • hypervisorType
  • ipAddresses - list
  • memoryCapacityInBytes
  • memoryReservedCapacityInBytes
  • numNetworkAdapters
  • numVCpus
  • nutanixGuestTools - object
  • nutanixVirtualDiskIds - list
  • nutanixVirtualDiskUuids - list
  • nutanixVirtualDisks - list
  • onDiskDedup
  • powerState
  • protectionDomainName
  • runningOnNdfs
  • stats - object
  • usageStats - object
  • uuid
  • vdiskFilePaths - list
  • vdiskNames - list
  • virtualNicIds - list
  • virtualNicUuids - list
  • vmId
  • vmName

You can run against a specific host by using --host and specifying either the VM name or IP address.

When run in --list mode, which is the default mode when Ansible calls this script, VMs are enumerated by their IP (note that VMs without assigned IPs will not be output) and grouped according to the following:

  • Name of their respective cluster.
  • Any groups specified in the VM description field.
  • The _meta group, with the above variables registered plus any hostvars specified in the VM description field.

When run in --names mode, or when environment variable NUTANIX_MODE=names, VMs are enumerated by their names and grouped according to the following:

  • Name of their respective cluster.
  • Power state.
  • Any groups specified in the VM description field.
  • The _meta group, with the above variables registered plus any hostvars specified in the VM description field.

Ansible can use this mode on the command line as in the following:

NUTANIX_MODE=names ansible-playbook -i nutanix.py myplaybook.yml

A VM description should look something like one of the following:

{"groups":["tomcat"]}
{"groups":["texas","pd","tomcat"]}
{"groups":["texas","pd","nfs"],"hostvars":{"foo":"bar","boo":"far"}}

VM descriptions can also be enclosed in quotes, which can be useful if using a script to pass descriptions as strings when creating or updating VMs.

VMs whose descriptions are not in JSON will not be grouped according to any description field information, though they will still be grouped according to cluster name and, if listed by name, power state.

Configuration

Configuration is pretty straightforward. An example nutanix.yml file will look something like this:

# Cluster settings
clusters:
    prod-cluster:
        address: prod-cluster.example.com
        port: 9440
        username: admin
        password: pass123
        verify_ssl: False
    qa-cluster:
        address: qa-cluster.example.com
        port: 9440
        username: admin
        password: pass123
        verify_ssl: False

# Global caching settings
caching:
    cache_max_age: 300
	cache_path: '/tmp/'
	cache_base_name: 'ansible-nutanix.cache'

The address, username, and password fields are all required. The port will default to 9440 if not specified, and verify_ssl will default to True if not specified. Caching settings are also required, though cache_max_age can be set to 0 if you don't want to use cache files.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].