Skip to content

Instantly share code, notes, and snippets.

@drrk
Created July 22, 2019 09:36
Show Gist options
  • Save drrk/9497a038d7c7a8f77a226d164bcd2ee9 to your computer and use it in GitHub Desktop.
Save drrk/9497a038d7c7a8f77a226d164bcd2ee9 to your computer and use it in GitHub Desktop.
[chef@ip-172-31-58-233 ~]$ chef generate repo chef-repo
Generating Chef Infra repo chef-repo
- Ensuring correct Chef Infra repo file content
[2019-07-22T09:22:01+00:00] WARN: Found a directory chef-repo in the cookbook path, but it contains no cookbook files. skipping.
================================================================================
Error executing action `create_if_missing` on resource 'template[/home/chef/chef-repo/LICENSE]'
================================================================================
NoMethodError
-------------
undefined method `metadata' for nil:NilClass
Resource Declaration:
---------------------
# In /home/chef/code_generator/recipes/repo.rb
12: template "#{repo_dir}/LICENSE" do
13: source "LICENSE.#{context.license}.erb"
14: helpers(ChefDK::Generator::TemplateHelper)
15: action :create_if_missing
16: end
17:
Compiled Resource:
------------------
# Declared in /home/chef/code_generator/recipes/repo.rb:12:in `from_file'
template("/home/chef/chef-repo/LICENSE") do
action [:create_if_missing]
default_guard_interpreter :default
source "LICENSE.all_rights.erb"
helper_modules [ChefDK::Generator::TemplateHelper]
declared_type :template
cookbook_name :code_generator
recipe_name "repo"
path "/home/chef/chef-repo/LICENSE"
owner nil
group nil
mode nil
verifications []
variables {}
end
System Info:
------------
chef_version=15.1.36
ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
program_name=/opt/chef-workstation/bin/chef
executable=/opt/chef-workstation/bin/chef
Traceback (most recent call last):
33: from /opt/chef-workstation/bin/chef:343:in `<main>'
32: from /opt/chef-workstation/bin/chef:343:in `load'
31: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/bin/chef:25:in `<top (required)>'
30: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/cli.rb:74:in `run'
29: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/base.rb:63:in `run_with_default_options'
28: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/generate.rb:89:in `run'
27: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/generator_commands/repo.rb:77:in `run'
26: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/chef_runner.rb:43:in `converge'
25: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:97:in `converge'
24: from /opt/chef-workstation/embedded/lib/ruby/2.6.0/forwardable.rb:230:in `execute_each_resource'
23: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
22: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
21: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
20: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
19: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
18: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
17: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:99:in `block in converge'
16: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:99:in `each'
15: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:99:in `block (2 levels) in converge'
14: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:70:in `run_action'
13: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource.rb:584:in `run_action'
12: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider.rb:177:in `run_action'
11: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider/template.rb:41:in `define_resource_requirements'
10: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/mixin/why_run.rb:309:in `assert'
9: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider/template.rb:43:in `block in define_resource_requirements'
8: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider/template/content.rb:32:in `template_location'
7: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider/template_finder.rb:40:in `find'
6: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_version.rb:276:in `preferred_filename_on_disk_location'
5: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook/file_system_file_vendor.rb:50:in `get_filename'
4: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook/file_system_file_vendor.rb:43:in `cookbooks'
3: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:76:in `load_cookbooks'
2: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:76:in `each_key'
1: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:77:in `block in load_cookbooks'
/opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:99:in `load_cookbook': undefined method `metadata' for nil:NilClass (NoMethodError)
33: from /opt/chef-workstation/bin/chef:343:in `<main>'
32: from /opt/chef-workstation/bin/chef:343:in `load'
31: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/bin/chef:25:in `<top (required)>'
30: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/cli.rb:74:in `run'
29: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/base.rb:63:in `run_with_default_options'
28: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/generate.rb:89:in `run'
27: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/generator_commands/repo.rb:77:in `run'
26: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/chef_runner.rb:43:in `converge'
25: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:97:in `converge'
24: from /opt/chef-workstation/embedded/lib/ruby/2.6.0/forwardable.rb:230:in `execute_each_resource'
23: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
22: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
21: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
20: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
19: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
18: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
17: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:99:in `block in converge'
16: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:99:in `each'
15: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:99:in `block (2 levels) in converge'
14: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/runner.rb:70:in `run_action'
13: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/resource.rb:584:in `run_action'
12: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider.rb:177:in `run_action'
11: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider/template.rb:41:in `define_resource_requirements'
10: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/mixin/why_run.rb:309:in `assert'
9: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider/template.rb:43:in `block in define_resource_requirements'
8: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider/template/content.rb:32:in `template_location'
7: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/provider/template_finder.rb:40:in `find'
6: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_version.rb:276:in `preferred_filename_on_disk_location'
5: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook/file_system_file_vendor.rb:50:in `get_filename'
4: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook/file_system_file_vendor.rb:43:in `cookbooks'
3: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:76:in `load_cookbooks'
2: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:76:in `each_key'
1: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:77:in `block in load_cookbooks'
/opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:99:in `load_cookbook': template[/home/chef/chef-repo/LICENSE] (code_generator::repo line 12) had an error: NoMethodError: undefined method `metadata' for nil:NilClass (NoMethodError)
8: from /opt/chef-workstation/bin/chef:343:in `<main>'
7: from /opt/chef-workstation/bin/chef:343:in `load'
6: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/bin/chef:25:in `<top (required)>'
5: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/cli.rb:74:in `run'
4: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/base.rb:63:in `run_with_default_options'
3: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/generate.rb:89:in `run'
2: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/command/generator_commands/repo.rb:77:in `run'
1: from /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/chef_runner.rb:41:in `converge'
/opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-dk-4.2.0/lib/chef-dk/chef_runner.rb:48:in `rescue in converge': Chef Infra failed to converge: template[/home/chef/chef-repo/LICENSE] (code_generator::repo line 12) had an error: NoMethodError: undefined method `metadata' for nil:NilClass from file /opt/chef-workstation/embedded/lib/ruby/gems/2.6.0/gems/chef-15.1.36/lib/chef/cookbook_loader.rb:99:in `load_cookbook' (ChefDK::ChefConvergeError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment