2. Cloudify - My First Blueprint

Cloudify supports many major cloud service providers, like AWS, Azure, and Google Cloud. With Cloudify, you can graphically design and deploy cloud applications automatically. Besides, relying on TOSCA, Cloudify is (almost) cloud-independent. Summarizing, Cloudify addresses the automation (automatic deployment), portability (no vendor lock-in) and interoperability (reuse common components) aspects of complex cloud applications.

In this tutorial, we will use the Cloudify Community edition to deploy an Hello World server locally on your computer through the Cloudify Command Line Interface (CLI).

Table of Contents:


Prerequisites

  • Cloudify CLI installed on your computer.
  • Your computer’s firewall should allow HTTP connections on port 8000.

Note: This tutorial is tested with Cloudify 5.0.0

Warm Up

  • Open a terminal, clone and enter in the Hello World example Cloudify Github repository.
git clone https://github.com/cloudify-examples/local-simple-python-webserver-blueprint.git
cd local-simple-python-webserver-blueprint
  • Before installing the webserver, let’s have a look at the blueprint.yaml file. The blueprint contains the topology of the cloud application. In this blueprint, there is a single node of type cloudify.nodes.WebServer. The blueprint describes the webserver_port input, that is the port on which the web server will listen to for connections. The default value is 8000. We notice that the http_web_server node has a property (the port) and two interfaces, create and delete (you can learn more on interfaces here). These interfaces are associated with two python scripts that actually install and uninstall the web server.
tosca_definitions_version: cloudify_dsl_1_3

imports:
  - http://www.getcloudify.org/spec/cloudify/4.3/types.yaml

inputs:

  webserver_port:
    description: >
            The HTTP web server port.
    default: 8000

node_templates:

  http_web_server:
    type: cloudify.nodes.WebServer
    properties:
      port: { get_input: webserver_port }
    interfaces:
      cloudify.interfaces.lifecycle:
        create:
          implementation: install.py
          executor: central_deployment_agent
        delete:
          implementation: uninstall.py
          executor: central_deployment_agent

Deploy

  • To install the blueprint and deploy the web server, run the code below. Beside other tasks, this will execute the install.py script and run the Hello World web server on your machine.
cfy install blueprint.yaml
  • To check that the web server is actually online, open your browser to http://localhost:8000. You should see something similar to the image below.

HelloWorld

Uninstall

  • To uninstall the blueprint and tear down the webserver, run the code below. Beside other tasks, this will execute the uninstall.py script.
cfy uninstall -b local-simple-python-webserver-blueprint

Conclusion

This is the introductory tutorial for familiarizing with the basic concepts of Cloudify. In next tutorials, we will see how to interact with an actual cloud service provider (i.e. AWS) and learn how to use Cloudify graphical interface.

Troubleshooting

  1. when installing the blueprint I get an error: [Errno 2] No such file or directory: '/opt/manager/resources/blueprints/None/local-simple-python-webserver-blueprint'

This is because the original install.py script does not actually create the directory. To solve this, either create the directory yourself or (recommended) modify the install.py file and remove the related os.chdir instruction.

  1. localhost:8000 returns a directory listing instead of the index.html file

This is because the python SimpleHTTPServer does not find the index.html file. The server looks for the file in the directory where it was launched (i.e. where you typed the ctx install blueprint.yaml command). Make sure you typed the installation command in the same directory where the index.html file is.

Last modified: 17 December 2019