diff --git a/README.md b/README.md index e88a27d..9433816 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,46 @@ When using Input plugins, please be aware that input values get cached between s backend_cache: false ``` +### Configure Chef License Key and Licensing Service URL for Inspec version 6 or higher + +To configure Chef License Key for Chef InSpec, modify your `kitchen.yml` in the following way: + +```yaml + verifier: + chef_license_key: LICENSE_KEY_VALUE +``` + +Or + +It could also be configured by setting environment variable `CHEF_LICENSE_KEY` with the license key string. + +Additionally, If you are using InSpec with Local Licensing Service, you can configure `chef_license_server` by providing the Licensing Service URL. + + +```yaml + verifier: + chef_license_key: LICENSE_KEY_VALUE + chef_license_server: https://test-local-licensing-service-url +``` + +Or + +For avoiding a single point of failure, it is possible to set up multiple local licensing services. To configure them for InSpec, modify your `kitchen.yml` as follows: + +```yaml + verifier: + chef_license_key: LICENSE_KEY_VALUE + chef_license_server: + - https://test-local-licensing-service-url-1 + - https://test-local-licensing-service-url-2 + - https://test-local-licensing-service-url-3 +``` + +It could also be configured by setting environment variable `CHEF_LICENSE_SERVER` with the Licensing Service URL(s). + + +See the [Chef License documentation](/license/) for more information about Chef licensing. + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/kitchen-inspec.gemspec b/kitchen-inspec.gemspec index 7d71123..c705d29 100644 --- a/kitchen-inspec.gemspec +++ b/kitchen-inspec.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").grep(/LICENSE|^lib/) spec.require_paths = ["lib"] spec.required_ruby_version = ">= 2.3.0" - spec.add_dependency "inspec", ">= 2.2.64", "< 6.0" # 2.2.64 is required for plugin v2 support + spec.add_dependency "inspec", ">= 2.2.64", "< 7.0" # 2.2.64 is required for plugin v2 support & InSpec 6 included spec.add_dependency "test-kitchen", ">= 2.7", "< 4" # 2.7 introduced no_parallel_for for verifiers spec.add_dependency "hashie", ">= 3.4", "<= 5.0" end diff --git a/lib/kitchen/verifier/inspec.rb b/lib/kitchen/verifier/inspec.rb index 01fba82..126b018 100644 --- a/lib/kitchen/verifier/inspec.rb +++ b/lib/kitchen/verifier/inspec.rb @@ -83,6 +83,8 @@ def call(state) # add inputs and waivers setup_inputs(opts, config) setup_waivers(opts, config) + # Configure Chef License Key and URL through kitchen + setup_chef_license_config(opts, config) # setup Inspec ::Inspec::Log.init(STDERR) @@ -116,6 +118,13 @@ def call(state) private + def setup_chef_license_config(opts, config) + # Pass chef_license_key to inspec if it is set + # Pass chef_license_server to inspec if it is set + opts[:chef_license_key] = config[:chef_license_key] || ENV["CHEF_LICENSE_KEY"] + opts[:chef_license_server] = config[:chef_license_server] || ENV["CHEF_LICENSE_SERVER"] + end + def setup_waivers(opts, config) # InSpec expects the singular inflection opts[:waiver_file] = config[:waiver_files] || []