heat_template_version: 2015-10-15

description: Simple template to deploy kuryr resources

parameters:
  image:
    type: string
    label: Image name or ID
    description: Image to be used for the kuryr nodes
    default: centos7
  flavor:
    type: string
    label: Flavor
    description: Flavor to be used for the masters
    default: m1.small
  worker_flavor:
    type: string
    label: Flavor
    description: Flavor to be used for the workers
    default: m1.small
  public_net:
    type: string
    description: public network for the instances
    default: public
  vm_net_cidr:
    type: string
    description: vm_net network address (CIDR notation)
    default: 10.11.0.0/24
  vm_net_gateway:
    type: string
    description: vm_net network gateway address
    default: 10.11.0.1
  node_num:
    type: number
    description: Number of VMs
    default: 1

resources:
  network:
    type: OS::Kuryr::DevstackNetworking
    properties:
      public_net: { get_param: public_net }
      vm_net_cidr: { get_param: vm_net_cidr }
      vm_net_gateway: { get_param: vm_net_gateway }

  master_key:
    type: OS::Nova::KeyPair
    properties:
      name: { get_param: 'OS::stack_name' }
      save_private_key: true

  nodes:
    type: OS::Heat::ResourceGroup
    properties:
      count: { get_param: node_num }
      resource_def:
        type: OS::Kuryr::DevstackNode
        properties:
          public_net: { get_param: public_net }
          image: { get_param: image }
          flavor: { get_param: flavor }
          key: { get_resource: master_key }
          private_key: { get_attr: [master_key, private_key] }
          public_key: { get_attr: [master_key, public_key] }
          vm_net: { get_attr: [network, vm_net_id] }
          vm_subnet: { get_attr: [network, vm_subnet_id] }
          k8s_api_sg: { get_attr: [network, k8s_api_sg_id] }
          name:
            str_replace:
              template: "__stack__/vm-%index%"
              params:
                __stack__: { get_param: 'OS::stack_name' }
          change_number: { get_param: 'OS::stack_name' }

outputs:
  node_fips:
    value: { get_attr: [nodes, node_fip] }
  vm_subnet:
    value: { get_attr: [network, vm_subnet_id] }
  k8s_api_sg:
    value: { get_attr: [network, k8s_api_sg_id] }
  master_key_pub:
    value: { get_attr: [master_key, public_key] }
  master_key_priv:
    value: { get_attr: [master_key, private_key] }
