Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ansible-playbook.bat shim for Babun
@echo off
REM This is the default Babun install location.
set CYGWIN=%USERPROFILE%\.babun\cygwin
REM This is the default Babun shell, changed to bash if you need to
set SH=%CYGWIN%\bin\zsh.exe
REM You'll need to adjust the sed command below in order for this shim to work for your installation.
REM Below the Babun install directory was C:\Users\Admin\.babun\ for the "Admin" user; if your user is FooUsername, change "Admin" to "FooUsername" in the sed commands
REM Setup a temp file where the default Vagrant private_key path is stored $HOME; if there's a previous entry in there, let's clear it
"%SH%" -c "cd $HOME && touch .babun_shim_vars && sed -i '/.*VAGRANT_PRIV_KEY_DIR.*/d' .babun_shim_vars"
REM Put the private_key path directory into the temp vars file we just setup: $HOME/.babun_shim_vars
"%SH%" -c "VAGRANT_PRIV_KEY_DIR=`echo %* | sed '0,/C:\/Users\/Admin\/\.babun\/cygwin/s///' | awk '{print $1}' | sed '0,/--private-key=/s///' | sed '0,/private_key/s///'` && echo export VAGRANT_PRIV_KEY_DIRECTORY=$VAGRANT_PRIV_KEY_DIR >> $HOME/.babun_shim_vars"
REM Change directory to where the private key is stored and set permissions
"%SH%" -c "source $HOME/.babun_shim_vars && cd $VAGRANT_PRIV_KEY_DIRECTORY && setfacl -s user::r--,group::---,other::--- private_key && ls -l private_key && pwd"
REM Run the playbook commands, except change the private_key location to the Cygwin path, instead of using the Windows file location reference.
"%SH%" -c "export ANSIBLE_SSH_ARGS='-o ControlMaster=no' && $HOME/ansible/bin/ansible-playbook `echo %* | sed '0,/C:\/Users\/Admin\/\.babun\/cygwin/s///'`"

This comment has been minimized.

Copy link
Owner Author

@jonathanhle jonathanhle commented May 8, 2015

Please only use this shim with Vagrant for nonDev testing on Windows. It's slows down Ansible a good bit and isn't representative of how quick Ansible can be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment