I'm trying to bootstrap a node using chef by using the command knife bootstrap <host> --ssh-user '<username>' -i <my-identity>.pem --sudo --use-sudo-password --node-name <node-name> --run-list 'recipe[<cookbook-name>::default]'
However, its failing because I can't accept the license
4 -----> Existing Chef installation detected
137.252.24.94 Starting the first Chef Client run...
137.252.24.94 +---------------------------------------------+
137.252.24.94 Chef License Acceptance
137.252.24.94
137.252.24.94 Before you can continue, 2 product licenses
137.252.24.94 must be accepted. View the license at
137.252.24.94 https://www.chef.io/end-user-license-agreement/
137.252.24.94
137.252.24.94 Licenses that need accepting:
137.252.24.94 * Chef Infra Client
137.252.24.94 * Chef InSpec
137.252.24.94
137.252.24.94 Do you accept the 2 product licenses (yes/no)?
And I can't input the answer from the host machine. I used to be able to run the chef boostrap
command easily before chef 14.0. It seems like they upgraded to Chef 14.0 and the new upgrade has a mandatory requirement for the license agreement. How do I agree the license into the client machine from the host machine?
Basically, based on my findings, this problem can occur in two different scenarios:
When you're running the kitchen converge
. This can be solved very easily by adding a piece of code inside the kitchen.yml
as
provisioner:
client_rb:
chef_license: accept
When you're running the knife bootstrap
, this can be a little bit of extra work. This page explains all that needs to be done. Inside the .chef
directory.
> mkdir bootstrap
> cd bootstrap && touch template.erb
> find /opt/chefdk/embedded/lib/ruby -type f -name chef-full.erb -exec cat {} \; > template.erb
Find the line that part that says
cat > /etc/chef/client.rb <<'EOP
<%= config_content %>
EOP
and replace it with
cat > /etc/chef/client.rb <<'EOP'
<%= config_content %>
chef_license "accept"
EOP
Next, run the command knife bootstrap <host> --ssh-user '<username>' -i <my-identity>.pem --sudo --use-sudo-password --node-name <node-name> --boostrap-template "template" --run-list 'recipe[<cookbook-name>::default]'
. That took care of it.