Skip to content

jmagudo/ansible-apicem-dynamic-inventory

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ansible-apicem-dynamic-inventory

With this python script you can use Cisco APIC-EM as a dynamic inventory for ansible.
I want to mention that I used code snippets from the project ansible-apic-em, which contains an APIC-EM ansible module.
By contrast my project uses APIC-EM as a real dynamic inventory for ansible playbooks.

usage

  1. Place the file apicem-dynamic-inventory.py in a folder at your ansible-project. For example the folder can be called "dynamic-inventory".
  2. Edit the file and change the variables self.controllername, self.username and self.password to your own APIC-EM values.
  3. Execute a playbook with APIC-EM as the dynamic inventory.

examples

The example playbook uses the ansible module ntc_show_command of the project ntc-ansible. Please consider that you need the module and the template-file for the command you are using (in this case show clock).

all devices

ansible-playbook regex.yml -i dynamic-inventory

limit to one location

ansible-playbook regex.yml -i dynamic-inventory --limit "mylocation"

limit to one device

ansible-playbook regex.yml -i dynamic-inventory --limit "mydevice"

returned variables

In this version the following variables are returned by the dynamic inventory as host variables:

  • macAddress
  • upTime
  • bootDateTime
  • location
  • device_ip
  • software
  • role
  • platformId
  • series
  • family

miscellaneous

  • this version doesnt return devices which have no location set in APIC-EM
  • this version returns all of the devices (currently the API returns only 500, because of that this version makes multiple API calls).

license

This project is published with the MIT license. So feel free to use the code in your own projects.

About

APIC-EM as a dynamic inventory for ansible

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%