diff --git a/POLICYFILE_README.md b/POLICYFILE_README.md index d68fc2c66..28790a23e 100644 --- a/POLICYFILE_README.md +++ b/POLICYFILE_README.md @@ -300,9 +300,9 @@ override["same"]["with"] = "overrides" ### Testing With Test Kitchen -ChefDK now includes a Test Kitchen provisioner, which allows you to -converge VMs using Chef Client in policyfile mode, using Chef Zero to -serve cookbook data. Add the following to your `.kitchen.yml`: +ChefDK includes a Test Kitchen provisioner, which allows you to converge +VMs using Chef Client in policyfile mode, using Chef Zero to serve +cookbook data. Add the following to your `.kitchen.yml`: ```yaml provisioner: @@ -313,6 +313,35 @@ provisioner: require_chef_omnibus: true ``` +#### Using Named Run Lists With Kitchen + +As of ChefDK 0.11, the Test Kitchen provisioner supports named run +lists. In addition to testing named run lists that you are using on +production policies, you can use this feature to test different recipes +in a library cookbook in isolation. + +To use a different named run list on a per-suite basis, specify the +named run list inside a `provisioner` section, like this: + +```yaml +suites: + - name: client + provisioner: + named_run_list: test_client_recipe + - name: server + provisioner: + named_run_list: test_server_recipe +``` + +To use a named run list globally, specify it at the top level of the +provisioner section: + +```yaml +provisioner: + name: policyfile_zero + named_run_list: integration_test_run_list +``` + ## Applying the Policy on a Node On the node you with to use the policy update the client.rb to include diff --git a/lib/kitchen/provisioner/policyfile_zero.rb b/lib/kitchen/provisioner/policyfile_zero.rb index 788bb94de..70306f12f 100644 --- a/lib/kitchen/provisioner/policyfile_zero.rb +++ b/lib/kitchen/provisioner/policyfile_zero.rb @@ -62,6 +62,7 @@ class PolicyfileZero < ChefBase # Since it makes no sense to modify these, they are hardcoded elsewhere. default_config :client_rb, {} default_config :json_attributes, true + default_config :named_run_list, nil default_config :chef_zero_host, nil default_config :chef_zero_port, 8889 default_config :policyfile, "Policyfile.rb" @@ -111,6 +112,10 @@ def run_command args << "--logfile #{config[:log_file]}" end + if config[:named_run_list] + args << "--named-run-list #{config[:named_run_list]}" + end + wrap_shell_code( [cmd, *args].join(" "). tap { |str| str.insert(0, reload_ps1_path) if windows_os? }