From 6a471d1cd9f9ca117ce823fd6374912c8387357c Mon Sep 17 00:00:00 2001 From: Nik08 Date: Mon, 2 Sep 2024 15:16:22 +0530 Subject: [PATCH 1/6] Upgraded InSpec version to 6 Signed-off-by: Nik08 --- kitchen-inspec.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kitchen-inspec.gemspec b/kitchen-inspec.gemspec index 7d71123..f59c418 100644 --- a/kitchen-inspec.gemspec +++ b/kitchen-inspec.gemspec @@ -17,7 +17,8 @@ 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 + # Version upgrade to InSpec 6 + spec.add_dependency "inspec", "~> 6.0" 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 From cce4eec36970e087007cdb89c761fb5bd955b6d8 Mon Sep 17 00:00:00 2001 From: Nik08 Date: Fri, 13 Sep 2024 16:35:53 +0530 Subject: [PATCH 2/6] Ability to chef license key and chef license server using kitchen inspec Signed-off-by: Nik08 --- lib/kitchen/verifier/inspec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/kitchen/verifier/inspec.rb b/lib/kitchen/verifier/inspec.rb index 01fba82..28fed3d 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,14 @@ 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 + chef_license_key = config[:chef_license_key] || ENV["CHEF_LICENSE_KEY"] + opts[:chef_license_key] = chef_license_key if chef_license_key + opts[:chef_license_server] = config[:chef_license_server] if config[:chef_license_server] + end + def setup_waivers(opts, config) # InSpec expects the singular inflection opts[:waiver_file] = config[:waiver_files] || [] From 0c3577703cb3a7dfc31fdbd9b5218014c05adfb5 Mon Sep 17 00:00:00 2001 From: Nik08 Date: Tue, 22 Aug 2023 15:19:27 +0530 Subject: [PATCH 3/6] Doc changes for chef licensing key and licensing service url configuration using kitchen Signed-off-by: Nik08 --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index e88a27d..f9b2225 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,40 @@ 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 +``` + +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 +``` + + +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. From 6775a637453556ca03ca6c09ffbaccab6c5f8d3c Mon Sep 17 00:00:00 2001 From: Nik08 Date: Thu, 24 Aug 2023 18:55:06 +0530 Subject: [PATCH 4/6] Added doc information for env variable usage on chef license key Signed-off-by: Nik08 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index f9b2225..b14668d 100644 --- a/README.md +++ b/README.md @@ -321,6 +321,10 @@ To configure Chef License Key for Chef InSpec, modify your `kitchen.yml` in the 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. From 7dd9fe7da3073bbae13a7f8eef96dfb922028e10 Mon Sep 17 00:00:00 2001 From: Nik08 Date: Tue, 1 Oct 2024 16:21:24 +0530 Subject: [PATCH 5/6] Enabled setting chef license server also via env variable Signed-off-by: Nik08 --- README.md | 2 ++ lib/kitchen/verifier/inspec.rb | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b14668d..9433816 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,8 @@ For avoiding a single point of failure, it is possible to set up multiple local - 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. diff --git a/lib/kitchen/verifier/inspec.rb b/lib/kitchen/verifier/inspec.rb index 28fed3d..126b018 100644 --- a/lib/kitchen/verifier/inspec.rb +++ b/lib/kitchen/verifier/inspec.rb @@ -121,9 +121,8 @@ def call(state) 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 - chef_license_key = config[:chef_license_key] || ENV["CHEF_LICENSE_KEY"] - opts[:chef_license_key] = chef_license_key if chef_license_key - opts[:chef_license_server] = config[:chef_license_server] if config[:chef_license_server] + 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) From 929d8a7c82a887fc0354a26821181bdb5f3a70b5 Mon Sep 17 00:00:00 2001 From: Nik08 Date: Fri, 4 Oct 2024 15:10:25 +0530 Subject: [PATCH 6/6] Version pinning for inspec dependency updated to include range of versions Signed-off-by: Nik08 --- kitchen-inspec.gemspec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kitchen-inspec.gemspec b/kitchen-inspec.gemspec index f59c418..c705d29 100644 --- a/kitchen-inspec.gemspec +++ b/kitchen-inspec.gemspec @@ -17,8 +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" - # Version upgrade to InSpec 6 - spec.add_dependency "inspec", "~> 6.0" + 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