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.
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:
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 a repository for the distelli-manifest.yml in one of the many software repositories that Pipelines supports. Give this repository a name like this:
Afterward, skip ahead to the Create the environment step.
You can create an application in Pipelines without a repository by using the Pipelines CLI. To do so, follow these steps:
distelli create DISTELLI_USERNAME/DISTELLI_APPNAME
Remember to replace the above DISTELLI_ values.
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.
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.
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.
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.
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.
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.
In the example above, you can see that the following environments have been chosen:
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.
Now that you understand how to setup provisioning scripts in Pipelines, here are a handful of examples: