-
Notifications
You must be signed in to change notification settings - Fork 0
Host Variables
Open-AudIT uses fields (which are meant to be "custom fields") and attributes (which are a special kind of fields) to identify device objects.
That is important as both are handled differently by the Open-AudIT api and so within this collection.
This collection will read and write both types of objects while they are managed slightly different.
Note: sedi.openaudit.set manages atm only the devices collection while this might get extended in the future to support others as well.
This page describes Ansible host (i.e. Open-AudIT device) variables only. For group variables check out Group variables.
| Available as Ansible host variables | yes |
| Open-AudIT configuration | https://<server>/open-audit/index.php/fields |
| Ansible configuration | inventory host file, eg. hosts.openaudit.yml
|
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 in Ansible. 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 inventory 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 hosts.openaudit.yml inventory file within the oa_fieldsTranslate dictionary. Now you can edit your device(s) in Open-AudIT and set the values you like for every of these custom fields and they will automagically appear in Ansible as host variables! That's it.
See the playbook example how these could then be changed by sedi.openaudit.set.
| Available as Ansible host variables | no |
| Open-AudIT configuration |
https://<server>/open-audit/index.php/attributeshttps://<server>/open-audit/index.php/devices
|
| Ansible configuration | within a task using sedi.openaudit.set
|
Internal Open-AudIT fields / objects and Attributes https://<server>/open-audit/index.php/attributes and basically any object you can find in a device's view. That means all except those which are shown in the "Custom fields" menu.
sedi.openaudit.set allows to set all these internal device fields, too. The main question here is how to find the proper field name for it:
Two ways to achieve this can be used:
- (Recommended) Specify an invalid fieldname, e.g.
this_field_doesnt_exist: foowithin yoursedi.openaudit.settask and let it run. The output will show all available internal / Open-AudIT field names. Task example:
- name: "Show all internal Open-AudIT fields"
connection: local
become: no
sedi.openaudit.set:
api_server: my.openauditserver.local
api_protocol: https
username: "{{ vault_api_server_user }}"
password: "{{ vault_api_server_password }}"
collection: devices
attributes:
- fqdn: "{{ inventory_hostname }}"
fields:
my_invalidfield: foo
- (only if 1 does not work for you) In Open-AudIT open the browsers developer console (network tab). change the value of interest and check the payload of the post. You will find there "meta" -> "received data" -> "attributes"
{<fieldname> : <value>}. Important is that all these internal Open-AudIT fields (i.e. not custom field) must be prefixed withoa.. sostatusbecomesoa.statusetc. Following the recommended step 1 above will show them correctly already so its always recommended to do it that way (besides its much easier).
See the playbook example how these could then be changed by sedi.openaudit.set.