自定义 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 资源上下文中是否存在问题?