在资源主厨的notify子句中使用属性

时间:2015-08-11 14:04:50

标签: ruby chef devops

我想在资源的notify子句中使用属性值。我写了下面的代码,它将首先创建一个目录,然后将.zip从cookbook_file复制到该目录。它为notify子句

提供了错误
notifies :create , 'cookbook_file["#{node['INSTALLDIR']}/#{node['INSTALLER']}"]', :immediately
 
cookbook_file "#{node['INSTALLDIR']}/#{node['INSTALLER']}" do
    source "installer.zip"
    mode 0755
    owner "no"
    group "admin"
    action :nothing
    notifies :install , 'apt_package[unzip]', :immediately
    notifies :run , 'bash[extract]', :immediately
end

user 'no' do
    comment 'User to run wso2 App Server'
    password 'admin@123'
    home '/home/no'
end

directory node['INSTALLDIR'] do
    owner "no"
    group "admin"
    mode "0755"
    action :create
    notifies :create , 'cookbook_file["#{node['INSTALLDIR']}/#{node['INSTALLER']}"]', :immediately
end

apt_package 'unzip' do
    action :install
end

apt_package 'openjdk-6-jdk' do
    action :install
end

由于

1 个答案:

答案 0 :(得分:1)

问题是字符串插值({ "data": { "type": "user", "id": 1361, "attributes": { "User": "foo", "Email": null, "PCTID": 1 } }, "included": [ { "type": "classification", "id": 1, "attributes": { "Classification": "Room", "PostedBy": "P Hauser", "DatePosted": "2014-09-17T00:00:00.000Z", "Bulletin": "All data is fictitious", "ExpireDate": null, "Title": "Bar for foo", "User": 1361, "UserClassification": { "UserId": 1361, "ClassificationId": 1 } } } ] } )仅适用于双引号内。试试这个:

#{...}