summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2019-04-24 14:36:56 -0400
committerMarc A. Paradise <marc.paradise@gmail.com>2019-04-29 18:33:22 -0400
commitb95649acc976ea33bd46fdd073869d70fb689684 (patch)
treef89e42673ccbaf0092c530332515fb8116efb4e7 /lib/chef
parent945b9f6636bb3236999ca43f313113bf74045d82 (diff)
downloadchef-b95649acc976ea33bd46fdd073869d70fb689684.tar.gz
Ensure license is accepted on remote bootstrap target
When performing the initial `chef-client` converge on a bootstrapped host, ensure that we set the license environment variable that indicates the license was accepted. This will allow the run to continue under Chef 15, which requires license acceptance. I used the environment variable instead of the CLI flag because older versions of Chef do not support the CLI flag. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb2
-rw-r--r--lib/chef/knife/core/windows_bootstrap_context.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index 5e987745e6..dcca7b8a69 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -171,7 +171,7 @@ class Chef
def start_chef
# If the user doesn't have a client path configure, let bash use the PATH for what it was designed for
client_path = @chef_config[:chef_client_path] || "#{Chef::Dist::CLIENT}"
- s = "#{client_path} -j /etc/chef/first-boot.json"
+ s = "CHEF_LICENSE=accept #{client_path} -j /etc/chef/first-boot.json"
if @config[:verbosity] && @config[:verbosity] >= 3
s << " -l trace"
elsif @config[:verbosity] && @config[:verbosity] >= 2
diff --git a/lib/chef/knife/core/windows_bootstrap_context.rb b/lib/chef/knife/core/windows_bootstrap_context.rb
index df69399074..7aa4c012aa 100644
--- a/lib/chef/knife/core/windows_bootstrap_context.rb
+++ b/lib/chef/knife/core/windows_bootstrap_context.rb
@@ -154,6 +154,7 @@ class Chef
def start_chef
bootstrap_environment_option = bootstrap_environment.nil? ? "" : " -E #{bootstrap_environment}"
start_chef = "SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin\"\n"
+ start_chef << "SET \"CHEF_LICENSE=accept\"\n"
start_chef << "chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json#{bootstrap_environment_option}\n"
end