Creating a cartridge for Apache Stratos

Posted: April 11, 2014 in Uncategorized
Apache Stratos is a polyglot PaaS framework, providing developers a cloud-based environment for developing, testing, and running scalable applications. You can plug any service such as PHP, Tomcat, Ruby, MySQL, etc. as a cartridge at runtime. This tutorial will give you a step-by-step approach on how to create a PHP cartridge. We use OpenStack as the underlying Infrastructure as a Service (IaaS). The steps are similar in other IaaSs, such as Amazon EC2.


Before creating the cartridge, puppet master has to be configured by using the following link; Apache Stratos Puppet Master setup guide

Live terminal recording of configuring a puppet master can be found through the link; live terminal recording of setting up

Let’s assume, the puppet master was configured with the values,



Creating the cartridge to Stratos

  1. Create an ubuntu VM in Openstack
  • Select the image with the OS and click Launch


  • This will lead to a popup window called Launch instance where the Flavor has to be selected


  • Choose a key pair


2 .Log in to the machine created via SSH

ssh -i udara.pem ubuntu@


3. Install unzip

sudo apt-get install unzip

This step is carried out to extract the Stratos Cartridge Agent before installing the Cartridge Agent


4. Create the configuration script in the path; /root/bin/ with the content copied from this configuration file.

vim /root/bin/

Copy the content.

Make the script executable

chmod +x /root/bin/

This script installs the service you want (PHP in this case) and install and start the Puppet agent. Then puppet agent connects to puppet master and installs the other required software such as Apache2, PHP, Java and Stratos cartridge agent, etc.


5. Create the init script in /root/bin/ with the content at this init script.

Copy and paste the content.

Make the script executable

chmod +x /root/bin/init.s


6. Create the puppet-install script in /root/bin/puppetinstall/puppetinstall with the content at this script.

vim /root/bin/puppetinstall/puppetinstall

Copy and paste the content

Make the script executable

chmod +x /root/bin/puppetinstall/puppetinstall


7. Create the configuration file /root/bin/stratos_sendinfo.rb with the content of stratos_sendinfo.rb

8. Now execute the

cd /root/bin



For the questions prompt in this step should be answered with the following values;

Since we are going to make a PHP cartridge


As we set up the puppet master in the machine which has the IP address of192.168.18.134

puppet master IP=

As we setup the puppet master with the hostname

puppet master hostname =

root@udara-cartridge:~/bin# ./

This script will install and configure puppet agent, do you want to continue [y/n]y

–2014-04-01 04:04:52–

Connecting to… connected.

HTTP request sent, awaiting response… 404 Not Found

2014-04-01 04:04:52 ERROR 404: Not Found.

Please provide stratos service-name:php

Please provide puppet master IP:

Please provide puppet master hostname []

      This process may take some time. You may have to wait, till the process complete.

A log similar to below will be seen, once the above process is completed.

Info: Creating state file /var/lib/puppet/state/state.yaml

Notice: Finished catalog run in 2367.76 seconds.


9.Create the Snapshot

Now the machine is ready to become a cartridge. Required software is installed and configurations have been completed.


Click on Create Snapshot button




Save snapshot with a preferred name


Snapshot is waiting to be created



When the snapshot creation is completed, click on the snapshot to find details about it. The most important information is the ID of the image (snapshot).

When a PHP runtime is required, the user has to subscribe to a PHP cartridge in Stratos. When a PHP cartridge is subscribed, behind the scene, Stratos creates an instance from the image ID retrieved earlier. Since PHP is already installed and configured at the snapshot creating stage, PHP runtime will be available when Stratos spawn an instance from that snapshot.


Deploy the cartridge JSON in Stratos

Below is the cartridge JSON which is need to be deployed in Stratos. It is notable that the image ID is same as the snapshot ID, created above.

     "type": "php",
     "provider": "apache",
     "host": "",
     "displayName": "PHP",
     "description": "PHP Cartridge",
     "version": "5.0",
     "multiTenant": "false",
     "portMapping": [
           "protocol": "http",
           "port": "80",
           "proxyPort": "8280"
           "protocol": "https",
           "port": "443",
           "proxyPort": "8243"
     "deployment": {
      "iaasProvider": [
         "type": "openstack",
         "imageId": "RegionOne/ac859fc9-d0dc-4f4fb084-bada02ad5129",
         "maxInstanceLimit": "5",
         "property": [
            "name": "instanceType",
            "value": "RegionOne/4"
            "name": "keyPair",
            "value": "stratos-s4"
Please refer to the cartridge deployment guide of Stratosfor more information.
  1. dungdb says:

    Dear Udara,
    I have just done installing Apache statos. But when i subcribe to cartridge, my code from gitbub can’t get to my VM instance (PHP cartridge). What is wrong? Can you help me, pls?

    • Hi,

      Log in to the instance and check the puppet logs first at /tmp/puppet. If puppet agent has executed successfully Stratos cartridge agent should start running. Stratos agent is the software which runs inside the cartridge instance which bridge the instances and Stratos. cartridge agent get a clone from the repository you provided at the time of subscription. Check the agent logs at /var/logs/apache-stratos. If your github code is not cloned in to the instance, there should be a error log in cartridge agent.

  2. dungdb says:

    Dear Udara,
    When i check the puppet logs at /tmp/puppet_log, i saw an error:

    Removing all existing certificates ..
    Node Id 331425081415..

    * Restarting puppet agent
    Rather than invoking init scripts through /etc/init.d, use the service(8)
    utility, e.g. service hostname start

    Since the script you are attempting to invoke has been converted to an
    Upstart job, you may also use the start(8) utility, e.g. start hostname
    Exiting; failed to retrieve certificate and waitforcert is disabled
    Initialization completed successfully.

    And, i check /var/log/ forder, i don’t saw apache-stratos forder.
    Pls tell me how to fix this?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s