Aaron
2010-Oct-05 00:11 UTC
[Puppet Users] exec a command if return value from exec''ing another command is non-zero
Hi puppet experts,
I''m pretty new to puppet and am having some trouble finding the right
way to specify the functionality I need.
Specifically, lets say I have a command to create some key/value pair:
myCommand -create "key" "value"
And I have a second command to list key/value pairs:
myCommand -list "key"
I only want to run the -create if the -list returns a some non-zero
value, indicating that no matching entries were found. I imagine I
would want something like this:
exec { myCommand-create:
command => "myCommand -create key value",
path => ["/bin"]
require => [
something that runs -list and checks return code.
]
}
--
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
2010-Oct-05 00:22 UTC
[Puppet Users] Re: exec a command if return value from exec''ing another command is non-zero
Sorry for wasting anyones time, just found the "onlyif" parameter. On Oct 4, 5:11 pm, Aaron <a.u.t.i.s.m....@gmail.com> wrote:> Hi puppet experts, > > I''m pretty new to puppet and am having some trouble finding the right > way to specify the functionality I need. > > Specifically, lets say I have a command to create some key/value pair: > > myCommand -create "key" "value" > > And I have a second command to list key/value pairs: > > myCommand -list "key" > > I only want to run the -create if the -list returns a some non-zero > value, indicating that no matching entries were found. I imagine I > would want something like this: > > exec { myCommand-create: > command => "myCommand -create key value", > path => ["/bin"] > require => [ > something that runs -list and checks return code. > ] > }-- 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.
Michael Knox
2010-Oct-05 00:25 UTC
Re: [Puppet Users] exec a command if return value from exec''ing another command is non-zero
Aaron, unless is probably the param you need for exec. require and before are for defining dependencies between items defined in puppet. See below in your example. Cheers On 5/10/10 11:11 AM, Aaron wrote:> Hi puppet experts, > > I''m pretty new to puppet and am having some trouble finding the right > way to specify the functionality I need. > > Specifically, lets say I have a command to create some key/value pair: > > myCommand -create "key" "value" > > And I have a second command to list key/value pairs: > > myCommand -list "key" > > I only want to run the -create if the -list returns a some non-zero > value, indicating that no matching entries were found. I imagine I > would want something like this: > > exec { myCommand-create: > command => "myCommand -create key value", > path => ["/bin"]unless => myCommand -list "key"> require => [whatever the dependancies of myCommand are> ] > } >-- 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.