I’m trying to work through custom resources a bit, and I’m using a users cookbook to do it. I have one custom resource for a standard user (call it custom_user), and then I have another user that I want to have ssh keys from multiple other users in (call it special_user).
First step in that is to find all of the custom users. I have this in a helper that I’ve made available to the custom resource:
def foo
public_keys = []
run_context.resource_collection.each do |res|
if res.is_a?(custom_user)
public_keys << res.public_keys
end
end
end
But, that isn’t working. I replaced it with a log entry to give me inspect output, and it looks like it has a class of custom_user – but I guess I’m not sure how to refer to my custom resource in the is_a line in a way that chef/ruby will recognize.
If it was the old-school resources, I’m guessing I could fix this by making the custom_user the parent class for a special_user – but I don’t think you can do that with the new custom resources, (or at least that’s not immediately obvious to me in the docs).