This repository has been archived by the owner on Jul 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathansible-babun-bootstrap.sh
executable file
·84 lines (70 loc) · 2.81 KB
/
ansible-babun-bootstrap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env zsh
ANSIBLE_DIR=$HOME/ansible
CURRENT_DIR=$( pwd )
if [ -f /etc/ansible-babun-bootstrap.completed ]
then
echo "First init setting up Ansible in Babun has already been completed."
cd $ANSIBLE_DIR
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 $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
echo "Remember to setup the ssh-agent."
else
#Replace babun sudo with new fake sudo for Ansible, throwing way all sudo args.
echo "#!/usr/bin/env bash" > /usr/bin/sudo
echo "count=0" >> /usr/bin/sudo
echo "for var in "$@"" >> /usr/bin/sudo
echo " do" >> /usr/bin/sudo
echo " (( count++ ))" >> /usr/bin/sudo
echo " done" >> /usr/bin/sudo
echo "shift $count" >> /usr/bin/sudo
echo "exec "$@"" >> /usr/bin/sudo
#Install Ansible Prereqs
pact install python
pact install python-paramiko
pact install python-crypto
pact install gcc-g++
pact install wget
pact install openssh
pact install python-setuptools
pact install libyaml-devel
easy_install pip
pip install PyYAML Jinja2 httplib2 boto awscli
#Create initial Ansible hosts inventory
mkdir -p /etc/ansible/
echo "127.0.0.1" > /etc/ansible/hosts
chmod -x /etc/ansible/hosts
#Setup Ansible from Source
mkdir -p $ANSIBLE_DIR
git clone git://github.com/ansible/ansible.git --recursive $ANSIBLE_DIR
cd $ANSIBLE_DIR
source ./hacking/env-setup
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
# 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 "# 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-babun-bootstrap.completed
fi