Chef
Chef server setup
sudo dpkg -i /tmp/chef-server-core-<version>.deb
chef-server-ctl reconfigure
chef-server-ctl user-create USER_NAME FIRST_NAME LAST_NAME EMAIL 'PASSWORD' --filename FILE_NAME
chef-server-ctl org-create northernsysadmin 'Northern Sysadmin Inc' --association_user sysadmin --filename /var/chef_ssh/northernsysadmin-validator.pem
knife ssl check
knife ssl fetch
knife cookbook upload $COOKBOOK_NAME_HERE
knife client list
knife cookbook list
knife bootstrap 10.255.255.8 --ssh-user sysadmin --ssh-password 'PASSWORD_HERE' --sudo --use-sudo-password --node-name puppet-minion1 --run-list 'recipe[learn_chef_apache2]'
knife node list
knife node show $NODE_NAME
Create roles and assign cookbooks to them.
roles/ntp.json
{
"name": "ntp",
"description": "NTP server role.",
"json_class": "Chef::Role",
"default_attributes": {
"chef_client": {
"interval": 60,
"splay": 1
}
},
"override_attributes": {
},
"chef_type": "role",
"run_list": ["recipe[chef-client::default]",
"recipe[chef-client::delete_validation]",
"recipe[ntpd::default]"
],
"env_run_lists": {
}
}
- Upload the role to the Chef Server :
knife role from file roles/web.json
- Check that the role is on the server :
knife role list
-knife role show ntp
- Find node name from
knife node list
-knife node run_list set puppet-minion1 "role[ntp]"
- Confirm that the role is applied to the Node :
knife node show puppet-minion1 --run-list
- Run
chef-client
on the node. knife ssh 10.255.255.8 'role:web' 'sudo chef-client' --ssh-user sysadmin --ssh-password 'PASSWORD_HERE' --sudo --use-sudo-password --node-name puppet-minion1
Dependencies in cookbooks.
metadata.rb - keyword "depends" - Used to list the other coobooks from which the cookbook depends to run properly.
name 'prometheus_node'
maintainer 'Laurent Dumont'
maintainer_email '[email protected]'
license 'All Rights Reserved'
description 'Installs/Configures prometheus-node'
long_description 'Installs/Configures prometheus-node'
version '0.1.1'
depends 'tar'
chef_version '>= 12.14' if respond_to?(:chef_version)