PowerShell module for Ansible Tower underway

Hi all,
This is strictly not related to this group, but I wanted to share anyway:
I’ve started development on a PowerShell module for interacting with Tower’s REST api. The Ansible team has done an amazing job of creating a very self-documenting api, so it shouldn’t take to long to have the most important functionality in place.

The current version only supports getting and creating organizations, but it’s set up in a way that lets me quickly add more stuff.

I’ll be looking for testers (and PR’s) down the road, but plan to do a little bit more development on it before I let more people in. If you want to keep track of progress, it’s published at:
https://github.com/trondhindenes/AnsibleTower-PowerShell

Mind you, you’ll need visual studio to combile the project as it sits right now (just build the included project in-place and then run import-module AnsibleTower.psd1).
I’m also running on basic authentication, plan to switch to token-based auth in the near future.

So, if you’re using Tower and are doing any Windows development so you happen to have Visual Studio on your machine, let me know if you want to help test/contribute!

Regards,
Trond

Offhand, I should mention some feedback I gave to Trond, namely:

(A) it’s nice to see this,
(B) for most people it’s going to be totally weird

To use ansible a user does need a Linux system, but might not have a Windows system.

As such, Python is the most obvious way to do this here.

A project to do this (open source is at): https://github.com/ansible/tower-cli and has useful python libraries that can be used by (if so desired) regular Ansible python modules.

So it’s understandable if you need something if you don’t know Python but IMHO in Ansible land, modules should only be powershell when they deal with managing Windows hosts.

In this case, it’s a bit of a weird thing.

Not saying it’s not valid, but if we’re going to include Tower CLI modules in core, they will be Python.

We may release some tower python modules in the future, but until now, most folks have been able to rely on the CLI.

James Martin wrote an example python application that uses the CLI’s libs here:

https://github.com/jsmartin/tower_populator

That could be used as a possible starting point reference

Anyhow, all good that this exists - just wanted to make sure nobody left confused as to why Powershell :slight_smile:

I completely agree.

I guess the “target group” of any are “mostly windows” shops who use/want to use Ansible Tower, but want to do their automation using .Net/Powershell. I’m guessing that’s a pretty small bunch right now, but who knows? At least this will enable me to demo Ansible for Windows people a bit easier.

yep yep, all good!

Trond, just want to thank you for your work and it is pity that you are stopped the work on this module.
This module definitely has the right to life.

Our project hosts in Azure, and we have ~ 50/50 Windows and Linux servers.
For Windows we are using PowerShell DSC.
For Azure we are using PowerShell.
For Linux we are using Ansible end Ansible Tower.

All deployments are managed from Release Management Server, and we have to use SSH-PowerShell module for connecting to the Ansible Tower box and then invoking the tower-cli for launching Job-Templates.
So it would be much easier to launch Job-Templates directly from PowerShell instead of connecting by SSH and then use tower-cli.

Hi,
Thanks, it was fun figuring out the API, super-easy really.

The module is not as done as I’d like to be, but as it stands you should be able to fire off job templates. Let me know if you need some pointers and I’d be happy to provide them here, or (even better) bake them into the PS module. Nothing would please me more than have people actually use it. It’s a pretty slick module IMHO :slight_smile:

you don't need to ssh into tower to run jobs, you can setup the
callback mechanism and just invoke through a web call.

So I quckly pushed an update to the repo with some in-fuction help Look at line 53 in https://github.com/trondhindenes/AnsibleTower-PowerShell/blob/master/AnsibleJobTemplate.ps1 for a basic example of how to invoke a job with the module.

Thank you Trond! I have tried and it works for me.
Brian, thanks for pointing to the callback mechanism, it’s really nice feature, but is it not always could be used.
In my case I need to perform a job on multiple hosts which is related to each other and I need to be sure that all of them (hosts) already available (in the same time) before launch a job.
So I don’t realize how to do it with callback mechanism.

Glad to hear it!

I’ll try and update the module with some more help examples.