Chef Error: NoMethodError: undefined method `preferred_filename_on_disk_location’ for nil:NilClass


[2022-11-22T07:43:11+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2022-11-22T07:43:11+00:00] FATAL: ---------------------------------------------------------------------------------------
[2022-11-22T07:43:11+00:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT
[2022-11-22T07:43:11+00:00] FATAL: ---------------------------------------------------------------------------------------
[2022-11-22T07:43:11+00:00] FATAL: NoMethodError: template[/var/www/html/index.html] ((chef-apply cookbook)::(chef-apply recipe) line 3) had an error: NoMethodError: undefined method `preferred_filename_on_disk_location' for nil:NilClass
[root@ip-172-31-11-246 template]# ls /opt/chef-workstation/bin/chef-apply

Solution



It seems like chef-apply is not able to run the template resource properly (see https://tickets.opscode.com/browse/CHEF-5317). As a better approach to run your recipes, you should use chef-solo