Chef Notes

Knife

Vault

Create a secret

knife vault create passwords root '{"username": "root", "password": "mypassword"}'

Show secrets vaults

knife vault list

Show secrets in a vault

secret_vault is the vault in this case:

knife vault show secret_vault

Show value of a secret in a vault

knife vault show <vault name> <secret name>

For example:

knife vault show secret_vault mysql_pw

Create a secret in a vault

knife vault create secret_vault postgresql_pw '{"user":"postgresql", "password": "TheM0stS3cr3T!!!"}'

Show information like interval frequency

knife search node 'name:<node name>' -a chef_client

Show which nodes are running a recipe

knife search node "recipes:<recipe_name>"

Resource: https://stackoverflow.com/questions/13579785/how-to-get-a-list-of-the-recipes-applied-to-chef-node

Get all nodes

knife node list

Get all linux nodes

knife search node "os:linux"

Add cookbook to a run_list for a chef node

knife node run_list add <node name> <cookbook name>

For example:

knife node run_list add chef-node evil

Remove cookbook from run_list for a chef node

knife node run_list remove <node name> recipe[<cookbook name>]

For example:

knife node run_list remove chef-agent-1 recipe[my_cmd]

Remove cookbook from chef server

knife cookbook delete <cookbook name>

Upload/Update Cookbook

knife cookbook upload <cookbook name>

Show run_list for a chef node

knife node show <node name>

Show run_lists for all chef nodes

knife exec -E 'nodes.all {|n| puts "#{n.name} has #{n.run_list}"}'

Resource: http://devopsblues.com/knife-exec-mass-operations-on-chef-node-run_list-and-attributes/