Create Ansible plugin procedures

3 minute readExtensibilityDeveloper productivity

Plugin procedures can be used in procedure steps, process steps, and pipeline tasks, allowing you to orchestrate third-party tools at the appropriate time in your component, application process, or pipeline.

Depending on your plugin configuration and how you run procedures, the Input parameters  Configuration name field may behave differently in the CloudBees CD/RO UI. For more information, refer to Differences in plugin UI behavior.

Run Ad-Hoc Command

Runs Ansible ad hoc commands. For more ad hoc commands, refer to Introduction to ad hoc commands.

The Ansible plugin does not handle interactive prompts when executing commands. However, it invokes Ansible, which uses SSH to connect to remote machines. Therefore, an implicit assumption is that SSH is configured and if the credentials are correct, no further interactive checks (such as fingerprint checks) are returned as part of the SSH login.

Input parameters

Table 1. Run Ad-Hoc Command input parameters
Parameter Description

Configuration name

Required. The previously defined configuration for the plugin.

Server group

Required. Server group to run a command.

Command/module args

Command to run (for example, as touch /tmp/myFile) or module arguments. The value of this field is passed as the argument --args.

Module

Module name to execute. For example, command, shell, or ping. Default is command.

Inventory

Inventory host path (for example, default=/etc/ansible/hosts) or the content of an inventory file.

Verbose?

If selected, the output from Ansible is verbose.

Additional parameters

Newline-separated list of parameters to pass to the Ansible executable.

Output parameters

Table 2. Run Ad-Hoc Command output parameters
Parameter Description

result

Run success/fail.

ansible_exitcode

Any returned Ansible exit codes.

ansible_stderr

STDERR output from Ansible.

Run Playbook

Runs Ansible playbooks.

The Ansible plugin does not handle interactive prompts when executing commands. However, it invokes Ansible, which uses SSH to connect to remote machines. Therefore, an implicit assumption is that SSH is configured and if the credentials are correct, no further interactive checks (such as fingerprint checks) are returned as part of the SSH login.

Input parameters

Table 3. Run Playbook input parameters
Parameter Description

Configuration name

Required. The previously defined configuration for the plugin.

Ansible playbook path

Required. Absolute path to the Ansible playbook. For example, /home/ansible/playbook.yml.

Inventory

Inventory host path (for example, default=/etc/ansible/hosts) or the content of an inventory file.

Tags

Only run plays and tasks tagged with these values. Tags can be defined per line or comma-separated.

Skip tags

Only run plays and tasks whose tags do not match these values. Tags can be defined per line or comma-separated.

Variables

Define the variables to pass to Ansible playbook. Variables may be defined in JSON or as newline-separated key=value pairs and are passed as --extra-vars.

Verbose?

If selected, the output from Ansible is verbose.

Additional parameters

Newline-separated list of parameters to pass to the Ansible executable.

Result property sheet

Property sheet name to save results into. The saved results are:

  • stdout: Raw STDOUT from the ansible-playbook command.

  • recap: This property sheet contains parsed RECAP from the ansible-playbook output with the following format:

    Host Name/ changed: number failed: number ok: number unreachable: number passed: true|false
    • passed: true is returned only if there are no failed and unreachable tasks.

  • recapJSON: The same RECAP as above, but in JSON.

  • verbose This property sheet contains information about executed tasks with the following format:

    Task Name/ Host Name/ state: ok|failed|ignoring... raw: raw json output, if any verbose: parsed output, if any
  • verboseJSON: Contains the same data as verbose but in JSON.

Output parameters

Table 4. Run Playbook output parameters
Parameter Description

result

Run success/fail.

ansible_exitcode

Any returned Ansible exit codes.

ansible_stderr

STDERR output from Ansible.