---
heat_template_version: 2013-05-23
description: "A simple template to boot a cluster of desktops (LoginNode, ManagementNodes and Desktop Nodes)"
# avz parameters disabled. they are working but I want just more options than monash-02. I would like to have a parameter that says "I don't care"
#This requires gc_secgroups to be called beforehand

parameters:
  ubuntu_1804_image_id:
    type: string
    label: Image ID
    description: Ubuntu Image
    default: 99d9449a-084f-4901-8bd8-c04aebd589ca
  centos_7_image_id:
    type: string
    label: Image ID
    description: Centos Image
    default: c47c3acb-9657-4243-9e14-e6c676157e3b #with NetworkManager
  rhel_77_image_id:
    type: string
    label: Image ID
    description: Rhel Image
    default: 19993115-ad60-4979-bdfb-67ae7a77e40c
  ssh_key:
    type: string
    default: gc_key
  avz:
    type: string
    default: monash-02
  project_name:
    type: string
  NetID:
    type: string
    default: Classic Provider
  Flavour:
    type: string
    default: m3.xsmall
  SlurmSecGroupID:
    type: string
    label: Resource ID
    default: 6e7a09b0-981c-424f-a9b7-9fd4f4d8f416
  NFSSecGroupID:
    type: string
    label: Resource ID
    default: b07a75a3-830c-4778-96c6-8a3732ec7d6c
  MySQLSecGroupID:
    type: string
    label: Resource ID
    default: 4478f245-de5c-4177-bcbd-6fa661032cbe
  SSHMonashSecGroupID:
    type: string
    label: Resource ID
    default: c15081f4-c756-4c57-b8cf-388dd7fdbcd4
  HTTPsSecGroupID:
    type: string
    label: Resource ID
    default: 2d4510c3-ae73-44ea-9700-b6f0a00bf7aa
  PublicSSHSecGroupID:
    type: string
    label: Resource ID
    default: 8a029c04-08ce-40f1-a705-d45a2077e27d
  LDAPSecGroupID:
    type: string
    label: Resource ID
    default: 070a32e2-858b-462a-b2b5-b3a92eec2669

resources:


  SQLNode0:
   type: "OS::Nova::Server"
   properties:
    name:
     list_join: [ '-', [ { get_param: "OS::stack_name" }, 'sql0' ]]
    availability_zone: { get_param: avz }
    flavor: m3.xsmall
    image: { get_param: centos_7_image_id }
    key_name: { get_param: ssh_key }
    security_groups: [ { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: MySQLSecGroupID }, { get_param: NFSSecGroupID }, { get_param: LDAPSecGroupID } ]
    metadata:
     ansible_host_groups: [ SQLNodes, NFSNodes, LDAPServer ]
     ansible_ssh_user: ec2-user
     project_name: { get_param: project_name }
    networks:
      - network: { get_param: NetID }

  NFSVolume:
   type: OS::Cinder::Volume
   properties:
    availability_zone: { get_param: avz }
    size: 1
    name: nfsvol
  NFSVolumeAttachment:
   type: "OS::Cinder::VolumeAttachment"
   properties:
    volume_id: { get_resource: NFSVolume }
    instance_uuid: { get_resource: SQLNode0 }

  SLURMSTATEVolume:
   type: OS::Cinder::Volume
   properties:
    availability_zone: { get_param: avz }
    size: 1
    name: slurmstate
  SLURMSTATEVolumeAttachment:
   type: "OS::Cinder::VolumeAttachment"
   properties:
    volume_id: { get_resource: SLURMSTATEVolume }
    instance_uuid: { get_resource: SQLNode0 }

  DBVolume:
   type: OS::Cinder::Volume
   properties:
    availability_zone: { get_param: avz }
    size: 10
    name: dbvol
  DBVolumeAttachment:
   type: "OS::Cinder::VolumeAttachment"
   properties:
    volume_id: { get_resource: DBVolume }
    instance_uuid: { get_resource: SQLNode0 }

  MgmtNodesCentos7:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 1
    resource_def:
      type: My::Server::MgmtNode
      properties:
        #avz: { get_param: avz }
        image: { get_param: centos_7_image_id }
        ansible_ssh_user: ec2-user
        mynodename:
         list_join: [ '-', [ { get_param: "OS::stack_name" }, 'mgmt%index%' ]]
        ssh_key: { get_param: ssh_key }
        security_groups: [ default, { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: MySQLSecGroupID } ]
        project_name: { get_param: project_name }

  MgmtNodesU:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 1
    resource_def:
      type: My::Server::MgmtNode
      properties:
        #avz: { get_param: avz }
        image: { get_param: ubuntu_1804_image_id }
        ansible_ssh_user: ubuntu
        mynodename:
         list_join: [ '-', [ { get_param: "OS::stack_name" }, 'mgmtU%index%' ]]
        ssh_key: { get_param: ssh_key }
        security_groups: [ default, { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: MySQLSecGroupID } ]
        project_name: { get_param: project_name }

  LoginNodesC:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 1
    resource_def:
     type: "OS::Nova::Server"
     properties:
      #availability_zone: { get_param: avz }
      flavor: m3.xsmall
      image: { get_param: centos_7_image_id }
      key_name: { get_param: ssh_key }
      name:
       list_join: [ '-', [ { get_param: "OS::stack_name" }, 'login%index%' ]]
      security_groups: [ default, { get_param: PublicSSHSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: LDAPSecGroupID } ]
      metadata:
       ansible_host_groups: [ LoginNodes ]
       ansible_ssh_user: ec2-user
       project_name: { get_param: project_name }
      networks:
       - network: { get_param: NetID }

  LoginNodesU:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 1
    resource_def:
     type: "OS::Nova::Server"
     properties:
      #availability_zone: { get_param: avz }
      flavor: m3.xsmall
      image: { get_param: ubuntu_1804_image_id }
      key_name: { get_param: ssh_key }
      name:
       list_join: [ '-', [ { get_param: "OS::stack_name" }, 'loginU%index%' ]]
      security_groups: [ default, { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: LDAPSecGroupID } ]
      metadata:
       ansible_host_groups: [ LoginNodes ]
       ansible_ssh_user: ubuntu
       project_name: { get_param: project_name }
      networks:
       - network: { get_param: NetID }

  DesktopNodes:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 0
    resource_def:
     type: "OS::Nova::Server"
     properties:
      #availability_zone: { get_param: avz }
      flavor: m3.xsmall
      image: { get_param: centos_7_image_id }
      key_name: { get_param: ssh_key }
      name:
       list_join: [ '-', [ { get_param: "OS::stack_name" }, 'desktopc%index%' ]]
      security_groups: [ default, { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: LDAPSecGroupID } ]
      metadata:
       ansible_host_groups: [ DesktopNodes, VisNodes, ComputeNodes ]
       ansible_ssh_user: ec2-user
       project_name: { get_param: project_name }
      networks:
       - network: { get_param: NetID }

  ComputeNodesU:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 0
    resource_def:
     type: "OS::Nova::Server"
     properties:
      #availability_zone: { get_param: avz }
      flavor: m3.xsmall
      image: { get_param: ubuntu_1804_image_id }
      key_name: { get_param: ssh_key }
      name:
       list_join: [ '-', [ { get_param: "OS::stack_name" }, 'computeU%index%' ]]
      security_groups: [ default, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: SSHMonashSecGroupID }, { get_param: LDAPSecGroupID } ]
      metadata:
       ansible_host_groups: [ ComputeNodes ]
       ansible_ssh_user: ubuntu
       project_name: { get_param: project_name }
      networks:
       - network: { get_param: NetID }

  ComputeNodesCentos7:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 1
    resource_def:
     type: "OS::Nova::Server"
     properties:
      #availability_zone: { get_param: avz }
      flavor: m3.xsmall
      image: { get_param: centos_7_image_id }
      key_name: { get_param: ssh_key }
      name:
       list_join: [ '-', [ { get_param: "OS::stack_name" }, 'computec7%index%' ]]
      security_groups: [ default, { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: LDAPSecGroupID } ]
      metadata:
       ansible_host_groups: [ ComputeNodes ]
       ansible_ssh_user: ec2-user
       project_name: { get_param: project_name }
      networks:
       - network: { get_param: NetID }

  UbuntuDesktopNodes:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 0
    resource_def:
     type: "OS::Nova::Server"
     properties:
      #availability_zone: { get_param: avz }
      flavor: mon.c10r35.gpu-k2
      image: { get_param: ubuntu_1804_image_id }
      key_name: { get_param: ssh_key }
      name:
       list_join: [ '-', [ { get_param: "OS::stack_name" }, 'gpudesktopu%index%' ]]
      security_groups: [ default, { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: LDAPSecGroupID } ]
      metadata:
       ansible_host_groups: [ DesktopNodes, GPU, ComputeNodes, VisNodes ]
       ansible_ssh_user: ubuntu
       project_name: { get_param: project_name }
      networks:
       - network: { get_param: NetID }

  CentosDesktopNodes:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 0
    resource_def:
     type: "OS::Nova::Server"
     properties:
      #availability_zone: { get_param: avz }
      flavor: mon.c10r35.gpu-k2
      image: { get_param: centos_7_image_id }
      key_name: { get_param: ssh_key }
      name:
       list_join: [ '-', [ { get_param: "OS::stack_name" }, 'gpudesktopc%index%' ]]
      security_groups: [ default, { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID } ]
      metadata:
       ansible_host_groups: [ DesktopNodes, GPU, ComputeNodes, K1, VisNodes ]
       ansible_ssh_user: ec2-user
       project_name: { get_param: project_name }
      networks:
       - network: { get_param: NetID }

  ComputeNodeRHEL:
   type: "OS::Heat::ResourceGroup"
   properties:
    count: 0
    resource_def:
     type: "OS::Nova::Server"
     properties:
      #availability_zone: { get_param: avz }
      flavor: m3.xsmall
      image: { get_param: rhel_77_image_id }
      key_name: { get_param: ssh_key }
      name:
       list_join: [ '-', [ { get_param: "OS::stack_name" }, 'computerhel%index%' ]]
      security_groups: [ default, { get_param: SSHMonashSecGroupID }, { get_param: SlurmSecGroupID }, { get_param: NFSSecGroupID }, { get_param: LDAPSecGroupID } ]
      metadata:
       ansible_host_groups: [ DGXRHELNodes ]
       ansible_ssh_user: cloud-user
       project_name: { get_param: project_name }
      networks:
       - network: { get_param: NetID }

#  PySSHauthz:
#   type: "OS::Nova::Server"
#   properties:
#    name:
#     list_join: [ '-', [ { get_param: "OS::stack_name" }, 'pysshautz' ]]
#    availability_zone: { get_param: avz }
#    flavor: m3.xsmall
#    image: { get_param: ubuntu_1804_image_id }
#    key_name: { get_param: ssh_key }
#    security_groups: [ { get_resource_id SSHMonashSecGroup }, { get_resource_id webaccess }, { get_param: LDAPSecGroupID } ]
#    metadata:
#     ansible_host_groups: [ PySSHauthz ]
#     ansible_ssh_user: ubuntu
#     project_name: { get_param: project_name }
#    networks:
#      - network: { get_param: NetID }