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 :
Key Manager:

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 ; apt-get update && sudo apt-get -y install ntp ; service ntp restart
> cd /tmp
> wget
> 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. puppet

4. Download and copy 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 to 

10. Download and copy directory to /opt/db_scripts

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

12. Download and copy file to /opt/ (Copy required private keys as well, to ssh to puppet agent nodes)

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

> chmod 755

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. puppet

4. Download and copy file to /opt/

5. Set execution rights.

> chmod 755 

6. Download and copy 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 ./ (or you can run in each agent node.)

If you have any questions, please post below.



  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

    1. Hi Shammi,

      Thank you for pointing out. Fixed the error.