Skip to content

Action Module Configuration

TF edited this page Feb 16, 2023 · 8 revisions

Action Module

It is highly recommended to store the previously created API credentials in an Ansible Vault and then using the vault variable(s) in your tasks.

sedi.openaudit.set is also available as Ansible-like documentation: here

sedi.openaudit.set

the following options are mandatory for a sedi.openaudit.set task:

option description
api_server the Open-AudIT server FQDN or IP
api_protocol how the API can be accessed, can be http or https only
username api username (pls add use a vault, see above)
password api password (pls add use a vault, see above)
collection at the moment the only supported option is devices here, might get extended to other collections (locations, orgs, etc)
attributes ansible type = list. Content depends on the defined collection.

collection = devices

The following describes possible options for the collection: devices beyond the option attributes.

All mentioned options are mandatory.

option description
fqdn The FQDN matching the FQDN field in Open-AudIT
fields ansible type: dict. Any (really any) field name which is available* for a device

* if you have an issue with fields not getting updated check the custom field:

  1. "ID": ensure you have a proper mapping in your inventory file
  2. "Organisation": a field is only available for devices belonging to the same org
  3. "Group": device must be part of the group where this field belongs to (not 100% about that one though)
  4. "Type": if it is set to a list you can set the here defined values only
  5. When not using a custom field but an internal Open-AudIT one check that you have not a typo anywhere and that the prefix is set correctly

Example

- name: Update my hosts
  gather_facts: false
  hosts: all
  become: no

  tasks:
    - name: "Update device attributes"
      connection: local
      sedi.openaudit.set:
        api_server: openaudit.myserver.com
        api_protocol: https
        username: "{{ vault_api_server_user }}"
        password: "{{ vault_api_server_password }}"
        validate_certs: false
        collection: devices
        attributes:
            - fqdn: "{{ inventory_hostname }}"
              fields:
                # internal Open-AudIT fields/objects
                oa.org_id: 2
                oa.oae_manage: n
                oa.owner: sedi
                oa.class: server
                oa.type: computer
                oa.manufacturer: "Gigabyte"
                oa.status: staging
                # custom fields:
                foo: 7
                myvar_for_ansible: 13
                my_other_var: 21
                network_configuration: 'true'
                my_other_custom_field: "{{ another_var }}"
                # set e.g. the following to get all valid internal OA fields
                #oa.invalidfield: foo

Clone this wiki locally