Some Cygwin Notes on installing Ansible in Cygwin on Windows

I wanted to install Ansible on Cygwin running in Windows. I also wanted to interact with AWS, so I needed to install boto. “six” just for kicks as well. Here’s what finally worked, along with some notes on the experience:

This step-by-step is valid on Windows Server 2012r2 machines as of 9/29/2017. It is the cleanest way of working with Cygwin that I’ve seen.

Install Cygwin
Download here:
Install to c:\cygwin64 for everything you have to specify a path for (use that for the source, it’s always fast, at least in the US)
Basic install, no additional packages
Add a shortcut to the desktop
– Shortcut points to mintty.exe, interestingly… never knew that
– C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico –

Open up the Cygwin shell:
echo ‘alias cyg-get=”/cygdrive/c/cygwin64/setup-x86_64.exe -q -P”‘ >> ~/.bash_profile
– This makes it so installing more cygwin-specific packages is just like using apt-get, all from within Cygwin
– Doing it this way makes cygwin even more portable 🙂
Close and reopen the Cygwin shell
– To get that alias thing from above

Install all the dependencies using our nifty apt-get-like approach
– cyg-get cygwin32-gcc-g++,gcc-core,gcc-g++,git,libffi-devel,nano,openssl,openssl-devel,python-crypto,python2,python2-devel,python2-openssl,python2-pip,python2-setuptools,python2-devel,tree,wget,zip,make,openssh
– You have to use a comma-delimited list. Some internet blog posts use spaces…. Those don’t cut it

Use pip2 to install:
– pip2 install boto six ansible==1.9.4
— Running bdist_wheel for pynacl
— That takes forever… you have to just wait…. Forever

At this point, you should be all set. And… you should be able to copy-paste the cygwin64 folder into any other Windows machine and everything will “just work”

– This approach is the cleanest, most portable way to work with Cygwin. Really, it’s completely self-contained, not affecting anything else on the host… All things Ansible, boto, gcc, etc live entirely in that cygwin64 folder. Delete the folder; they’re all gone, as though they were never there.
– At the time of this writing, the world is kind of between Python 2.7 and Python 3.x. As such, this is a case where we have to explicitly say we want to install pip2 and python2.
– Note that the permissions and execution bits on files can kind of get scrubbed out when checking things out from GitHub (other vcs too?), so in the case of Ansible and boto, the hosts file and the ec2 file may need to have their execution bits updated after a checkout – hosts should not be executable; ec2 should be executable. It’s possible other .sh files you check out from, say, GitHub may need their execution bits changed as well