how pass the bash script's parameter into heat template.

Asked by Jeffrey Guan

Dear all,

Could you please help to let know how to pass the bash script's parameter into heat template? Thank you very much.

I'd like to show an example to make my question more clear.

Suppose I have two heat templates. test.env.yaml and test.hot.yaml.

[root@vm1 ~]#cat test.env.yaml
parameters:

.....
       zoneB_net0_ip: "192.168.1.1"

.....

[root@vm1 ~]#cat test.hot.yaml

heat_template_version: '2014-10-16'
parameters:
     _user_data_script: {"#!/bin/bash
          IPV6_ADDR_POSTFIX=`echo ${ipv6_addr} | grep \"/\" | cut '/' -d -f2`
          echo ${IPV6_ADDR_POSTFIX}
          exit 0

resources:
    test_group1:
     type: OS::Nova::Server
     properties:
          .....
          user_data:
                str_replace:
                     template: {get_param: _user_data_script_}

                      params:
                           $ipv6_addr: {get_param: zoneB_net0_ip}

My question is:
how to pass the result of the command
`echo ${ipv6_addr} | grep \"/\" | cut '/' -d -f2`
to the bash script in the heat template?
I tried to echo the IPV6_ADDR_POSTFIX in the bash script. When check the user_data.txt in the VM and found that IPV6_ADDR_POSTFIX is not replaced by the result of the command: `echo ${ipv6_addr} | grep \"/\" | cut '/' -d -f2`

Thanks,

Question information

Language:
English Edit question
Status:
Solved
For:
Heat Templates Edit question
Assignee:
No assignee Edit question
Solved by:
Jeffrey Guan
Solved:
Last query:
Last reply:
Revision history for this message
Jeffrey Guan (double12gzh) said :
#1

Solved. Grammar error.

need to add the \ and ". See below.

 echo \"${IPV6_ADDR_POSTFIX}\"

[root@vm1 ~]#cat test.hot.yaml

heat_template_version: '2014-10-16'
parameters:
     _user_data_script: {"#!/bin/bash
          IPV6_ADDR_POSTFIX=`echo ${ipv6_addr} | grep \"/\" | cut '/' -d -f2`
          echo \"${IPV6_ADDR_POSTFIX}\"
          exit 0