chef / chef/chef-cli

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

Open
#39 4 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Triage: Confirmed Triage: Needs Information Type: Bug
Dominant language
Ruby
Stars
18
Forks
23
Avg merge
5d 17h
Merged PRs (30d)
1

Description

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>'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the case with chef install Policyfile.rb, then trace the failure from lib/chef-dk/policyfile_compiler.rb:88 through lib/chef-dk/policyfile_services/install.rb. Compare a policy with a run_list against an including policy without one. Done means the including policy uses the included run_lists without emitting “run_list cannot be empty,” with regression coverage for the replication case.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.