Completed TemplateΒΆ

Here is the full completed template. You can download it at this link docker_apache_server.yaml.

####################################################################################################################################################
# This sample deploys a Docker single server stack with an Apache Web Server.
####################################################################################################################################################
#
# This sample is intended for demonstrating the Blueprint function. It is not intended for "production" use and is unsupported.
# Use it at your own risk.
#
# Note: This Blueprint launches servers from public Ubuntu machine images. You should verify that the machine images still exist before launching.
#
# Refer to the Dell Cloud Manager Blueprint Designer Guide for more details.
# http://blueprint-designer-guide.enstratius.com/tutorials/docker/tutorial1/overview.html
#
####################################################################################################################################################
template_name: "Docker Apache Server on Linux"
template_author: "Gary Forghetti"
template_version: "1.00"
description: "Docker single server stack with an Apache Web Server."
long_description: "Deploys a Docker single server stack with an Apache Web Server."

imports:
  - base_types.yaml                                                   # Import the DCM base type definitions that are referenced in this template

topology_template:

  inputs:                                                             # Define the inputs
    ################################################################################################################################################
    # This defines the AccountRegionSelector which allows the user to select the Cloud, Region and Datacenter
    ################################################################################################################################################
    account_region_zone_selector:                                     # Define the section for the Cloud, Region and Datacenter selection boxes
      type: dcm.inputs.AccountRegionSelector                          # Input type is dcm.inputs.accountRegionSelector
      properties:
        regions:                                                      # Define the Cloud and Regions
          "Amazon":                                                   # Amazon
            "us-east-1": [ ]                                          # All data centers for the us-east-1 region
            "us-west-1": ["us-west-1a", "us-west-1c"]
            "us-west-2": ["us-west-2a", "us-west-2b", "us-west-2c"]
            "eu-west-1": ["eu-west-1a", "eu-west-1c"]
          "Azure":                                                    # Azure
            "East US": ["East US"]
          "DigitalOcean":                                             # Digital Ocean
            "nyc1": ["nyc1"]
          "Google":                                                   # Google
            "us-east1": ["us-east1-b"]
            "us-central1": ["us-central1-a"]
          "Joyent":                                                   # Joyent
            "us-east-1": ["us-east-1a"]

    ################################################################################################################################################
    # This defines the Product selector which allows the user to select the server product size
    ################################################################################################################################################
    product_selector:                                                 # Define the product selector so the user can select the cloud and region
      type: dcm.inputs.Product                                        # Input type is dcm.inputs.Product
      properties:
        accountRegionSelector: account_region_zone_selector           # This connects the AccountRegionSelector to the Product selector
        platform: UNIX                                                # Virtual machine images are Linux
        architecture: I64                                             # 64 bit images
        productMappings:
          "Amazon":                                                   # Amazon cloud
            "us-east-1":                                              # us-east-1 Region
              image: "ami-c4edc0d3"                                   # Machine image identifier for an Ubuntu image in this region
              products: ['t1.micro', 'm1.small', 'm1.medium']         # The virtual machine product sizes for this region
            "us-west-1":                                              # us-west-1 Region
              image: "ami-e7035687"                                   # Machine image identifier for an Ubuntu image in this region
              products: ['t1.micro', 'm1.small', 'm1.medium']         # The virtual machine product sizes for this region
            "us-west-2":                                              # us-west-2 Region
              image: "ami-578c2f37"                                   # Machine image identifier for an Ubuntu image in this region
              products: ['t1.micro', 'm1.small', 'm1.medium']         # The virtual machine product sizes for this region
            "eu-west-1":                                              # eu-west-1 Region
              image: "ami-e6a1f795"                                   # Machine image identifier for an Ubuntu image in this region
              products: ['t1.micro', 'm1.small', 'm1.medium']         # The virtual machine product sizes for this region

          "Azure":                                                    # Azure cloud
            "East US":                                                # East US Region
              # Machine image identifier in this region
              image: "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_4-LTS-amd64-server-20160406-en-us-30GB"
              products: ['Basic_A1', 'Medium', 'Standard_D1']         # The virtual machine product sizes for this region

          "DigitalOcean":                                             # DigitalOcean Cloud
            "nyc1":                                                   # New York City 1 region
              image: "18173769"                                       # Machine image identifier for an Ubuntu image in this region
              products: ['1gb', '4gb', '8gb']                         # The virtual machine product sizes for this region

          "Google":                                                   # Google cloud
            "us-east1":                                               # us-east1 Region
              image: "ubuntu-os-cloud_ubuntu-1404-trusty-v20160516"   # Machine image identifier for an Ubuntu image in this region
              products: ['g1-small', 'n1-standard-4', 'n1-highmem-4'] # The virtual machine product sizes for this region
            "us-central1":                                            # us-central1 Region
              image: "ubuntu-os-cloud_ubuntu-1404-trusty-v20160516"   # Machine image identifier for an Ubuntu image in this region
              products: ['g1-small', 'n1-standard-4', 'n1-highmem-4'] # The virtual machine product sizes for this region

          "Joyent":                                                   # Joyent cloud
            "us-east-1":                                              # us-east-1 Region
              image: "c864f104-624c-43d2-835e-b49a39709b6b"           # Machine image identifier for an Ubuntu image in this region
              products: ['Medium 4GB', 'Large 8GB']                   # The virtual machine product sizes for this region

  ##################################################################################################################################################
  # This defines the two outputs to appear on the DCM console Stack overview page (IP address and URL of the Docker Server)
  ##################################################################################################################################################
  outputs:                                                        # Define outputs

    application_group:                                            # Create a Group
      type: dcm.outputs.DisplayGroup                              # It's a displayGroup
      properties:
        displayName: "Apache Web Server Information"              # Set the display name for the group containing the outputs which appears on the Stack Overview page

    link:                                                         # Define an output
      type: dcm.outputs.Uri                                       # It's a URI output
      value: http://xxxxxxxxxxxxx                                 # Set the initial value
      properties:
        host: {get_attribute: [docker_vm, publicIpAddress]}       # Set the hostname/ipaddress of the URI to the public IP address of the server running in the stack
        displayName: Apache Server URL                            # Set the display name (label) for the string output
        displayGroup: application_group                           # Place this output in the displayGroup named application_group

    tutorial_group:                                               # Create a Group
      type: dcm.outputs.DisplayGroup                              # It's a displayGroup
      properties:
        displayName: "Blueprint Designer Guide"                   # Set the display name for the group

    tutorial_link:                                                # Define an output
      type: dcm.outputs.Uri                                       # It's a URI output
      value: "http://blueprint-designer-guide.enstratius.com/tutorials/docker/tutorial1/overview.html"
      properties:
        displayName: "Tutorial Link:"                             # Set the display name (label) for the URI output
        displayGroup: tutorial_group                              # Place this output in the displayGroup named application_group

  node_templates:

    ##################################################################################################################################################
    # This node_template defines a Docker application which will launch a container to run the apache docker image
    ##################################################################################################################################################
    docker_app:
      type: dcm.nodes.DockerApp                                   # This is a DockerApp node
      properties:
        image: 'gforghetti/apache'                                # Launch an image from the Docker user repository gforghetti/apache
        tag: 'latest'                                             # Launch the latest image in that user repository
        ports: [80]                                               # Expose port 80 (the container will use the http port 80)
        portBindings:
          80: [['0.0.0.0', 80]]                                   # Bind port 80 on the container to port 80 on the launched server from any incoming connection

      requirements:
        - host: docker_vm                                         # This DockerApp node has a requirement on the docker_vm node (launched server)

    ##################################################################################################################################################
    # This node_template defines a virtual machine named "docker_vm" which will host the Apache Web Server
    ##################################################################################################################################################
    docker_vm:
      type: dcm.nodes.Server                                                     # This is a Server node
      properties:
        name: "apache-server"
        cloud: { get_input: [account_region_zone_selector, cloud] }              # Retrieve cloud from the AccountRegionSelector
        cloudAccountId: { get_input: [account_region_zone_selector, accountId] } # Retrieve the cloud account ID from the AccountRegionSelector
        region: { get_input: [account_region_zone_selector, region] }            # Retrieve region from the AccountRegionSelector
        zone: { get_input: [account_region_zone_selector, zone] }                # Retrieve zone from the AccountRegionSelector
        platform: { get_input: [product_selector, platform] }                    # Retrieve platform from the Product selector
        architecture: { get_input: [product_selector, architecture] }            # Retrieve architecture from the Product selector
        product: { get_input: [product_selector, product] }                      # Retrieve product from the Product selector
        image: { get_input: [product_selector, image] }                          # Retrieve machine from the Product selector
        serverProductId: { get_input: [product_selector, serverProductId] }      # Retrieve server product id from the Product selector

        startupScript:  |                                                    # Startup script with commands to install the DCM Agent and Docker
            #!/bin/bash
            ##########################################################################################################################################
            # Install curl on Debian/Ubuntu if necessary
            ##########################################################################################################################################
            which apt-get && apt-get update -qq && (which curl || apt-get install curl -y)

            ##########################################################################################################################################
            # Install curl on RHEL/CentOS if necessary
            ##########################################################################################################################################
            which yum && yum -q makecache && (which curl || yum install curl -y)

            ##########################################################################################################################################
            # Install the Dell Cloud Manager agent and Docker
            # The -Z argument configures the Dell Cloud Manager agent and allows it to accept unknown certificates.
            # This is only recommended for testing and should not be done in a production environment.
            ##########################################################################################################################################
            export DCM_URL=${dcm.callback.url}
            curl -L --retry 10 https://linux-stable-agent.enstratius.com/agent_docker-1.0.0-1.sh | bash -s - -Z

            ##########################################################################################################################################
            # Create iptables rule to open http port 80 and save it
            ##########################################################################################################################################
            iptables -I INPUT -p tcp --dport 80 -j ACCEPT
            iptables-save

      requirements:                                                   # This virtual machine node has a requirement on a firewall
        - firewall: vm_firewall_rules                                 # The firewall statement is named "vm_firewall_rules"
          relationship_type: tosca.relationships.DependsOn

    ###################################################################################################################################################
    # This node_template defines a firewall which opens the Tomcat HTTP port 8080 for the Docker server
    ###################################################################################################################################################
    vm_firewall_rules:
      type: dcm.nodes.FirewallGroup                                              # This is a firewall
      properties:                                                                # Retrieve the cloud properties from the "inputs"
        name: "fw-docker-server"                                                 # Define a name for the firewall (it will get prefixed with the stack name)
        cloud: { get_input: [account_region_zone_selector, cloud] }              # Retrieve the cloud from the AccountRegionSelector
        cloudAccountId: { get_input: [account_region_zone_selector, accountId] } # Retrieve the cloud account ID from the AccountRegionSelector
        region: { get_input: [account_region_zone_selector, region] }            # Retrieve the region from the AccountRegionSelector
        zone: { get_input: [account_region_zone_selector, zone] }                # Retrieve the zone from the AccountRegionSelector
        rules:
          - remote_ip_prefix: 0.0.0.0/0
            port: 80                                                             # Define a rule to open port 8080  (HTTP for Tomcat)