And ran into this error that has had me going out of my mind:
Running handlers:
[2019-06-20T21:44:36+00:00] ERROR: Running exception handlers
Running handlers complete
[2019-06-20T21:44:36+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2019-06-20T21:44:36+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2019-06-20T21:44:36+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-06-20T21:44:36+00:00] ERROR: undefined method `sysctl' for cookbook: os-hardening, recipe: sysctl :Chef::Recipe
[2019-06-20T21:44:36+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
This error has had me stumped for the awhile now.. and now getting back into it, I searched and found that this method is now deprecated: https://supermarket.chef.io/cookbooks/sysctl
Perhaps this cookbook should be updated being part of the training module?
How would I fix this?
I found with some digging in the code that ~/learn-chef/cookbooks/lcr-policyfiles-getstarted/cookbooks/hardening/recipes/default.rb needs to be edited as follows:
#
# Cookbook:: hardening
# Recipe:: default
#
# Copyright:: 2018, The Authors, All Rights Reserved.
if node['os'] == 'linux'
# include_recipe 'os-hardening::default'
include_recipe 'hardening::remediation'
elsif node['os'] == 'windows'
include_recipe 'windows-hardening'
end
After this edit, I performed a:
$ kitchen converge
And SUCCESS!
Finished converging <default-centos-7> (0m17.57s).
-----> Kitchen is finished. (0m22.00s)
Can I ask which version of Chef Workstation/ChefDK you are using, and if you pinned the chef version in the .kitchen.yml
I have just run this through with the latest, and after ensuring the chef-client license is accepted it runs with no changes required to the cookbook.
As for the sysctl cookbook, it is deprecated because the functionality is included directly in Chef Infra now. The os-hardening cookbook has been updated to support this.
I was fiddling with product_version here based on documentation and other bits because the license wasn't being accepted, but found this to be the variables that worked for this setup. This is in the "lcr-policyfiles-getstarted" cookbook.