Skip to content

Commit f9d09d1

Browse files
authored
Merge pull request #1 from dtest/ansible23_test
Ansible23 test
2 parents 0a5709d + 5a3d036 commit f9d09d1

3 files changed

Lines changed: 60 additions & 66 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
ansible/library
2+
**/.vagrant/

Vagrantfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.require_version ">= 1.9.1"
5+
VAGRANTFILE_API_VERSION = "2"
6+
7+
### Scenario based variables (Use vagrant_config.yml in scenario folder) ###
8+
# Customize to avoid network clashes of VMs
9+
IP_BLOCK = "192.168.41."
10+
###########
11+
12+
### Local Environment Variables (use ENVIRONMENT variables) ###
13+
# Configure for environment
14+
RAM_ASSIGNED = if ENV['VAGRANT_VM_MEMORY_SIZE']!=nil then ENV['VAGRANT_VM_MEMORY_SIZE'].to_i else 1024 end
15+
###########
16+
17+
# Ability to override the default vagrant file from a scenario's setup.sh script setting this environment variable.
18+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
19+
config.vm.boot_timeout = 600
20+
21+
# scenario['servers'].each_with_index do |server, machine_id|
22+
config.vm.define "tutorial" do |node|
23+
node.vm.box = "ubuntu/trusty64"
24+
node.vm.network "private_network", ip: "#{IP_BLOCK}#{100}"
25+
node.vm.hostname = "tutorial"
26+
node.vm.provider :virtualbox do |vb|
27+
vb.name = "proxysql_tutorial"
28+
vb.memory = RAM_ASSIGNED
29+
vb.cpus = 1
30+
end
31+
end
32+
end

setup.sh

Lines changed: 27 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,26 @@ ANSIBLE_DIR="proxysql_ansible_modules"
1818
DATE=$(date +"%s")
1919
LOG_FILE="setup_${DATE}.log"
2020

21+
# Do the permissions as very first thing.
22+
if [ $(grep docker /etc/group |wc -l) -lt 1 ];then
23+
sudo groupadd docker
24+
sudo usermod -aG docker $USER
25+
echo
26+
echo "========================================================================"
27+
echo "Permissions need updating. Will exit in 5s for changes to take effect"
28+
echo "Log back in and re-run script to continue."
29+
echo "========================================================================"
30+
echo
31+
echo "Sleeping 5 before exiting."
32+
sleep 5
33+
kill -HUP $PPID
34+
fi
2135

22-
if [ ! -e ${PLAM_DIR} ] || [ ! -e ${ANSIBLE_DIR} ];then
36+
echo "Confirmed permissions. Continuing"
37+
echo
38+
sleep 1
39+
40+
if [ ! -e ${PLAM_DIR} ];then
2341

2442
echo "Updating apt"
2543
echo
@@ -35,47 +53,12 @@ if [ ! -e ${PLAM_DIR} ] || [ ! -e ${ANSIBLE_DIR} ];then
3553
echo
3654
git clone https://github.com/dtest/${PLAM_DIR}.git
3755
echo
38-
39-
echo "Cloning Proxysql_ansible_modules repo"
40-
echo
41-
git clone https://github.com/bmildren/${ANSIBLE_DIR}.git
42-
echo
43-
44-
echo "Linking in ${ANSIBLE_DIR}"
45-
echo
46-
ln -s ${CWD}/${ANSIBLE_DIR} ${CWD}/${PLAM_DIR}/ansible/library
47-
echo
48-
49-
# echo "Getting sakila database."
50-
# echo
51-
# wget http://downloads.mysql.com/docs/sakila-db.tar.gz
52-
# echo
53-
5456
fi
5557

56-
echo "Confirmed ${PLAM_DIR} and ${ANSIBLE_DIR} exist."
58+
echo "Confirmed ${PLAM_DIR} exist."
5759
echo
5860
echo
5961

60-
if [ $(grep docker /etc/group |wc -l) -lt 1 ];then
61-
sudo groupadd docker
62-
sudo usermod -aG docker $USER
63-
echo
64-
echo "========================================================================"
65-
echo "Permissions need updating. Will exit in 5s for changes to take effect"
66-
echo "Log back in and re-run script to continue."
67-
echo "========================================================================"
68-
echo
69-
echo "Sleeping 5 before exiting."
70-
sleep 5
71-
kill -HUP $PPID
72-
fi
73-
74-
echo "Confirmed permissions. Continuing"
75-
echo
76-
sleep 1
77-
78-
7962
if [ $(dpkg -l |grep python |grep pip| wc -l) -lt 1 ];then
8063

8164
exec > >(tee ${LOG_FILE}) 2>&1
@@ -108,17 +91,9 @@ if [ $(dpkg -l |grep python |grep pip| wc -l) -lt 1 ];then
10891
sudo apt-get -y install libssl-dev
10992
sudo apt-get -y install libffi-dev
11093
sudo pip install markupsafe
111-
# This seemed to fail..
112-
# sudo apt-get -y install ansible
113-
# Was having an issue with current version of ansible
114-
sudo pip install ansible==2.1.1.0
115-
# sudo pip install ansible
116-
# Installed above
117-
# sudo apt-get -y install git
118-
#
94+
sudo pip install ansible
11995
sudo pip install docker-compose
12096

121-
12297
echo
12398
echo
12499
echo "=================================================="
@@ -136,27 +111,13 @@ if [ $(docker ps |grep -v CONTAINER |wc -l) -lt 4 ] || [ $(docker ps |grep mast
136111
sleep 5
137112

138113
cd ${PLAM_DIR}
139-
time docker-compose pull # updates latest containers
140-
time docker-compose up -d
141-
142-
echo "Giving time for containers to start; sleeping..." && sleep 50
143-
144-
cd ansible && time ansible-playbook -i inventory setup.yml
145114

146-
fi
147-
148-
# echo
149-
# echo "Sleeping 5s to ensure master container is ready for sakila"
150-
# echo
151-
# sleep 5
115+
./run_proxy.sh
116+
# time docker-compose pull # updates latest containers
117+
# time docker-compose up -d
152118

153-
# if [ $(docker ps |grep master |wc -l) -gt 0 ];then
154-
# echo "Copying sakila db to master container."
155-
# echo
156-
# docker cp ${CWD}/sakila-db.tar.gz master:/var/tmp
157-
# echo
119+
# echo "Giving time for containers to start; sleeping..." && sleep 50
158120

159-
# fi
121+
# cd ansible && time ansible-playbook -i inventory setup.yml
160122

161-
cd ${CWD}/${PLAM_DIR}
162-
exec bash
123+
fi

0 commit comments

Comments
 (0)