ben schwartz
ben schwartz

Reputation: 2589

How can I populate a heat template in OpenStack with `user_data` without including the script inline?

I.e. I want my template to look something like:

...
resources:
  server1:
    type: OS::Nova::Server
    properties:
      name: Server1
      image: { get_param: image }
      flavor: { get_param: flavor }
      user_data: ?????
...

and I want the contents of user_data to be stored in a separate file.

How can I accomplish this?

Upvotes: 1

Views: 4803

Answers (1)

James Polley
James Polley

Reputation: 8181

I believe that's what get_file is for. From the doc:

The example below demonstrates get_file usage with both relative and absolute URLs.

resources:
  my_instance:
    type: OS::Nova::Server
    properties:
      # general properties ...
      user_data:
        get_file: my_instance_user_data.sh
  my_other_instance:
    type: OS::Nova::Server
    properties:
      # general properties ...
      user_data:
        get_file: http://example.com/my_other_instance_user_data.sh

If this template was launched from a local file this would result in a files dictionary containing entries with keys file:///path/to/my_instance_user_data.sh and http://example.com/my_other_instance_user_data.sh.

Upvotes: 2

Related Questions