Heat template to load-balance a web stack

Here is a heat template to create a web stack.  This template will create a resource group of 3 web servers (you must have a web server image, mine is named webv2), a load-balancing pool with an internal VIP and finally, a floating IP pointing to this VIP for external access.

* Note that this heat template assumes that you only have one private network. You will have to specify which subnet you want to use if you have more than one. You should create your public network under “services” project as an external network. This way, your internal network will be the default one if you only have one.

heat_template_version: 2015-04-30

description: |   
  Heat template provisioning a stack a web servers,
  a load-balancer and a floating IP mapped to the 
  load-balacing VIP.

parameters:
  image:
    type: string
    label: image
    description: Image name
    default: webv2
  flavor:
    type: string
    label: flavor
    description: Flavor name
    default: m1.tiny

resources:
  web_nodes:
    type: OS::Heat::ResourceGroup
    properties:
      count: 3
      resource_def:
        type: OS::Nova::Server
        properties:
          image: { get_param: image }
          flavor: { get_param: flavor }
          security_groups:
          - default
          - web
  pool:
    type: OS::Neutron::Pool
    properties:
      name: mypool1
      protocol: HTTP
      lb_method: ROUND_ROBIN
      subnet: web 
      vip: {"protocol_port": 80}
  lb:
    type: OS::Neutron::LoadBalancer
    properties:
      members: { get_attr: [web_nodes, refs] }
      pool_id: { get_resource: pool }
      protocol_port: 80
  floatingip:
    type: OS::Neutron::FloatingIP
    properties:
      fixed_ip_address: { get_attr: [pool, vip, address] }
      floating_network: public
      port_id: { get_attr: [pool, vip, port_id] }

outputs:
  FloatingIP:
    description: Service public VIP
    value: { get_attr: [floatingip, floating_ip_address] }
  VIP:
    description: Internal VIP
    value: { get_attr: [pool, vip, address] }