New to Kestra?
Use blueprints to kickstart your first workflows.
Kestra flow that takes a ServiceNow incident, runs an Ansible playbook for Software category tickets, and closes the incident via the ServiceNow plugin.
Close the loop between a ServiceNow incident and the actual fix. This Kestra blueprint receives one incident's details as inputs, decides whether the category qualifies for automated remediation, runs an Ansible playbook in a container when it does, and then writes the resolution back to ServiceNow so the ticket is closed with notes, a close code, and a resolution code. It is designed as the per-ticket worker behind a polling or webhook front end such as the servicenow-incident-triage-scan blueprint, but it runs standalone too: execute it manually with any incident's sys_id to remediate and close a single ticket.
ticketNumber, shortDescription, openedAt, sysID, and category.logTicket task (io.kestra.plugin.core.log.Log) records every field so the execution itself becomes the audit record.triggerAnsibleIfSoftwareCategory task (io.kestra.plugin.core.flow.If) checks inputs.category == 'Software'. Matching tickets run run_remediation_playbook (io.kestra.plugin.ansible.cli.AnsibleCLI), which executes ansible-playbook -i inventory.ini myplaybook.yml inside the cytopia/ansible:latest-tools container. The inventory and playbook are inlined via inputFiles as stubs you replace with real remediation logic. Non-matching tickets hit the out_of_scope branch and are only logged.sendNotification task logs completion; in production you would swap it for Slack or email.updateServiceNowTicket task (io.kestra.plugin.servicenow.Update) sets state: 7 (Closed) on the incident identified by sysId, adding close_notes, close_code, and resolution_code so the closure passes ServiceNow validation rules.Running Ansible from a ServiceNow workflow usually means a MID Server, credentials scattered across the instance, and no unified log. Kestra inverts the model: ServiceNow stays the system of record while Kestra owns execution, secrets, containers, and retries. If the playbook fails, the ticket is not closed and the execution shows exactly which Ansible task broke. Each remediation is an isolated, replayable execution you can rerun after fixing the playbook, and the same flow serves as the reusable worker behind any trigger, polling, webhook, or manual.
incident table.cytopia/ansible:latest-tools image.serviceNowInstance variable to your instance name.servicenow-incident-triage-scan blueprint as the upstream feeder.SERVICENOW_USERNAME: ServiceNow user allowed to update incidents.SERVICENOW_PASSWORD: password for that user, used by the Update task's basic auth.serviceNowInstance variable.myplaybook.yml with your real remediation playbook and point inventory.ini at real hosts.sys_id and category set to Software.servicenow-incident-triage-scan for fully automated triage.io.kestra.plugin.core.flow.Switch to map categories to different playbooks.sendNotification log with io.kestra.plugin.notifications.slack.SlackIncomingWebhook.io.kestra.plugin.core.flow.Pause before touching production hosts.state to 6 and letting the caller confirm.Update task data.