Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #28 from msmshariq/master
Browse files Browse the repository at this point in the history
Sync configs using file provisioner
  • Loading branch information
DilanUA authored Mar 20, 2018
2 parents 957cba6 + 6e1728a commit 35088a8
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 19 deletions.
3 changes: 3 additions & 0 deletions APIM-ISasKM-with-Analytics/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ Vagrant.configure(2) do |config|
vb.customize ['modifyvm', :id, '--memory', memory]
vb.customize ['modifyvm', :id, '--cpus', cpu]
end
if server['conf_dir']
server_config.vm.provision "file", source: FILES_PATH + server['conf_dir'], destination: DEFAULT_MOUNT + server['conf_dir']
end

# configure shell provisioner
if !server['provisioner_script']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ WORKING_DIRECTORY=/home/vagrant
JAVA_HOME=/opt/java/
WUM_HOME=/usr/local
WUM_PATH=PATH=$PATH:/usr/local/wum/bin
DEFAULT_MOUNT=/vagrant
CONFIGURATIONS=${DEFAULT_MOUNT}/api-manager-analytics/confs
CONFIGURATIONS=${WORKING_DIRECTORY}/api-manager-analytics/confs

# operating in non-interactive mode
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -69,6 +68,9 @@ echo "Successfully copied the files."
export JAVA_HOME
export WUM_PATH

echo "Removing configurations directories."
rm -rf ${CONFIGURATIONS}

# start the WSO2 product pack as a background service
echo "Starting ${WSO2_SERVER}-${WSO2_SERVER_VERSION}..."
sh ${WORKING_DIRECTORY}/${WSO2_SERVER}-${WSO2_SERVER_VERSION}/bin/wso2server.sh start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ WORKING_DIRECTORY=/home/vagrant
JAVA_HOME=/opt/java/
WUM_HOME=/usr/local
WUM_PATH=PATH=$PATH:/usr/local/wum/bin
DEFAULT_MOUNT=/vagrant
CONFIGURATIONS=${DEFAULT_MOUNT}/api-manager/confs
CONFIGURATIONS=${WORKING_DIRECTORY}/api-manager/confs

# operating in non-interactive mode
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -70,6 +69,9 @@ echo "Successfully copied the files."
export JAVA_HOME
export WUM_PATH

echo "Removing configurations directories."
rm -rf ${CONFIGURATIONS}

# start the WSO2 product pack as a background service
echo "Starting ${WSO2_SERVER}-${WSO2_SERVER_VERSION}..."
sh ${WORKING_DIRECTORY}/${WSO2_SERVER}-${WSO2_SERVER_VERSION}/bin/wso2server.sh start
Expand Down
4 changes: 4 additions & 0 deletions APIM-ISasKM-with-Analytics/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ servers:
ram: 2048
cpu: 1
provisioner_script: mysql/provisioner/db_provisioner.sh
conf_dir: mysql/scripts

-
hostname: api-manager-analytics
Expand All @@ -28,6 +29,7 @@ servers:
ram: 2048
cpu: 1
provisioner_script: api-manager-analytics/provisioner/product_provisioner.sh
conf_dir: api-manager-analytics/confs

-
hostname: is-as-km
Expand All @@ -36,6 +38,7 @@ servers:
ram: 2048
cpu: 1
provisioner_script: is-as-km/provisioner/product_provisioner.sh
conf_dir: is-as-km/confs

-
hostname: api-manager
Expand All @@ -48,3 +51,4 @@ servers:
ram: 2048
cpu: 1
provisioner_script: api-manager/provisioner/product_provisioner.sh
conf_dir: api-manager/confs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ WORKING_DIRECTORY=/home/vagrant
JAVA_HOME=/opt/java/
WUM_HOME=/usr/local
WUM_PATH=PATH=$PATH:/usr/local/wum/bin
DEFAULT_MOUNT=/vagrant
CONFIGURATIONS=${DEFAULT_MOUNT}/api-manager-analytics/confs
CONFIGURATIONS=${WORKING_DIRECTORY}/api-manager-analytics/confs

# operating in non-interactive mode
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -69,6 +68,9 @@ echo "Successfully copied the files."
export JAVA_HOME
export WUM_PATH

echo "Removing configurations directories."
rm -rf ${CONFIGURATIONS}

# start the WSO2 product pack as a background service
echo "Starting ${WSO2_SERVER}-${WSO2_SERVER_VERSION}..."
sh ${WORKING_DIRECTORY}/${WSO2_SERVER}-${WSO2_SERVER_VERSION}/bin/wso2server.sh start
Expand Down
10 changes: 7 additions & 3 deletions APIM-ISasKM-with-Analytics/mysql/provisioner/db_provisioner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

DB_USER=root
DB_PASSWORD=wso2carbon
WORKING_DIRECTORY=/home/vagrant

# run product db script
echo "Execute the database scripts..."
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source /vagrant/mysql/scripts/mysql.sql"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source /vagrant/mysql/scripts/um_mysql.sql"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source /vagrant/mysql/scripts/mb_store_mysql.sql"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source ${WORKING_DIRECTORY}/mysql/scripts/mysql.sql"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source ${WORKING_DIRECTORY}/mysql/scripts/um_mysql.sql"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source ${WORKING_DIRECTORY}/mysql/scripts/mb_store_mysql.sql"

echo "Successfully executed the database scripts."

Expand All @@ -36,3 +37,6 @@ echo "Grant access to the user..."
mysql -u${DB_USER} -p${DB_PASSWORD} -e "grant all privileges on *.* to 'root'@'%' with grant option;"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "flush privileges;"
echo "Successfully granted access to the user."

echo "Removing configurations directories."
rm -rf ${WORKING_DIRECTORY}/mysql
6 changes: 6 additions & 0 deletions APIM-with-Analytics/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ $stdout.print "password: "
PASSWORD = $stdin.noecho(&:gets).chomp
TOKEN = [ERB::Util.url_encode(USERNAME), ERB::Util.url_encode(PASSWORD)].join(':')

FILES_PATH = "./"
DEFAULT_MOUNT = "/home/vagrant/"

# load server configurations from YAML file
CONFIGURATIONS = YAML.load_file('config.yaml')
Vagrant.configure(2) do |config|
Expand Down Expand Up @@ -72,6 +75,9 @@ Vagrant.configure(2) do |config|
vb.customize ['modifyvm', :id, '--memory', memory]
vb.customize ['modifyvm', :id, '--cpus', cpu]
end
if server['conf_dir']
server_config.vm.provision "file", source: FILES_PATH + server['conf_dir'], destination: DEFAULT_MOUNT + server['conf_dir']
end

# configure shell provisioner
if !server['provisioner_script']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ WORKING_DIRECTORY=/home/vagrant
JAVA_HOME=/opt/java/
WUM_HOME=/usr/local
WUM_PATH=PATH=$PATH:/usr/local/wum/bin
DEFAULT_MOUNT=/vagrant
CONFIGURATIONS=${DEFAULT_MOUNT}/api-manager-analytics/confs
CONFIGURATIONS=${WORKING_DIRECTORY}/api-manager-analytics/confs

# operating in non-interactive mode
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -69,6 +68,9 @@ echo "Successfully copied the files."
export JAVA_HOME
export WUM_PATH

echo "Removing configurations directories."
rm -rf ${CONFIGURATIONS}

# start the WSO2 product pack as a background service
echo "Starting ${WSO2_SERVER}-${WSO2_SERVER_VERSION}..."
sh ${WORKING_DIRECTORY}/${WSO2_SERVER}-${WSO2_SERVER_VERSION}/bin/wso2server.sh start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ WORKING_DIRECTORY=/home/vagrant
JAVA_HOME=/opt/java/
WUM_HOME=/usr/local
WUM_PATH=PATH=$PATH:/usr/local/wum/bin
DEFAULT_MOUNT=/vagrant
CONFIGURATIONS=${DEFAULT_MOUNT}/api-manager/confs
CONFIGURATIONS=${WORKING_DIRECTORY}/api-manager/confs

# operating in non-interactive mode
export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -69,6 +68,9 @@ echo "Successfully copied the files."
export JAVA_HOME
export WUM_PATH

echo "Removing configurations directories."
rm -rf ${CONFIGURATIONS}

# start the WSO2 product pack as a background service
echo "Starting ${WSO2_SERVER}-${WSO2_SERVER_VERSION}..."
sh ${WORKING_DIRECTORY}/${WSO2_SERVER}-${WSO2_SERVER_VERSION}/bin/wso2server.sh start
Expand Down
3 changes: 3 additions & 0 deletions APIM-with-Analytics/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ servers:
ram: 2048
cpu: 1
provisioner_script: mysql/provisioner/db_provisioner.sh
conf_dir: mysql/scripts

-
hostname: api-manager-analytics
Expand All @@ -28,6 +29,7 @@ servers:
ram: 2048
cpu: 1
provisioner_script: api-manager-analytics/provisioner/product_provisioner.sh
conf_dir: api-manager-analytics/confs

-
hostname: api-manager
Expand All @@ -40,3 +42,4 @@ servers:
ram: 2048
cpu: 1
provisioner_script: api-manager/provisioner/product_provisioner.sh
conf_dir: api-manager/confs
8 changes: 6 additions & 2 deletions APIM-with-Analytics/mysql/provisioner/db_provisioner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

DB_USER=root
DB_PASSWORD=wso2carbon
WORKING_DIRECTORY=/home/vagrant

# run product db script
echo "Execute the database scripts..."
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source /vagrant/mysql/scripts/mysql.sql"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source /vagrant/mysql/scripts/um_mysql.sql"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source ${WORKING_DIRECTORY}/mysql/scripts/mysql.sql"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "source ${WORKING_DIRECTORY}/mysql/scripts/um_mysql.sql"
echo "Successfully executed the database scripts."

# grants root access to MySQL server from any host
Expand All @@ -34,3 +35,6 @@ echo "Grant access to the user..."
mysql -u${DB_USER} -p${DB_PASSWORD} -e "grant all privileges on *.* to 'root'@'%' with grant option;"
mysql -u${DB_USER} -p${DB_PASSWORD} -e "flush privileges;"
echo "Successfully granted access to the user."

echo "Removing configurations directories."
rm -rf ${WORKING_DIRECTORY}/mysql
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,31 @@ Virtualization should be enabled in BIOS settings before building the boxes.
1. Checkout this repository into your local machine using the following Git command.

```
https://github.com/wso2/vagrant-apim.git
https://github.com/wso2/vagrant-apim.git
```
> If you are to try out an already released zip of this repo, please ignore this 1st step.

2. Move to `vagrant-apim` folder.

```
cd vagrant-apim
cd vagrant-apim
```
>If you are to try out an already released zip of this repo, please ignore this 2nd step also. Instead, extract the zip file and directly browse to `vagrant-apim-<released-version>` folder.
>If you are to try out an already released tag, after executing 2nd step, checkout the relevant tag, i.e. for example: <br> git checkout tags/v2.1.0.4 and continue below steps.


3. Switch to WSO2 API Manager deployment pattern directory

```
cd < deployment-pattern-directory >
cd < deployment-pattern-directory >
```

4. Spawn up the Vagrant setup.

```
vagrant up
vagrant up
```

0 comments on commit 35088a8

Please sign in to comment.