Skip to content

Commit

Permalink
Merge pull request #299 from inspec/nm/inspec-version-upgrade
Browse files Browse the repository at this point in the history
CHEF-12879 Kitchen integration with InSpec 6
  • Loading branch information
Nik08 authored Jan 13, 2025
2 parents dadf198 + 929d8a7 commit 8c808d1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<!-- TODO Insert Link to right document -->
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.
Expand Down
2 changes: 1 addition & 1 deletion kitchen-inspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions lib/kitchen/verifier/inspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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] || []
Expand Down

0 comments on commit 8c808d1

Please sign in to comment.