heat_template_version: 2013-05-23

description: sample

parameters:
  floating_id:
    type: string
    description: ID reseau public
    default: 77e7bded-b920-41c0-91b6-579c4a8e6b32

  internal_cidr:
    type: string
    description: CIDR for the internal net
    default: "10.42.42.0/24"

  key_name:
    type: string
    description: SSH key to deploy in instances
    default: mgaigniere

  image:
    type: string
    description: Glance image to use
    default: "CentOS7"

  flavor:
    type: string
    description: Flavor to use
    default: m1.large


resources:
  internal_net:
    type: OS::Neutron::Net

  internal_snet:
    type: OS::Neutron::Subnet
    properties:
      cidr: { get_param: internal_cidr }
      network_id: { get_resource: internal_net }

  router:
    type: OS::Neutron::Router
    properties:
      external_gateway_info:
        enable_snat: true
        network: { get_param: floating_id }

  router_interface:
    type: OS::Neutron::RouterInterface
    properties:
      router_id: { get_resource: router }
      subnet_id: { get_resource: internal_snet }


#########################################
# CONTROLLER
#########################################

  port_controller:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: internal_net }
      security_groups:
        - openbar
      fixed_ips:
        - { ip_address: "10.42.42.20" }

  floating_ip_controller:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network_id: { get_param: floating_id }
      port_id: { get_resource: port_controller }

  controller:
    type: OS::Nova::Server
    depends_on: [router_interface]
    properties:
      image: { get_param: image }
      flavor: { get_param: flavor }
      key_name: { get_param: key_name }
      networks:
        - port: { get_resource: port_controller }


#########################################
# COMPUTE
#########################################

  port_compute:
    type: OS::Neutron::Port
    properties:
      network: { get_resource: internal_net }
      security_groups:
        - openbar
      fixed_ips:
        - { ip_address: "10.42.42.22" }

  floating_ip_compute:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network_id: { get_param: floating_id }
      port_id: { get_resource: port_compute }

  compute:
    type: OS::Nova::Server
    depends_on: [router_interface]
    properties:
      image: { get_param: image }
      flavor: { get_param: flavor }
      key_name: { get_param: key_name }
      networks:
        - port: { get_resource: port_compute }

  volume_compute:
    type: OS::Cinder::Volume
    properties:
      name: volume_compute
      size: 5

  volume_compute_attachment:
    type: OS::Cinder::VolumeAttachment
    properties:
      volume_id: { get_resource: volume_compute }
      instance_uuid: { get_resource: compute }
      mountpoint: /dev/vdb
