This is a tale of a newcomer vs a relative oldie in the Configuration Management (CM) arena. Both are tools to help the sysadmin or devops professional to better manage large numbers of servers. They excel at stuff like repetitive task automation, simultaneous deployment of apps and packages to a group of servers, or configuration and provisioning of new servers from scratch.
What They Are, How They Work
Chef was originally released in 2009 - in the world of CM tools, that’s an eternity ago. It is supported by parent sponsor Opscode, and is frequently compared and contrasted to that other old-timer CM tool Puppet. Like Puppet, Chef is also written in Ruby, and its CLI also uses a Ruby-based DSL. Chef utilizes a master-agent model, and in addition to a master server, a Chef installation also requires a workstation to control the master. The agents can be installed from the workstation using the ‘knife’ tool that uses SSH for deployment, easing the installation burden. From there managed nodes authenticate with the master through certificates. Chef doesn't yet have a well-formed push feature, though beta code is available to do this. But in the meantime the implication is that agents must be configured to check in with the master periodically and instantaneous master-to-agent rollout of changes isn't really possible. Continuing with the kitchen metaphor (see ‘knife’ above), Chef configs are packaged into JSON files called ‘recipes’. Also, the software can run in either a client-server or in a standalone mode called ‘Chef-solo’.
Ansible is quite different from Chef. It is similar to another upstart, Salt, than to the old boys Chef and Puppet. It was developed and first released in early 2012 by the parent company AnsibleWorks, and is starting to gain a dedicated following despite its youth and untested-ness. It is written in Python and only requires the Python libraries to be present on the servers to be configured, which anyway is the default on almost all Linux distros today. Ansible’s USP’s are its light weight, relative ease of use and speed of deployment compared to other CM tools. For example you don’t need to learn Ruby - Ansible packages all commands into YAML modules called playbooks - as long as your preferred language can output JSON modules, you’re good to go. Ansible also does away with the need for agents; all master-agent communication is handled either via standard SSH commands, or the Paramiko module which provides a Python interface to SSH2. An added bonus is the SSH’s excellent inbuilt security.
Support, Performance, Ease of Use
<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In -->
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
x="0px" y="0px" width="437px" height="103px" viewBox="0 0 437 103" style="enable-background:new 0 0 437 103;"
<path class="st0" d="M120.7,63.7c0,8,4.2,12.1,12.7,12.1c8.5,0,12.7-4,12.7-12.1V21.5h10.1v42c0,7.3-1.9,12.6-5.8,16
<path class="st0" d="M168.5,103V38.2h9.8V41c4.2-2.5,8.1-3.8,11.7-3.8c6,0,10.4,1.8,13.1,5.5c2.8,3.7,4.2,9.8,4.2,18.4
<path class="st0" d="M243.6,59.8v-8.9h17.7v31.5c-1.6,0.4-4.9,0.9-9.9,1.4c-5,0.5-8.6,0.7-10.8,0.7c-9.4,0-15.9-2.6-19.5-7.8
<path class="st0" d="M300.1,38.2h9.8v45.3h-9.8v-2.8c-4.4,2.5-8.5,3.8-12.2,3.8c-6.2,0-10.4-1.7-12.5-5c-2.1-3.4-3.2-9.2-3.2-17.6
<path class="st0" d="M355.4,52.2v20.7c0.1,1.3,0.4,2.3,1,2.9c0.6,0.6,1.6,1,2.9,1.2l-0.3,7.5c-5.2,0-9.2-1.1-12.1-3.4
<path class="st0" d="M367.8,83.5V38.2h9.8v5.4c5.1-3.3,10.3-5.5,15.4-6.4v9.9c-5.2,1-9.6,2.4-13.3,4l-2,0.8v31.6H367.8z"/>
<path class="st0" d="M437,19.4v64.1h-9.8v-2.4c-4.4,2.2-8.5,3.4-12.1,3.4c-5.9,0-10.3-1.8-13-5.3c-2.7-3.6-4.1-9.5-4.1-17.9
<path class="st0" d="M83.4,51.2c-2.8,6.1-6,11.7-8.9,16.5c-3,5.2-5.9,9.9-9.6,15.1c-1.4,2-3,4.2-4.8,6.5
Chef is an older product, so its documentation is better than Ansible’s. That said, there are complaints by many new to Chef that it is quite confusing to learn compared to the blissfully simple Ansible. Chef offers support for Linux, *nix, and Windows. The browser-based GUI is quite good (again, no surprise considering it’s been around for a few years), although it’s not as complete as Puppet’s, lacking features like reporting and advanced config options. All in all, Chef’s relative maturity means it may appeal to corporations, who place a premium on stability, more than individuals.
IT guys are famous for avoiding documenting anything, so it’s no surprise that Ansible’s documentation is still a weak point. This, however, is somewhat mitigated by how easy it is to learn. Ansible is currently only available for Linux and Unix, and its GUI is terrible compared to Chef’s – it’s not even synced to the CLI, so you may occasionally find that the GUI and CLI give different results of a query. Ansible’s agent-less push-mode using the ZeroMq implementation at the transport layer means quick deployment and very low performance overhead; the caveat is that it’s just not as flexible and powerful as using agents.
First off, any admin or devops will be mighty glad to have such tools in their corner; just a few years ago there was much less choice in this field. Choosing either of them is a win, and your life will be richer and easier for it.
That said, if you must choose between them, consider your own needs carefully first and weigh them against what each solution offers. You can use the infographic below to compare Chef and Ansible.