-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Wouldn't this possibly have unintended consequences, or would the scope of the overrides be restricted to the define in this case?
Trevor On 12/22/2009 08:14 AM, R.I.Pienaar wrote: > hello, > > You can use the ability to set defaults for resources: > > define mfile($content = undef, $source = undef) { > if $content { > File[$name] { > content => $content > } > } else { > File[$name] { > source => $source > } > } > > file{$name: } > } > > > > ----- "Daniel Pittman" <dan...@rimspace.net> wrote: > >> G'day. >> >> I sometimes want to write a 'define' that wraps some higher level >> behaviour >> around a low level 'file' statement, akin to this: >> >> define example ($source = false, $content = false) { >> file { "/path/to/whatever/${name}": >> ensure => file, source => $source, content => $content, >> notify => Service["some-service"], >> etc, etc, etc >> } >> } >> >> This is great, except it doesn't work. It returns an error that >> source is >> nil, if I specify content, and that is that. >> >> Instead, I get to write out the same file stanza twice, once with >> content and >> once with source, as well as a third stanza that fails when neither is >> set. >> >> >> Wouldn't it be wonderful if there was a standard way to express this >> idiom? >> >> Daniel >> >> ...now someone is gonna tell me that I missed something obvious, but >> that is >> fine with me: saving the time I waste on these is worth enough for me. >> :) >> >> -- >> ✣ Daniel Pittman ✉ dan...@rimspace.net ☎ +61 401 >> 155 707 >> ♽ made with 100 percent post-consumer electrons >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups "Puppet Users" group. >> To post to this group, send email to puppet-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkszQy0ACgkQyjMdFR1108B18gCdFlXjDTAkiM7+6itiTS5DXab6 gAYAoKaRhcCPk9v0lc1ZxLb4hcNcUXNo =t2F3 -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.