Sunday, January 31, 2016

Install Ansible on Windows with Cygwin

  1. Install Cygwin with all the items under the categories Devel, Python, plus openssh and wget 

    At the step of "Select Packages", toggle the categories Devel, Python from "Default" to "Install" which selects all the items under the category, and toggle openssh under "Net" and wget under "Web" from "Skip" to each version. Ignore any "Setup Alert" message boxes which say that you should install something else by yourself.
  2. Create Ansible.bat

    You may have Windows-native Python installed on your Windows. In order to prevent it from interfering with Cygwin's python, write the following batch script that clears the Windows PATH. Run this Ansible.bat to enter the sandboxed Ansible environment.
    @path ;
    @C:\cygwin64\Cygwin.bat
    
  3. Install PIP and Ansible through PIP

    At the bash prompt of Ansible.bat, enter the following commands
    $ easy_install-2.7 pip
    $ pip install ansible
    
  4. Add Ansible variables to .bashrc

    Edit ~/.bashrc by adding the following environment variables used by Ansible
    # Ansible settings
    export ANSIBLE_SCP_IF_SSH=y
    export ANSIBLE_SSH_ARGS='-o ControlMaster=no'
    
  5. Install sshpass

    In order to enable Ansible options --ask-pass, --ask-become-pass, you need to install sshpass by yourself. Run the following commands
    $ wget http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz
    $ tar -xvf sshpass-1.05.tar.gz
    $ cd sshpass-1.05
    $ ./configure
    $ make install
    
  6. Rerun Ansilbe.bat

    Close the previous Cygwin prompt that you have used for installing and run Ansible.bat again. Now you can run the following command to check if Ansible is installed.
    $ ansible --version
    
    Always run Ansible.bat to use Ansible commands.

2 comments:

  1. Excellent directions, worked great on my Windows 7 laptop. Thanks!

    ReplyDelete
  2. Superb!! It helped me a lot. Thanks :)

    ReplyDelete