openstackprivate-keyopenstack-heat

openstack heat doesn't recognize key_name parameter


hy

i have an openstack deployed on my laptop. i'm trying to create a stack with heat.

i have created a keypair openstack keypair create heat_key > heat_key.priv which is recognized by nova nova keypair-list give the following output :

+----------+------+-------------------------------------------------+
| Name     | Type | Fingerprint                                     |
+----------+------+-------------------------------------------------+
| heat_key | ssh  | 0b:7a:36:20:e2:e3:19:3b:ab:a1:95:ac:67:41:67:d7 |
+----------+------+-------------------------------------------------+

this is my simple HOT template :

heat_template_version: 2013-05-23

description: Hot Template to deploy a single server

parameters:
  image_id:
    type: string
    description: Image ID
  key_name:
    type: string
    description: name of keypair to enable ssh to the instance

resources:
  test_stack:
    type: OS::Nova::Server
    properties:
      name: "test_stack"
      image: { get_param: image_id }
      flavor: "ds1G"
      key_name:{ get_param: key_name }

outputs:
  test_stack_ip:
    description: IP of the server
    value: { get_attr: [ test_stack, first_address ] }

when i try to create the stack

openstack stack create -t myTemp.hot --parameter key_name=heat_key --parameter image_id=trusty-server-cloudimg-amd64-disk1 test_stack

i get the following error

ERROR: Property error: : resources.test_stack.properties: : Unknown Property key_name:{ get_param

i have tried with different versions of templates but i get the same error

any idea why this is happening?


Solution

  • WORST part about the YAML file is, it is SPACE sensitive, so we need to be really careful while editing or copying conetent of HEAT templete. There is no space between "key_name" and "{" which is why it is failing.

    key_name:{ get_param: key_pair_name }

    Just put an extra space between these and it will work. I tested it :-)

    key_name: { get_param: key_pair_name }