tmpup
2011-Nov-14 05:28 UTC
[Puppet Users] How to use built-in resource in custom provider?
I''m trying to use the existing type: file in a custom provider. I''ve tried about every single thing I can find, and each way presents a different problem. Here''s how it looks now: --- require ''puppet/file_serving/configuration'' require ''puppet/file_serving/fileset'' require ''puppet/type'' require ''fileutils'' Puppet::Type.type(:tmfile).provide(:pupfile) do def create @catalog.add_resource Puppet::Type.type(:file).new({ :name => @resource.value(:path), :path => @resource.value(:path), :source => @resource.value(:source), :ensure => ''present'', }) @catalog.apply #def generate #Puppet::Type.type(:file).new(:path => resource[:path], :source => resource[:path], :ensure => ''present'') #end end def destroy FileUtils.rm_rf resource[:path] end def exists? File.exists?(@resource[:path]) end end ---- As you can see, another method I tried is commented out: Puppet::Type.type(:file).new(:path => resource[:path], :source => resource[:path], :ensure => ''present''). With this method, the puppet run actually succeeds and it says it created the resource. However, the file doesn''t actually get created, and next run, it simply creates the resource again without error. However, the file is never there. With the current method (not commented out), I get: ".. ensure: change from absent to present failed: Could not set ''present on ensure: undefined method `add_resource'' for nil:NilClass at .." I will admit that I''m pretty new at custom types and providers. I have researched as much as I can but can''t really find any clear documentation on how to do this. Any ideas/suggestions would be greatly appreciated! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2011-Nov-14 14:32 UTC
[Puppet Users] Re: How to use built-in resource in custom provider?
On Nov 13, 11:28 pm, tmpup <justin.francesc...@gmail.com> wrote:> I''m trying to use the existing type: file in a custom provider. I''ve > tried about every single thing I can find, and each way presents a > different problem. > > Here''s how it looks now: > > --- > require ''puppet/file_serving/configuration'' > require ''puppet/file_serving/fileset'' > require ''puppet/type'' > require ''fileutils'' > > Puppet::Type.type(:tmfile).provide(:pupfile) do > def create > @catalog.add_resource Puppet::Type.type(:file).new({ > :name => @resource.value(:path), > :path => @resource.value(:path), > :source => @resource.value(:source), > :ensure => ''present'', > }) > @catalog.apply > #def generate > #Puppet::Type.type(:file).new(:path => > resource[:path], :source => resource[:path], :ensure => ''present'') > #end > end > > def destroy > FileUtils.rm_rf resource[:path] > end > > def exists? > File.exists?(@resource[:path]) > end > > end > ---- > > As you can see, another method I tried is commented out: > Puppet::Type.type(:file).new(:path => resource[:path], :source => > resource[:path], :ensure => ''present''). With this method, the puppet > run actually succeeds and it says it created the resource. However, > the file doesn''t actually get created, and next run, it simply creates > the resource again without error. However, the file is never there. > > With the current method (not commented out), I get: > ".. ensure: change from absent to present failed: Could not set > ''present on ensure: undefined method `add_resource'' for nil:NilClass > at .." > > I will admit that I''m pretty new at custom types and providers. I > have researched as much as I can but can''t really find any clear > documentation on how to do this. Any ideas/suggestions would be > greatly appreciated!For what you appear to be doing, a Ruby custom type is too heavy. If that''s all you need to do then you should use a definition (a.k.a. defined type) instead, or perhaps just a bare File resource. I think it unlikely that any variation on your approach will work, inasmuch as it is surely incorrect for a provider to invoke @catalog.apply. The agent will invoke that method, so you''ll get duplicate invocations, and anyway the provider''s invocation(s) cannot help but be timed wrongly. You could try just removing that, but I suspect that also a provider''s create() method is too late for catalog.add_resource(). In general, I don''t think that the catalog API is intended to be used by types or providers at all. It is far more typical for providers that want to manage files to do so via the standard Ruby APIs (e.g. class File). If you want to use Puppet''s File resouce then you should do so from within your manifests, not within a custom provider. If a Puppet defined type isn''t powerful enough to do all of what you want, then perhaps your design concept needs to be reconsidered. We might be able to help with that if you''ll give us the big picture. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
tmpup
2011-Nov-14 16:28 UTC
[Puppet Users] Re: How to use built-in resource in custom provider?
What you alluded to in your final paragraph is exactly right - I''m basically trying to extend the file type. I''d like for a source to be S3, and be able to specify it much like you specify the source being the puppet file server (e.g puppet:/// would be s3://). So, I got the s3 part working, now I just need to have the type/provider handle files if the source is puppet. I figured the easiest way to do this was using the existing type. Right now, I can''t envision how I''d make a definition work here, as a new provider is obviously required for the s3 part. For reference, removing the the catalog.apply method still left things with the same error (undefined method `add_resource''). Any advice is greatly appreciated. On Nov 14, 6:32 am, jcbollinger <John.Bollin...@stJude.org> wrote:> On Nov 13, 11:28 pm, tmpup <justin.francesc...@gmail.com> wrote: > > > > > > > > > > > I''m trying to use the existing type: file in a custom provider. I''ve > > tried about every single thing I can find, and each way presents a > > different problem. > > > Here''s how it looks now: > > > --- > > require ''puppet/file_serving/configuration'' > > require ''puppet/file_serving/fileset'' > > require ''puppet/type'' > > require ''fileutils'' > > > Puppet::Type.type(:tmfile).provide(:pupfile) do > > def create > > @catalog.add_resource Puppet::Type.type(:file).new({ > > :name => @resource.value(:path), > > :path => @resource.value(:path), > > :source => @resource.value(:source), > > :ensure => ''present'', > > }) > > @catalog.apply > > #def generate > > #Puppet::Type.type(:file).new(:path => > > resource[:path], :source => resource[:path], :ensure => ''present'') > > #end > > end > > > def destroy > > FileUtils.rm_rf resource[:path] > > end > > > def exists? > > File.exists?(@resource[:path]) > > end > > > end > > ---- > > > As you can see, another method I tried is commented out: > > Puppet::Type.type(:file).new(:path => resource[:path], :source => > > resource[:path], :ensure => ''present''). With this method, the puppet > > run actually succeeds and it says it created the resource. However, > > the file doesn''t actually get created, and next run, it simply creates > > the resource again without error. However, the file is never there. > > > With the current method (not commented out), I get: > > ".. ensure: change from absent to present failed: Could not set > > ''present on ensure: undefined method `add_resource'' for nil:NilClass > > at .." > > > I will admit that I''m pretty new at custom types and providers. I > > have researched as much as I can but can''t really find any clear > > documentation on how to do this. Any ideas/suggestions would be > > greatly appreciated! > > For what you appear to be doing, a Ruby custom type is too heavy. If > that''s all you need to do then you should use a definition (a.k.a. > defined type) instead, or perhaps just a bare File resource. > > I think it unlikely that any variation on your approach will work, > inasmuch as it is surely incorrect for a provider to invoke > @catalog.apply. The agent will invoke that method, so you''ll get > duplicate invocations, and anyway the provider''s invocation(s) cannot > help but be timed wrongly. You could try just removing that, but I > suspect that also a provider''s create() method is too late for > catalog.add_resource(). In general, I don''t think that the catalog > API is intended to be used by types or providers at all. > > It is far more typical for providers that want to manage files to do > so via the standard Ruby APIs (e.g. class File). If you want to use > Puppet''s File resouce then you should do so from within your > manifests, not within a custom provider. If a Puppet defined type > isn''t powerful enough to do all of what you want, then perhaps your > design concept needs to be reconsidered. We might be able to help > with that if you''ll give us the big picture. > > John-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
tmpup
2011-Nov-14 20:12 UTC
[Puppet Users] Re: How to use built-in resource in custom provider?
An update - I went with a define as you suggested, and just made had my type/provider handle s3 only. This is working great, so I guess this is the method I''ll go with. Only issue I''m having now - all the parameters available with file() type. Sometimes we may want to specify owner, sometimes not, but it seems I have to predefine all the variables in the define (), and then if I DON''T use one of those variables, the puppet run fails. Conversely, if I do use a parameter but don''t have it as a variable in the define, it fails. So, basically, I need a way to specify optional parameters with defines(). I''ll keep looking around, but if anyone has any quick tips, it would be appreciated. On Nov 14, 6:32 am, jcbollinger <John.Bollin...@stJude.org> wrote:> On Nov 13, 11:28 pm, tmpup <justin.francesc...@gmail.com> wrote: > > > > > > > > > > > I''m trying to use the existing type: file in a custom provider. I''ve > > tried about every single thing I can find, and each way presents a > > different problem. > > > Here''s how it looks now: > > > --- > > require ''puppet/file_serving/configuration'' > > require ''puppet/file_serving/fileset'' > > require ''puppet/type'' > > require ''fileutils'' > > > Puppet::Type.type(:tmfile).provide(:pupfile) do > > def create > > @catalog.add_resource Puppet::Type.type(:file).new({ > > :name => @resource.value(:path), > > :path => @resource.value(:path), > > :source => @resource.value(:source), > > :ensure => ''present'', > > }) > > @catalog.apply > > #def generate > > #Puppet::Type.type(:file).new(:path => > > resource[:path], :source => resource[:path], :ensure => ''present'') > > #end > > end > > > def destroy > > FileUtils.rm_rf resource[:path] > > end > > > def exists? > > File.exists?(@resource[:path]) > > end > > > end > > ---- > > > As you can see, another method I tried is commented out: > > Puppet::Type.type(:file).new(:path => resource[:path], :source => > > resource[:path], :ensure => ''present''). With this method, the puppet > > run actually succeeds and it says it created the resource. However, > > the file doesn''t actually get created, and next run, it simply creates > > the resource again without error. However, the file is never there. > > > With the current method (not commented out), I get: > > ".. ensure: change from absent to present failed: Could not set > > ''present on ensure: undefined method `add_resource'' for nil:NilClass > > at .." > > > I will admit that I''m pretty new at custom types and providers. I > > have researched as much as I can but can''t really find any clear > > documentation on how to do this. Any ideas/suggestions would be > > greatly appreciated! > > For what you appear to be doing, a Ruby custom type is too heavy. If > that''s all you need to do then you should use a definition (a.k.a. > defined type) instead, or perhaps just a bare File resource. > > I think it unlikely that any variation on your approach will work, > inasmuch as it is surely incorrect for a provider to invoke > @catalog.apply. The agent will invoke that method, so you''ll get > duplicate invocations, and anyway the provider''s invocation(s) cannot > help but be timed wrongly. You could try just removing that, but I > suspect that also a provider''s create() method is too late for > catalog.add_resource(). In general, I don''t think that the catalog > API is intended to be used by types or providers at all. > > It is far more typical for providers that want to manage files to do > so via the standard Ruby APIs (e.g. class File). If you want to use > Puppet''s File resouce then you should do so from within your > manifests, not within a custom provider. If a Puppet defined type > isn''t powerful enough to do all of what you want, then perhaps your > design concept needs to be reconsidered. We might be able to help > with that if you''ll give us the big picture. > > John-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Aaron Grewell
2011-Nov-14 20:56 UTC
Re: [Puppet Users] Re: How to use built-in resource in custom provider?
Any parameters you don''t always want to provide have to have sensible defaults in the define. define dostuff (ImOptional="true", ImRequired){} On Mon, Nov 14, 2011 at 12:12 PM, tmpup <justin.francesconi@gmail.com> wrote:> An update - I went with a define as you suggested, and just made had > my type/provider handle s3 only. This is working great, so I guess > this is the method I''ll go with. > > Only issue I''m having now - all the parameters available with file() > type. Sometimes we may want to specify owner, sometimes not, but it > seems I have to predefine all the variables in the define (), and then > if I DON''T use one of those variables, the puppet run fails. > Conversely, if I do use a parameter but don''t have it as a variable in > the define, it fails. > > So, basically, I need a way to specify optional parameters with > defines(). I''ll keep looking around, but if anyone has any quick > tips, it would be appreciated. > > On Nov 14, 6:32 am, jcbollinger <John.Bollin...@stJude.org> wrote: >> On Nov 13, 11:28 pm, tmpup <justin.francesc...@gmail.com> wrote: >> >> >> >> >> >> >> >> >> >> > I''m trying to use the existing type: file in a custom provider. I''ve >> > tried about every single thing I can find, and each way presents a >> > different problem. >> >> > Here''s how it looks now: >> >> > --- >> > require ''puppet/file_serving/configuration'' >> > require ''puppet/file_serving/fileset'' >> > require ''puppet/type'' >> > require ''fileutils'' >> >> > Puppet::Type.type(:tmfile).provide(:pupfile) do >> > def create >> > @catalog.add_resource Puppet::Type.type(:file).new({ >> > :name => @resource.value(:path), >> > :path => @resource.value(:path), >> > :source => @resource.value(:source), >> > :ensure => ''present'', >> > }) >> > @catalog.apply >> > #def generate >> > #Puppet::Type.type(:file).new(:path => >> > resource[:path], :source => resource[:path], :ensure => ''present'') >> > #end >> > end >> >> > def destroy >> > FileUtils.rm_rf resource[:path] >> > end >> >> > def exists? >> > File.exists?(@resource[:path]) >> > end >> >> > end >> > ---- >> >> > As you can see, another method I tried is commented out: >> > Puppet::Type.type(:file).new(:path => resource[:path], :source => >> > resource[:path], :ensure => ''present''). With this method, the puppet >> > run actually succeeds and it says it created the resource. However, >> > the file doesn''t actually get created, and next run, it simply creates >> > the resource again without error. However, the file is never there. >> >> > With the current method (not commented out), I get: >> > ".. ensure: change from absent to present failed: Could not set >> > ''present on ensure: undefined method `add_resource'' for nil:NilClass >> > at .." >> >> > I will admit that I''m pretty new at custom types and providers. I >> > have researched as much as I can but can''t really find any clear >> > documentation on how to do this. Any ideas/suggestions would be >> > greatly appreciated! >> >> For what you appear to be doing, a Ruby custom type is too heavy. If >> that''s all you need to do then you should use a definition (a.k.a. >> defined type) instead, or perhaps just a bare File resource. >> >> I think it unlikely that any variation on your approach will work, >> inasmuch as it is surely incorrect for a provider to invoke >> @catalog.apply. The agent will invoke that method, so you''ll get >> duplicate invocations, and anyway the provider''s invocation(s) cannot >> help but be timed wrongly. You could try just removing that, but I >> suspect that also a provider''s create() method is too late for >> catalog.add_resource(). In general, I don''t think that the catalog >> API is intended to be used by types or providers at all. >> >> It is far more typical for providers that want to manage files to do >> so via the standard Ruby APIs (e.g. class File). If you want to use >> Puppet''s File resouce then you should do so from within your >> manifests, not within a custom provider. If a Puppet defined type >> isn''t powerful enough to do all of what you want, then perhaps your >> design concept needs to be reconsidered. We might be able to help >> with that if you''ll give us the big picture. >> >> John > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
tmpup
2011-Nov-14 22:01 UTC
[Puppet Users] Re: How to use built-in resource in custom provider?
That sort of works. The problem with that becomes multiple ways to get the file: source, content, target. You can''t specify both in the file definition. There would have to be some sort of conditional, I suppose. On Nov 14, 12:56 pm, Aaron Grewell <aaron.grew...@gmail.com> wrote:> Any parameters you don''t always want to provide have to have sensible > defaults in the define. > > define dostuff (ImOptional="true", ImRequired){} > > > > > > > > On Mon, Nov 14, 2011 at 12:12 PM, tmpup <justin.francesc...@gmail.com> wrote: > > An update - I went with a define as you suggested, and just made had > > my type/provider handle s3 only. This is working great, so I guess > > this is the method I''ll go with. > > > Only issue I''m having now - all the parameters available with file() > > type. Sometimes we may want to specify owner, sometimes not, but it > > seems I have to predefine all the variables in the define (), and then > > if I DON''T use one of those variables, the puppet run fails. > > Conversely, if I do use a parameter but don''t have it as a variable in > > the define, it fails. > > > So, basically, I need a way to specify optional parameters with > > defines(). I''ll keep looking around, but if anyone has any quick > > tips, it would be appreciated. > > > On Nov 14, 6:32 am, jcbollinger <John.Bollin...@stJude.org> wrote: > >> On Nov 13, 11:28 pm, tmpup <justin.francesc...@gmail.com> wrote: > > >> > I''m trying to use the existing type: file in a custom provider. I''ve > >> > tried about every single thing I can find, and each way presents a > >> > different problem. > > >> > Here''s how it looks now: > > >> > --- > >> > require ''puppet/file_serving/configuration'' > >> > require ''puppet/file_serving/fileset'' > >> > require ''puppet/type'' > >> > require ''fileutils'' > > >> > Puppet::Type.type(:tmfile).provide(:pupfile) do > >> > def create > >> > @catalog.add_resource Puppet::Type.type(:file).new({ > >> > :name => @resource.value(:path), > >> > :path => @resource.value(:path), > >> > :source => @resource.value(:source), > >> > :ensure => ''present'', > >> > }) > >> > @catalog.apply > >> > #def generate > >> > #Puppet::Type.type(:file).new(:path => > >> > resource[:path], :source => resource[:path], :ensure => ''present'') > >> > #end > >> > end > > >> > def destroy > >> > FileUtils.rm_rf resource[:path] > >> > end > > >> > def exists? > >> > File.exists?(@resource[:path]) > >> > end > > >> > end > >> > ---- > > >> > As you can see, another method I tried is commented out: > >> > Puppet::Type.type(:file).new(:path => resource[:path], :source => > >> > resource[:path], :ensure => ''present''). With this method, the puppet > >> > run actually succeeds and it says it created the resource. However, > >> > the file doesn''t actually get created, and next run, it simply creates > >> > the resource again without error. However, the file is never there. > > >> > With the current method (not commented out), I get: > >> > ".. ensure: change from absent to present failed: Could not set > >> > ''present on ensure: undefined method `add_resource'' for nil:NilClass > >> > at .." > > >> > I will admit that I''m pretty new at custom types and providers. I > >> > have researched as much as I can but can''t really find any clear > >> > documentation on how to do this. Any ideas/suggestions would be > >> > greatly appreciated! > > >> For what you appear to be doing, a Ruby custom type is too heavy. If > >> that''s all you need to do then you should use a definition (a.k.a. > >> defined type) instead, or perhaps just a bare File resource. > > >> I think it unlikely that any variation on your approach will work, > >> inasmuch as it is surely incorrect for a provider to invoke > >> @catalog.apply. The agent will invoke that method, so you''ll get > >> duplicate invocations, and anyway the provider''s invocation(s) cannot > >> help but be timed wrongly. You could try just removing that, but I > >> suspect that also a provider''s create() method is too late for > >> catalog.add_resource(). In general, I don''t think that the catalog > >> API is intended to be used by types or providers at all. > > >> It is far more typical for providers that want to manage files to do > >> so via the standard Ruby APIs (e.g. class File). If you want to use > >> Puppet''s File resouce then you should do so from within your > >> manifests, not within a custom provider. If a Puppet defined type > >> isn''t powerful enough to do all of what you want, then perhaps your > >> design concept needs to be reconsidered. We might be able to help > >> with that if you''ll give us the big picture. > > >> John > > > -- > > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > > To post to this group, send email to puppet-users@googlegroups.com. > > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. > > For more options, visit this group athttp://groups.google.com/group/puppet-users?hl=en.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2011-Nov-15 14:10 UTC
[Puppet Users] Re: How to use built-in resource in custom provider?
On Nov 14, 10:28 am, tmpup <justin.francesc...@gmail.com> wrote:> What you alluded to in your final paragraph is exactly right - I''m > basically trying to extend the file type. I''d like for a source to be > S3, and be able to specify it much like you specify the source being > the puppet file server (e.g puppet:/// would be s3://). So, I got the > s3 part working, now I just need to have the type/provider handle > files if the source is puppet. I figured the easiest way to do this > was using the existing type. > > Right now, I can''t envision how I''d make a definition work here, as a > new provider is obviously required for the s3 part. For reference, > removing the the catalog.apply method still left things with the same > error (undefined method `add_resource''). > > Any advice is greatly appreciated.Normally I might suggest writing a custom provider for the File type instead of creating a separate custom type, but File appears to be a special case that eschews the usual type / provider structure. At least in some versions of Puppet. Nevertheless, you do have the option of modifying the File type itself. If you are at liberty to do so then you might even consider contributing the modifications to Puppetlabs for inclusion in future versions of Puppet (though I cannot say how likely it is that they would be accepted). You could also try copying the File type wholesale, renaming it, and making your modifications there. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2011-Nov-30 17:00 UTC
Re: [Puppet Users] Re: How to use built-in resource in custom provider?
On 11/14/2011 09:12 PM, tmpup wrote:> So, basically, I need a way to specify optional parameters with > defines(). I''ll keep looking around, but if anyone has any quick > tips, it would be appreciated.Hi, on the risk of repeating myself ;) define my_file($ensure="present",$owner="",$mode="",content="") { if $owner != "" { File { owner => $owner } } if $mode != "" { File { mode => $mdoe } } if $content != "" { File { content => $content } } file { $name: ensure => $ensure } } You get the picture. With the above, you cannot pass ''content => ""'' to your custom file, but that should be acceptable. HTH, Felix -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2011-Nov-30 17:10 UTC
Re: [Puppet Users] Re: How to use built-in resource in custom provider?
On Wed, Nov 30, 2011 at 12:00 PM, Felix Frank <felix.frank@alumni.tu-berlin.de> wrote:> On 11/14/2011 09:12 PM, tmpup wrote: >> So, basically, I need a way to specify optional parameters with >> defines(). I''ll keep looking around, but if anyone has any quick >> tips, it would be appreciated. > > Hi, > > on the risk of repeating myself ;) > > define my_file($ensure="present",$owner="",$mode="",content="") { > if $owner != "" { File { owner => $owner } } > if $mode != "" { File { mode => $mdoe } } > if $content != "" { File { content => $content } } > file { $name: ensure => $ensure } > } >Wouldn''t undef make this easier? define my_file ( $ensure = present, $owner = undef, $mode = undef, $content = undef, ) { file { $name: ensure => $ensure, owner => $owner, mode => $mode, content => $content, } } Thanks, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2011-Dec-02 08:52 UTC
Re: [Puppet Users] Re: How to use built-in resource in custom provider?
On 11/30/2011 06:10 PM, Nan Liu wrote:> Wouldn''t undef make this easier?Yes, but I''ve had poor luck trying this back in the 0.25 days (e.g., having $mode be undef would not do nothing, as I''d hoped, iirc). I''ll give it another whirl one of these days. Thanks for bringing it up again :-) Cheers, Felix -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2011-Dec-12 09:40 UTC
Re: [Puppet Users] Re: How to use built-in resource in custom provider?
Hi, stumbled upon this again a couple of days ago. Turns out you *can* use undef as a default value for parameters of a define and it will word in Puppet 2.7.x. With 2.6.8, no cigar. Your parameters get the string value "undef", and defined($paramname) yields true. Cheers, Felix On 12/02/2011 09:52 AM, Felix Frank wrote:> On 11/30/2011 06:10 PM, Nan Liu wrote: >> > Wouldn''t undef make this easier? > Yes, but I''ve had poor luck trying this back in the 0.25 days (e.g., > having $mode be undef would not do nothing, as I''d hoped, iirc). > > I''ll give it another whirl one of these days. Thanks for bringing it up > again :-)-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.