chef / chef/chef-cli

Chef Generate ignores config.rb options placed in credentials file

Open
#190 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Version:

Chef Workstation version: 21.8.555
Chef Infra Client version: 17.3.48
Chef InSpec version: 4.38.9
Chef CLI version: 5.4.1
Chef Habitat version: 1.6.351
Test Kitchen version: 3.0.0
Cookstyle version: 7.15.4

Environment:

Confirmed on Ubuntu and Fedora

Scenario:

The docs seem to imply the credentials file is the new way of doing things: https://docs.chef.io/workstation/knife_setup

"Previous Chef Infra setups recommended setting up knife with a config.rb file."

The docs also seem to suggest that any config.rb values are valid in the credentials file (emphasis mine):

"Set up knife profiles by adding them to the .chef/credentials file in your home directory on your workstation. The credentials file is TOML formatted. Each profile is listed as a separate ‘table’ name of your choice, and is followed by key = value pairs. The keys correspond to any setting permitted in the config.rb file."

However, this does not seem to work...

Steps to Reproduce:

Create ~/.chef/credentials file

[default]
client_name     = 'foo'
client_key      = '/home/foo/.chef/foo.pem'
chef_server_url = 'https://foo.ec2.internal/organizations/myorg'
cookbook_email  = 'foo [at] gmail.com'
cookbook_license = 'apachev2'
cookbook_copyright = 'foo'

Generate cookbook

chef generate cookbook foo

Find default info in metadata:

$ grep maintainerffoo/metadata.rb 
maintainer 'The Authors'
maintainer_email 'you@example.com'
$ grep license foo/metadata.rb 
license 'All Rights Reserved'

Expected Result:

license, maintainer, and maintainer_email should be replaced.

Actual Result:

Default information still in place.

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

Start with the chef generate cookbook foo entry point and trace how options from ~/.chef/credentials are loaded for cookbook generation. Compare the documented config.rb keys with the generated metadata.rb; done means license, maintainer, and maintainer_email use the credential values instead of their defaults.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.