Invoke Ansible Tower (AWX) API Job using PowerShell

Posted by

With Ansible tower or the open-source variant AWX you can create Job templates and workflows. Starting these job templates could be done using the GUI, a Schedule or using the cool REST API. Because I like scripting in PowerShell I used the Ansible Tower PowerShell module which is already available in the following Github Repository: Github Repo

In the following example I use the: Connect-AnsibleTower, Get-AnsibleJobTemplate, Invoke-AnsibleRequest from the module created by gpduck. Thanks!

It was a little search how to parse the Ansible job output to something we could re-use in PowerShell. I just print the msg var in my playbook and read this one from the job_events rest API call.
If you have a better way to do this, just commend below :).

Printing a variable in Ansible:

Get job template output using the API (sample function):

Leave a Reply

Your email address will not be published. Required fields are marked *