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
10 changes: 5 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ Windows Server 2019 (check `metadata.rb`, `kitchen.yml`, and `.github/workflows/
- `libraries/` - Library helpers to assist with the cookbook. May contain multiple files depending on complexity of the cookbook.
- `templates/` - ERB templates that may be used in the cookbook
- `files/` - files that may be used in the cookbook
- `metadata.rb`, `Berksfile` - Cookbook metadata and dependencies
- `metadata.rb`, `Policyfile.rb` - Cookbook metadata and test dependencies

## Build and Test System

### Environment Setup
**MANDATORY:** Install Chef Workstation first - provides chef, berks, cookstyle, kitchen tools.
**MANDATORY:** Install Chef Workstation first - provides chef, cookstyle, and kitchen tools.

### Essential Commands (strict order)
```bash
berks install # Install dependencies (always first)
chef install Policyfile.rb # Install dependencies (always first)
cookstyle # Ruby/Chef linting
yamllint . # YAML linting
markdownlint-cli2 '**/*.md' # Markdown linting
Expand All @@ -42,7 +42,7 @@ chef exec rspec # Unit tests (ChefSpec)
- **License:** Set `CHEF_LICENSE=accept-no-persist`

### Common Issues and Solutions
- **Always run `berks install` first** - most failures are dependency-related
- **Always run `chef install Policyfile.rb` first** - most failures are dependency-related
- **Chef Workstation required** - no workarounds, no alternatives
- **Windows Vagrant provider availability matters** for local kitchen runs

Expand Down Expand Up @@ -87,7 +87,7 @@ These instructions are validated for Sous Chefs cookbooks. **Do not search for b

**Error Resolution Checklist:**
1. Verify Chef Workstation installation
2. Confirm `berks install` completed successfully
2. Confirm `chef install Policyfile.rb` completed successfully
3. Ensure the local Windows Vagrant provider can boot and expose WinRM before blaming cookbook code
4. Check for missing test data dependencies

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
uses: sous-chefs/.github/.github/workflows/lint-unit.yml@9.0.0
with:
platform: windows-latest
gems: rake
permissions:
actions: write
checks: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
- name: Install Cinc Workstation
uses: sous-chefs/.github/.github/actions/install-workstation@9.0.0
- name: Install cookbooks
run: berks install
run: chef install Policyfile.rb
2 changes: 2 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ config:
line-length: false # MD013
no-duplicate-heading: false # MD024
reference-links-images: false # MD052
table-column-style:
style: compact # MD060
no-multiple-blanks:
maximum: 2
ignores:
Expand Down
9 changes: 0 additions & 9 deletions Berksfile

This file was deleted.

15 changes: 15 additions & 0 deletions Policyfile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

name 'powershell'

run_list 'test::default'

cookbook 'ms_dotnet', git: 'https://github.com/criteo-cookbooks/ms_dotnet.git', branch: 'master'
cookbook 'powershell', path: '.'
cookbook 'test', path: './test/cookbooks/test'

Dir.children('./test/cookbooks/test/recipes').grep(/\.rb\z/).sort.each do |recipe|
recipe_name = File.basename(recipe, '.rb')

named_run_list recipe_name.to_sym, "test::#{recipe_name}"
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ end
Local Vagrant runs use `kitchen.yml`. CI uses the exec driver with `kitchen.exec.yml`.

```shell
berks install
chef install Policyfile.rb
cookstyle
chef exec rspec --format documentation
kitchen test default-windows-2019 --destroy=always
Expand Down
4 changes: 2 additions & 2 deletions documentation/powershell_dsc.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Installs the PowerShell prerequisites required for Desired State Configuration.
## Actions

| Action | Description |
|--------|-------------|
| -------- | ------------- |
| `:create` | Installs WMF 4.0 prerequisites and configures WinRM (default) |

## Properties

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| ---------- | ------ | --------- | ------------- |
| `name` | String | name property | Resource name |
| `enable_https_transport` | Boolean | `false` | Whether WinRM should expose an HTTPS listener |
| `thumbprint` | String | `''` | Certificate thumbprint used for HTTPS transport |
Expand Down
4 changes: 2 additions & 2 deletions documentation/powershell_lcm.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ Configures the Windows Local Configuration Manager for Desired State Configurati
## Actions

| Action | Description |
|--------|-------------|
| -------- | ------------- |
| `:enable` | Generates and applies an LCM configuration (default) |
| `:disable` | Disables LCM refresh mode |

## Properties

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| ---------- | ------ | --------- | ------------- |
| `name` | String | name property | Resource name |
| `temp_dir` | String | cached path | Temporary directory used for generated MOF files |
| `config_mode` | String | `'ApplyOnly'` | LCM configuration mode |
Expand Down
4 changes: 2 additions & 2 deletions documentation/powershell_winrm.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Configures WinRM for DSC and remote PowerShell usage.
## Actions

| Action | Description |
|--------|-------------|
| -------- | ------------- |
| `:create` | Enables WinRM and optionally creates an HTTPS listener (default) |

## Properties

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| ---------- | ------ | --------- | ------------- |
| `name` | String | name property | Resource name |
| `enable_https_transport` | Boolean | `false` | Whether to create an HTTPS listener |
| `thumbprint` | String | `''` | Certificate thumbprint used for HTTPS transport |
Expand Down
4 changes: 2 additions & 2 deletions documentation/powershell_wmf.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Installs a legacy Windows Management Framework release when the target platform
## Actions

| Action | Description |
|--------|-------------|
| -------- | ------------- |
| `:install` | Installs the requested WMF release (default) |

## Properties

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| ---------- | ------ | --------- | ------------- |
| `version` | String | name property | WMF version to install (`2.0`, `3.0`, `4.0`, `5.1`) |
| `download_url` | String | computed | Override the Microsoft package URL |
| `checksum` | String | computed | Override the Microsoft package checksum |
Expand Down
21 changes: 9 additions & 12 deletions kitchen.exec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@ provisioner:
deprecations_as_errors: true
enforce_idempotency: true
multiple_converge: 2
policyfile: Policyfile.rb

verifier:
name: inspec
name: shell
command: >-
powershell.exe -NoLogo -NoProfile -NonInteractive
-Command "$version = $PSVersionTable.PSVersion; Write-Output $version; if ($version -lt [version]'5.1') { exit 1 }"
shellout_opts:
timeout: 30

platforms:
- name: windows-2019

x-run_lists:
default: &default_run_list
- recipe[test::default]

x-verifiers:
default: &default_verifier
inspec_tests:
- path: test/integration/default

suites:
- name: default
run_list: *default_run_list
verifier: *default_verifier
provisioner:
named_run_list: default
8 changes: 3 additions & 5 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ provisioner:
enforce_idempotency: true
multiple_converge: 2
deprecations_as_errors: true
policyfile: Policyfile.rb

verifier:
name: inspec
Expand All @@ -31,16 +32,13 @@ platforms:
driver:
box: tas50/windows_2019

x-run_lists:
default: &default_run_list
- recipe[test::default]

x-verifiers:
default: &default_verifier
inspec_tests:
- path: test/integration/default

suites:
- name: default
run_list: *default_run_list
provisioner:
named_run_list: default
verifier: *default_verifier
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'chefspec'
require 'chefspec/berkshelf'
require 'chefspec/policyfile'

Dir[File.join(__dir__, '..', 'libraries', '*.rb')].sort.each { |f| require File.expand_path(f) }

Expand Down
2 changes: 1 addition & 1 deletion test/integration/default/controls/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
impact 1.0
title 'PowerShell 5.1 or newer is available'

describe powershell('(Get-Host).Version.ToString()') do
describe command('powershell.exe -NoLogo -NoProfile -NonInteractive -Command "$PSVersionTable.PSVersion.ToString()"', timeout: 30) do
its('stdout') { should match(/^5\.1/) }
end
end
Loading