Developing playbooks on Windows

I’m new to Ansible and I spend my days on a Windows workstation. Our company is adopting Ansible because one large section of the company uses Linux for servers and workstations. I’m in a smaller section that has a mix of Windows and Linux servers but mostly everyone has Windows workstations. Is anyone else developing Ansible playbooks on Windows yet? I think the answer is “no” since Ansible Control Machine doesn’t run on Windows. So how do those that have Windows workstations develop new playbooks? Do you forgo a BDD style of work? Ideally I want to follow a development style similar to this example using Vagrant: https://www.youtube.com/watch?v=tNCDsnQvbHI, but can’t on Windows.

Thanks for any advice,
Brian

Hi,

I mostly just create playbooks having sshed into a virtual machine. We keep the entire ansible configuration (inventory, playbooks, roles, custom modules and plugins etc) in Mercurial (mandated version control where I work). For a while I used to edit playbooks on windows using Notepad++ which has yaml syntax highlighting and then use mercurial commit push then switch to the vm and do pull and update to run the playbooks, but I tend to just use the vm now I’m more confident that I can write valid yaml and the feedback cycle is faster.
I used putty for long time to connect, but have recently started using cmder (cmder.net) which lets you have multiple tabs open against the machines (I often have 1 pty for running playbooks and another couple for editing files).

Very shortly the anniversary update to windows 10 will be out, and with that the ability to run ubuntu within windows. I’ve tried it out on an Insider build and its certainly good enough to develop playbooks in and run them against a few windows hosts. Once it is available in official released window 10, I intend trying it out to see if I can make a slicker development workflow.

Hope this helps,

Jon

Thanks Jon for the help.

I’ve settled on a combo of two things:

  1. Test Kitchen for developing playbooks. Neill Turner’s Ansible Provisioner works great on Windows since it uses Vagrant and handles running Ansible within the Linux VM: https://github.com/neillturner/kitchen-ansible
  2. A local Linux VM for running playbooks. I’ve created a Vagrant VM running CentOS (our company distro of choice) with our team dev tools installed, including Ansible.

So I can use Test Kitchen and ServerSpec for behavior-driven development of my playbooks, and use our devtools VM for running the playbooks.

Hoping this update helps others stuck on Windows with a direction to go, and to know you aren’t alone.

Brian

If you’re able to run a recent Windows 10 build, the WSL (so-called “Bash on Linux”) is really nice for developing. In WSL I point to a special “developer” inventory, and my library/roles are configured to point to my Ansible repos on my c-drive. That way I can work locally in VSCode (which has a really nice yaml plugin), hit save and execute tests from within WSL. No need to check code into source control before I have ironed out the worst kinks.

If you want to take it a step further I have this little rest api which lets you execute ansible playbooks/commands thru rest (https://github.com/trondhindenes/flansible), so you won’t have to touch your linux environment at all, you can just hit the api using powershell or postman.

test-kitchen for Ansible is really looking promising tho.

-Trond