FAQ
The following code example is purely academical but it illustrates my
question pretty well.

define touch($file=$title, $unless='/bin/false') {
exec { "/bin/touch ${file}": unless => $unless }
}

If I define my own resource type that wraps another *exec* resource and I
want to *add an optional "unless" condition* that I - if set - pass to the
optional "unless" condiftion of *exec* - do I have to preset the field with
'/bin/false'?

My understanding is that for each catalog run and all uses of this custom
ressource type this resource's unless check will then spawn a bash process
running '/bin/false' if the unless field of "touch" hasn't been set .

What I actually intend is not to do any "unless" check at all if the field
hasn't been set - including calling "/bin/false".

Any thoughts? Thanks!

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jcbollinger at Apr 10, 2013 at 2:14 pm

    On Wednesday, April 10, 2013 4:26:19 AM UTC-5, christian...@gmail.com wrote:
    The following code example is purely academical but it illustrates my
    question pretty well.

    define touch($file=$title, $unless='/bin/false') {
    exec { "/bin/touch ${file}": unless => $unless }
    }

    If I define my own resource type that wraps another *exec* resource and I
    want to *add an optional "unless" condition* that I - if set - pass to
    the optional "unless" condiftion of *exec* - do I have to preset the
    field with '/bin/false'?

    My understanding is that for each catalog run and all uses of this custom
    ressource type this resource's unless check will then spawn a bash process
    running '/bin/false' if the unless field of "touch" hasn't been set .

    What I actually intend is not to do any "unless" check at all if the field
    hasn't been set - including calling "/bin/false".

    Any thoughts? Thanks!
    I think a parameter default of 'undef' will probably achieve what you want:

    # note: the undef keyword must be unquoted
    define touch($unless = undef) {
    exec { "/bin/touch ${title}": unless => $unless }
    }

    If that doesn't work then you can use a testable dummy value for the
    parameter default, and use conditional code to declare the Exec without an
    'unless' parameter when no explicit value is declared for the defined-type
    instance.


    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Christian Le Flamm at Apr 10, 2013 at 3:18 pm
    Never heard of *undef *before - sounds great! Thanks

    --
    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?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedApr 10, '13 at 9:26a
activeApr 10, '13 at 3:18p
posts3
users2
websitepuppetlabs.com

2 users in discussion

Christian Le Flamm: 2 posts Jcbollinger: 1 post

People

Translate

site design / logo © 2021 Grokbase