Knife-Zero supports Policyfile.
If you are using a Policyfile at Knife-Zero, select the usage from the following two.
chef export
.
local
.knife serve
and chef push
.
chef export
.Add the following to knife.rb
.
use_policyfile true
versioned_cookbooks true
policy_document_native_api false
First, reflect the contents of the Policyfile to Chef-Repo.
Notice: Executing
chef export ./ -f
empties the. / Chef
directory and overwrites it. recommended to putknife.rb
and other configs to the project root directory.
chef install
or chef update
to create Policyfile.lock.json
.chef export ./ -f
to update following directories in your Chef-Repo.
cookbooks/
data_bags/policyfiles/
policies
policy_groups
Use --policy-name
with zero bootstrap
.
$ knife zero bootstrap HOST_NAME --policy-name POLICY_NAME -N NODE_NAME
For example, It’ll add the following to client.rb
when passed --policy-name build
.
use_policyfile true
versioned_cookbooks true
policy_document_native_api true
policy_name build
policy_group local
There is no change to the zero converge
normaly.
$ knife zero converge "QUERY"
You can -n/--named-run-list
to use named runlist
.
$ knife zero converge "QUERY" -n NAMED_RUNLIST
If you want to every time surely apply the update of Policyfile, you can append the following to the knife.rb
.
knife[:before_bootstrap] = 'chef update && chef export ./ -f'
knife[:before_converge] = 'chef update && chef export ./ -f'
knife serve
and chef push
Add the following to knife.rb
.
use_policyfile true
versioned_cookbooks true
policy_document_native_api false
chef_server_url "http://localhost:8889" # for `chef push`
First, launch a local Chef-Zero. It is necessary only when you manage policies by chef command, such as the chef push
or chef show-policy
or others.
$ knife serve
Serving files from:
repository at /Users/sawanoboriyu/worktemp/knife-zero_policy
Multiple versions per cookbook
>> Starting Chef Zero (v4.5.0)...
...
Open another terminal, then run chef push
with specific group name.
$ chef push -c knife.rb mygroup policies/mypolicy.rb
After push, you should terminate knife serve
.
Use --policy-name
and --policy-group
with zero bootstrap
.
$ knife zero bootstrap HOST_NAME --policy-name POLICY_NAME --policy-group POLICY_GROUP_NAME -N NODE_NAME
For example, It’ll add the following to client.rb
when passed --policy-name mypolicy
and --policy-group mygroup
.
use_policyfile true
versioned_cookbooks true
policy_document_native_api true
policy_name mypolicy
policy_group mygroup
There is no change to the zero converge
normaly.
$ knife zero converge "QUERY"
You can -n/--named-run-list
to use named runlist
.
$ knife zero converge "QUERY" -n NAMED_RUNLIST