Ask Your Question
0

Post-Creation to HOT template

asked 2015-06-15 13:08:18 -0500

anonymous user

Anonymous

I can create an openstack Instance and use the Post-Creation steps to have the ability to login to my image after instance creation

   #cloud-config
                   password: mysecret
                   chpasswd: { expire: False }
                   ssh_pwauth: True

However I am trying to create a HOT autoscaling template using the same information. I am not having much success. It seems that the stack creation fails every time with a very log error

(this is the information for the autoscaling template)

server_group:
    type: OS::Heat::AutoScalingGroup
    properties:
      min_size: 1
      max_size: 3
      resource:
        type: OS::Nova::Server
        properties:
          flavor: {get_param: flavor}
          image: {get_param: image}
          key_name: {get_param: key}
          networks:
          - network: { get_param: network }
          metadata: {"metering.stack": {get_param: "OS::stack_id"}}
          user_data:
          str_replace: 
          template: |
               #cloud-config
               password: mysecret
               chpasswd: { expire: False }
               ssh_pwauth: True

The error is as follows:

Error: ERROR: u'u\'"str_replace" syntax should be str_replace:\\n template: This is var1 template var2\\n params:\\n var1: a\\n var2: string\'\nTraceback (most recent call last):\n\n File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 134, in _dispatch_and_reply\n incoming.message))\n\n File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 177, in _dispatch\n return self._do_dispatch(endpoint, method, ctxt, args)\n\n File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 123, in _do_dispatch\n result = getattr(endpoint, method)(ctxt, **new_args)\n\n File "/opt/stack/heat/heat/engine/service.py", line 69, in wrapped\n return func(self, ctx, *args, **kwargs)\n\n File "/opt/stack/heat/heat/engine/service.py", line 646, in create_stack\n owner_id)\n\n File "/opt/stack/heat/heat/engine/service.py", line 569, in _parse_template_and_validate_stack\n stack.validate()\n\n File "/opt/stack/heat/heat/engine/stack.py", line 449, in validate\n dup_names = set(self.parameters.keys()) & set(self.keys())\n\n File "/usr/lib/python2.7/_abcoll.py", line 391, in keys\n return list(self)\n\n File "/opt/stack/heat/heat/engine/stack.py", line 346, in __iter__\n return iter(self.resources)\n\n File "/opt/stack/heat/heat/engine/stack.py", line 158, in resources\n self.t.resource_definitions(self).items())\n\n File "/opt/stack/heat/heat/engine/hot/template.py", line 241, in resource_definitions\n for name, data in resources.items())\n\n File "/opt/stack/heat/heat/engine/hot/template.py", line 241, in <genexpr>\n for name, data in resources.items())\n\n File "/opt/stack/heat/heat/engine/hot/template.py", line 181, in rsrc_defn_item\n data = self.parse(stack, snippet)\n\n File "/opt/stack/heat/heat/engine/template.py", line 179, in parse\n return parse(self.functions, stack, snippet)\n\n File "/opt/stack/heat/heat/engine/template.py", line 221, in parse\n return dict((k, recurse(v)) for k, v in six.iteritems(snippet))\n\n File "/opt/stack/heat/heat/engine/template.py", line 221, in <genexpr>\n return dict((k, recurse(v)) for k, v in six.iteritems(snippet))\n\n ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-07-20 13:27:13 -0500

JD Hallen gravatar image

Ok, a couple of things I see here. 1) Your 'str-replace' lines needs to be indented, since its the "value" part of str-replace'. 2) Your 'template:' line and below that also needs to be indented. It should look like this:

user_data:
    str_replace: 
        template: |
            # code goes here...

3) The lines underneath the 'template: |' line are meant to be executed as a shell script...at least that is what I have seen in examples on the web. You have a YAML format, so that's going to cause errors I would guess.

When you get errors like this, be sure that check your heat-api.log file, as the error could be coming from the heat client trying to send in the stack-create command plus parameters via the api, and errors are happening there. I get this error also for one of my templates, and checking the heat-api.log file shows that its actually a "'str_replace' parameters must be a mapping" error (I have no 'params', and I suspect that is causing the issue.) Try running the heat stack-create with the '--debug' option to at least get a better debug output to go from.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2015-06-15 13:08:18 -0500

Seen: 1,034 times

Last updated: Jul 20 '15