【问题标题】:Using Heat template parameter value in bash script在 bash 脚本中使用 Heat 模板参数值
【发布时间】:2015-08-03 21:32:04
【问题描述】:

在 Heat 模板的 bash 脚本中,是否可以使用该模板中的参数值?

【问题讨论】:

    标签: bash templates openstack heat devstack


    【解决方案1】:

    是的,根据Heat Orchestration Template specification,您可以使用str_replace 函数完成此操作。他们给出了一个使用str_replaceget_param 在bash 脚本中使用参数值DBRootPassword 的示例:

    parameters:
      DBRootPassword:
        type: string
        label: Database Password
        description: Root password for MySQL
        hidden: true
    
    resources:
      my_instance:
        type: OS::Nova::Server
        properties:
          # general properties ...
          user_data:
            str_replace:
              template: |
                #!/bin/bash
                echo "Hello world"
                echo "Setting MySQL root password"
                mysqladmin -u root password $db_rootpassword
                # do more things ...
              params:
                $db_rootpassword: { get_param: DBRootPassword }
    

    params 中的每个键都在 template 中替换为其值。由于$db_rootpassword 的值被设置为get_param 的结果,这意味着参数被传递到使用$db_rootpassword 的bash 脚本中。

    【讨论】:

      猜你喜欢
      • 2018-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-05
      • 2015-10-04
      • 2013-08-02
      • 2015-03-21
      相关资源
      最近更新 更多