shlo.afgin@gmail.com
2013-Dec-18 08:41 UTC
[Puppet Users] How Puppet can evaluate the output od command?
Hi, I want to run a command something like: *cat /tmp/aao | grep aa | wc -l* Check the output of that command, if the output is ''0'', I want to get a failure from puppet. I tried to use ''exec'' with ''returns'' but it''s seem that ''returns'' take the return code of the command and not the output of the command. How can I do it right? -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/8e6127be-3919-4769-a68f-c0e9c01a46c1%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Stephen Gran
2013-Dec-18 09:11 UTC
Re: [Puppet Users] How Puppet can evaluate the output od command?
On 12/18/2013 08:41 AM, shlo.afgin@gmail.com wrote:> > Hi, > > I want to run a command something like: > /cat /tmp/aao | grep aa | wc -l/ > Check the output of that command, if the output is ''0'', I want to get a > failure from puppet. > I tried to use ''exec'' with ''returns'' but it''s seem that ''returns'' take > the return code of the command and not the output of the command. > How can I do it right?test $(grep -c aa /tmp/aao) -gt 0 Cheers, -- Stephen Gran Senior Systems Integrator - theguardian.com Please consider the environment before printing this email. ------------------------------------------------------------------ Visit theguardian.com On your mobile, download the Guardian iPhone app theguardian.com/iphone and our iPad edition theguardian.com/iPad Save up to 33% by subscribing to the Guardian and Observer - choose the papers you want and get full digital access. Visit subscribe.theguardian.com This e-mail and all attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender and delete the e-mail and all attachments immediately. Do not disclose the contents to another person. You may not use the information for any purpose, or store, or copy, it in any way. Guardian News & Media Limited is not liable for any computer viruses or other material transmitted with or as part of this e-mail. You should employ virus checking software. Guardian News & Media Limited A member of Guardian Media Group plc Registered Office PO Box 68164 Kings Place 90 York Way London N1P 2AP Registered in England Number 908396 -------------------------------------------------------------------------- -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/52B166A4.5060304%40guardian.co.uk. For more options, visit https://groups.google.com/groups/opt_out.
shlo.afgin@gmail.com
2013-Dec-18 09:40 UTC
Re: [Puppet Users] How Puppet can evaluate the output od command?
I did not understand where exactly put the test line. I tried: exec { "ls": command => test $(grep -c aa /tmp/aao) -gt 0 returns => 1, path => "/usr/bin:/usr/sbin:/bin", } I got the error: Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not match $(grep at /etc/puppet/.../init.pp:4 on node agent.... I need the test to run each time Puppet run. Thank you for your quick response. On Wednesday, December 18, 2013 11:11:00 AM UTC+2, Stephen Gran wrote:> > On 12/18/2013 08:41 AM, shlo....@gmail.com <javascript:> wrote: > > > > Hi, > > > > I want to run a command something like: > > /cat /tmp/aao | grep aa | wc -l/ > > Check the output of that command, if the output is ''0'', I want to get a > > failure from puppet. > > I tried to use ''exec'' with ''returns'' but it''s seem that ''returns'' take > > the return code of the command and not the output of the command. > > How can I do it right? > > test $(grep -c aa /tmp/aao) -gt 0 > > Cheers, > > -- > Stephen Gran > Senior Systems Integrator - theguardian.com > Please consider the environment before printing this email. > ------------------------------------------------------------------ > Visit theguardian.com > > On your mobile, download the Guardian iPhone app theguardian.com/iphoneand our iPad edition > theguardian.com/iPad > Save up to 33% by subscribing to the Guardian and Observer - choose the > papers you want and get full digital access. > Visit subscribe.theguardian.com > > This e-mail and all attachments are confidential and may also > be privileged. If you are not the named recipient, please notify > the sender and delete the e-mail and all attachments immediately. > Do not disclose the contents to another person. You may not use > the information for any purpose, or store, or copy, it in any way. > > Guardian News & Media Limited is not liable for any computer > viruses or other material transmitted with or as part of this > e-mail. You should employ virus checking software. > > Guardian News & Media Limited > > A member of Guardian Media Group plc > Registered Office > PO Box 68164 > Kings Place > 90 York Way > London > N1P 2AP > > Registered in England Number 908396 > > -------------------------------------------------------------------------- > >-- 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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/d0a7ec9b-82a7-4f1d-800c-29ddd53cc480%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jeff Bachtel
2013-Dec-18 14:58 UTC
Re: [Puppet Users] How Puppet can evaluate the output od command?
The command should be in single quotes, try exec { "ls": command => ''test $(grep -c aa /tmp/aao) -gt 0'', returns => 1, path => "/usr/bin:/usr/sbin:/bin", } Note also that you were missing a comma after the command property, that must be present. Jeff On 12/18/2013 04:40 AM, shlo.afgin@gmail.com wrote:> > I did not understand where exactly put the test line. I tried: > exec { "ls": > command => test $(grep -c aa /tmp/aao) -gt 0 > returns => 1, > path => "/usr/bin:/usr/sbin:/bin", > } > I got the error: > Error: Could not retrieve catalog from remote server: Error 400 on > SERVER: Could not match $(grep at /etc/puppet/.../init.pp:4 on node > agent.... > > I need the test to run each time Puppet run. > Thank you for your quick response. > > On Wednesday, December 18, 2013 11:11:00 AM UTC+2, Stephen Gran wrote: > > On 12/18/2013 08:41 AM, shlo....@gmail.com <javascript:> wrote: > > > > Hi, > > > > I want to run a command something like: > > /cat /tmp/aao | grep aa | wc -l/ > > Check the output of that command, if the output is ''0'', I want > to get a > > failure from puppet. > > I tried to use ''exec'' with ''returns'' but it''s seem that > ''returns'' take > > the return code of the command and not the output of the command. > > How can I do it right? > > test $(grep -c aa /tmp/aao) -gt 0 > > Cheers, > > -- > Stephen Gran > Senior Systems Integrator - theguardian.com <http://theguardian.com> > Please consider the environment before printing this email. > ------------------------------------------------------------------ > Visit theguardian.com <http://theguardian.com> > > On your mobile, download the Guardian iPhone app > theguardian.com/iphone <http://theguardian.com/iphone> and our > iPad edition theguardian.com/iPad <http://theguardian.com/iPad> > Save up to 33% by subscribing to the Guardian and Observer - > choose the papers you want and get full digital access. > Visit subscribe.theguardian.com <http://subscribe.theguardian.com> > > This e-mail and all attachments are confidential and may also > be privileged. If you are not the named recipient, please notify > the sender and delete the e-mail and all attachments immediately. > Do not disclose the contents to another person. You may not use > the information for any purpose, or store, or copy, it in any way. > > Guardian News & Media Limited is not liable for any computer > viruses or other material transmitted with or as part of this > e-mail. You should employ virus checking software. > > Guardian News & Media Limited > > A member of Guardian Media Group plc > Registered Office > PO Box 68164 > Kings Place > 90 York Way > London > N1P 2AP > > Registered in England Number 908396 > > -------------------------------------------------------------------------- > > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/d0a7ec9b-82a7-4f1d-800c-29ddd53cc480%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.-- 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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/52B1B810.5090906%40bericotechnologies.com. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Dec-18 15:00 UTC
Re: [Puppet Users] How Puppet can evaluate the output od command?
On Wednesday, December 18, 2013 3:40:21 AM UTC-6, shlo....@gmail.com wrote:> > > I did not understand where exactly put the test line. I tried: > exec { "ls": > command => test $(grep -c aa /tmp/aao) -gt 0 > returns => 1, > path => "/usr/bin:/usr/sbin:/bin", > } > I got the error: > Error: Could not retrieve catalog from remote server: Error 400 on SERVER: > Could not match $(grep at /etc/puppet/.../init.pp:4 on node agent.... > >Add provider => ''sh'' to the exec. Or, better, the command grep -q ''aa'' /tmp/aao better and more simply matches your intent: it exits 0 if any match is found, or nonzero otherwise. No need for wc. 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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6ac45a8a-9e1d-455d-ad69-8778cd98df18%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.