【问题标题】:Chef template variables syntax error, unexpected '}', expecting keyword_end厨师模板变量语法错误,意外'}',期待keyword_end
【发布时间】:2019-09-02 21:43:53
【问题描述】:

对于我的以下食谱:

    template '/etc/filebeat/filebeat.yml' do
      source 'filebeat.yml.erb'
      owner 'root'
      group 'root'
      mode '0600'
      variables(
            stack_name: stack_name, 
            instance_ip: instance_ip
            )
    end

我收到以下错误:

    Chef::Mixin::Template::TemplateError
    ------------------------------------
    (erubis):74: syntax error, unexpected '}', expecting keyword_end

    Resource Declaration:
    ---------------------
    # In /var/chef/runs/8f9aa33c-6b69-419d-8a02-5668701a228a/local-mode-cache/cache/cookbooks/filebeat/recipes/filebeat.rb

    28: template '/etc/filebeat/filebeat.yml' do
    29:   source 'filebeat.yml.erb'
    30:   owner 'root'
    31:   group 'root'
    32:   mode '0600'
    33:   variables(
    34:         stack_name: stack_name, 
    35:         instance_ip: instance_ip
    36:         )
    37: end
    38: 

    Compiled Resource:
    ------------------
    # Declared in /var/chef/runs/44a77122-2816-4f89-97c4-9cbff0bbdfcb/local-mode-cache/cache/cookbooks/-filebeat/recipes/filebeat.rb:28:in `from_file'

    template("/etc/filebeat/filebeat.yml") do
    action [:create]
    retries 0
    retry_delay 2
    default_guard_interpreter :default
    source "filebeat.yml.erb"
    variables {:stack_name=>"fsdfsd", :instance_ip=>"172.31.63.242"}
    declared_type :template
    cookbook_name "filebeat"
    recipe_name "filebeat"
    owner "root"
    group "root"
    mode "0600"
    path "/etc/filebeat/filebeat.yml"

end

我做错了什么?

【问题讨论】:

    标签: ruby chef-infra


    【解决方案1】:

    我认为错误在您的模板文件中,例如filebeat.yml.erb

    我假设的原因是基于(erubis):74: syntax error, unexpected '}', expecting keyword_end - erubis 是厨师使用的快速 eRuby 兼容模板引擎(“erb”)。所以错误源于解析/渲染模板文件,而不是厨师特定的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-12
      • 1970-01-01
      • 1970-01-01
      • 2015-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多