diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 3cab8b4..d50c484 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 196ca0b..decb673 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index d931cfe..78f0971 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -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 diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml index ac5076b..baa5307 100644 --- a/.markdownlint-cli2.yaml +++ b/.markdownlint-cli2.yaml @@ -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: diff --git a/Berksfile b/Berksfile deleted file mode 100644 index 4c37302..0000000 --- a/Berksfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://supermarket.chef.io' - -metadata - -group :integration do - cookbook 'test', path: 'test/cookbooks/test' -end diff --git a/Policyfile.rb b/Policyfile.rb new file mode 100644 index 0000000..21d7f6d --- /dev/null +++ b/Policyfile.rb @@ -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 diff --git a/README.md b/README.md index b97ac7c..31265de 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/documentation/powershell_dsc.md b/documentation/powershell_dsc.md index ef52aef..e17efbb 100644 --- a/documentation/powershell_dsc.md +++ b/documentation/powershell_dsc.md @@ -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 | diff --git a/documentation/powershell_lcm.md b/documentation/powershell_lcm.md index 363b7a5..2db36a8 100644 --- a/documentation/powershell_lcm.md +++ b/documentation/powershell_lcm.md @@ -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 | diff --git a/documentation/powershell_winrm.md b/documentation/powershell_winrm.md index 6e73e66..2d43c24 100644 --- a/documentation/powershell_winrm.md +++ b/documentation/powershell_winrm.md @@ -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 | diff --git a/documentation/powershell_wmf.md b/documentation/powershell_wmf.md index 87839f0..2ef38f5 100644 --- a/documentation/powershell_wmf.md +++ b/documentation/powershell_wmf.md @@ -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 | diff --git a/kitchen.exec.yml b/kitchen.exec.yml index 01511e2..233e586 100644 --- a/kitchen.exec.yml +++ b/kitchen.exec.yml @@ -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 diff --git a/kitchen.yml b/kitchen.yml index fe9deb3..4581493 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -22,6 +22,7 @@ provisioner: enforce_idempotency: true multiple_converge: 2 deprecations_as_errors: true + policyfile: Policyfile.rb verifier: name: inspec @@ -31,10 +32,6 @@ platforms: driver: box: tas50/windows_2019 -x-run_lists: - default: &default_run_list - - recipe[test::default] - x-verifiers: default: &default_verifier inspec_tests: @@ -42,5 +39,6 @@ x-verifiers: suites: - name: default - run_list: *default_run_list + provisioner: + named_run_list: default verifier: *default_verifier diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 323ee1d..f6da6e9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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) } diff --git a/test/integration/default/controls/default_spec.rb b/test/integration/default/controls/default_spec.rb index 399ef3f..486e86b 100644 --- a/test/integration/default/controls/default_spec.rb +++ b/test/integration/default/controls/default_spec.rb @@ -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