Quickstart

In this kick-start document, we will write blueprint for minimalistic web server using built-in mock server type.

Preprequisites

First, we will assume that we have Cloudify Manager installed and configured. If this is not the case, consult official documentation on how to bootstrap the manager.

Writing blueprint

Let us now write a simple blueprint that can be used to deploy minimalistic web server that will serve static web page. First thing we need to do is define tosca_definitions_version and import plugins that we will be using.

tosca_definitions_version: cloudify_dsl_1_3

imports:
  - http://dice-project.github.io/DICE-Deployment-Cloudify/spec/openstack/0.2.1/plugin.yaml

All blueprints need the imports section - this is where basic type definitions are found. Since we are preparing blueprint for OpenStack, we included OpenStack plugin that will make sure we can create new virtual machines. If you wish to deploy to FCO, simply replace openstack in URL with fco.

Next section of the blueprint specifies actually topology of our application. In our example, topology is simple and consists of:

  • single virtual machine to host web server (vm),
  • actual web server (server),
  • virtual ip that allows us to access virtual machine from outside and
  • firewall that protects the whole thing.

All of the predefined types have all of their properties set to sane default values, which makes it easy to start writing blueprints. In our case, we only need to list all four nodes that are present in deployment and connect them using relationships.

node_templates:
  virtual_ip:
    type: dice.VirtualIP

  firewall:
    type: dice.firewall_rules.mock.WebServer

  vm:
    type: dice.hosts.ubuntu.Small
    relationships:
      - type: dice.relationships.ProtectedBy
        target: firewall
      - type: dice.relationships.IPAvailableFrom
        target: virtual_ip

  server:
    type: dice.components.mock.WebServer
    relationships:
      - type: dice.relationships.ContainedIn
        target: vm

And that is basically all that we need to write. Complete blueprints (with some additional stuff that is not directly relevant to our goal of getting something up and running) are available in examples folder for OpenStack and FCO platforms.

Last thing before we can attempt to deploy our server is to prepare some inputs. TOSCA types that are defined by this library require some configuration in order to be able to use them on various platforms. There are input files present in example folder that should server as a reference and starting point.

Deploying our server is now as simple as

cfy blueprint upload -p hello-openstack.yaml -b hello
cfy deployments create -b hello -d hello -i inputs.openstack
cfy executions start -w install -d hello -l

After a couple of minutes, we should have our server up. Tearing it down is again simple. Executing

cfy executions start -w uninstall -d hello -l
cfy deployments delete -d hello
cfy blueprints delete -b hello

And that is basically all there is to creating and deploying simple static web server. For more examples visit Github repo with examples.