Skip to content
Merged
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
119 changes: 115 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ env:
SPEC_OPTS: --format progress

jobs:
dokken:
ubuntu:
env:
KITCHEN_LOCAL_YAML: kitchen.dokken.yml
KITCHEN_LOCAL_YAML: kitchen.exec.yml
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -31,5 +31,116 @@ jobs:
run: |
bundle config set --local with 'integration'
bundle install
- name: Verify Dokken
run: bundle exec kitchen verify
- name: Verify Exec (Ubuntu)
run: bundle exec kitchen verify default-localhost
- name: Capture kitchen.log on failure
if: failure()
run: |
if [ -f .kitchen/logs/kitchen.log ]; then
echo "=== .kitchen/logs/kitchen.log ==="
cat .kitchen/logs/kitchen.log
fi
for f in .kitchen/logs/*.log; do
[ -f "$f" ] || continue
echo "=== $f ==="
cat "$f"
done
- name: Run kitchen diagnose on failure
if: failure()
run: bundle exec kitchen diagnose --all || true
- name: Show generated client.rb on failure
if: failure()
run: |
find .kitchen /tmp -name "client.rb" -o -name "solo.rb" 2>/dev/null | while read f; do
echo "=== $f ==="
cat "$f"
done || true

macos:
env:
KITCHEN_LOCAL_YAML: kitchen.exec.yml
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
ruby: ["3.4"]
steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Setup Machine
run: |
bundle config set --local with 'integration'
bundle install
- name: Verify Exec (macOS)
run: bundle exec kitchen verify default-localhost
- name: Capture kitchen.log on failure
if: failure()
run: |
if [ -f .kitchen/logs/kitchen.log ]; then
echo "=== .kitchen/logs/kitchen.log ==="
cat .kitchen/logs/kitchen.log
fi
for f in .kitchen/logs/*.log; do
[ -f "$f" ] || continue
echo "=== $f ==="
cat "$f"
done
- name: Run kitchen diagnose on failure
if: failure()
run: bundle exec kitchen diagnose --all || true
- name: Show generated client.rb on failure
if: failure()
run: |
find .kitchen /tmp -name "client.rb" -o -name "solo.rb" 2>/dev/null | while read f; do
echo "=== $f ==="
cat "$f"
done || true

windows:
env:
KITCHEN_LOCAL_YAML: kitchen.exec.yml
runs-on: windows-latest
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
ruby: ["3.4"]
steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Setup Machine
run: |
bundle config set --local with integration
bundle install
- name: Verify Exec (Windows)
run: bundle exec kitchen verify default-windows-localhost
- name: Capture kitchen.log on failure
if: failure()
shell: pwsh
run: |
if (Test-Path .kitchen/logs/kitchen.log) {
Write-Host "=== .kitchen/logs/kitchen.log ==="
Get-Content .kitchen/logs/kitchen.log
}
Get-ChildItem .kitchen/logs -Filter *.log -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host "=== $($_.FullName) ==="
Get-Content $_.FullName
}
- name: Run kitchen diagnose on failure
if: failure()
continue-on-error: true
run: bundle exec kitchen diagnose --all
- name: Show generated client.rb on failure
if: failure()
shell: pwsh
run: |
Get-ChildItem .kitchen, $env:TEMP -Recurse -Include client.rb,solo.rb -File -ErrorAction SilentlyContinue | ForEach-Object {
Write-Host "=== $($_.FullName) ==="
Get-Content $_.FullName
}
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.bundle/
/pkg/
/checksums/
/vendor/
/coverage/
/tmp/
*.gem
Gemfile.lock
.kitchen/
.kitchen.local.yml
Policyfile.lock.json
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
AllCops:
TargetRubyVersion: 3.4
Exclude:
- "vendor/**/*"
- "spec/**/*"

require: cookstyle/chefstyle
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Kitchen-cinc Change Log

## 0.1.0 (Unreleased)

- Initial release of kitchen-cinc gem
- Cinc Infra provisioner (`cinc_infra`) using cinc-client in local mode
- Cinc Solo provisioner (`cinc_solo`)
- Cinc Apply provisioner (`cinc_apply`)
- Cinc Target provisioner (`cinc_target`) for remote execution (Cinc 19.0.0+)
- Cinc Zero provisioner (`cinc_zero`) as deprecated alias for `cinc_infra`
- Policyfile support with auto-detection
- Berkshelf fallback support
- Omnitruck-based package installation via `omnitruck.cinc.sh`
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@cinc-project/maintainers
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Release Process

This release process applies to all Cinc Project Test Kitchen plugins, but each project may have additional requirements.

1. Perform a diff between main and the last released version. Determine whether included MRs justify a patch, minor or major version release.
2. Check out the main branch of the project being prepared for release.
3. Branch into a release-branch of the form `150_release_prep`.
4. Modify the `cinc_version.rb` file to specify the version for releasing.
5. Run `rake changelog` to regenerate the changelog.
6. `git commit` the `cinc_version.rb` and `CHANGELOG.md` changes to the branch and setup an MR for them. Allow the MR to run any automated tests and review the CHANGELOG for accuracy.
7. Merge the MR to main after review.
8. Switch your local copy to the main branch and `git pull` to pull in the release preparation changes.
9. Run `rake release` on the main branch.
10. Modify the `cinc_version.rb` file and bump the patch or minor version, and commit/push.
31 changes: 31 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
source "https://rubygems.org"

gemspec

gem "mixlib-install", ">= 3.14", source: "https://rubygems.cinc.sh"
gem "chef-cli", ">= 5.3.1", source: "https://rubygems.cinc.sh"
gem "chef", ">= 19.0", source: "https://rubygems.cinc.sh"
gem "chef-bin", ">= 19.0", source: "https://rubygems.cinc.sh"
gem "chef-utils", source: "https://rubygems.cinc.sh"
gem "chef-zero", source: "https://rubygems.cinc.sh"

# Transitive deps of cinc-branded gems that aren't on rubygems.cinc.sh
gem "unf_ext", ">= 0.0.8.2"

group :test do
gem "rake"
gem "fakefs"
gem "minitest"
gem "mocha"
gem "test-kitchen"
end

group :integration do
gem "kitchen-dokken"
gem "kitchen-vagrant"
gem "kitchen-inspec"
end

group :linting do
gem "cookstyle"
end
7 changes: 7 additions & 0 deletions Policyfile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name "kitchen-cinc"

default_source :supermarket

run_list "test_cookbook"

cookbook "test_cookbook", path: "test/cookbooks/test_cookbook"
146 changes: 145 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,146 @@
# kitchen-cinc
A Test Kitchen provisioner for omnibus Cinc Clinet

A Test Kitchen provisioner for [Cinc Client](https://cinc.sh/) (the community distribution of Chef Infra Client) that downloads and installs omnibus packages via the [Cinc omnitruck API](https://omnitruck.cinc.sh/).

## Overview

This Test Kitchen plugin provides provisioners that automatically download and install the desired version of Cinc Client on your test instances. This allows you to test your cookbooks against different Cinc versions without pre-installing Cinc on your images.

## Installation

**Note:** This gem will ship as part of Cinc Workstation. If you're using Cinc Workstation, no additional installation is necessary.

For standalone installation, add this line to your Gemfile:

```ruby
gem "kitchen-cinc"
```

Then execute:

```shell
bundle install
```

Or install it directly:

```shell
gem install kitchen-cinc
```

## Usage

### Available Provisioners

This gem provides five provisioners:

- **`cinc_infra`** — Modern Cinc Client provisioner using local mode (recommended)
- **`cinc_zero`** — Deprecated alias for `cinc_infra` (maintained for backward compatibility)
- **`cinc_solo`** — Cinc Solo provisioner (note: does not support parallel converge)
- **`cinc_apply`** — Cinc Apply provisioner for running individual recipes
- **`cinc_target`** — Cinc Target Mode provisioner (requires Cinc 19.0.0+, Train-based transport)

### Basic Configuration

To use the Cinc Infra provisioner in your `kitchen.yml`:

```yaml
provisioner:
name: cinc_infra
```

### Complete Example

```yaml
---
driver:
name: vagrant

provisioner:
name: cinc_infra
product_name: cinc
install_strategy: always
channel: stable

platforms:
- name: ubuntu-24.04
- name: almalinux-9

suites:
- name: default
run_list:
- recipe[my_cookbook::default]
```

### Docker (Dokken) Example

```yaml
---
driver:
name: dokken
privileged: true
chef_image: cincproject/cinc
chef_version: latest

provisioner:
name: cinc_infra
product_name: cinc

transport:
name: dokken

platforms:
- name: ubuntu-24.04
driver:
image: dokken/ubuntu-24.04
pid_one_command: /bin/systemd

- name: almalinux-9
driver:
image: dokken/almalinux-9
pid_one_command: /usr/lib/systemd/systemd
```

### Configuration Options

Every option exposed by the provisioners is documented under
[`docs/`](docs/README.md):

- [Provisioners](docs/provisioners.md) — overview of `cinc_infra`,
`cinc_zero`, `cinc_solo`, `cinc_apply`, and `cinc_target`.
- [Installation options](docs/installation.md) — `product_name`,
`product_version`, `channel`, `install_strategy`, `download_url`,
`checksum`, proxies, and the legacy omnibus options.
- [Converge options](docs/converge.md) — `run_list`, `attributes`,
logging, `multiple_converge`, `enforce_idempotency`, `client_rb` /
`solo_rb`, Chef Zero host/port, and more.
- [Cookbook resolution](docs/cookbook-resolution.md) — Policyfile and
Berkshelf integration.
- [Paths](docs/paths.md) — sandbox, on-instance, and binary paths.
- [Target mode](docs/target-mode.md) — extra requirements and option
overrides for `cinc_target`.

## Development

### Running Tests

```shell
bundle install
bundle exec rake # Run all tests and linting
bundle exec rake spec # Run unit tests only
bundle exec rake lint # Run Cookstyle linting only
```

### Integration Tests

```shell
# Vagrant
KITCHEN_YAML=kitchen.yml bundle exec kitchen test

# Docker (Dokken)
KITCHEN_YAML=kitchen.dokken.yml bundle exec kitchen test
```

## License

Apache-2.0 — see [LICENSE](LICENSE) for details.
26 changes: 26 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require "bundler/gem_tasks"

require "rake/testtask"
Rake::TestTask.new(:unit) do |t|
t.libs.push "lib"
t.test_files = FileList["spec/**/*_spec.rb"]
t.verbose = true
end

desc "Run all test suites"
task test: %i{unit}

begin
require "cookstyle/chefstyle"
require "rubocop/rake_task"
RuboCop::RakeTask.new(:style) do |task|
task.options += ["--display-cop-names", "--no-color"]
end
rescue LoadError
puts "cookstyle/chefstyle is not available. (sudo) gem install cookstyle to do style checking."
end

desc "Run all quality tasks"
task quality: %i{style}

task default: %i{test quality}
Loading
Loading