Ask Your Question
0

Using local environment variables in heat template

asked 2015-04-15 04:45:36 -0600

ccowley gravatar image

I want to create an instance that can hit the same API endpoints as I am using create my stack. These endpoints could vary from usage to usage, but they will always be the same as the ones I use to create the instance. As a result I would like to automatically put my credentials (OS_AUTH_URL etc) into my template to inject them into the instance via cloud-init.

How can I do something like:

Parameters :
  os_auth_url :
    default: env[OS_AUTH_URL]
  os_username :
    default: env[OS_AUTH_URL]


Resources :
…
      user_data:
        str_replace:
          "%os_auth_url%": {get_param: os_auth_url }
          "%os_username%": {get_param: os_username }

        template: |
          #cloud-config
          write_files:
          - content: |
              export OS_AUTH_URL=%os_auth_url%
              export OS_USERNAME=%os_username%
            path: /home/cloud/authcreds.rc

At the moment, my solution is to create a template.in that I then pass through sed to create my actual template. Is there a way I can do this natively in Heat?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2015-08-05 19:38:15 -0600

asalkeld gravatar image

Remember that the template is used in the cloud (so there is no access to your env).

A different way to do this is:

heat stack-create -f template.yaml -P "os_auth_url=$OS_AUTH_URL;os_username=$OS_AUTH_URL"
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-04-15 04:42:42 -0600

Seen: 1,441 times

Last updated: Aug 05 '15