-
Notifications
You must be signed in to change notification settings - Fork 0
Auto mapped Open AudIT Variables
The inventory plugin creates hosts and all stuff around (group mappings, variables) based on the Open-AudIT field oa.fqdn.
So this field (Manage -> Devices -> Device details -> field: FQDN) must be set (and be unique) for every device in Open-AudIT.
The following lists all directly available variables fetched from Open-AudIT.
| Variable Name | Meaning | Example value |
|---|---|---|
oa.id |
Unique device id (Manage -> Devices -> Device details -> digit from URL) |
213 |
oa.fqdn |
The FQDN of that device (Manage -> Devices -> Device details -> field: FQDN).Used by the inventory plugin to create hosts entries so it must exist in your Open-AudIT device config. Becomes ansible_host if not overwritten by e.g. compose or a custom field |
myhost.somewhere.com |
oa.org |
Organisation Name (Manage -> Orgs) that device belongs to |
My awesome company |
oa.org_id |
Organisation unique ID (Manage -> Orgs -> Org details -> field: ID) that device belongs to |
11 |
oa.location_id |
The unique location id (Manage -> Locations -> Location details -> field: ID) that device belongs to |
3 |
oa.ip |
Main IP of that device (Manage -> Devices -> Device details -> field: IP) |
9.9.9.9 |
oa.manufacturer |
Manufacturer Name of that device (Manage -> Devices -> Device details -> field: Manufacturer) |
DELL |
oa.status |
The defined status of that device (Manage -> Devices -> Device details -> field: Status) |
Production |
https://<server>/open-audit/index.php/locations
| Variable Name | Meaning | Example value |
|---|---|---|
oa.location |
The location name (Manage -> Locations -> Location details -> field: Name) |
Munich |
oa.location_vars* |
Location/Group variables (Manage -> Locations -> Location details -> field: Suite).A semicolon separated list of key=value pairs which will be automatically translated to <ansible-variable-name>:<value>. |
foo=bar;cow=moo;and=so_on |
[*] The idea of this one is to be able to use / define group variables directly in Open-AudIT. The groups in Open-AudIT are SQL queries and so nothing an inexperienced user will use actually. So the only option which makes sense (afaik) is to use a field in the organisation or location. The orgs do not fit from the logically point of view and there is only 1 field (description) available so this plugins makes use of the most useless (imho) location field I could think of: "Suite". You just add in this line semicolon separated all those key=value definitions you want and this plugin will translate them accordingly and (ofc) making them available to all hosts part of that location. Always keep an eye on the variable inheritance though ;)
https://<server>/open-audit/index.php/fields
You can add as many custom fields you like and as soon as you configure them in oa_fieldsTranslate and add values at a device they will appear as a host variable. These have the highest precedence and can be overwritten only by extra-vars set on the CLI call directly.
Usually (and this is the recommended approach) you will create a custom field in Open-AudIT and then do the <variable-name>: id mapping in your local hosts.openaudit.yml config file:
oa_fieldsTranslate:
foo: 7
myvar_for_ansible: 13
my_other_var: 21
Means: you have created 3 custom fields in Open-AudIT (named it somehow - the name there does NOT matter) and you got the ids 7, 13 and 21 from Open-AudIT (Manage -> Fields -> field details -> field: ID). Then you added them to your local hosts.openaudit.yml config file to the oa_fieldsTranslate dictionary. Now you can open your device(s) and set the values you like for every of these custom fields and they will automagically appear in the inventory as host variables! That's it.
Note:
You might noticed it already that all predefined variable names are prefixed with cmdb_. While it is recommended to prefix all your variable names with cmdb_ it is actually not required. It is more meant as an indicator where that specific variable is coming from.
But sometimes you might need/want to have just 1 single field which holds all your variables in once. Here comes a special "magic" variable into play: free_form_vars:
| Variable Name | Meaning | Example value |
|---|---|---|
free_form_vars |
A magic custom field which you need to create once. It can hold all key=value pairs (semicolon separated) you like in 1 line.Must be added to oa_fieldsTranslate once created. |
foo=bar;cow=moo;and=so_on |
free_form_vars is a very special one. You might better avoid using it as it can become messy when it grows but well, it's here if you need it ;)