Ansible Integration: Getting Started

Pliant facilitates the re-use of your existing Ansible playbooks as a component of any larger Pliant workflow. As part of your Pliant instance, we run Ansible as an add-on (a separate, dedicated container). Using the Pliant Ansible integration requires two pieces: An Ansible Authentication and the Ansible Block.

Ansible Authentication

The Ansible Authentication has two parameters:

  1. Private Key  An RSA key / PEM key from a host you might want to connect to (optional)

  2. Inventory  An INI format Ansible inventory (required) See this guide for further information about how to structure an Ansible Inventory

  • A common practice is to create a blank Ansible authentication with both Private Key and Inventory checked as Overridable, then using an AuthOverride Block to set the values within the flow.

An inventory can be as simple as:

[cisco]
ansible_user=dave ansible_password=dave ansible_host=192.168.109.37
ansible_user=dave ansible_password=dave ansible_host=192.168.109.39

Ansible Playbook Block

The Ansible Playbook block has two Input parameters:

  1. authKey is the name of the authKey containing the private key and inventory for the device you will be working with:

    You can also change the parameter to “Expression” mode and populate it with a variable name that contains the authKey name:

  2. playbook is the YAML format text of the playbook you wish to run. With the parameter in “Constant” mode, you can paste in the raw text of the playbook:

Or with the parameter in “Expression” mode, you can use the name of a variable that contains the playbook text

or create a JavaScript expression to add dynamic components to the playbook

This is an example Ansible playbook. It will connect to the host(s) and create a file /tmp/testfile.txt with content  hello world

`- name: This is a hello-world example
  hosts: helloteam
  tasks:
    - name: Create a file called '/tmp/testfile.txt' with the content 'hello world'.
      copy:
        content: hello world
        dest: /tmp/testfile.txt
`

When the flow runs the Ansible Playbook block, Pliant will send the Ansible inventory and playbook to the Ansible addon, which will process them and return the output back to the Pliant workflow. The output will be available under a variable with the same name as the block, and will have the following parameters:

  • authKey - the authKey name used in the block

  • result - the standard output from running the Ansible operation

  • error - the standard error output from running the Ansible operation

  • success - whether or not the operation was initiated successfully