chef-cookbooks / chef-server

Cookbook to install standalone Chef Server

Home Page:http://supermarket.chef.io/cookbooks/chef-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node attribute `accept_license` not working

ctbarrett opened this issue · comments

Cookbook version

5.5.2

Chef-client version

14.14.29

Platform Details

ubuntu-18.04

Scenario:

Attempting to validate a minimal use-case converge in test-kitchen via wrapper cookbook

Steps to Reproduce:

  1. Initialize blank cookbook
  2. Add default['chef-server']['accept_license'] = true to attributes/default.rb
  3. Add include_recipe 'chef-server' to recipes/default.rb
  4. Add depends 'chef-server' to metadata.rb
  5. Add run_list: my-wrapper-cookbook to kitchen.yml
  6. Run kitchen converge

Expected Result:

Expecting vagrant VM with chef-server package installed

Actual Result:

Chef converge fails with

         * chef_ingredient[chef-server] action reconfigure
           * ingredient_config[chef-server] action render
             * directory[/etc/opscode] action create (up to date)
             * file[/etc/opscode/chef-server.rb] action create (up to date)
       (up to date)
           * execute[chef-server-core-reconfigure] action run

             ================================================================================
             Error executing action `run` on resource 'execute[chef-server-core-reconfigure]'
             ================================================================================

             Mixlib::ShellOut::ShellCommandFailed
             ------------------------------------
             Expected process to exit with [0], but received '172'
             ---- Begin output of chef-server-ctl reconfigure ----
             STDOUT: Chef Infra Server cannot execute without accepting the license
             STDERR:
             ---- End output of chef-server-ctl reconfigure ----
             Ran chef-server-ctl reconfigure returned 172

             Resource Declaration:
             ---------------------
             # In /tmp/kitchen/cache/cookbooks/chef-ingredient/resources/chef_ingredient.rb

             106:     execute "#{ingredient_package_name}-reconfigure" do
             107:       command "#{ingredient_ctl_command} reconfigure"
             108:     end
             109:   end

             Compiled Resource:
             ------------------
             # Declared in /tmp/kitchen/cache/cookbooks/chef-ingredient/resources/chef_ingredient.rb:106:in `block in class_from_file'

             execute("chef-server-core-reconfigure") do
        action [:run]
        default_guard_interpreter :execute
        command "chef-server-ctl reconfigure"
        backup 5
        declared_type :execute
        cookbook_name "chef-server"
        domain nil
        user nil
             end

             System Info:
             ------------
             chef_version=14.14.29
             platform=ubuntu
             platform_version=18.04
             ruby=ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux]
             program_name=/opt/chef/bin/chef-client
             executable=/opt/chef/bin/chef-client


           ================================================================================
           Error executing action `reconfigure` on resource 'chef_ingredient[chef-server]'
           ================================================================================

           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           execute[chef-server-core-reconfigure] (/tmp/kitchen/cache/cookbooks/chef-ingredient/resources/chef_ingredient.rb line 106) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '172'
           ---- Begin output of chef-server-ctl reconfigure ----
           STDOUT: Chef Infra Server cannot execute without accepting the license
           STDERR:
           ---- End output of chef-server-ctl reconfigure ----
           Ran chef-server-ctl reconfigure returned 172

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/chef-server/recipes/default.rb

            29: chef_ingredient 'chef-server' do
            30:   extend ChefServerCookbook::Helpers
            31:   version node['chef-server']['version'] unless node['chef-server']['version'].nil?
            32:   package_source node['chef-server']['package_source']
            33:   config <<-EOS
            34: topology "#{node['chef-server']['topology']}"
            35: #{"api_fqdn \"#{node['chef-server']['api_fqdn']}\"" if api_fqdn_available?}
            36: #{node['chef-server']['configuration']}
            37: EOS
            38:   action :install
            39: end
            40:

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/chef-server/recipes/default.rb:29:in `from_file'

           chef_ingredient("chef-server") do
             action [:install]
             updated true
             default_guard_interpreter :default
             declared_type :chef_ingredient
             cookbook_name "chef-server"
             recipe_name "default"
             package_source nil
             config "topology \"standalone\"\napi_fqdn \"default-ubuntu-1804.vagrantup.com\"\n\n"
             product_name "chef-server"
             platform "ubuntu"
             platform_version "18.04"
             architecture "x86_64"
           end

           System Info:
           ------------
           chef_version=14.14.29
           platform=ubuntu
           platform_version=18.04
           ruby=ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux]
           program_name=/opt/chef/bin/chef-client
           executable=/opt/chef/bin/chef-client


       Running handlers:
       [2019-12-09T20:43:29+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2019-12-09T20:43:29+00:00] ERROR: Exception handlers complete
       Chef Client failed. 7 resources updated in 01 minutes 08 seconds
       [2019-12-09T20:43:29+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2019-12-09T20:43:29+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2019-12-09T20:43:29+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: chef_ingredient[chef-server] (chef-server::default line 29) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[chef-server-core-reconfigure] (/tmp/kitchen/cache/cookbooks/chef-ingredient/resources/chef_ingredient.rb line 106) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '172'
       ---- Begin output of chef-server-ctl reconfigure ----
       STDOUT: Chef Infra Server cannot execute without accepting the license
       STDERR:
       ---- End output of chef-server-ctl reconfigure ----
       Ran chef-server-ctl reconfigure returned 172
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-ubuntu-1804>.  Please see .kitchen/logs/default-ubuntu-1804.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

The following must be fixed first:
Honors accept_license for the Chef Infra Server install #159 (#159)
Honoring Chef Infra Server license accept #241 (chef-cookbooks/chef-ingredient#241)

You may try this workaround.

  1. Define an attribute:
    default['chef-server']['chef_license'] = 'accept' # user defined attribute

  2. Copy all the content of default.rb in chef-server cookbook to your recipe and add the attribute:

chef_ingredient 'chef-server' do
  extend ChefServerCookbook::Helpers
  version node['chef-server']['version'] unless node['chef-server']['version'].nil?
  package_source node['chef-server']['package_source']
  config <<-EOS
topology "#{node['chef-server']['topology']}"
#{"api_fqdn \"#{node['chef-server']['api_fqdn']}\"" if api_fqdn_available?}
chef_license "#{node['chef-server']['chef_license']}"
#{node['chef-server']['configuration']}
  EOS
  action :install
end

Ref: https://docs.chef.io/chef_license_accept.html#chef-infra-server