厨师从包装食谱中倒带cookbook_file定义 [英] chef rewind cookbook_file definition from a wrapper cookbook recipe

查看:150
本文介绍了厨师从包装食谱中倒带cookbook_file定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用食谱github.com opscode-cookbooks/openldap. 我写了一个包装食谱"lab_openldap",其中包含"openldap :: server"食谱.

I am using an cookbook github.com opscode-cookbooks/openldap. I wrote an wrapper cookbook "lab_openldap" that includes "openldap::server" recipe.

server.rb配方使用以下子句将PEM文件从Cookbooks文件/ssl/*.pem上传到服务器到位置节点['openldap'] ['ssl_cert'].

The server.rb recipe uses following clausule to upload the PEM file from cookbooks files/ssl/*.pem to server to the location node['openldap']['ssl_cert'].

if node['openldap']['tls_enabled'] && node['openldap']['manage_ssl']
  cookbook_file node['openldap']['ssl_cert'] do
    source "ssl/#{node['openldap']['server']}.pem"
    mode 00644
    owner "root"
    group "root"
  end
end

尝试从"openldap"食谱文件/ssl/#{node['openldap']['server']}.pem"位置读取PEM.

The PEM is tried to be read from "openldap" cookbook file/ssl/#{node['openldap']['server']}.pem" location.

我的包装盒"lab_openldap"食谱文件/ssl/#{node['openldap']['server']}.pem中有我的PEM文件.

I have my PEM file in wrapper "lab_openldap" cookbook file/ssl/#{node['openldap']['server']}.pem" location.

是否可以修改"lab_openldap :: server.rb"配方以从包装食谱中加载PEM?

Is it possible to modify the "lab_openldap::server.rb" recipe to load PEM from a wrapper cookbook?

注意: 我知道 https://github.com/bryanwb/chef-rewind 但它没有似乎可以解决这种情况.

Notes: I am aware of https://github.com/bryanwb/chef-rewind but it does not seem to manage this situation.

使用r.resource提供的答案是正确的.

The provided answer using r.resource is correct.

实际上,特定代码中的问题是根据 http://docs的"source"关键字上的. opscode.com/resource_cookbook_file.html 指的是位于厨师仓库中的食谱中/files目录中文件的位置.

Actually the issue in the particular code is on "source" keyword that according to http://docs.opscode.com/resource_cookbook_file.html refers to the location of a file in the /files directory in a cookbook located in the chef-repo.

r = resources("cookbook_file[#{node['openldap']['ssl_cert']}]")
r.cookbook('lab_openldap')

cookbook_file node['openldap']['ssl_cert'] do
    source "ssl/#{node['openldap']['server']}.pem"
    mode 00644
    owner "root"
    group "root"
end

推荐答案

当然是!包装时,只需在资源上设置cookbook属性.默认情况下,它是当前食谱",但是您可以更改它:

Of course it is! You just need to set the cookbook attribute on the resource when you wrap it. By default, it's "the current cookbook", but you can change it:

r = resources("cookbook_file[#{node['openldap']['ssl_cert']}]")
r.cookbook('my_wrapper_cookbook')

如果您查看Bryan的厨师倒带,您会看到它

If you look at Bryan's Chef Rewind, you'll see it does the same thing

这篇关于厨师从包装食谱中倒带cookbook_file定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆