Thanks Peter, but I can't make that work either. Puppet doesn't seem to like the defined( ) function inside the exec attributes list. It's kicking back a syntax error of the form: Error: Syntax error at 'defined'; expected '}' at /tmp/vagrant-puppet-1/modules-0/drush/manifests/exec.pp:65
-Mark On Thursday, May 29, 2014 9:42:49 AM UTC-5, Peter Bukowinski wrote: > > > On May 29, 2014, at 10:23 AM, Mark McFate <[email protected]<javascript:>> > wrote: > > I'm probably going about this all wrong, but I have an instance where I've > employed a Puppet module and need to *sometimes* add a "creates" > attribute to one of the exec's defined there. My code (below) is probably > all wrong, but I think you'll see what I am trying to do... > > if $creates != nil { > exec { "drush-${title}" : > command => "drush ${command} ${root_option} ${uri_option} > ${force_option} ${additional_options}", > path => [ '/bin', '/usr/bin' ], > creates => $creates, > } > } else { > exec { "drush-${title}" : > command => "drush ${command} ${root_option} ${uri_option} > ${force_option} ${additional_options}", > path => [ '/bin', '/usr/bin' ], > } > } > > > This doesn't work and neither does specifying an empty or nil attribute, > like "creates => ''" or "creates => nil". > > If nothing else, I will create two different exec's, one with and the > other without a creates attribute. Can anyone suggest a more elegant > solution? > > Thanks in advance. > > > This can likely be solved with the defined() function. > http://docs.puppetlabs.com/references/latest/function.html#defined > > exec { "drush-${title}" : > command => "drush ${command} ${root_option} ${uri_option} > ${force_option} ${additional_options}", > path => [ '/bin', '/usr/bin' ], > if defined('$creates') { > creates => $creates, > } > } > > -- > Peter > > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ee02f68e-d675-4367-ba55-a68ce316e38f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
