FAQ

On Wednesday, July 17, 2013 1:29:20 PM UTC-5, Jakov Sosic wrote:
Hi,

is it possible to choose the provider based on property?

For example, I'm trying to develop two different providers for same type
of resource. If i use path location on the local filesystem I want
provider "local" to be chosen, and if I use link property, then I want
provider "remote" to be chosen.

For example, this definition should chose provider 'local':

resource { 'a':
path => '/some/local/disk.iso',
}


And this definition should chose provider 'remote':

resource { 'a':
link => 'http://example.com/disk.iso',
}

Is this possible without manually specifying "provider => remote"?
Not to my knowledge, no.

This is not the correct provider paradigm. The provider for a given
resource type used on a given node, if not specified explicitly, is
supposed to be chosen based on the characteristics of the node, not of the
resource. You seem to be artificially separating your provider into two
pieces. My recommendation would be to create one provider whose behavior
varies according to the resource's properties, instead of trying to make
the choice between different providers depend on resource properties.


Also, second question. It would be great if puppet could raise error in
case when both conflicting properties are set. For example this should
yeild an error:

resource { 'a':
path => '/some/local/disk.iso',
link => 'http://example.com/disk.iso',
}

Is this possible?

I think you can use the property validation hook to accomplish this. It is
focused on validating individual properties, and there is no guarantee of
which property will be validated first, but all you really need is to raise
/ check a flag an the resource instance as part of the validation of each
of those properties. You raise an ArgumentError if the validation code for
either property finds that the flag is already raised. See
http://docs.puppetlabs.com/guides/custom_types.html for general details on
the property validation hook.

If these questions are more suitable to puppet-dev list, I will post
them there. Thank you guys.

No, puppet-dev is for discussion of the development of Puppet itself, not
for questions about its use. "Development" of Puppet manifests is a usage
issue with respect to the Puppet program.


John

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJul 17, '13 at 6:29p
activeJul 18, '13 at 2:46p
posts3
users2
websitepuppetlabs.com

2 users in discussion

Jakov Sosic: 2 posts Jcbollinger: 1 post

People

Translate

site design / logo © 2021 Grokbase