Custom Playbook

Custom playbook enables you to customize or create your own playbook based on requirements.

Creating Custom Playbook

To create a custom playbook, perform the following:

  1. Use the following command to establish connection to Pulse host:

cd <PULSE_HOME>/work/<CLUSTER_NAME>/director/playbooks
  1. Use the following command to access the directory:

mkdir -p test-playbook
  1. Add a file playbook.json in above created directory. Refer the following example of JSON structure:

{ "filename": "test-script/playbook.yml", "version": "0.0.1", "id": "test-playbook", "name": "Test Playbook", "category": ["General"], "description": "Test Acceldata Action feature", "variables": [ { "name": "echo_text", "data_type": "string", "description": "The text to echo." } ] }

The following table provides description of the parameters:

Parameter

Description

Filename

Name of the ansible playbook file. Path relative to src folder.

Version

Version of the playbook. Note Currently unused.

ID

A unique playbook identifier.

Name

Name of the playbook. The name that is displayed Actions page in the UI.

Category

Category of the playbook.

Description

Describes the function of the playbook.

Variables

List of variables included in the ansible playbook. Variables required by the user to input from the Actions page in the UI.

The following table provides description of the variable structure:

Parameters

Description

Name

Name of the variable. Note The name should match with the variable identifier in the playbook.

Data type

string or number or boolean

Description

Description of the variable used in UI.

  1. Add a file playbook.yml in above created directory. Perform the following steps to authenticate Kerberos:

Note:

Pulse v2.1.0 introduces a task Kerberos Auth which is required when creating a new playbook. If Kerberos is enabled the user must supply the is_kerberized flag as true, as well as the Kerberos Principle and the Keytab file path.

4.1. Copy the keytab file from the source to the destination.

Use the following task to copy the keytab file from source to the destination location.

--- - hosts: all tasks: - name: Copy Kerberos Keytab to remote at /tmp when : is_kerberized is defined and is_kerberized|bool == true ansible.builtin.copy: src: "{{ kerberos_keytab }}" dest: /tmp/kerberos_{{ kerberos_principle }}.keytab owner: root group: root mode: '0600'

Note: The file is copied as read-only and the owner is defined as root.

4.2 Authenticate Kerberos running the kinit command.

The task uses the kerberos_principal and kerberos_keytab files to do the authentication. Run the following task and ensure to add is_kerberized as true to authenticate.

- name: Keberos Auth using kinit when : is_kerberized is defined and is_kerberized|bool == true command : kinit -kt /tmp/kerberos_"{{ kerberos_principle }}".keytab "{{ kerberos_principle }}" register: output_kerberos - debug: var=output_kerberos.stdout_lines

4.3 Add the task that you want to run. The following YAML task is an example.

name: Test command command : echo " scan 'hbase:meta', {COLUMNS => ['info:state', 'info:server']} " | hbase shell -n register: output - debug: var=output

4.4 Remove the keytab file from the /tmp location.

Run the following task to remove the copied file from the destination.

- name: Remove kerberos keytab file from /tmp when : is_kerberized is defined and is_kerberized|bool == true ansible.builtin.file: path: /tmp/kerberos_{{ kerberos_principle }}.keytab state: absent

Command to Run the Playbook

ansible-playbook -i <host_ip>, --private-key <ssh_key_path> -u <ssh_host> --extra-vars "kerberos_keytab=<PATH of the keytab file> kerberos_principle=<kerberos_principle> is_kerberized=<boolean>" playbook.yml

Deploying Custom Playbook

To deploy the playbook you created to the Pulse UI, Perform the following:

  1. Structure of playbook directory:

test-playbook └── test_playbook.sh ├── playbook.json └── playbook.yml
  1. Run the following command to restart the ad-director container.

accelo restart ad-director
  1. Go to Pulse UI and click on the option Create Action to view the newly added playbook.

Limitations:
  1. Does not support password-based authentication to execute playbooks

  2. Option to export and import created playbooks.