Options that can be specified in each sub-command can be found in knife zero SUBCOMMAND --help
.
knife zero bootstrap [SSH_USER@]FQDN (options)
Initializes the remote Node, it has the following features.
Attributes that you specify from the option will be persistent saved as Normal attribute.
Almost options are inheritance from knife bootstrap
. Depending on the version of Chef, you can use options will vary.
And options that you added in Knife-Zero, frequently asked option is is as follows.
--converge/--no-converge
-N, --node-name NAME
(ChefCore)-j JSON_ATTRIBS, --json-attributes
(ChefCore)--json-attribute-file FILE
--remote-chef-zero-port
-r, --run-list RUN_LIST
(ChefCore)--sudo
(ChefCore)-W, --why-run
--appendix-config PATH
client.rb
of the remote node.--[no-]overwrite
--alter-project PROJECT
chef
or cinc
.Please refer to the knife zero bootstrap --help
for the other.
Reachability to host and name.
# Node has a resolvable host name
$ knife zero bootstrap zero.example.com
# It will grant any name
$ knife zero bootstrap zero.example.com --name zero.example.com
# Node doesn't have a resolvable host name
$ knife zero bootstrap 210.152.xxx.xxx --name zero01
# The login name to connect via SSH is ubuntu, and sudo is necessary
$ knife zero bootstrap 210.152.xxx.xxx --name zero01 -x ubuntu --sudo
OR
$ knife zero bootstrap ubuntu@210.152.xxx.xxx --name zero01 --sudo
It will grant the Normal Attribute at the time of the first Chef-Client run.
# as String
$ knife zero bootstrap zero.example.com --json-attributes '{"mykey":"myval"}'
# from File
$ knife zero bootstrap zero.example.com --json-attribute-file tmp/node.json
Specify run-list to Chef-Client first run.
# Comma separated list
$ knife zero bootstrap zero.example.com --run-list "role[base],recipe[iptables::www]"
# with JSON Attributes
$ knife zero bootstrap zero.example.com --run-list "role[base],recipe[iptables::www]" --json-attribute-file tmp/node.json
only update client.rb on Node which was bootstrapped.
$ knife zero bootstrap zero.example.com -N zero.example.com --no-converge
Bootstrap multi-nodes via GNU Parallel.
$ parallel -j 5 knife zero bootstrap ::: nodeA nodeB nodeC...
knife zero converge QUERY (options)
Run Chef-Client to update for Node.
Target Nodes are based on the results of a search query. The query format is the same as SEARCH_QUERY
of knife search.
Almost options are inheritance from knife ssh
. And, taken over some of the options from chef-client
.
Depending on the version of Chef, you can use options will vary.
And options that we added in Knife-Zero, frequently asked option is as follows.
-a, --attribute ATTR
(ChefCore)
as knife_zero.host
.-C, --concurrency NUM
(ChefCore)--remote-chef-zero-port
-W, --why-run
-o, --override-runlist RunlistItem,RunlistItem
--sudo/--no-sudo
--splay SECONDS
(Chef-Client)--skip-cookbook-sync
--client-version [latest|VERSION]
-j, --json-attributes JSON_ATTRIBS
--override-runlist
because to avoid updating local node object.--chef-license ACCEPTANCE
--client-version
option.accept
’, ‘accept-no-persist
’, or ‘accept-silent
’.--alter-project PROJECT
chef
or cinc
.# Converge all Nodes
$ knife zero converge "name:*" --attribute knife_zero.host
# Converge all Nodes, concurrent in 5 node.
$ knife zero converge "name:*" --attribute knife_zero.host --concurrency 5
# Converge Nodes matched Environment == "production"
$ knife zero converge "chef_environment:production" --attribute knife_zero.host
# specified run-list
$ knife zero converge "name:*" --attribute knife_zero.host --override-runlist "role[patch]"
--client-version
usage.
# Upgrade chef-client to latest and converge all Nodes
$ knife zero converge "name:*" --attribute knife_zero.host --client-version latest
# install specific version (e.g. 12.4.3) and converge all Nodes
$ knife zero converge "name:*" --attribute knife_zero.host --client-version 12.4.3
# Without converge
$ knife zero converge "name:*" --attribute knife_zero.host --client-version 12.4.3 --why-run
Note:
If you don’t want to use omnibus-chef installation, you should not use--client-version
option.
Try run your specified command to upgrade chef-client as you like viaknife ssh
.
knife zero apply QUERY (options)
(※ after v1.12.0)
Run Chef-Apply to execute spot tasks for Node from a single recipe.
Target Nodes are based on the results of a search query. The query format is the same as SEARCH_QUERY
of knife search.
The recipe string are passed to chef-apply from stdin.
Almost options are inheritance from knife ssh
and zero converge
. Depending on the version of Chef, you can use options will vary.
And options as follows.
-a, --attribute ATTR
(ChefCore)
as knife_zero.host
.-r, --recipe Recipe String or @filename
-j, --json-attributes JSON_ATTRIBS
-C, --concurrency NUM
(ChefCore)--remote-chef-zero-port
-W, --why-run
-o, --override-runlist RunlistItem,RunlistItem
--sudo/--no-sudo
--client-version [latest|VERSION]
chef-apply(12.6.0) does not have function to load the Node objects from Chef-Server.
The bear in only limited use, please use the --override-runlist
with converge
if you need to retrieve objects from ChefRepo.
# Install tmux to all nodes from String.
$ knife zero apply "name:*" -r "package 'tmux'"
# Update tmux by all nodes from String.
$ knife zero apply "name:*" --attribute knife_zero.host --concurrency 5 -r "package 'tmux' do action :upgrade end"
# Execute single recipe in all nodes from file.
$ knife zero apply "name:*" -r @apply/maintenance.rb
It will roughly output settings that are generated from knife.rb. There is no option.
For check setting or bug reports.
$ knife zero diagnose
Chef::Config
====================
---
:local_mode: true
:knife_zero: {}
:verbosity:
:log_location: !ruby/object:IO {}
:config_file: "/Users/sawanoboriyu/github/higanworks/knife-zero_playground/knife.rb"
:color: true
:log_level: :warn
:chef_repo_path: "/Users/sawanoboriyu/github/higanworks/knife-zero_playground"
:chef_server_url: chefzero://localhost:8889
:repo_mode: everything
Knife::Config
====================
---
:verbosity: 0
:color: true
:editor: vim
:disable_editing: false
:format: summary
:remote_chef_zero_port:
:config_file: "/Users/sawanoboriyu/github/higanworks/knife-zero_playground/knife.rb"
Zero Bootstrap Config
====================
---
:encrypt: false
:ssh_user: root
:run_list: []
:first_boot_attributes: {}
:host_key_verify: true
:remote_chef_zero_port:
:bootstrap_converge: true
Zero Converge Config
====================
---
:concurrency:
:manual: false
:ssh_password_ng: false
:host_key_verify: true
:remote_chef_zero_port:
:use_sudo: true
:override_runlist:
:config_file: "/Users/sawanoboriyu/github/higanworks/knife-zero_playground/knife.rb"