Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a virtual image of an operating system. As you set up a PHP runtime here, Ubuntu is recommended.

  2. Execute the following commands on the VM instance:

    TaskCommand

    Login to the instance using SSH and get root access to the instance

    sudo su
    Install zip and unzip
    apt-get install zip unzip
    Create a new directory named bin in the home directory
    mkdir ~/bin
    Download the Save the config.sh  to in the ~/bin directory and make it executable. As this is a puppet-based configuration, the config.sh script is used to install the puppet agent to the instance. This puppet agent communicates with the puppet master and configures the required environment using puppet scripts. You configure the puppet master at the time the App Factory is installed. The config.sh script also configures the init.sh file to be executed automatically during the startup of the instance.
    chmod +x config.sh
    Download Save the   init.sh  to in the ~/bin directory and make it an executable. 

    This init.sh script,

    • Starts the puppet agent
    • The cartridge agent needs several parameters from the Amazon EC2 metadata service as payload to communicate with the Stratos manager in the App Factory. The metadata service is used for virtual machine instances to retrieve instance-specific data. It supports two sets of APIs: an OpenStack metadata API and an EC2-compatible API. Instances access the metadata service on http://169.254.169.254
      Downloads the launch parameters from the Amazon EC2 metadata service using the following command: wget http://169.254.169.254/latest/user-data -O /tmp/payload/launch-params. 

    • Configurs the host file of the instance with the required host entries
    • Downloads the cartridge agent from the puppet master in the App Factory
     
    chmod +x init.sh
    Download Save the stratos_sendinfo.rb file to in the ~/bin directory. 
    Create a directory named puppetinstall inside the ~/bin directory.mkdir ~/bin/puppetinstall
    Download Save the puppetinstall file to in ~/bin/puppetinstall/ and make it an executable.chmod +x ~/bin/puppetinstall/puppetinstall
    In the above script file, set the TIMEZONE value that matched the timezone set in the puppet master using the following command. In this case, we are setting the timezone to Etc/UTC.sed -i 's:^TIMEZONE=.*$:TIMEZONE=\"Etc/UTC\":g' ~/bin/puppetinstall/puppetinstall
    Create a directory named apache-stratos-cartridge-agent in /mnt/
    mkdir /mnt/apache-stratos-cartridge-agent/

    Download Save the cartridge-agent.sh file to  file in /mnt/apache-stratos-cartridge-agent/ and make it an executable. This script is used to configure and start the cartridge agent.

    chmod +x /mnt/apache-stratos-cartridge-agent/cartridge-agent.sh
    Execute the config.sh file using the following command:
    ~/bin/config.sh

    Provide the following details when prompted:

    Code Block
    This script will install and configure puppet agent, do you want to continue [y/N] y
    Please provide stratos service-name: php
    Please provide puppet master IP: <IP-Of-AppFactoryServer>
    Please provide puppet master hostname [puppet.test.org]: puppet.test.org
  3. In OpenStack, create a snapshot image of the runtime instance that you configured in the IaaS. Note that an ID is generated for the snapshot. We use that in step 5 below.

  4. Add this runtime configuration to the App Factory by saving it as an XML file in <AF_HOME>/repository/deployment/server/runtimes/. As hot deployment is enabled, it will be deployed automatically. 

    Code Block
    <Runtime>
        <Runtime>php</Runtime>
        <DeployerClassName>org.wso2.carbon.appfactory.jenkins.deploy.JenkinsArtifactDeployer</DeployerClassName>
        <PAASArtifactStorageURLPattern>{@stage}/as</PAASArtifactStorageURLPattern>
        <AliasPrefix>{@appName}</AliasPrefix>
        <CartridgeTypePrefix>php</CartridgeTypePrefix>
        <DeploymentPolicy>af-deployment</DeploymentPolicy>
        <AutoscalePolicy>economy</AutoscalePolicy>
        <SubscribeOnDeployment>true</SubscribeOnDeployment>
        <UndeployerClassName>org.wso2.carbon.appfactory.jenkins.deploy.JenkinsArtifactUndeployer</UndeployerClassName>
    </Runtime>

    The elements of the above configuration are described below:

    ElementDescriptionData typeDefault value
    <Runtime>Name of the runtime that you wish to addString 
    <DeployerClassName>The fully qualified class name of the application deployerStringDefault is org.wso2.carbon.appfactory.jenkins.deploy.JenkinsArtifactDeployer
    <PAASArtifactStorageURLPattern>

    The artifact storage URL where the application artifact is stored. The URL is resolved using the stage of the application in the runtime.

    {@stage}- resolves the current stage of the application (e.g., Development, Testing, Production etc.) as the runtime prefix.
    String

    <@stage>/as

    'as' stands for Application Server.
    <AliasPrefix>Prefix of the aliasString 
    <CartridgeTypePrefix>Prefix of the cartridge typeString 
    <DeploymentPolicy>Deployment policy used for subscriptionStringaf-deployment
    <AutoscalePolicy>Autoscale policy used for subscriptionStringeconomy
    <SubscribeOnDeployment>Whether subscription is required at the time of deployment or not.BooleanFalse
    <UndeployerClassName>Fully qualified class name of the application un-deployerString

    org.wso2.carbon.appfactory.deployers.

    JenkinsS tratosUndeployer

...