Hi,
So, I'm testing something out just to get a better understanding of how attributes work in chef. I'm trying to put a pre-defined attribute into my template in the form of a variable.
Here is my attribute file:
default['myname'] = 'Spiderman'
Here is my recipe file:
template '/root/name.txt' do
source 'testtemp.erb'
variables( name: node['myname'] )
end
And here is my template:
My name = <%= @name %>
When I try to apply the recipe, it gives me this error:
Recipe: (chef-apply cookbook)::(chef-apply recipe)
-
template[/root/name.txt] action create
================================================================================
Error executing actioncreate
on resource 'template[/root/name.txt]'NoMethodError
undefined method `preferred_filename_on_disk_location' for nil:NilClass
Resource Declaration:
In testrecipe.rb
7: template '/root/name.txt' do
8: source 'testtemp.erb'
9: variables( name: node['myname'] )
10: endCompiled Resource:
Declared in testrecipe.rb:7:in `run_chef_recipe'
template("/root/name.txt") do
action [:create]
default_guard_interpreter :default
source "testtemp.erb"
declared_type :template
cookbook_name "(chef-apply cookbook)"
recipe_name "(chef-apply recipe)"
variables {:name=>nil}
path "/root/name.txt"
owner nil
group nil
mode nil
verifications
endSystem Info:
chef_version=14.10.9
platform=ubuntu
platform_version=18.04
ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
program_name=/usr/bin/chef-apply
executable=/opt/chefdk/bin/chef-apply
[2019-05-13T11:43:59-03:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2019-05-13T11:43:59-03:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-05-13T11:43:59-03:00] FATAL: NoMethodError: template[/root/name.txt] ((chef-apply cookbook)::(chef-apply recipe) line 7) had an error: NoMethodError: undefined method `preferred_filename_on_disk_location' for nil:NilClass
I just want to know what the error message means specifically, and potentially how to fix this.
Thanks in advance.