Skip to content

Commit

Permalink
Merge pull request #210 from jcesario/cesario/fixvagrantdbs
Browse files Browse the repository at this point in the history
Thank you
  • Loading branch information
Shlomi Noach committed May 18, 2016
2 parents 54bfca2 + 002be44 commit ed53215
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BOX = ENV['VAGRANT_BOX'].nil? || ENV['VAGRANT_BOX'].empty? ? 'nrel/CentOS-6.6-x8
VAGRANTFILE_API_VERSION = "2"

system("
if [ #{ARGV[0]} = 'up' ]; then
if [[ #{ARGV[0]} = 'up' ]] && [[ ! -e 'vagrant/vagrant-ssh-key' ]]; then
ssh-keygen -t rsa -b 768 -N '' -q -f vagrant/vagrant-ssh-key
fi
")
Expand All @@ -32,7 +32,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
db.vm.network "private_network", ip: "192.168.57.20" + n.to_s
db.vm.provision "shell", path: "vagrant/base-build.sh"
if name == "admin"
config.vm.network "forwarded_port", guest:3000, host:3000
db.vm.network "forwarded_port", guest:3000, host:3000
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions vagrant/admin-build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Install orchestrator
rpm -i /tmp/orchestrator-release/orchestrator*.rpm
/sbin/chkconfig orchestrator on
cp /usr/local/orchestrator/orchestrator-sample.conf.json /etc/orchestrator.conf.json
/sbin/service orchestrator start

echo '* * * * * root /usr/bin/orchestrator -c discover -i db1' > /etc/cron.d/orchestrator-discovery

# Discover instances
/usr/bin/orchestrator -c discover -i localhost
17 changes: 7 additions & 10 deletions vagrant/base-build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,22 @@ if [[ -e /etc/redhat-release ]]; then

# Setup mysql
/sbin/chkconfig mysql on

if [[ -e "/orchestrator/vagrant/${HOSTNAME}-my.cnf" ]]; then
rm -f /etc/my.cnf
cp /orchestrator/vagrant/${HOSTNAME}-my.cnf /etc/my.cnf
fi

/sbin/service mysql start
cat <<-EOF | mysql -u root
CREATE DATABASE orchestrator;
CREATE DATABASE IF NOT EXISTS orchestrator;
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_client_user'@'%' IDENTIFIED BY 'orc_client_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'%';
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_client_user'@'localhost' IDENTIFIED BY 'orc_client_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'localhost';
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_server_user'@'localhost' IDENTIFIED BY 'orc_server_password';
EOF

# Install orchestrator
rpm -i /tmp/orchestrator-release/orchestrator*.rpm
/sbin/chkconfig orchestrator on
cp /usr/local/orchestrator/orchestrator-sample.conf.json /etc/orchestrator.conf.json
/sbin/service orchestrator start

# Discover instances
/usr/bin/orchestrator -c discover -i localhost

elif [[ -e /etc/debian_version ]]; then
sudo echo exit 101 > /usr/sbin/policy-rc.d
sudo chmod +x /usr/sbin/policy-rc.d
Expand Down
14 changes: 2 additions & 12 deletions vagrant/db1-build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
if [[ -e /etc/redhat-release ]]; then
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/my.cnf
sudo service mysql start
elif [[ -e /etc/debian_version ]]; then
if [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

sudo cat <<-EOF >> /root/.my.cnf
[client]
user = root
password = vagrant
EOF
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.202", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.202", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl", MASTER_CONNECT_RETRY=10, MASTER_RETRY_COUNT=36'
/usr/bin/mysql -uroot -ss -e 'START SLAVE'
1 change: 1 addition & 0 deletions vagrant/db1-my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ symbolic-links=0
server_id=1
log_bin
log-slave-updates
report-host=db1

[mysqld_safe]
log-error=/var/log/mysqld.log
Expand Down
16 changes: 3 additions & 13 deletions vagrant/db2-build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
if [[ -e /etc/redhat-release ]]; then
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db2-my.cnf /etc/my.cnf
sudo service mysql start
elif [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db2-my.cnf /etc/mysql/my.cnf
if [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

sudo cat <<-EOF >> /root/.my.cnf
[client]
user = root
password = vagrant
EOF
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.201", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.201", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl", MASTER_CONNECT_RETRY=10, MASTER_RETRY_COUNT=36'
/usr/bin/mysql -uroot -ss -e 'START SLAVE'
1 change: 1 addition & 0 deletions vagrant/db2-my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ symbolic-links=0
server_id=2
log_bin
log-slave-updates
report-host=db2

[mysqld_safe]
log-error=/var/log/mysqld.log
Expand Down
16 changes: 3 additions & 13 deletions vagrant/db3-build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
if [[ -e /etc/redhat-release ]]; then
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db3-my.cnf /etc/my.cnf
sudo service mysql start
elif [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db3-my.cnf /etc/mysql/my.cnf
if [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

sudo cat <<-EOF >> /root/.my.cnf
[client]
user = root
password = vagrant
EOF
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.201", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.201", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl", MASTER_CONNECT_RETRY=10, MASTER_RETRY_COUNT=36'
/usr/bin/mysql -uroot -ss -e 'START SLAVE'
1 change: 1 addition & 0 deletions vagrant/db3-my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ symbolic-links=0
server_id=3
log_bin
log-slave-updates
report-host=db3

[mysqld_safe]
log-error=/var/log/mysqld.log
Expand Down
16 changes: 3 additions & 13 deletions vagrant/db4-build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
if [[ -e /etc/redhat-release ]]; then
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db4-my.cnf /etc/my.cnf
sudo service mysql start
elif [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db4-my.cnf /etc/mysql/my.cnf
if [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

sudo cat <<-EOF >> /root/.my.cnf
[client]
user = root
password = vagrant
EOF
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.202", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.202", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl", MASTER_CONNECT_RETRY=10, MASTER_RETRY_COUNT=36'
/usr/bin/mysql -uroot -ss -e 'START SLAVE'
1 change: 1 addition & 0 deletions vagrant/db4-my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ symbolic-links=0
server_id=4
log_bin
log-slave-updates
report-host=db4

[mysqld_safe]
log-error=/var/log/mysqld.log
Expand Down

0 comments on commit ed53215

Please sign in to comment.