Ansible adapter module


The BMC-AD-Ansible adapter module consists of the Ansible Command and Ansible Playbook wrapper processes or workflows.

Ansible Command workflow

This workflow runs Ansible commands on the managed nodes. 

The process directory for this workflow is BMC-AD-Ansible:commands: and the process name is Ansible Command.

The following table describes the input elements for the adapter wrapper workflow. 

Input element

Description

Required

adapter name

Specifies the name of the adapter.

Default name is Ansible Adapter.

No

host name

Specifies the host name or IP address of the remote node, or a host.

No

port

Specifies the port number for the remote host.

No

user name

Specifies the user name required to log on to the remote host.

No

password

Specifies the password that matches the username.

No

password encryption type

Specifies the encryption method used for the password.

Note

Supports plain encryption type only.

No

Known host config

Specifies the path to the local known_hosts file. This file is used for performing key-based verification.

No

allow unknown hots

Specifies whether a connection should continue if key verification fails.

Valid values: true, false.

If true, the connection is maintained when connecting to an unknown or a mismatched system. If false, the connection is discontinued and the adapter returns an error.

No

preferred PK algorithm

Specifies the algorithm to be used to encrypt the public key.

Valid values: ssh-dss, ssh-rsa

No

private key file

Specifies the path and file name for the local SSH key file.

No

pass phrase

Specifies the passphrase used to protect the private key file.

No

pass phrase encryption type

Specifies the encryption type used to provide the passphrase.

No

Private key data

Specifies the private key data of the local ssh key file.
This element is used if the password element is not provided. If the password and private key data are both specified, then private Key Data approach is used and the password element is ignored.

Conditional; required if the password is not provided.

command

Specifies the Ansible command, with arguments if required.

No

command timeout

Specifies the time, in seconds, after which the workflow expires.

Default value: 60

No

inventory group

Specifies the group of managed nodes defined in inventory file.


Inventory file path

Specifies the path to the inventory file in which managed nodes (remote hosts) are defined.

If not specified, /etc/ansible/hosts file is considered by default for this command.

No

Command module

Specifies the Ansible module to be specified to run the command .
Default module is command.


cli options

Contains the <option> elements used to specify Ansible command options.

No

Character set

Specifies the name of the character set to encode or decode the characters.

Default value: UTF-8

No

The following table describes the output elements for the adapter wrapper workflow. 

Output element

Description

success

Shows the status of the workflow.

Valid values: true, false.

output

Contains the actual output.

Example
<values>
<value>hostname | CHANGED | rc=0 &gt;&gt;</value>
<value>XYZ</value>
<value>hostname | CHANGED | rc=0 &gt;&gt;</value>
<value>XYZ</value>
</values>

adapter response

Contains the adapter response, which consists of the command and the command output values.

<ansible-response>
  <metadata>
     <status>success</status>
  </metadata>
  <targets-output>
     <target-output host="hostname">
        <metadata>
           <os-id>Linux</os-id>
           <os-version>4.1.12-112.14.13.el7uek.x86_64</os-version>
           <status>success</status>
        </metadata>
        <commands-output>
           <command-output>
              <metadata>
                 <command>ansible linuxusers
-i /etc/ansible/host_inventory1 -m command
-b --become-user=deepak -a "whoami"</command>
                 <line-count>4</line-count>
                 <execution-milliseconds>2160</execution-milliseconds>
                 <exit-code>0</exit-code>
                 <status>success</status>
              </metadata>
              <output>
                 <line index="1">hostname | CHANGED | rc=0 &gt;&gt;</line>
                 <line index="2">XYZ</line>
                 <line index="3">hostname | CHANGED | rc=0 &gt;&gt;</line>
                 <line index="4">XYZ</line>
              </output>
           </command-output>
        </commands-output>
     </target-output>
  </targets-output>
</ansible-response>

exit code

Specifies the code on which the request is executed.

0 indicates success, and any other code shows failure.

error

Contains the error message, in case the workflow fails.

Ansible Playbook workflow

This workflow runs the Ansible playbook, which contains the list of defined tasks to be executed on managed nodes

The process directory for this workflow is BMC-AD-Ansible:commands: and the process name is Ansible Playbook.

The following table describes the input elements for the adapter wrapper workflow. 

Input element

Description

Required

adapter name

Specifies the name of the adapter.

Default name is Ansible Adapter.

No

host name

Specifies the host name or IP address of the remote node, or a host.

No

port

Specifies the port number for the remote host.

No

user name

Specifies the user name required to log on to the remote host.

No

password

Specifies the password that matches the username.

No

password encryption type

Specifies the encryption method used for the password.

Note

Supports plain encryption type only.

No

Known host config

Specifies the path to the local known_hosts file. This file is used for performing key-based verification.

No

allow unknown hots

Specifies whether a connection should continue if key verification fails.

Valid values: true, false.

If true, the connection is maintained when connecting to an unknown or a mismatched system. If false, the connection is discontinued and the adapter returns an error.

No

preferred PK algorithm

Specifies the algorithm to be used to encrypt the public key.

Valid values: ssh-dss, ssh-rsa

No

private key file

Specifies the path and file name for the local SSH key file.

No

pass phrase

Specifies the passphrase used to protect the private key file.

No

pass phrase encryption type

Specifies the encryption type used to provide the passphrase.

No

Private key data

Specifies the private key data of the local ssh key file.
This element is used if the password element is not provided. If the password and private key data are both specified, then private Key Data approach is used and the password element is ignored.

Conditional; required if the password is not provided.

playbook

Specifies the name of the playbook, inside a <commands> element, which contains the tasks to be executed on the managed hosts.

Playbook is a YAML file.

No

command timeout

Specifies the time, in seconds, after which the workflow expires.

Default value: 60

No

Inventory file path

Specifies the path to the inventory file in which managed nodes (remote hosts) are defined.

If not specified, /etc/ansible/hosts file is considered by default for this command.

No

cli options

Contains the <option> elements used to specify Ansible command options.

No

Character set

Specifies the name of the character set to encode or decode the characters.

Default value: UTF-8

No

The following table describes the output elements for the adapter wrapper workflow. 

Output element

Description

success

Shows the status of the workflow.

Valid values: true, false.

output

Contains the actual output.

Example
<values>
<value />
<value>PLAY [rhel8] *******************************************************************</value>
<value />
<value>TASK [Gathering Facts] *********************************************************</value>
<value>ok: [hostname]</value>
<value />
<value>PLAY RECAP *********************************************************************</value>
<value>hostname : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 </value>
</values>

adapter response

Contains the adapter response, which consists of the command and the command output values.

Sample adapter response
<ansible-response>
<metadata>
<status>success</status>
</metadata>
<targets-output>
<target-output host="clm-pun-u5lpbw">
<metadata>
<os-id>Linux</os-id>
<os-version>4.1.12-112.14.13.el7uek.x86_64</os-version>
<status>success</status>
</metadata>
<commands-output>
<command-output>
<metadata>
<command>ansible-playbook /etc/ansible/sampleyml.yml </command>
<line-count>8</line-count>
<execution-milliseconds>2852</execution-milliseconds>
<exit-code>0</exit-code>
<status>success</status>
</metadata>
<output>
<line index="1" />
<line index="2">PLAY [rhel8] *******************************************************************</line>
<line index="3" />
<line index="4">TASK [Gathering Facts] *********************************************************</line>
<line index="5">ok: [clm-pun-ucqwio]</line>
<line index="6" />
<line index="7">PLAY RECAP *********************************************************************</line>
<line index="8">hostname : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 </line>
</output>
</command-output>
</commands-output>
</target-output>
</targets-output>
</ansible-response>

exit code

Specifies the code on which the request is executed.

0 indicates success, and any other code shows failure.

error

Contains the error message, in case the workflow fails.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*