DocsPipelines for ApplicationsServers
Provisioning servers automatically

Provisioning servers automatically

Sections

You can create provisioning applications in Pipelines to simplify repetitive tasks. These provisioning applications can be used when spinning up new servers to install prerequisites, or on existing servers.

Provision script

For this example, lets take a look at an install of Node Version Manager (nvm).

You can find more information on nvm here.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash

Note: The above syntax expects that curl and bash are already installed. Also realize that using nodejs and npm via nvm may have other requirements like “build essentials.” The install for these could be accomodated in this script, or in their own.

The above commands should be placed into the Install: section of a distelli-manifest.yml.

DISTELLI_USERNAME/DISTELLI_APPNAME:
  Env:
    NVM_VERSION: "v.0.31.7"
  Install:
    - curl -o- "https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh" | bash

Replace the following fields:

Create the application

You can create a repository for this application and add it to Pipelines, or you can use the Pipelines CLI to create this application in Pipelines.

Create Pipelines app from repository

  1. Create a repository for the distelli-manifest.yml in one of the many software repositories that Pipelines supports. Give this repository a name like this:

    provision_linux_nvm

  2. Create an application in Pipelines from that repository

  3. Afterward, skip ahead to the Create the environment step.

Create Pipelines app with the Pipelines CLI

You can create an application in Pipelines without a repository by using the Pipelines CLI. To do so, follow these steps:

  1. On the computer where the above distelli-manifest.yml file exists, install the Pipelines CLI
  2. From the directory where the distelli-manifest.yml sits, execute a
    distelli create DISTELLI_USERNAME/DISTELLI_APPNAME
    command to create the application in Pipelines.</li>

Remember to replace the above DISTELLI_ values.

  1. From the directory where the distelli-manifest.yml sits, execute a
    distelli push
    command to push the first release of the application.

Create the environment

Now that you have the application in Pipelines and you should have a release created. This release would have either been from a build of your repository, or created in the Pipelines CLI push.

  1. In the Pipelines web UI, navigate to your application.
  2. Click the Create Environment link on the right.
  3. Name your environment provision_linux_nvm.
  4. Create Env
  5. Click Create

By default, the option Automatically deploy the active release when a new server joins this environment is enabled. To validate this, navigate to the new environment’s Settings page.

validate settings

Deploy the release

This section is called Deploy the Release, but it is really about setting the Active Release in an environment.

The active release of an environment is set a couple ways. A successful deploy of a release to an environment will make that release the environments active release.

The other way of setting the active release is to use the Pipelines API call SetEnvActiveRelease.

  1. Navigate to your application in Pipelines.
  2. In the App Pipeline click the Add Step button.
  3. From Select Environment for Step, select the environment you just created, provision_linux_nvm
  4. Setup pipeline for deploy
  5. Click the Add button.
  6. Click (check) the Auto Deploy option that has appeared.
  7. Click the Hammer Build Application icon at the top right to build a release.
  8. Build active release
  9. Finally, click the Build button in the Control Room.

Great. Pipelines will now build your application. In this case, you’ll receive the message “Nothing to build”. After a successful build, a release will be created. Pipelines will automatically deploy this newly created release to the environment provision_linux_nvm.

There are currently 0 of 0 servers and the deploy of 0 will succeed, thus setting the active release of this environment to the newly created release. You are ready to provision servers with this.

Realize, in the future, if you want to update your provisioning script, update the Pipelines manifest, and re-push your code.

Provision a server

To provision a server, add the server to the environment provision_linux_nvm. When adding a server to this environment, you will be prompted if you would like to deploy the active release. If “yes” this will run the deploy steps of the distelli-manifest.yml on the server.

If you use Pipelines to provision cloud instances (i.e. AWS, GCE) you can instruct the instance to join the environment provision_linux_nvm. This is where the earlier noted option Automatically deploy the active release when a new Server joins this environment comes into play. As the server joins the environment, it will request the active release and run the deploy steps.

Select env for provision

Realize, that if you choose multiple provisioning scripts (environments to join), Pipelines will have the server/instance join all the environments and deploy each ones active release, thus providing multiple provisionings. This is done sequentially.

Select env for provision

In the example above, you can see that the following environments have been chosen:

  • provision_linux_nvm
  • Provision_ubuntu14_java8
  • provision_ubuntu14_tomcat
  • provision_ubuntu14_docker

This means the instance will come up, install the Pipelines agent, the agent will connect back to Pipelines, join each environment in sucession, and deploy each environments active release.

Examples

Now that you understand how to setup provisioning scripts in Pipelines, here are a handful of examples:

How helpful was this page?
Puppet sites use proprietary and third-party cookies. By using our sites, you agree to our cookie policy.