我非常对厨师来说是新手,并且带着ubuntu 12的新鲜内容我正在玩厨师独奏。在关于这个主题的一些博客教程之后,我决定修改我的vm上的配方安装ntp服务。在完成了使用vm安装ruby,rubygems和最后的厨师的引导过程之后,最初的ntp运行似乎运行正常。在运行之前,pgrep ntpd将返回空白,运行后相同的命令将返回进程ID。但仔细检查了/etc/ntp.conf文件后,我意识到它没有使用我的配方中定义的模板的模板化版本。在进一步调查之后,我开始测试我的ntp配方在厨师 - 独奏运行中根本没有被提及的理论。我将cookbooks / ntp目录重命名为cookbooks / ntp_foo。然而,引用它的基本配方非常满意,并继续安装ntp服务。是否有某些服务在“核心”厨师安装中定义了配方?这是我的设置布局:
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]"
]
站点食谱/食谱/碱/ default.rb
package 'ntp'
cookbooks/ntp
食谱不是自己创建的,但似乎是有效的,它只是没有被调用。
修改的
添加日志:
[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.
有关可能发生的事情的任何想法?谢谢!
答案 0 :(得分:0)
您正在阅读哪些教程?
你应该有一个名为“base”的角色,在你应该拥有recipe[ntp]
的运行列表中,以及一个ntp cookbook,它应该在site-cookbooks / ntp下(ntp recipe将是site -cookbooks / NTP /食谱/ default.rb)。
老实说,我不确定在你的厨师运行期间究竟发生了什么,你可以张贴日志吗?
答案 1 :(得分:0)
所以确实没有问题,只是我从根本上误解了run_lists
和recipes
的关系。我的site-cookbooks
目录中的基本配方是配方,这是一个令人难以置信的简单配方,但仍然是:
package 'ntp'
因为我在ntp
目录中看到了一个单独的cookbooks
食谱,这让我误以为上面的行以某种方式需要在cookbooks
中引用食谱。不是这种情况。所以我的run_list
改为:
"run_list": [
"recipe[base]"
]
为:
"run_list": [
"recipe[ntp]"
]
这会调用cookbooks\ntp
食谱,所有内容在我的虚拟机上看起来都是预期的。感谢您对此提出了一些想法,希望这能帮助一位厨师新手。