Ask Your Question
0

How to pass parameter value to runcmd in OS::Heat::CloudConfig resource.

asked 2017-03-01 22:57:58 -0500

joon gravatar image

I'd like to pass string type value read from environment file as an argument to runcmd in OS::Heat::CloudConfig. Below is parameter definition.

  oam_stat_routes:
    type: string
    label: oam_stat_routes
    description: List of static route destination on OAM side in CIDR notation.

Below is the CloudConfig definition with runcmd. What I want to do is to pass the value of oam_stat_routes to shell script command /usr/local/bin/set_route as an argument. Wonder if this is possible.

  dns_network:                   
    type: OS::Heat::CloudConfig 
    properties:
      cloud_config:
        runcmd:
           - /usr/local/bin/set_route oam_stat_routes
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2017-03-02 15:04:54 -0500

zaneb gravatar image

Easy:

dns_network:
  type: OS::Heat::CloudConfig
  properties:
    cloud_config:
      runcmd:
        - str_replace:
            template: /usr/local/bin/set_route %oam_stat_routes%
            parameters:
              "%oam_stat_routes%": {get_param: oam_stat_routes}
edit flag offensive delete link more

Comments

Thanks a lot, Zaneb. Let me try that.

Wonder if I can use the same statements with oam_stat_routes as comma delimited list type.

joon gravatar imagejoon ( 2017-03-02 16:08:21 -0500 )edit
0

answered 2017-03-03 15:18:23 -0500

joon gravatar image

updated 2017-03-03 15:20:35 -0500

With below Heat statements under runcmd:

  - str_replace:
    template: dns-statroute-eth0.sh %eth0_gateway% %oam_stat_routes%
    parameters:
      "%eth0_gateway%": { get_param: dns_oam_gateway }
      "%oam_stat_routes%": { get_param: oam_stat_routes }

The VM was launched but the intended command failed to be executed. Here is the related content in /var/lib/cloud/instances/58acd270-3622-48cf-96ef-9ff73d579693/user-data.txt file. Seems the parameter replacement didn't happen.

#cloud-config
runcmd:
- parameters: {'%eth0_gateway%': 192.168.183.97, '%oam_stat_routes%': 192.168.0.0/16  192.168.127.0/24 }
  str_replace: null
  template: dns-statroute-eth0.sh %eth0_gateway% %oam_stat_routes%
edit flag offensive delete link more

Comments

Your indentation is incorrect. In JSON terms, you have {"str_replace": null, "parameters": {...}, "template": ...} instead of {"str_replace": {"parameters": {...}, "template": ...}}.

zaneb gravatar imagezaneb ( 2017-03-06 08:22:05 -0500 )edit

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: 2017-03-01 22:57:58 -0500

Seen: 1,480 times

Last updated: Mar 03 '17