Puppet 无法将hiera中的哈希解析为erb模板

Puppet 无法将hiera中的哈希解析为erb模板,puppet,hiera,Puppet,Hiera,我有一个木偶清单,看起来像这样: $webapp_list = lookup('webapps', Hash, 'hash') $webapp_list.each | $app_name, $app_info| { $app_port = $app_info[port] $app_description = $app_info[description] $app_settings = [ $app_info[settings] ] <% @app_settings.each

我有一个木偶清单,看起来像这样:

$webapp_list = lookup('webapps', Hash, 'hash')
$webapp_list.each | $app_name, $app_info| {
  $app_port = $app_info[port]
  $app_description = $app_info[description]
  $app_settings = [ $app_info[settings] ]
<% @app_settings.each do |settingKey, settingValue| -%>
  export <%= settingKey -%>='<%= settingValue -%>'
<% end %>
export FLASK_APP=appname.py
export MAIL_USERNAME=email@example.com
export MAIL_PASSWORD=<extra strong password>
export {"FLASK_APP"=>"appname.py", "MAIL_USERNAME"=>"email@example.com", "MAIL_PASSWORD"=>"<extra strong password>"}=''
和hiera代码:

webapps:
    webapp-template:
            port: 5001
            description: "Webapp Description"
            live: false
            settings:
                    FLASK_APP: appname.py
                    MAIL_USERNAME: email@example.com
                    MAIL_PASSWORD: <extra strong password>
或生成如下所示的文件:

$webapp_list = lookup('webapps', Hash, 'hash')
$webapp_list.each | $app_name, $app_info| {
  $app_port = $app_info[port]
  $app_description = $app_info[description]
  $app_settings = [ $app_info[settings] ]
<% @app_settings.each do |settingKey, settingValue| -%>
  export <%= settingKey -%>='<%= settingValue -%>'
<% end %>
export FLASK_APP=appname.py
export MAIL_USERNAME=email@example.com
export MAIL_PASSWORD=<extra strong password>
export {"FLASK_APP"=>"appname.py", "MAIL_USERNAME"=>"email@example.com", "MAIL_PASSWORD"=>"<extra strong password>"}=''
export{“FLASK\u APP”=>“appname.py”,“MAIL\u USERNAME”=>“email@example.com“,”邮件密码“=>”}=''

我知道答案在某种程度上与我如何处理数组和散列有关,解决方案就在眼前,但我目前对我的下一步行动一无所知。

我找到了解决方案。这主要是因为我的yaml文件中有其他没有“设置”部分的Web应用程序,这导致了它的崩溃。我的最终代码可以在下面看到

希拉:

webapps:
    webapp-template:
        port: 5001
        description: "Webapp Description"
        live: false
        settings:
            FLASK_APP: appname.py
            MAIL_USERNAME: email@example.com
            MAIL_PASSWORD: <extra strong password>
Settings.conf.erb:

<% @app_settings.each do |key,value| -%>
  export <%= key %>='<%= value %>'
<% end -%>

导出=“”