Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ansible/library
**/.vagrant/
32 changes: 32 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.require_version ">= 1.9.1"
VAGRANTFILE_API_VERSION = "2"

### Scenario based variables (Use vagrant_config.yml in scenario folder) ###
# Customize to avoid network clashes of VMs
IP_BLOCK = "192.168.41."
###########

### Local Environment Variables (use ENVIRONMENT variables) ###
# Configure for environment
RAM_ASSIGNED = if ENV['VAGRANT_VM_MEMORY_SIZE']!=nil then ENV['VAGRANT_VM_MEMORY_SIZE'].to_i else 1024 end
###########

# Ability to override the default vagrant file from a scenario's setup.sh script setting this environment variable.
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.boot_timeout = 600

# scenario['servers'].each_with_index do |server, machine_id|
config.vm.define "tutorial" do |node|
node.vm.box = "ubuntu/trusty64"
node.vm.network "private_network", ip: "#{IP_BLOCK}#{100}"
node.vm.hostname = "tutorial"
node.vm.provider :virtualbox do |vb|
vb.name = "proxysql_tutorial"
vb.memory = RAM_ASSIGNED
vb.cpus = 1
end
end
end
93 changes: 27 additions & 66 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,26 @@ ANSIBLE_DIR="proxysql_ansible_modules"
DATE=$(date +"%s")
LOG_FILE="setup_${DATE}.log"

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

if [ ! -e ${PLAM_DIR} ] || [ ! -e ${ANSIBLE_DIR} ];then
echo "Confirmed permissions. Continuing"
echo
sleep 1

if [ ! -e ${PLAM_DIR} ];then

echo "Updating apt"
echo
Expand All @@ -35,47 +53,12 @@ if [ ! -e ${PLAM_DIR} ] || [ ! -e ${ANSIBLE_DIR} ];then
echo
git clone https://github.com/dtest/${PLAM_DIR}.git
echo

echo "Cloning Proxysql_ansible_modules repo"
echo
git clone https://github.com/bmildren/${ANSIBLE_DIR}.git
echo

echo "Linking in ${ANSIBLE_DIR}"
echo
ln -s ${CWD}/${ANSIBLE_DIR} ${CWD}/${PLAM_DIR}/ansible/library
echo

# echo "Getting sakila database."
# echo
# wget http://downloads.mysql.com/docs/sakila-db.tar.gz
# echo

fi

echo "Confirmed ${PLAM_DIR} and ${ANSIBLE_DIR} exist."
echo "Confirmed ${PLAM_DIR} exist."
echo
echo

if [ $(grep docker /etc/group |wc -l) -lt 1 ];then
sudo groupadd docker
sudo usermod -aG docker $USER
echo
echo "========================================================================"
echo "Permissions need updating. Will exit in 5s for changes to take effect"
echo "Log back in and re-run script to continue."
echo "========================================================================"
echo
echo "Sleeping 5 before exiting."
sleep 5
kill -HUP $PPID
fi

echo "Confirmed permissions. Continuing"
echo
sleep 1


if [ $(dpkg -l |grep python |grep pip| wc -l) -lt 1 ];then

exec > >(tee ${LOG_FILE}) 2>&1
Expand Down Expand Up @@ -108,17 +91,9 @@ if [ $(dpkg -l |grep python |grep pip| wc -l) -lt 1 ];then
sudo apt-get -y install libssl-dev
sudo apt-get -y install libffi-dev
sudo pip install markupsafe
# This seemed to fail..
# sudo apt-get -y install ansible
# Was having an issue with current version of ansible
sudo pip install ansible==2.1.1.0
# sudo pip install ansible
# Installed above
# sudo apt-get -y install git
#
sudo pip install ansible
sudo pip install docker-compose


echo
echo
echo "=================================================="
Expand All @@ -136,27 +111,13 @@ if [ $(docker ps |grep -v CONTAINER |wc -l) -lt 4 ] || [ $(docker ps |grep mast
sleep 5

cd ${PLAM_DIR}
time docker-compose pull # updates latest containers
time docker-compose up -d

echo "Giving time for containers to start; sleeping..." && sleep 50

cd ansible && time ansible-playbook -i inventory setup.yml

fi

# echo
# echo "Sleeping 5s to ensure master container is ready for sakila"
# echo
# sleep 5
./run_proxy.sh
# time docker-compose pull # updates latest containers
# time docker-compose up -d

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

# fi
# cd ansible && time ansible-playbook -i inventory setup.yml

cd ${CWD}/${PLAM_DIR}
exec bash
fi