├── .gitignore ├── README.md ├── ansible-babun-bootstrap.sh ├── ansible-playbook.bat └── install.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Vim template 3 | [._]*.s[a-w][a-z] 4 | [._]s[a-w][a-z] 5 | *.un~ 6 | Session.vim 7 | .netrwhist 8 | *~ 9 | 10 | 11 | ### JetBrains template 12 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion 13 | 14 | *.iml 15 | 16 | ## Directory-based project format: 17 | .idea/ 18 | # if you remove the above rule, at least ignore the following: 19 | 20 | # User-specific stuff: 21 | # .idea/workspace.xml 22 | # .idea/tasks.xml 23 | # .idea/dictionaries 24 | 25 | # Sensitive or high-churn files: 26 | # .idea/dataSources.ids 27 | # .idea/dataSources.xml 28 | # .idea/sqlDataSources.xml 29 | # .idea/dynamic.xml 30 | # .idea/uiDesigner.xml 31 | 32 | # Gradle: 33 | # .idea/gradle.xml 34 | # .idea/libraries 35 | 36 | # Mongo Explorer plugin: 37 | # .idea/mongoSettings.xml 38 | 39 | ## File-based project format: 40 | *.ipr 41 | *.iws 42 | 43 | ## Plugin-specific files: 44 | 45 | # IntelliJ 46 | /out/ 47 | 48 | # mpeltonen/sbt-idea plugin 49 | .idea_modules/ 50 | 51 | # JIRA plugin 52 | atlassian-ide-plugin.xml 53 | 54 | # Crashlytics plugin (for Android Studio and IntelliJ) 55 | com_crashlytics_export_strings.xml 56 | crashlytics.properties 57 | crashlytics-build.properties 58 | 59 | 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ansible-babun-bootstrap 2 | 3 | ## 🚨 DEPRECATED 🚨 4 | 5 | I'm no longer working on Windows as my main system (for several years I've been using mainly Ubuntu Linux). And now Windows 10 has WSL (Windows Subsystem for Linux). 6 | 7 | If you're a developer, you would have a much better time using WSL than Babun, and as it's Linux, it will be natively compatible with Ansible. So, you no longer need this script. 8 | 9 | ## Description 10 | 11 | Simple shell script to setup [Ansible](http://www.ansible.com/) within [Babun](http://babun.github.io/), to allow using Ansible from Windows without needing a virtual machine. 12 | 13 | ## Installation 14 | 15 | * Install [Babun](http://babun.github.io/) and start a terminal. 16 | * Run the following command: 17 | 18 | ``` 19 | curl -s https://raw.githubusercontent.com/tiangolo/ansible-babun-bootstrap/master/install.sh | source /dev/stdin 20 | ``` 21 | 22 | Note: the previous command will get a script from this repository and run it immediately, performing all the needed 23 | steps to install everything (the same steps described in "Manual installation"). 24 | If you don't want to run it, you can do a manual installation. 25 | 26 | ----- 27 | 28 | ## Manual installation 29 | 30 | * Go to your home directory: 31 | 32 | ``` 33 | cd 34 | ``` 35 | 36 | * Clone this repository: 37 | 38 | ``` 39 | git clone https://github.com/tiangolo/ansible-babun-bootstrap 40 | ``` 41 | 42 | * Enter the repository directory: 43 | 44 | ``` 45 | cd ansible-babun-bootstrap 46 | ``` 47 | 48 | * Run the bootstrap script: 49 | 50 | ``` 51 | source ./ansible-babun-bootstrap.sh 52 | ``` 53 | 54 | All the prerequisites will be installed and Ansible will run from: $HOME/ansible/. 55 | 56 | A file /etc/ansible/hosts will be created with a default (127.0.0.1) host. 57 | 58 | A file ~/.ansible.cfg will be created with default configurations, including setting paramiko as the transport to allow 59 | using passwords. 60 | 61 | A bootstrap script will be added to .zshrc in $HOME, every time you start babun it will update Ansible and setup the 62 | environment. If you don't want to update Ansible every time (it takes some time), you can edit ~/.zshrc and set 63 | BOOTSTRAP_ANSIBLE_UPDATE=0. 64 | -------------------------------------------------------------------------------- /ansible-babun-bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | ANSIBLE_DIR=$HOME/ansible 3 | 4 | CURRENT_DIR=$( pwd ) 5 | 6 | if [ -f /etc/ansible-babun-bootstrap.completed ] 7 | then 8 | echo "First init setting up Ansible in Babun has already been completed." 9 | cd $ANSIBLE_DIR 10 | if [ $BOOTSTRAP_ANSIBLE_UPDATE = 1 ] 11 | then 12 | echo "Performing Ansible update from source, if available." 13 | #Setup rebase Ansible 14 | git pull --rebase 15 | git submodule update --init --recursive 16 | fi 17 | source ./hacking/env-setup 18 | cd $CURRENT_DIR 19 | 20 | echo "Update Ansible Vagrant Shims in bin Directory" 21 | cp -r $HOME/ansible-babun-bootstrap/ansible-playbook.bat $HOME/ansible/bin/ansible-playbook.bat 22 | 23 | echo "Remember to setup the ssh-agent." 24 | 25 | else 26 | #Replace babun sudo with new fake sudo for Ansible, throwing way all sudo args. 27 | echo "#!/usr/bin/env bash" > /usr/bin/sudo 28 | echo "count=0" >> /usr/bin/sudo 29 | echo "for var in "$@"" >> /usr/bin/sudo 30 | echo " do" >> /usr/bin/sudo 31 | echo " (( count++ ))" >> /usr/bin/sudo 32 | echo " done" >> /usr/bin/sudo 33 | echo "shift $count" >> /usr/bin/sudo 34 | echo "exec "$@"" >> /usr/bin/sudo 35 | 36 | #Install Ansible Prereqs 37 | pact install python 38 | pact install python-paramiko 39 | pact install python-crypto 40 | pact install gcc-g++ 41 | pact install wget 42 | pact install openssh 43 | pact install python-setuptools 44 | pact install libyaml-devel 45 | easy_install pip 46 | pip install PyYAML Jinja2 httplib2 boto awscli 47 | 48 | #Create initial Ansible hosts inventory 49 | mkdir -p /etc/ansible/ 50 | echo "127.0.0.1" > /etc/ansible/hosts 51 | chmod -x /etc/ansible/hosts 52 | 53 | #Setup Ansible from Source 54 | mkdir -p $ANSIBLE_DIR 55 | git clone git://github.com/ansible/ansible.git --recursive $ANSIBLE_DIR 56 | cd $ANSIBLE_DIR 57 | source ./hacking/env-setup 58 | cd $CURRENT_DIR 59 | 60 | echo "Copy Ansible Vagrant Shims to bin Directory" 61 | cp -r $HOME/ansible-babun-bootstrap/ansible-playbook.bat $HOME/ansible/bin/ansible-playbook.bat 62 | 63 | # Copy default config 64 | cp $ANSIBLE_DIR/examples/ansible.cfg ~/.ansible.cfg 65 | # Use paramiko to allow passwords 66 | sed -i 's|#\?transport.*$|transport = paramiko|' ~/.ansible.cfg 67 | # Disable host key checking for performance 68 | sed -i 's|#host_key_checking = False|host_key_checking = False|' ~/.ansible.cfg 69 | 70 | BOOTSTRAP_ANSIBLE_UPDATE=1 71 | #Set this script to run at Babun startup 72 | echo "# If you don't want to update Ansible every time set BOOTSTRAP_ANSIBLE_UPDATE=0" >> $HOME/.zshrc 73 | echo "export BOOTSTRAP_ANSIBLE_UPDATE=1" >> $HOME/.zshrc 74 | echo "source $HOME/ansible-babun-bootstrap/ansible-babun-bootstrap.sh" >> $HOME/.zshrc 75 | echo " " 76 | echo "Remember to setup the ssh-agent." 77 | echo " " 78 | echo "Please restart Babun!!!!" 79 | 80 | # touch a file to mark first app init completed 81 | touch /etc/ansible-babun-bootstrap.completed 82 | 83 | 84 | fi 85 | -------------------------------------------------------------------------------- /ansible-playbook.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM This is the default Babun install location. 4 | set CYGWIN=%USERPROFILE%\.babun\cygwin 5 | 6 | REM This is the default Babun shell, changed to bash if you need to 7 | set SH=%CYGWIN%\bin\zsh.exe 8 | 9 | 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 10 | "%SH%" -c "cd $HOME && touch .babun_shim_vars && sed -i '/.*VAGRANT_PRIV_KEY_DIR.*/d' .babun_shim_vars" 11 | 12 | REM Put the private_key path directory into the temp vars file we just setup: $HOME/.babun_shim_vars 13 | "%SH%" -c "VAGRANT_PRIV_KEY_DIR=`echo %* | sed '0,\|C:/Users/%USERNAME%/.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" 14 | 15 | REM Change directory to where the private key is stored and set permissions 16 | "%SH%" -c "source $HOME/.babun_shim_vars && cd $VAGRANT_PRIV_KEY_DIRECTORY && setfacl -s user::r--,group::---,other::--- private_key" 17 | 18 | REM Run the playbook commands, except change the private_key location to the Cygwin path, instead of using the Windows file location reference. 19 | "%SH%" -c "$HOME/ansible/bin/ansible-playbook `echo %* | sed '0,\|C:/Users/%USERNAME%/.babun/cygwin/ s///'`" -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | if [ ! -d ansible-babun-bootstrap ] 4 | then 5 | git clone https://github.com/tiangolo/ansible-babun-bootstrap.git 6 | else 7 | cd ansible-babun-bootstrap 8 | git pull 9 | cd .. 10 | fi 11 | 12 | source ansible-babun-bootstrap/ansible-babun-bootstrap.sh --------------------------------------------------------------------------------