Skip to content

Instantly share code, notes, and snippets.

@maurizi
Last active December 16, 2022 11:34
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save maurizi/325387aee9ea94fbf903 to your computer and use it in GitHub Desktop.
Save maurizi/325387aee9ea94fbf903 to your computer and use it in GitHub Desktop.
Running Ansible on Windows
@echo off
cygwin-shim.bat /bin/ansible-galaxy %*
@echo off
cygwin-shim.bat /bin/ansible-playbook %*
@echo off
set COMMAND=%1
REM If you used the standard Cygwin installer this will be C:\cygwin
set CYGWIN=%USERPROFILE%\.babun\cygwin
REM You can switch this to work with bash with %CYGWIN%\bin\bash.exe
set SH=%CYGWIN%\bin\zsh.exe
if not exist "%SH%" (
echo cygwin's sh.exe not found. Did you delete %CYGWIN% ?
exit /b 255
)
"%SH%" -c "[[ -x "%COMMAND%" ]]"
if not errorlevel 0 (
echo %COMMAND% not found. Did you uninstall it ?
exit /b 255
)
"%SH%" -c "%*"
@pwyoung
Copy link

pwyoung commented May 7, 2020

FWIW, I use this sort of command since I want to mimic logging in.

c:\cygwin64\bin\bash.exe -l -c "echo 'the above is from my login script'"
JAVA_HOME is C:\Java\jdk1.8.0_241
the above is from my login script

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