Ask Your Question
0

[Heat] cloud-init and colon+space

asked 2018-02-20 10:57:04 -0600

doka.ua gravatar image

updated 2018-02-20 10:58:02 -0600

Hi colleagues,

I'm using the following way to pass cloud-init info into VM:

  n2:
    type: OS::Nova::Server
    properties:
     [ ... ]
      user_data_format: SOFTWARE_CONFIG
      user_data:
          str_replace:
            template: { get_file: CI-v17.yaml }
            params:
              NTFY: { get_attr: ['wait_handle', 'curl_cli'] }

where CI-v17.yaml is the following:

#cloud-config

[ ... ]
timezone: Europe/Kiev
runcmd:
  - NTFY --data-binary '{"status": "SUCCESS"}'
[ ... ]

Unfortunatelty, NTFY expands to something that contains YAML control sequence ": " (colon+space e.g. X-Auth-Token: 'something') which leads to parsing error.

Is there any way to escape this sequence with something that will prevent YAML parsing error? Note that I want to use external file to store cloud-init config since I use it for multiple VMs.

Try to use

  n2-ci:
    type: OS::Heat::CloudConfig
    properties:
      cloud_config:
        str_replace:
          template: { get_file: CI-v17.yaml }
          params:
            NTFY: { get_attr: ['wait_handle', 'curl_cli'] }

  n2:
    type: OS::Nova::Server
    properties:
     [ ... ]
      user_data_format: SOFTWARE_CONFIG
      user_data: { get_resource: n2-ci }

leads to the following Heat error:

ERROR: Property error: : resources.n2-ci.properties.cloud_config: : "#cloud-config [ ... ]" is not a map

I will appreciate any ideas on how to work around this issue.

Thank you.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2018-02-20 15:55:45 -0600

doka.ua gravatar image

Quote it and backslash nested quotes:

runcmd:
  - "NTFY --data-binary '{\"status\": \"SUCCESS\"}'"
edit flag offensive delete link more
0

answered 2018-09-06 17:25:51 -0600

I've found that OS::Heat::CloudConfig does not like accepting data from str_replace, it always gives that is not a map error. I think it's how str_replace returns data, probably a literal string, when OS::Heat::CloudConfig is expecting yaml(or a map as it says).

This works for me(using your code as an example):

  n2-ci:
    type: OS::Heat::CloudConfig
    properties:
      cloud_config:
        runcmd:
          - str_replace:
              template: "NTFY --data-binary '{\"status\": \"SUCCESS\"}'"
                params:
                  NTFY: { get_attr: ['wait_handle', 'curl_cli'] }
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: 2018-02-20 10:57:04 -0600

Seen: 174 times

Last updated: Feb 20 '18