Skip to content
Amy Buck edited this page Aug 13, 2018 · 21 revisions

Chef

Chef is a powerful automation tool transforms infrastructure into code. Whether you are operating in the cloud, on-premises or in a hybrid environment, Chef automates how infrastructure is configured, deployed, and managed across your network — no matter its size.

Chef has three main components:

  • The Chef DK workstation is the location where users interact with Chef. On the workstation, users author and test cookbooks using tools such as Test Kitchen and interact with the Chef server using the knife and Chef command line tools.

  • Chef client nodes are the machines (such as OPX devices) that are managed by Chef. The Chef client is installed on each node and is used to configure the node to its desired state.

  • The Chef server acts as a hub for configuration data. The Chef server stores cookbooks, the policies that are applied to nodes, and metadata that describe each registered node that is being monitored by Chef. Nodes use the Chef client to ask the Chef server for configuration details such as recipes, templates, and file distributions.

Dependencies

The sample recipe inside the cookbooks are build on resources included in the core Chef code. The resources are available in Chef 12.17.15. It requires the Chef setup (workstation-server-client) to be done and working with an SSH connection to an OpenSwitch OPX device (client).

Chef setup and execution

Cookbooks/roles

Cookbooks are written, tested, and maintained in Chef workstations. The cookbooks are uploaded to the Chef server from the workstation.

NOTE: Various sample cookbooks are available in the Chef supermarket.

Upload cookbook and execute example

Copy the sample cookbooks to the ~/chef-repo/cookbooks directory in the workstation.

NOTE: my_node is the Chef client created for an OPX device.

Copy the sample cookbooks in the cookbooks directory to ~/chef-repo/cookbooks in the workstation. The clos-fabric folder alone contains both the cookbook and the role to configure a leaf-spine topology.

NOTE: opx_node is the Chef client created for an OpenSwitch OPX device.

Upload the cookbook (ex: lldp) from the local repo to the Chef server

knife cookbook upload lldp

Include the cookbook/role into the run_list of the managed node

knife node run_list add opx_node lldp <and/or>
knife node run_list add opx_node role[leaf1]

Execute the run_list of the node (Chef client)

knife ssh `name:opx_node` `sudo chef-client`

Sample OPX Chef cookbooks

Clone this wiki locally