Sunday, March 13, 2016

[WSO2 APIM] Setting up API Manager Distributed Setup with Puppet Scripts





In this post we are going to use puppet to setup a 4 node API Manager distributed setup. You can find the puppet scripts I used, in this git repo.

NOTE: This blog post can be useful to troubleshoot any issues you get while working with puppet.

In my puppet scripts there are below IPs of the nodes I used. You have to replace them with yours.

Puppet Master/MySQL :   192.168.57.92
Publisher:   192.168.57.93
Store:   192.168.57.94
Key Manager:   192.168.57.96
Gateway:   192.168.57.97

That's just some information. Now let's start setting up each node, one by one.

1) Configure Puppet Master/ MySQL Node 

1. Install NTP, Puppet Master and MySQL.

> sudo su
> ntpdate pool.ntp.org ; apt-get update && sudo apt-get -y install ntp ; service ntp restart
> cd /tmp
> wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
> dpkg -i puppetlabs-release-trusty.deb
> apt-get update
> apt-get install puppetmaster
> apt-get install mysql-server


2. Change hostname in /etc/hostname to puppet (This might need a reboot)

3. Update /etc/hosts with below entry. 

127.0.0.1 puppet


4. Download and copy https://github.com/bhathiya/apim-puppet-scripts/tree/master/puppet directory to /etc/puppet

5. Replace IPs in copied puppet scripts. 

6. Before restarting the puppet master, clean all certificates, including puppet master’s certificate which is having its old DNS alt names.

> puppet cert clean --all


7. Restart puppet master

> service puppetmaster restart

8. Download and copy jdk-7u79-linux-x64.tar.gz to /etc/puppet/environments/production/modules/wso2base/files/jdk-7u79-linux-x64.tar.gz

9. Download and copy wso2am-2.0.0-SNAPSHOT.zip to 
/etc/puppet/environments/production/modules/wso2am/files/wso2am-2.0.0-SNAPSHOT.zip

10. Download and copy https://github.com/bhathiya/apim-puppet-scripts/tree/master/db_scripts directory to /opt/db_scripts

11. Unzip wso2am-2.0.0-SNAPSHOT.zip and copy wso2am-2.0.0-SNAPSHOT/dbscripts directory to /opt/db_scripts/dbscripts

12. Download and copy https://github.com/bhathiya/apim-puppet-scripts/tree/master/run_puppet.sh file to /opt/run_puppet.sh (Copy required private keys as well, to ssh to puppet agent nodes)

13. Open and update run_puppet.sh script as required, and set read/execution rights.

> chmod 755 
run_puppet.sh


2) Configure Puppet Agents 

Repeat these steps in each agent node.

1. Install Puppet.

> sudo su
> apt-get update
> apt-get install puppet


2. Change hostname in /etc/hostname to apim-node-1 (This might need a reboot)

3. Update /etc/hosts with puppet master's host entry.

192.168.57.92 puppet

4. Download and copy https://github.com/bhathiya/apim-puppet-scripts/tree/master/puppet-agents/setup.sh file to /opt/setup.sh

5. Set execution rights.

> chmod 755 
setup.sh 


6. Download and copy https://github.com/bhathiya/apim-puppet-scripts/tree/master/puppet-agents/deployment.conf file to /opt/deployment.conf (Edit this as required. For example, product_profile should be one of api-store, api-publisher, api-key-manager and gateway-manager)


3) Execute Database and Puppet Scripts

Go to /opt in puppet master and run ./run_puppet.sh (or you can run setup.sh in each agent node.)

If you have any questions, please post below.


References:
[1] https://github.com/wso2/puppet-modules/wiki/Use-WSO2-Puppet-Modules-in-puppet-master-agent-Environment
[2] https://github.com/wso2/puppet-modules/

2 comments:

  1. Bhathiya,

    it seems there is an error in the configured paths in script.sql file located in db_scripts folder. Paths configured as follows.

    use UM_DB;
    source /opt/dbscripts/mysql.sql;
    use GOV_REG_DB;
    source /opt/dbscripts/mysql.sql;
    use CONFIG_REG_DB;
    source /opt/dbscripts/mysql.sql;
    use AM_DB;
    source /opt/dbscripts/apimgt/mysql.sql;
    use WSO2MB_DB;
    source /opt/dbscripts/mb-store/mysql-mb.sql;

    But the actual paths should be as follows

    use UM_DB;
    source /opt/db_scripts/dbscripts/mysql.sql;
    use GOV_REG_DB;
    source /opt/db_scripts/dbscripts/mysql.sql;
    use CONFIG_REG_DB;
    source /opt/db_scripts/dbscripts/mysql.sql;
    use AM_DB;
    source /opt/db_scripts/dbscripts/mysql.sql;
    use WSO2MB_DB;
    source /opt/db_scripts/dbscripts/mb-store/mysql-mb.sql;

    Please correct it

    ReplyDelete
    Replies
    1. Hi Shammi,

      Thank you for pointing out. Fixed the error.

      Regards,
      Bhathiya

      Delete