-
Notifications
You must be signed in to change notification settings - Fork 0
Dynamic Inventory (pure CLI)
To see all available options and their meaning:
ansible-doc -t inventory sedi.openaudit.inventory
or as a human friendly Ansible-like website here
It is recommended to encrypt your credentials for accessing the Open-AudIT API.
Due to the nature of how Ansible works this can be done inline only (i.e. not a full encrypted vault file).
Example:
ansible-vault encrypt_string 'this-is-my-username' --name oa_username --ask-vault-passansible-vault encrypt_string 'this-is-my-password' --name oa_password --ask-vault-pass
Example inventory file ( e.g. named: inventory.openaudit.yaml):
plugin: sedi.openaudit.inventory
oa_api_server: openaudit.myserver.com
oa_api_proto: https
verify_certs: False
oa_username: !vault |
$ANSIBLE_VAULT;1.1;AES256
37613130323132393165303666656339343436666437383165653333643466636537633830656236
3331393866363762303061393564643663626366663839300a306435383232623061373730353737
38353536336463636430336337353531633737396531636535333738303165643631333238393936
3238626537636536650a356536393164306633656539316464393265663136623066636330663364
38386461393135633636636138353433333134373034316232633935383162316462
oa_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
30333461363261633939656530633836373661663465666263633664616266373734336662363261
3832343361653132306464393162633532333438383531650a666138646135316239316434336435
37306535393365663736326264396436623534343465323737316635316237653566363364633430
6434313164326461340a663138356137366365666638316239303135643234303662393839376132
62373835363736323561356165373230656537343032633563363361633162373135
oa_fieldsTranslate:
cmdb_foo: 7
myvar_for_ansible: 13
my_other_var: 21
groups:
edge_devices: "'edge' in inventory_hostname"
backup_servers: inventory_hostname.startswith('backup')
non_gigabyte_devices: cmdb_manufacturer.upper() != "GIGABYTE"
keyed_groups:
- prefix: FAI_profile
key: cmdb_fai_profile
- prefix: VENDOR
key: cmdb_manufacturer.lower()
compose:
ansible_host: cmdb_ip
Check Host Variables for details regarding the meaning of oa_fieldsTranslate and the plugin documentation for the rest.
The above example shows 2 parts of the constructed plugin which can be used: compose and keyed_groups. Using these might be contra-productive when working with a dynamic inventory and so might not what you want. Before setting these consider to check out Group-Variables first!
If you still have the need read on about their syntax here.
Ansible is smart enough to figure out the right plugin when the inventory file is configured properly (see above) but if you want to add one the following is the bare minimum:
[inventory]
enable_plugins = sedi.openaudit.inventory, auto