【发布时间】:2014-08-19 21:53:06
【问题描述】:
自定义 LWRP 的创建报告资源在 Chef 的资源上下文中为零。这是我的第一步?
action :install do
converge_by "Installing postgresql-#{@new_resource.version}" do
execute "sudo apt-get install postgresql-#{@new_resource.version} #{@new_resource.options}" do
not_if { "dpkg --get-selections | grep postgresql-#{VERSION}" }
end
@new_resource.updated_by_last_action(true)
end
end
但是,我将全局变量值保存在其他局部变量中。像这样:
action :install do
converge_by "Installing postgresql-#{@new_resource.version}" do
VERSION = @new_resource.version
OPTIONS = @new_resource.options
execute "sudo apt-get install postgresql-#{VERSION} #{OPTIONS}" do
not_if { "dpkg --get-selections | grep postgresql-#{VERSION}" }
end
@new_resource.updated_by_last_action(true)
end
end
然后,问题就解决了。
Chef 资源上下文中的全局变量是否存在问题?
【问题讨论】:
-
你不使用verify_by + updated_by_last_action
标签: chef-infra chef-solo lwrp