New to Kestra?
Use blueprints to kickstart your first workflows.
Provision AWS EC2 instances, build a dynamic inventory, and deploy config files to multiple servers at scale with Ansible, orchestrated by Kestra.
Configuration drift starts the moment you SSH into servers one at a time. This blueprint provisions multiple AWS EC2 instances, builds an Ansible inventory from the live infrastructure, and pushes the same configuration file to every host in one declarative Kestra flow. It pairs Infrastructure as Code provisioning with Ansible configuration management so DevOps and platform teams can stand up fleets and keep them consistent without hand-editing hosts. Keywords: Ansible automation, AWS EC2 provisioning, configuration management, Infrastructure as Code, dynamic inventory, server orchestration.
aws_setup task (io.kestra.plugin.aws.cli.AwsCLI) runs the AWS CLI to create an SSH key pair, create a security group opening port 22, and launch two t2.micro EC2 instances. It exports ssh-key.pem via outputFiles and emits instance metadata as Kestra outputs.ansible task (io.kestra.plugin.ansible.cli.AnsibleCLI) receives the SSH key plus two generated inputFiles: an inventory.ini built dynamically from the provisioned instance IPs, and a playbook.yml that copies a .env configuration file to /home/app/.env with mode: '0600' on every host in the servers group.ansible-playbook -i inventory.ini playbook.yml --key-file ssh-key.pem, applying identical configuration in parallel across all targets.Ansible runs playbooks but does not schedule, retry, or track lineage between a provisioning step and a configuration step. Kestra closes that gap: chain AwsCLI output (keys, IPs) directly into the Ansible task with templating, add event triggers (a new commit, a webhook, a schedule) to drive runs, attach retries and alerting, and keep everything as declarative, version-controlled YAML with full execution history. The whole provision-then-configure sequence becomes one auditable pipeline instead of two disconnected tools.
ansible-playbook CLI available to the Ansible task runner (for example via a Docker task runner image that bundles Ansible).This flow as written embeds AWS CLI calls and SSH key handling inline and does not reference any {{ secret('NAME') }} values. Before running in production, move AWS credentials and any sensitive playbook values (such as the database password and API secret in the .env content) into Kestra secrets and reference them with {{ secret('AWS_ACCESS_KEY_ID') }}, {{ secret('AWS_SECRET_ACCESS_KEY') }}, and similar.
AwsCLI task (env vars or pluginDefaults)..env copy with templated config rendered from inputs or secrets.--count and let the inventory grow automatically.