Ask Your Question
1

Custom type and confine

asked 2015-02-26 23:23:20 -0500

sheshi gravatar image

I am writing a type with two providers. Can I specify 'confine' option to each provider based on the type param value?

Thanks

-Sheshi

edit retag flag offensive close merge delete

Comments

Thanks Greg, That is exactly what I wanted. Let me give it a try. -Sheshi

sheshi gravatar imagesheshi ( 2015-02-27 22:46:36 -0500 )edit

Hi Greg, I am getting undefined local variable or method `resource' for Puppet::Type::, if I am trying to access the resource hash in the confine block. Is 'resource' not visible in the confine block? Thanks -Sheshi

sheshi gravatar imagesheshi ( 2015-02-27 23:47:37 -0500 )edit

Can you post your complete type and provider code and sample usage somewhere for me to look at?

GregLarkin gravatar imageGregLarkin ( 2015-03-02 18:16:00 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-02-27 17:56:48 -0500

GregLarkin gravatar image

It does look like you can write something like this:

confine :true => begin
  # Test for the suitability of this provider based on some attributes value
  if (resource[:myparam] == myvalue)
    true
  else
    false
  end
end

I'm no Puppet provider developer yet, and not too much of a Ruby programmer either, so take this with a large grain of salt and YMMV! I would like to hear if it does what you want, though.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-26 23:22:43 -0500

Seen: 252 times

Last updated: Feb 27 '15