sadaf2605
sadaf2605

Reputation: 7540

Chef template variables syntax error, unexpected '}', expecting keyword_end

For my following recipe:

    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

I am getting following error:

    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

What am I doing wrong?

Upvotes: 0

Views: 524

Answers (1)

Roland
Roland

Reputation: 1426

I think the error is in your template file, e.g. filebeat.yml.erb

The reason for my assumption is based on (erubis):74: syntax error, unexpected '}', expecting keyword_end - erubis is a fast eRuby-compatible template engine ("erb") used by chef. So the error origins from parsing/rendering the template file, not a chef specific issue.

Upvotes: 1

Related Questions