Skip to content

Commit 759a6b1

Browse files
committed
fix: migrate to Policyfile
1 parent 55ae40c commit 759a6b1

9 files changed

Lines changed: 49 additions & 35 deletions

File tree

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
- name: Install Chef
2222
uses: actionshub/chef-install@main
2323
- name: Install cookbooks
24-
run: berks install
24+
run: chef install Policyfile.rb

LIMITATIONS.md renamed to AGENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Postfix Cookbook Limitations
1+
# Postfix Cookbook Notes
22

33
This cookbook manages Postfix through operating system packages and service/configuration files. It does not build Postfix from source.
44

@@ -10,6 +10,8 @@ FreeBSD, SmartOS, Scientific Linux, and legacy CentOS releases were removed from
1010

1111
Map backends depend on distribution packages and Postfix module availability. The `postfix_map` resource only runs `postmap` for database-backed map types such as `hash`, `lmdb`, `btree`, `cdb`, `dbm`, and `sdbm`.
1212

13+
Dependency resolution uses `Policyfile.rb`. Keep test cookbook suites represented as Policyfile named run lists so Kitchen can select them with `provisioner.named_run_list`.
14+
1315
Sources:
1416

1517
* [Postfix home page](https://www.postfix.org/)

Berksfile

Lines changed: 0 additions & 8 deletions
This file was deleted.

Policyfile.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
name 'postfix'
4+
5+
run_list 'test::default'
6+
7+
cookbook 'postfix', path: '.'
8+
cookbook 'apt', git: 'https://github.com/sous-chefs/apt.git', branch: 'main'
9+
cookbook 'test', path: './test/cookbooks/test'
10+
11+
Dir.children('./test/cookbooks/test/recipes').grep(/\.rb\z/).sort.each do |recipe|
12+
recipe_name = File.basename(recipe, '.rb')
13+
14+
named_run_list recipe_name.to_sym, "test::#{recipe_name}"
15+
end

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Installs and configures postfix for client or outbound relayhost, or to do SASL
1212

1313
This cookbook is resource-first. Recipes and cookbook attributes have been removed.
1414

15-
See [migration.md](migration.md) for recipe migration guidance, [LIMITATIONS.md](LIMITATIONS.md) for supported platform constraints, and the files in [documentation/](documentation/) for resource usage.
15+
See [migration.md](migration.md) for recipe migration guidance, [AGENTS.md](AGENTS.md) for supported platform constraints, and the files in [documentation/](documentation/) for resource usage.
1616

1717
On RHEL-family systems, sendmail will be replaced with postfix.
1818

kitchen.dokken.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
driver:
22
name: dokken
33
privileged: true
4-
chef_version: <%= ENV['CHEF_VERSION'] || 'latest' %>
4+
chef_image: "<%= ENV.fetch('KITCHEN_PRODUCT_NAME', 'cinc') == 'cinc' ? 'cincproject/cinc' : 'chef/chef' %>"
5+
chef_version: "<%= ENV['CHEF_VERSION'] || (ENV.fetch('KITCHEN_PRODUCT_NAME', 'cinc') == 'cinc' ? 'latest' : 'current') %>"
56

67
transport: { name: dokken }
78
provisioner:
89
name: dokken
9-
product_name: cinc
10+
chef_binary: "<%= ENV.fetch('KITCHEN_PRODUCT_NAME', 'cinc') == 'cinc' ? '/opt/cinc/bin/cinc-client' : '/opt/chef/bin/chef-client' %>"
11+
product_name: "<%= ENV['KITCHEN_PRODUCT_NAME'] || 'cinc' %>"
1012

1113
platforms:
1214
- name: almalinux-8

kitchen.global.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
provisioner:
3-
name: cinc_infra
3+
name: policyfile_zero
4+
product_name: <%= ENV['KITCHEN_PRODUCT_NAME'] || 'cinc' %>
45
product_version: <%= ENV['CHEF_VERSION'] || 'latest' %>
56
channel: stable
67
install_strategy: once
@@ -9,6 +10,7 @@ provisioner:
910
multiple_converge: <%= ENV['MULTIPLE_CONVERGE'] || 2 %>
1011
deprecations_as_errors: true
1112
log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %>
13+
policyfile: Policyfile.rb
1214

1315
verifier:
1416
name: inspec

kitchen.yml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ driver:
33
name: vagrant
44

55
provisioner:
6-
name: chef_infra
7-
product_name: chef
6+
name: policyfile_zero
7+
product_name: cinc
88
enforce_idempotency: true
99
multiple_converge: 2
1010
deprecations_as_errors: true
11+
policyfile: Policyfile.rb
1112

1213
verifier:
1314
name: inspec
@@ -29,12 +30,12 @@ platforms:
2930

3031
suites:
3132
- name: default
32-
run_list:
33-
- recipe[test::default]
33+
provisioner:
34+
named_run_list: default
3435

3536
- name: aliases
36-
run_list:
37-
- recipe[test::aliases]
37+
provisioner:
38+
named_run_list: aliases
3839
attributes:
3940
postfix:
4041
aliases:
@@ -48,37 +49,37 @@ suites:
4849
- bar
4950

5051
- name: client
51-
run_list:
52-
- recipe[test::client]
52+
provisioner:
53+
named_run_list: client
5354

5455
- name: server
55-
run_list:
56-
- recipe[test::server]
56+
provisioner:
57+
named_run_list: server
5758

5859
- name: access
59-
run_list:
60-
- recipe[test::access]
60+
provisioner:
61+
named_run_list: access
6162

6263
- name: canonical
63-
run_list:
64-
- recipe[test::canonical]
64+
provisioner:
65+
named_run_list: canonical
6566
attributes:
6667
postfix:
6768
recipient_canonical_map_entries:
6869
john: john@doe.com
6970

7071
- name: sasl_auth_none
71-
run_list:
72-
- recipe[test::sasl_auth_none]
72+
provisioner:
73+
named_run_list: sasl_auth_none
7374
attributes:
7475
postfix:
7576
main:
7677
relayhost: "localhost"
7778
smtp_sasl_auth_enable: "yes"
7879

7980
- name: sasl_auth_multiple
80-
run_list:
81-
- recipe[test::sasl_auth_multiple]
81+
provisioner:
82+
named_run_list: sasl_auth_multiple
8283
attributes:
8384
postfix:
8485
main:
@@ -93,8 +94,8 @@ suites:
9394
password: "yet-not-a-real-thing"
9495

9596
- name: sasl_auth_one
96-
run_list:
97-
- recipe[test::sasl_auth_one]
97+
provisioner:
98+
named_run_list: sasl_auth_one
9899
attributes:
99100
postfix:
100101
main:

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'chefspec'
2-
require 'chefspec/berkshelf'
2+
require 'chefspec/policyfile'
33

44
RSpec.configure do |config|
55
config.color = true # Use color in STDOUT

0 commit comments

Comments
 (0)