This demo will walk you through using Chef 12 inside CloudLab's experiment
Autor: Dmitry Duplyakin
- Profile with Chef Server, Workstation, and Clients. See more information in the profile description
Emulab's Chef Repository
- Repository of recommended (carefully developed and well tested) cookbooks. It will be cloned onto the head node on the instance of the profile
Chef Supermarket (collection of community developed cookbooks)
- We will download and use the NFS cookbook in this demo
Launching an Experiment
- Instantiate Chef12Slice
- Wait until it says "Your experiment is ready"
- After a few minutes, when Chef is fully configured, you should get an email:
After receiving this email, log into the head node
- Switch to root:
ssh -p 22 email@example.com
sudo su -
Getting Started with knife
- There are two nodes in the Chef environment and no cookbooks by default
- You should see some cookbooks downloaded from the Emulab's repostory
root@head:~# knife node list head node-1 root@head:~# knife cookbook list root@head:~#
- Notice that emulab-nfs cookbook depends on nfs. Install nfs and its dependencies from Chef Supermarket
You should see more cookbooks in /chef-repo/cookbooks after this step.
- Upload all cookbooks to Chef server (on head) in order to make them available to the clients and check
- Along with the cookbooks, your copy of the Emulab's Chef repository contains some roles
- Just like cookbooks, roles need to be uploaded to the server in order to become useable
Roles prescribe which recipes (potentially from different cookbooks) and in which order should run on the nodes, to which the roles are assigned.
Configuring NFS Server
root@head:/# knife node run_list add head "role[nfs_server]" head: run_list: role[nfs_server]
- Assign nfs_server role to head
- Check what is assigned to run on head
root@head:/# chef-client Starting Chef Client, version 12.0.3 resolving cookbooks for run list: ["emulab-nfs::export"] Synchronizing Cookbooks: ... Running handlers complete Chef Client finished, 14/22 resources updated in 9.592334135 seconds
- Trigger the configuration process locally, on head (in Chef terms: converge the node)
root@head:/chef-repo/cookbooks/nfs/recipes# knife node show head Node Name: head FQDN: pc-c220m4-r02-07.wisc.cloudlab.us Run List: role[nfs_server]
root@head:/# service nfs-kernel-server status nfsd running
- NFS server is running now:
Configuring NFS Client
root@head:~# knife node run_list add node-1 "role[nfs_client]" node-1: run_list: role[nfs_client]
root@head:~# knife node show node-1 Node Name: node-1 FQDN: pc-c220m4-r04-05.wisc.cloudlab.us Run List: role[nfs_client]
- Check what is assigned to run on node-1
- Assign nfs cookbooks to node-1
root@head:~# ssh node-1 chef-client [2015-09-14T12:44:11-05:00] INFO: Forking chef instance to converge... [2015-09-14T12:44:11-05:00] INFO: *** Chef 12.4.1 *** [2015-09-14T12:44:13-05:00] INFO: Run List is [role[nfs_client]] ... [2015-09-14T12:44:32-05:00] INFO: Report handlers complete [2015-09-14T12:44:32-05:00] INFO: Chef Run complete in 19.37269083 seconds
- Converge node-1 via ssh
Mounting and Testing
root@head:/# ls /exports/ root@head:/# ssh node-1 "ls /imports" root@head:/# touch /exports/test root@head:/# ssh node-1 "ls /imports" test
- Testing NFS export/mount - add a file on head and see it on node-1
After both head and node-1 converge to their roles, /exports from head should be exported and mounted on node-1 under /imports.
Keep in mind that configuration options (in Chef terms, attributes), which define which directory is exported and where it is mounted, are set in the roles nfs_server.rb and nfs_client.rb in /chef-repo/roles. If you change those files, they should be uploaded to the server again.
In this demo we:
- Used Chef12Slice with Chef Server, Workstation (knife utility), and Clients (on head and node-1)
- Downloaded and installed a community cookbook (nfs) and its dependecies
- Uploaded local cookbooks and roles (cloned from the Emulab's Chef repository) to Chef Server
- Assigned roles to nodes
- Converged two nodes (head and node-1 via ssh) to install and configure both server and client sides of NFS
- Tested the NFS installation
- Performed all these steps, essentially without leaving the head node
If you want to see a demo with more manual steps, where we build recipes and roles from scratch instead of cloning them, please follow this link.
Email firstname.lastname@example.org if you have any questions.
Demo of Chef 12 inside CloudLab's Experiment
By Dmitry Duplyakin