Execute Ansible Playbook

Overview

The Execute Ansible Playbook action enables users to run Ansible playbooks directly within their bot workflows. This feature facilitates effective automation of configuration management tasks, including vulnerability management and package management. Users can seamlessly deploy configurations and updates across multiple systems without extensive manual intervention, promoting consistency and security within their infrastructure.

Prerequisites

Linux Agent

  1. Agent Configuration:
    Ensure the Linux Agent is configured. Refer to the Agent Installation Guide.
  2. Ensure that Ansible is installed on the agent. Refer to the Ansible installation guide
  3. The Ansible inventory file must be configured correctly on the agent to ensure communication with the target hosts (e.g., using SSH keys).

How to Use This Action?

To use the Execute Ansible Playbook action, follow these steps:

  • In your bot workflow, navigate to the Linux Actions and select Library.
    Navigate to Linux Action

  • Search for or locate the Execute Ansible Playbook action and drag it into your workflow.

  • Select the Linux integration that is connected to your Ansible-configured agent.

  • Under the Parameters section, specify the required parameter values according to your requirements. For more details, refer to the Parameter Details section.

  • In the ansible_playbook field, provide the content of the Ansible playbook you want to execute. You can choose one of the following methods to provide the playbook:

    1. Manually Write the YAML Playbook: Ensure the playbook is in YAML format and follows Ansible’s syntax.
      Manual Ansible Playbook Entry

    2. Use AI to Generate the Playbook: Instead of writing the playbook manually, select the AI option to generate the playbook content.
      AI Generate Playbook

  • Specify the ansible_host_file parameter. Directly provide the content of the Ansible host file in this parameter. If not provided, the default path /etc/ansible/hosts will be used.

  • Save or update the bot, then click on the Run button to execute the bot or the Run button inside the action node. Wait for the execution to complete. After execution, view the results in the execution details.

Parameter Details

ParameterRequiredDescription
ansible_playbookYesThe content of the Ansible playbook to execute. It must be in YAML format and follow Ansible's syntax.
ansible_host_fileNoThe content of the Ansible inventory file. If not specified, defaults to the inventory path /etc/ansible/hosts.
run_as_userYesSpecifies the user under which the command runs (default value is "ubuntu").
execution_timeoutYesThe maximum time (in seconds) allowed for command execution (defaults to 900 seconds).
ansible_host_key_checkingNoDefault is False. Set to True to enable SSH host key checking . If set to True, ensure that all hosts are added to known hosts to avoid issues.
dry_runNoIf set to True, performs a dry run of the playbook without making changes (default is False).

Example Use Case

Scenario: Vulnerability Management and Package Management

In the context of vulnerability management, you can utilize this action to run a playbook that checks for outdated packages and installs necessary updates across your infrastructure. This ensures that all systems are compliant with the latest security patches.

Ansible Playbook to Update Packages: Example Ansible playbook configuration to check and update all packages:

- name: Update all packages hosts: all become: true tasks: - name: Ensure all packages are updated apt: upgrade: dist update_cache: yes