Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE: CHEF-12879 Kitchen integration with InSpec 6 #299

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading