summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--_drafts/ansible-and-chef.mdown111
1 files changed, 67 insertions, 44 deletions
diff --git a/_drafts/ansible-and-chef.mdown b/_drafts/ansible-and-chef.mdown
index 87b1000..2f65ea8 100644
--- a/_drafts/ansible-and-chef.mdown
+++ b/_drafts/ansible-and-chef.mdown
@@ -4,65 +4,88 @@ category: devops
title: Where we talk about ansible and chef
---
-I've been using Chef for some time now, but it was always via Vagrant,
-so a few weeks ago I decided to get more familiar with it. Since a
-friend of mine set up a Chef server for his own use and was OK to let
-me use it for my own server, I put to profit the Thanksgiving weekend
-to reinstall my Linode server with it.
+I've been using [Chef](http://www.opscode.com/chef/) for some time now, but it was always via [Vagrant](http://vagrantup.com),
+so a few weeks ago I decided to get more familiar with it. A friend
+of mine had set up a Chef server for his own use and was OK to let me use
+it for my personal server. There was a four days weekend for Thanksgiving
+coming, so it was the perfect occasion to take a better look at it,
+and to re-install my Linode server with Chef. And since it was a
+really long weekend, I also decided to take a look at [ansible](http://ansible.cc), another
+tool to push stuff to your server.
I'm not going to talk about installation, configuration, set up and
-all that kind of stuff, there's enough blog posts, articles and books
-about that subject. Instead, I will focus on my experience and share
-my (very valuable) opinion (because, clearly, the world deserve to
-know what I think).
+all that kind of stuff, there's enough material available around (blog
+posts, articles, books, etc). Instead, I will talk about my
+experience and share my (very valuable) opinion (because, clearly, the
+world deserve to know what I think).
## Writing cookbooks for Chef
For the few of you who don't know, cookbooks, in Chef's world, are a
-group of files (templates, static files) and code to change the state
-of your machine.
+group of files (templates, static files) and code that are used to
+automate your infrastructure. Usually, you'll create a cookbook for
+each of your application (one for nginx, one for MySQL, etc).
+
+I've a few services on my server (git, gitolite, Jenkins, graphite,
+collectd, phabricator, ...), and I wanted a coobook for each of them.
+I've started by looking for the one already existing (there's a lot of
+them on GitHub, on the
+[opscode's account](https://github.com/opscode-cookbooks/)), and I tried to use
+them without any modification. Usually, a cookbook will let you set
+some configuration details in your role or node to override the
+defaults it provides (like
+the password for MySQL, or the path where to put logs). So what I did
+was to set the interesting cookbook as a git submodule in my cookbook
+repository. Unfortunately, for almost all of them, I had to give up
+and import them in the repo, so I could edit and modify them.
+
+That's probably my biggest complaint with cookbooks: I doubt code
+re-usability is possible. You can use a cookbook as a base for your
+own version, but either they are too generic; or sometimes you need a
+workaround; or they do way too many things. And as a result, you need to edit the
+code to make them behave the way you want.
+
+In my opinion, developers/ops should just publish [LWRP](http://docs.opscode.com/essentials_cookbook_lwrp.html) (Lightweight
+Resources and Providers) and templates, that's the only thing that I
+can see as really re-usable (take a look at
+[perl-chef](https://github.com/dagolden/perl-chef), I think that this one is a good
+example).
+
+## Using ansible
-I've a few services on my server: git, gitolite, Jenkins, graphite,
-collectd and phabricator, and I wanted a coobook for all of them.
-I've started by looking for some cookbooks on the web and try to use
-them without any modification. Usually, I would fetch them as a
-submodule in my cookbooks repository. But for all of them, I had to
-give up and import them in the repo, so I could modify them.
-
-That's probably my biggest concern with cookbooks: I doubt code
-re-usability is possible. Cookbooks should just provides LWRP
-(Lightweight Resources and Providers), that's the only thing that I
-can see as really re-usable.
+ansible was a new tool for me. A few friends mentionned it to me last
+October when I was at the [OSDC.fr](http://osdc.fr) and it was also suggested to me by a
+colleague at work.
-Another annoying thing, I've not found a way to run the chef-client
-with only one specific cookbook (well, I was able to, by commenting
-all the cookbooks except one in my role, but that's gross).
+This tool is definitely less known that Chef, so I'll give a quick
+introduction. In ansible world, you write "playbooks", which are the
+orchestration language for the tool. That sounds very similar with
+Chef, but the main difference is they are not actual code, but a
+scenario with actions.
-## Using Ansible
+On the web site of the project, there's a quote saying:
-ansible was a new tool for me. A few friends mentionned it to me last
-October when I was at OSDC.fr and it was also suggested to me by a
-colleague at work.
+> You can get started in minutes.
-~~~~~~ description of what ansible is
-It's probably less known that Chef.
+and for once, that's true. I only had to read the first page of the
+documentation, and I was able to write a very simple playbook that I
+was able to evolve very quickly to do something actually useful.
-~~~~~~REWORK THAT PART
-With ansible you write playbooks don't write code, you only write a description in
-YAML. They don't encourage to share your entire playbooks, but
-instead they incite you to write modules (in Python). (you can see modules as being
-similar to LWRP in Chef's world).
+Another difference with Chef is that they don't incite you to share
+your playbooks, but instead to share your modules. Modules could be
+compared to Chef's LWRP. They are Python code to do something
+specific (like the [`pip`](http://ansible.cc/docs/modules.html#pip) module, to install Python package, or the
+[`template`](http://ansible.cc/docs/modules.html#template)'s one).
## Chef vs Ansible
-I've decided to stick to this: use Chef for my supporting application
-(nginx, MySQL, etc) and ansible for my applications.
+For now, I've decided to stick to this: use Chef for my supporting
+application (nginx, MySQL, etc) and ansible for my own applications.
So far, I prefer ansible to Chef. There's definitely less available
-material about ansible on the net, but the quality is better, and it's
-usually well organized. I've never spend more than 10 minutes looking
-for something and to implement it. It can't say the same with Chef:
-the wiki is confusing, there's way too many cookbooks available, their
-quality is very disparate, etc.
-
+material about ansible on the net, but the quality is better, and the
+main documentation is very (I insist on the *very*) well organized. I've never spend more than
+10 minutes looking for something and to implement it. I can't say
+the same with Chef: the wiki is confusing; there's way too many
+cookbooks available; their quality is very disparate.