Created
May 8, 2015 06:04
-
-
Save jonathanhle/ff41bafb7c66efd72f78 to your computer and use it in GitHub Desktop.
ansible-playbook.bat shim for Babun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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///'`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.