Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Add named_run_list support to provisioner #607

Merged
merged 2 commits into from
Nov 17, 2015
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
35 changes: 32 additions & 3 deletions POLICYFILE_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/kitchen/provisioner/policyfile_zero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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? }
Expand Down