chef-cli icon indicating copy to clipboard operation
chef-cli copied to clipboard

When using include_policy with no run_list, 'run_list cannot be empty' emitted

Open PeterGrace opened this issue 7 years ago • 4 comments

Description

When using include_policy in a Policyfile, if you follow a pattern of using a single Policyfile to define multiple actions via include_policies without specifying run_list, the Policyfile generation will fail with

Reason: (ChefDK::PolicyfileError) Invalid run_list. run_list cannot be empty

However, it would stand to reason that if you are including policies into your Policyfile, that the parser should take the run_lists from those included policies into account before claiming there's no run_list.

ChefDK Version

Chef Development Kit Version: 3.0.36
chef-client version: 14.1.12
delivery version: master (7206afaf4cf29a17d2144bb39c55b7212cfafcc7)
berks version: 7.0.2
kitchen version: 1.21.2
inspec version: 2.1.72

Platform Version

CentOS 7

Replication Case

  • Create a policy (A) that has a run_list
  • Create a policy (B) that includes policy A, but has no run_list in the Policyfile.
  • Execute chef install Policyfile.rb on Policy B
  • You will receive Reason: (ChefDK::PolicyfileError) Invalid run_list. run_list cannot be empty

Stacktrace

Error: Failed to generate Policyfile.lock
Reason: (ChefDK::PolicyfileError) Invalid run_list. run_list cannot be empty


/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.0.36/lib/chef-dk/policyfile_compiler.rb:88:in `error!'
/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.0.36/lib/chef-dk/policyfile_services/install.rb:93:in `generate_lock_and_install'
/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.0.36/lib/chef-dk/policyfile_services/install.rb:62:in `run'
/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.0.36/lib/chef-dk/command/install.rb:78:in `run'
/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.0.36/lib/chef-dk/command/base.rb:58:in `run_with_default_options'
/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.0.36/lib/chef-dk/cli.rb:73:in `run'
/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-dk-3.0.36/bin/chef:25:in `<top (required)>'
/opt/chefdk/bin/chef:270:in `load'
/opt/chefdk/bin/chef:270:in `<main>'

PeterGrace avatar Jul 03 '18 20:07 PeterGrace

Moved this to the chef-cli repo and triaged it. I added the Needs Information tag because I want to go repro this with the latest version of Chef Workstation, but I have a feeling it is still an issue.

Thanks @PeterGrace for the report! I agree with your logic about the run-list not being empty even though thats what the error complains about.

tyler-ball avatar Sep 30 '19 20:09 tyler-ball

Is there a workaround other than adding a random item that is in the inherited run_list anyway?

mrmarbury avatar Oct 30 '19 13:10 mrmarbury

This is being worked in the chef/chef repo itself

tas50 avatar Feb 11 '20 03:02 tas50

This is being worked in the chef/chef repo itself

Would you provide a link to the issue you're referencing?

YAMLcase avatar Apr 22 '21 23:04 YAMLcase