This destination creates an dynamic inventory for the configuration management tool Ansible. The exporter walks through all CMDB objects that are configured as export source and creates Ansible groups. The output is written to stdout.
As ansible has some specifications when executing scripts for dynamic inventory, you need a little wrapper script, which comes with yourCMDB, to use this exporter. You can find the wrapper ansibleExport.sh in the <yourCMDB-dir>/contrib directory. To use it, please set the following variables in the script to fit your needs:
EXPORTER_TASK=<name of the yourCMDB exporter task> EXPORTER_BIN=<path to the exporter.php in yourCMDB/scripts>
short information | |
---|---|
class name | ExternalSystemAnsible |
needed variables | hostname |
hostvar_* | |
group_* |
no destination parameters are available at the moment
name | required | description | example |
---|---|---|---|
hostname | required | hostname or IP that Ansible uses for connecting to the host | test.example.com |
group_* | required | Ansible group membership. | group_webservers ⇒ true |
hostvar_* | optional | host variables that should be given to Ansible | hostvar_snmpread ⇒ public |
For each CMDB object the export variable hostname has to be set which is used by Ansible to connect to a CMDB object. Hosts are organized in Ansible groups. For adding a CMDB object to a specific group, the group_* variables are used. The variable name is group_groupname and the value is true, if the CMDB object should be a member of the group. Example:
variablename: group_webserver value of the variable for object: true behavior: the object is part of the Ansible group webserver.
You can set host variables for Ansible using the hostvar_* variables. The variable name is hostvar_varname, which means, you can access the value by using the name varname in Ansible.
example of export task configuration:
<task name="ansible-example"> <sources> <source objecttype="server" status="A" /> </sources> <destination class="ExternalSystemAnsible"> <parameter key="output" value="stdout" /> </destination> <variables> <variable name="hostname"> <value objecttype="server" fieldname="management-ip" /> </variable> <variable name="hostvar_hostname"> <value objecttype="server" fieldname="hostname" /> </variable> <variable name="hostvar_ip"> <value objecttype="server" fieldname="management-ip" /> </variable> <variable name="group_defaultpackage"> <value objecttype="server" fieldname="configtask-defaultpackage" /> </variable> <variable name="group_backupagent"> <value objecttype="server" fieldname="configtask-backupagent" /> </variable> <variable name="group_fail2ban"> <value objecttype="server" fieldname="configtask-fail2ban" /> </variable> </variables> </task>