sedi.openaudit.set module – Updates defined attributes for an existing device in Open-AudIT

Note

This module is part of the sedi.openaudit collection (version 2.1.0).

To install it, use: ansible-galaxy collection install sedi.openaudit. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: sedi.openaudit.set.

New in sedi.openaudit 1.2.0

Synopsis

  • Updates any field of an existing device object in Open-AudIT.

  • This plugin is not developed by Firstwave (was Opmantek until 2021) nor has any commercial relationship to them.

  • It is simply a contribution to the community in the hope it is useful and of course without any warranties.

Note

This module has a corresponding action plugin.

Requirements

The below requirements are needed on the host that executes this module.

  • python3 >= ‘3.5’

  • python-requests

  • Open-AudIT >= ‘4.3.4’

Parameters

Parameter

Comments

api_protocol

string / required

Protocol to be used for accessing the Open-AudIT server API

Choices:

  • "http"

  • "https"

api_server

string / required

FQDN or IP of the Open-AudIT server API

attributes

string / required

A list of device key/value pairs

fields

dictionary / required

A dictionary of field names including their target values.

The field name is either specified in your own field mappings in “oa_fieldsTranslate”

(e.g. in ./inventories/dynamic/inventory.openaudit.yml) or is a valid internal Open-AudIT field.

The easiest way to get a list of all valid Open-AudIT fields is specifying an invalid key

(e.g. set oa.invalidkey) and it will print all available (internal, i.e. not custom) field names.

You can set any (valid) field name you wish to update.

Important is that for drop-down lists in Open-AudIT you have to set exactly the value as it is defined!

For custom field lists fields -> List -> Values or internal lists in attributes -> list -> Value store

If you want to specify a boolean true|false as value, you HAVE TO quote it so it gets not translated by Ansible.

fqdn

string / required

The FQDN of the device to be updated (must match the field ‘FQDN’ of that device within Open-AudIT)

collection

string / required

The collection name/type.

For details & examples check the documentation.

Choices:

  • "devices"

password

string / required

Password for logging into the API.

Avoid storing sensitive data in clear text by using e.g. Ansible Vault

username

string / required

Username for logging into the API.

Avoid storing sensitive data in clear text by using e.g. Ansible Vault

See Also

See also

Plugin documentation

Detailed examples and guidelines for this plugin

Open-AudIT

Official Open-AudIT product page

Open-AudIT API

Official Open-AudIT API documentation

Examples

For more examples and details check L(documentation,https://github.com/secure-diversITy/ansible_openaudit_inventory/wiki)

---
- name: Update OA
  gather_facts: false
  hosts: all

  tasks:
    - name: "Update CMDB info for {{ inventory_hostname }}"
      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 }}"
        return_content: true
        validate_certs: false
        collection: devices
        attributes:
            - fqdn: "{{ inventory_hostname }}"
              fields:
                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:
                network_configuration: 'true'
                my_other_custom_field: "{{ another_var }}"
                # set e.g. the following to get all valid internal OA fields
                #oa.invalidfield: foo

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

Changed Open-AudIT fields

dictionary

Each (translated) Open-AudIT field with its changed value

Returned: always

Sample: {"Changed Open-AudIT fields": {"network_ip": "changed to 10.1.1.124"}}

Authors

  • Thomas Fischer (@se-di)