Chef On Linode - with ‘knife linode’
OpsCode’s VirtualBox VM seems pretty light, sudo du -sh /
gives
1.1G. Can I use that image to install stuff on Linode? Or am I better
off starting with Linode’s Ubuntu 12.04 LTS image? I think I probably
want to start with Linode’s image. While looking for other stuff, I
ran across the knife-linode
plugin. Looking at the docs on the Opscode site,
there seem to be configuration parameters for knife-linode that will
let you create a server using one of Linode’s stock images so let’s
see if I can use that to create a box.
To play with it, I needed to go to the Linode “My Profile” page and create an API key. Then I can list my current servers:
And delete one:
OK so now can I create one?
The user doesn’t seem to have been created. So I can’t ssh in as cnk
(and cnk isn’t in /etc/passwd), but I can ssh in as root. And I don’t
seem to have any ruby or chef - perhaps because I didn’t choose a
distro or template file. Let’s try that again - with --distro
chef-full
added.
That give similar output (on a new IP). But when I logged in, I still don’t have chef or ruby. In fact, there isn’t anything in /opt at all. Let’s see if I can bootstrap chef by hand.
That seems a bit better; now we have ruby 1.9.3-p484 in /opt/chef/embedded/bin/ruby. And it came with rubygems 1.8.24, bundler (1.1.5), rake (10.1.0, 0.9.2.2), and chef (11.8.2). There are a couple of gems that have more recent versions but I decided not to try running ‘gem update’ because the installed versions may have been chosen specifically to satisfy chef dependencies.
I’ll probably want to have chef doing my updates but for now, I think
I should have the server patched so ran apt-get update
and apt-get
upgrade
by hand for now. (Before I ran the upgrade, I took a list of
the packages that were installed originally with dpkg-query -W >
/root/original-packages.txt
so I would know what the Linode Precise
Penguin image came with.)
Connecting my Linode node to Chef server
After installing chef with the knife bootstrap command, I see it tries to converge the new node. However, there is nothing in my run list - and no cookbook repository for this new server. Time to make one - and then put my Linode API configuration into the knife.rb file so I can quit passing it on the command line all the time.
UGH actually knife seems to have created a node on the server for
me. Was that during knife linode server create
? or during the knife
bootstrap
command? I can’t really tell from the docs. I should have
passed -N <name>
to knife linode server create
so that my node
would not end up named ‘localhost’ (and then when that didn’t do the
bootstrapping, again send the name). From what I can tell by Googling,
you can’t really rename a node, though there are delete and readd
proceedures that end up being quite similar. I think I’ll try this one
to get the chef node for my Linode sever named something more sensible
than localhost
. I skipped step 6 since I didn’t see ‘localhost’ in
the /etc/chef/client.rb file. Running chef-client -N linode
gave:
And now I see a node named “linode” in both the Opscode web interface
and in the output of knife node list
. Yeah!