Skip to content
This repository has been archived by the owner on Jul 29, 2020. It is now read-only.

Some changes #1

Merged
merged 13 commits into from Jul 22, 2015
Merged
59 changes: 59 additions & 0 deletions .gitignore
@@ -0,0 +1,59 @@
# Created by .ignore support plugin (hsz.mobi)
### Vim template
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~


### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties


66 changes: 52 additions & 14 deletions README.md
@@ -1,24 +1,62 @@
# ansible-babun-bootstrap
Simple shell script to setup Ansible within Babun

1. Install Babun and start a terminal.
2. Clone repo into Babun $HOME:
## Description

- cd $HOME
- git clone https://github.com/jonathanhle/ansible-babun-bootstrap
Simple shell script to setup [Ansible](http://www.ansible.com/) within [Babun](http://babun.github.io/).

3. Run the bootstrap script:
## Installation

* Install [Babun](http://babun.github.io/) and start a terminal.
* Run the following command:

- cd ansible-babun-bootstrap
- . ./ansible-babun-bootstrap.sh
```
curl -s https://raw.githubusercontent.com/tiangolo/ansible-babun-bootstrap/master/install.sh | source /dev/stdin
```

Be sure not to forget the extra ". ./" at the begining of the script, since we want to run the shell in the current environment.
Note: the previous command will get a script from this repository and run it immediately, performing all the needed
steps to install everything (the same steps described in "Manual installation").
If you don't want to run it, you can do a manual installation.

Prereqs will be installed and Ansible will run from: /home/$USERNAME/ansible/
Bootstrap script will be added to .zshrc in $HOME.
-----

You'll need to change the username in the ansible-playbook.bat to your username in the sed statements and/or adjust them to fit where Babun was installed.
## Manual installation

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.
* Go to your home directory:

```
cd
```

* Clone this repository:

```
git clone https://github.com/tiangolo/ansible-babun-bootstrap
```

* Enter the repository directory:

```
cd ansible-babun-bootstrap
```

* Run the bootstrap script:

```
source ./ansible-babun-bootstrap.sh
```

All the prerequisites will be installed and Ansible will run from: $HOME/ansible/.

A file /etc/ansible/hosts will be created with a default (127.0.0.1) host.

A file ~/.ansible.cfg will be created with default configurations, including setting paramiko as the transport to allow
using passwords.

A bootstrap script will be added to .zshrc in $HOME, every time you start babun it will update Ansible and setup the
environment. If you don't want to update Ansible every time (it takes some time), you can edit ~/.zshrc and set
BOOTSTRAP_ANSIBLE_UPDATE=0.


> 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.
39 changes: 23 additions & 16 deletions ansible-babun-bootstrap.sh
@@ -1,24 +1,25 @@
#!/usr/bin/env zsh
ANSIBLE_DIR=$HOME/ansible

if [ -f /etc/ansible_init_babun.completed ]
CURRENT_DIR=$( pwd )

if [ -f /etc/ansible-babun-bootstrap.completed ]
then
echo "First init setting up Ansible in Babun has already been completed."
echo "Performing Ansible update from source, if available."
#Setup rebase Ansible
cd $ANSIBLE_DIR
git pull --rebase
git submodule update --init --recursive
if [ $BOOTSTRAP_ANSIBLE_UPDATE = 1 ]
then
echo "Performing Ansible update from source, if available."
#Setup rebase Ansible
git pull --rebase
git submodule update --init --recursive
fi
source ./hacking/env-setup
cd $HOME
cd $CURRENT_DIR

echo "Update Ansible Vagrant Shims in bin Directory"
cp -r $HOME/ansible-babun-bootstrap/ansible-playbook.bat $HOME/ansible/bin/ansible-playbook.bat

#Setup ENV_VARs for Ansible on Babun
export ANSIBLE_SSH_ARGS='-o ControlMaster=no'
export ANSIBLE_HOST_KEY_CHECKING=False

echo "Remember to setup the ssh-agent."

else
Expand Down Expand Up @@ -54,24 +55,30 @@ if [ -f /etc/ansible_init_babun.completed ]
git clone git://github.com/ansible/ansible.git --recursive $ANSIBLE_DIR
cd $ANSIBLE_DIR
source ./hacking/env-setup
cd $HOME
cd $CURRENT_DIR

echo "Copy Ansible Vagrant Shims to bin Directory"
cp -r $HOME/ansible-babun-bootstrap/ansible-playbook.bat $HOME/ansible/bin/ansible-playbook.bat

#Setup ENV_VARs for Ansible on Babun
export ANSIBLE_SSH_ARGS='-o ControlMaster=no'
export ANSIBLE_HOST_KEY_CHECKING=False
# Copy default config
cp $ANSIBLE_DIR/examples/ansible.cfg ~/.ansible.cfg
# Use paramiko to allow passwords
sed -i 's|transport.*$|transport = paramiko|' ~/.ansible.cfg
# Disable host key checking for performance
sed -i 's|#host_key_checking = False|host_key_checking = False|' ~/.ansible.cfg

BOOTSTRAP_ANSIBLE_UPDATE=1
#Set this script to run at Babun startup
echo ". $HOME/ansible-babun-bootstrap/ansible-babun-bootstrap.sh" >> $HOME/.zshrc
echo "# If you don't want to update Ansible every time set BOOTSTRAP_ANSIBLE_UPDATE=0" >> $HOME/.zshrc
echo "export BOOTSTRAP_ANSIBLE_UPDATE=1" >> $HOME/.zshrc
echo "source $HOME/ansible-babun-bootstrap/ansible-babun-bootstrap.sh" >> $HOME/.zshrc
echo " "
echo "Remember to setup the ssh-agent."
echo " "
echo "Please restart Babun!!!!"

# touch a file to mark first app init completed
touch /etc/ansible_init_babun.completed
touch /etc/ansible-babun-bootstrap.completed


fi
7 changes: 2 additions & 5 deletions ansible-playbook.bat
Expand Up @@ -6,17 +6,14 @@ 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"
"%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"

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"

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///'`"
"%SH%" -c "$HOME/ansible/bin/ansible-playbook `echo %* | sed '0,\|C:/Users/%USERNAME%/.babun/cygwin/ s///'`"
12 changes: 12 additions & 0 deletions install.sh
@@ -0,0 +1,12 @@
#!/usr/bin/env zsh

if [ ! -d ansible-babun-bootstrap ]
then
git clone https://github.com/tiangolo/ansible-babun-bootstrap.git
else
cd ansible-babun-bootstrap
git pull
cd ..
fi

source ansible-babun-bootstrap/ansible-babun-bootstrap.sh