diff options
author | danielsdeleo <dan@chef.io> | 2015-09-23 12:50:54 -0700 |
---|---|---|
committer | danielsdeleo <dan@chef.io> | 2015-09-24 12:37:26 -0700 |
commit | 14d7baab6365e0b4146990a5306f80a7f0d09a82 (patch) | |
tree | 70292b704f85ab6c06b6b52f3a0d89e418c954f1 /lib/chef/knife/core | |
parent | 4141c33df8e31b78359fb316315547d36f837df6 (diff) | |
download | chef-14d7baab6365e0b4146990a5306f80a7f0d09a82.tar.gz |
Don't pass -E to chef-client unless given an environment
Chef::PolicyBuilder::Policyfile requires `Chef::Config[:environment]` to
be nil or empty, in order to prevent confusion that could arise from
using two conflicting features. Because `chef-client` merges CLI options
to `Chef::Config` automatically, running `chef-cient -E _default` causes
`Chef::Config[:environment]` to be non-nil, resulting in chef-client
emitting this error when bootstrapping:
```
192.168.99.143 Unexpected Error:
192.168.99.143 -----------------
192.168.99.143 Chef::PolicyBuilder::Policyfile::UnsupportedFeature:
Policyfile does not work with Chef Environments
```
For non-policyfile users, this should behave the same as before since
Chef will just default to the `_default` environment (this gets set via
Node#initialize) if none is specified.
Diffstat (limited to 'lib/chef/knife/core')
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index d85ee91490..d210b9418f 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -40,7 +40,7 @@ class Chef end def bootstrap_environment - @chef_config[:environment] || '_default' + @chef_config[:environment] end def validation_key @@ -128,7 +128,7 @@ CONFIG client_path = @chef_config[:chef_client_path] || 'chef-client' s = "#{client_path} -j /etc/chef/first-boot.json" s << ' -l debug' if @config[:verbosity] and @config[:verbosity] >= 2 - s << " -E #{bootstrap_environment}" + s << " -E #{bootstrap_environment}" unless bootstrap_environment.nil? s end |