Chef :: Resource :: Directory的未定义方法`checksum'

时间:2012-11-28 11:23:39

标签: checksum chef recipe

在运行金字塔的配方时,以下内容在chef-solo中失败:

================================================================================
Error executing action `create` on resource 'directory[/etc/service/pyramid/supervise/status]'
================================================================================

NoMethodError
-------------
undefined method `checksum' for Chef::Resource::Directory

Resource Declaration:
---------------------
# In /var/chef-solo/cookbooks/project/recipes/pyramid.rb

 22:     directory "#{node['runit']['service_dir']}/pyramid#{dir}/supervise/#{f}" do
 23:       owner login
 24:       group login
 25:     end
 26:   end

Compiled Resource:
------------------
# Declared in /var/chef-solo/cookbooks/project/recipes/pyramid.rb:22:in `block (2 levels) in from_file'

directory("/etc/service/pyramid/supervise/status") do
  provider Chef::Provider::Directory
  action :create
  retries 0
  retry_delay 2
  path "/etc/service/pyramid/supervise/status"
  cookbook_name :project
  recipe_name "pyramid"
  owner "myusername"
  group "myusername"
  mode 420
end

为什么这会得到“未定义的方法checksum”,我该怎么办呢?

此错误似乎不一致。有时厨师跑步似乎挂了。其他时候,经过多次运行,厨师能够通过这一点。

我正在运行一个带有部署脚本的厨师Ubuntu服务器12.04LTS上运行:

sudo apt-get install -y ruby1.9.1 ruby1.9.1-dev make &&
sudo gem1.9.1 install chef ohai --no-rdoc --no-ri

这是完整的金字塔食谱:

login = node["user"]["login"]
home = node["user"]["home"]
app_root = node["user"]["app_root"]

runit_service "pyramid" do #, :template_name => "site" do
  template_name "pyramid"
  owner login
  group login
  options({
    :login => login,
    :app_root => app_root,
    :home => home,
    :config => "#{app_root}/config/gunicorn.conf.py"
  })
end

["", "/log"].each do |dir|
  directory "#{node['runit']['service_dir']}/pyramid#{dir}/supervise" do
    mode "0755"
  end
  %w(ok control status).each do |f|
    directory "#{node['runit']['service_dir']}/pyramid#{dir}/supervise/#{f}" do
      owner login
      group login
    end
  end
end

1 个答案:

答案 0 :(得分:3)

这是我的解决方案 - 经过一些黑客攻击后发现加上来自@Draco-ater的小费......

如果食谱引用directory("/etc/service/pyramid/supervise/status"),则状态“目录”是已存在的文件,导致出现问题。

此外,该脚本还尝试将controlok管道更新为目录 - 这也是失败的。我使用bashchmod

解决了这个问题
bash "give_perms_pyramid" do
    user "chef"
    cwd "#{node['runit']['service_dir']}/pyramid#{dir}/supervise"
    code <<-EOH
        sudo chown myuser:root control
        sudo chmod g+rw control
    EOH

也许这会对某人有所帮助。