AnsibleCLI icon

Ansible 101, How to Orchestrate and Run a Simple Ansible Playbook

Run your first Ansible playbook locally with Kestra, no remote hosts needed. A beginner blueprint for Ansible orchestration, demos, and DevOps onboarding.

Categories
Infrastructure
id: ansible-local-message
namespace: company.team

tasks:
  - id: ansible
    type: io.kestra.plugin.ansible.cli.AnsibleCLI
    inputFiles:
      inventory.ini: |
        [local_servers]
        localhost1 ansible_connection=local
      playbook.yml: |
        ---
        - name: Hello World Playbook
          hosts: local_servers
          
          tasks:
            - name: Print Hello World
              debug:
                msg: "Hello World!"
    commands:
      - ansible-playbook -i inventory.ini -c local playbook.yml

Run an Ansible playbook end to end from Kestra without provisioning remote servers or cloud infrastructure. This beginner-friendly blueprint covers the fundamentals of Ansible orchestration: it defines an inventory and a playbook inline, executes them against the local machine, and lets you observe the whole run from the Kestra UI. It is the fastest way to learn how Ansible automation, Infrastructure as Code (IaC), and a workflow orchestrator fit together before you scale to real hosts.

How it works

A single ansible task of type io.kestra.plugin.ansible.cli.AnsibleCLI does all the work.

  1. The task ships two inputFiles into its working directory: an inventory.ini that declares a local_servers group pointing at localhost1 with ansible_connection=local, and a playbook.yml that runs a single debug task printing Hello World!.
  2. The commands property invokes ansible-playbook -i inventory.ini -c local playbook.yml, forcing a local connection so nothing leaves the machine.
  3. Kestra captures stdout, the exit status, and execution metadata so the playbook output is visible directly in the Outputs and Logs tabs.

What you get

  • A working Ansible run with zero remote infrastructure.
  • Inline inventory and playbook definitions you can edit in place.
  • Full execution logs and outputs surfaced in the Kestra UI.
  • A clean starting point for real IaC and configuration-management flows.

Who it's for

  • Ansible beginners learning the playbook and inventory model.
  • DevOps and platform engineers onboarding to Kestra.
  • Anyone building a demo or proof of concept around Ansible automation.

Why orchestrate this with Kestra

Ansible has no built-in scheduler, no retry engine, and no central place to see run history. Kestra fills that gap. You declare the playbook in versioned, declarative YAML, attach event or schedule triggers, set automatic retries on failure, and get execution lineage, logs, and outputs in one UI. As your automation grows you can chain Ansible runs with other tasks (Git checkouts, notifications, cloud APIs) in the same orchestrated pipeline instead of stitching together cron jobs and shell scripts.

Prerequisites

  • A running Kestra instance with the Ansible plugin available.
  • Ansible installed in the task execution environment (or run the task in a Docker image that bundles ansible-playbook).

Secrets

None. This blueprint targets the local machine and references no {{ secret('NAME') }} values.

Quick start

  1. Add this blueprint to your Kestra instance.
  2. Confirm ansible-playbook is available in the execution environment.
  3. Execute the flow.
  4. Open the Logs and Outputs tabs to see the Hello World! message.

How to extend

  • Replace localhost1 with real hosts and swap the local connection for SSH.
  • Add roles, variables, and multiple plays to the playbook.yml.
  • Pull playbooks from a Git repository with the Git plugin.
  • Add a schedule or event trigger and retry policy for production runs.
  • Pass inventory or extra-vars values through Kestra inputs.

Links

Orchestrate with Kestra
Orchestrate Ansible with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.