Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knife bootstrap_environment should use Explicit config before Implicit #3864

Conversation

evan2645
Copy link
Contributor

@evan2645 evan2645 commented Sep 2, 2015

When the knife cli utility is run, it invokes a method named apply_computed_config, which transposes some of the CLI options onto Chef::Config. Both Chef::Config, as well as the explicitly passed knife options, are given to the Bootstrap Context.

Bootstrap Context is responsible for setting values for the bootstrap template... one of which is the Chef environment. Currently, this logic pulls the value directly from Chef::Config, and if there is none there, it defaults to _default. The problem is that this logic relies on apply_computed_config having been run previously. Rather than completely ignoring the Explicit config that we have available to us, we should consider it. If Chef Environment has been explicitly set in this knife invocation, we should use that... else, we can look in Chef::Config... else, we can finally fall back to _default.

It is worth noting that chef_node_name is also governed by this same pattern, though the Bootstrap Context does not take the value from Chef::Config, and instead looks only to the explicit config that Knife has received. I would like to see the same behavior for Chef Environment... the underlying issue being that if I programmatically call Knife Bootstrap, I cannot simply pass it a configuration and tell it to run... I must first call apply_computed_config, otherwise my node will come up with the default environment.

@ranjib
Copy link
Contributor

ranjib commented Sep 3, 2015

👍
i cant reproduce the travis failures.. both master and this PR is passing on my machine/goatos

@thommay
Copy link
Contributor

thommay commented Sep 18, 2015

please rebase onto master and see if that fixes the test failures.

@@ -40,7 +40,7 @@ def initialize(config, run_list, chef_config, secret = nil)
end

def bootstrap_environment
@chef_config[:environment] || '_default'
@config[:environment] || @chef_config[:environment] || '_default'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty certain that you want to drop @chef_config entirely here.

@lamont-granquist
Copy link
Contributor

created a #3946 epic for issues like this all over the knife codebase.

@lamont-granquist lamont-granquist added this to the Accepted Minor milestone Sep 22, 2015
@evan2645 evan2645 force-pushed the knife-bootstrap-should-obey-environment-config branch 2 times, most recently from b56cdef to 291bc78 Compare September 24, 2015 20:48
…ontext

Setting these values in Chef::Config is being deprecated in favor of
using the knife config directly.
chef#3946
@evan2645 evan2645 force-pushed the knife-bootstrap-should-obey-environment-config branch from 291bc78 to b258f11 Compare September 25, 2015 19:44
@evan2645
Copy link
Contributor Author

In light of #3946, I have dropped Chef::Config from consideration. Rebased, Squashed.

@thommay
Copy link
Contributor

thommay commented Oct 7, 2015

👍 LGTM

@lamont-granquist lamont-granquist mentioned this pull request Oct 25, 2015
@evan2645 evan2645 deleted the knife-bootstrap-should-obey-environment-config branch January 30, 2017 17:52
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants