1
votes

I'm very new to chef and with a fresh vm of ubuntu 12 I'm playing around with chef-solo. Following some blog tutorials on the subject I decided to tinker with installing the ntp service through a recipe on my vm. After going through the bootstrapping process of getting the vm to install ruby, rubygems and finally chef, the initial ntp run seemed to run ok. Before the run, pgrep ntpd would return blank, after the run the same command would return a process id. But after close examination of the /etc/ntp.conf file I realized it wasn't using the templated version of this file defined in my recipe. After further investigating, I began to test the theory that my ntp recipe is not being referred to at all in the chef-solo run. I renamed my cookbooks/ntp directory to be cookbooks/ntp_foo. Yet, the base recipe from which this is referenced is perfectly happy with this and proceeds to install the ntp service. Are there certain services that have recipes defined within the "core" chef install? Here's a layout of my setup:

solo.rb

root = File.absolute_path(File.dirname(__FILE__))

data_bag_path root + '/data-bags'
file_cache_path root

cookbook_path [root + '/cookbooks', root + '/site-cookbooks']

solo.json

"run_list": [
    "recipe[base]"
]

site-cookbooks/recipes/base/default.rb

package 'ntp'

The cookbooks/ntp recipe was not created myself but seems to be valid, it's just not getting called.

edit

adding logs:

[Sat, 02 Jun 2012 22:25:13 -0700] INFO: *** Chef 0.10.10 ***
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Building node object for mike-VirtualBox
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Extracting run list from JSON attributes provided on command line
[Sat, 02 Jun 2012 22:25:14 -0700] INFO: Setting the run_list to ["recipe[base]"] from JSON
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Applying attributes from json file
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Platform is ubuntu version 12.04
[Sat, 02 Jun 2012 22:25:14 -0700] INFO: Run List is [recipe[base]]
[Sat, 02 Jun 2012 22:25:14 -0700] INFO: Run List expands to [base]
[Sat, 02 Jun 2012 22:25:14 -0700] INFO: Starting Chef Run for mike-VirtualBox
[Sat, 02 Jun 2012 22:25:14 -0700] INFO: Running start handlers
[Sat, 02 Jun 2012 22:25:14 -0700] INFO: Start handlers complete.
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: No chefignore file found at /tmp/chef/site-cookbooks/chefignore no files will be ignored
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Loading Recipe base via include_recipe
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Found recipe default in cookbook base
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Platform ubuntu not found, using all defaults. (Unsupported platform?)
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Loading from cookbook_path: /tmp/chef/site-cookbooks
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Converging node mike-VirtualBox
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Processing package[ntp] on mike-VirtualBox
[Sat, 02 Jun 2012 22:25:14 -0700] INFO: Processing package[ntp] action install (base::default line 3)
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: package[ntp] checking package status for ntp
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: package[ntp] current version is nil
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: package[ntp] candidate version is 1:4.2.6.p3+dfsg-1ubuntu3
[Sat, 02 Jun 2012 22:25:14 -0700] DEBUG: Executing apt-get -q -y install ntp=1:4.2.6.p3+dfsg-1ubuntu3
[Sat, 02 Jun 2012 22:25:21 -0700] DEBUG: ---- Begin output of apt-get -q -y install ntp=1:4.2.6.p3+dfsg-1ubuntu3 ----
[Sat, 02 Jun 2012 22:25:21 -0700] DEBUG: STDOUT: Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
    ntp-doc
The following NEW packages will be installed:
    ntp
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/570 kB of archives.
After this operation, 1,368 kB of additional disk space will be used.
Selecting previously unselected package ntp.
(Reading database ... 171196 files and directories currently installed.)
Unpacking ntp (from .../ntp_1%3a4.2.6.p3+dfsg-1ubuntu3_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up ntp (1:4.2.6.p3+dfsg-1ubuntu3) ...
* Starting NTP server ntpd
...done.

Any ideas on what might be going on? Thanks!

2

2 Answers

0
votes

What tutorials exactly are you following?

You should have a role called "base", in the run list of which you should have recipe[ntp], and an ntp cookbook, which should be under site-cookbooks/ntp (the ntp recipe would then be site-cookbooks/ntp/recipes/default.rb).

I'm honestly not sure what exactly is happening during your chef run, could you maybe post a log?

0
votes

So there really was no problem, just me fundamentally misunderstanding the relationship of run_lists and recipes. The base recipe in my site-cookbooks directory is the recipe, an incredibly simply recipe but one nonetheless:

package 'ntp'

Because I saw a separate ntp recipe within the cookbooks directory, this led me to the misunderstanding that the line above somehow needed to reference the recipe within cookbooks. This is not the case. So my run_list changed from:

"run_list": [
    "recipe[base]"
]

to:

"run_list": [
    "recipe[ntp]"
]

This calls the cookbooks\ntp recipe and everything looks as expected on my vm. Thanks for bouncing ideas off on this, hope this helps a fellow chef newbie.