Ahh so close! Your load_current_resource
method isn't quite right. You need to set the instance_variable, but you've only set a local variable:
def load_current_resource
@current_resource = Chef::Resource::AppCookbookUserPostgresql.new(new_resource.name)
begin
@current_resource.name(new_resource.name)
@current_resource.username(new_resource.username)
@current_resource.password(new_resource.password)
@current_resource.database_name(new_resource.database_name)
@current_resource
rescue
Chef::Log.debug("Cannot find #{new_resource} in the swarm")
end
end
I've also moved the initial creation outside of the begin
block. You still want to create an empty resource, even if something fails. That being said, that rescue block is entirely unnecessary. It should just be:
def load_current_resource
@current_resource = Chef::Resource::AppCookbookUserPostgresql.new(new_resource.name)
@current_resource.username(new_resource.username)
@current_resource.password(new_resource.password)
@current_resource.database_name(new_resource.database_name)
@current_resource
end