I''ve clearly not approaching this correctly, so would appreciate some advice. I have a trivial shell script to execute. I''ve whittled this down to a one line invocation of true. The file is called test and has mode 755 I''m testing with: sudo puppetd --debug --test I''m using puppet-0.25.5-2.fc15.noarch on the client and puppet-0.25.5-1.fc14.noarch on the server. I have an exec component that looks like this: exec { "initMysql": cwd => "/home/tim/backups", path => ["/usr/bin", "/bin"], command => "/home/tim/backups/test", # fails # command => "/home/tim/backups/test 2>&1", # works # command => "/home/tim/backups/test > /tmp/wibble", # works # command => "/home/tim/backups/test 2> /tmp/wibble", # works logoutput => true, creates => "/home/tim/backups/inited", } Failure looks like this: debug: //Node[uranustest]/Exec[initMysql]: Changing returns debug: //Node[uranustest]/Exec[initMysql]: 1 change(s) debug: //Node[uranustest]/Exec[initMysql]: Executing ''/home/tim/ backups/test'' debug: Executing ''/home/tim/backups/test'' err: //Node[uranustest]/Exec[initMysql]/returns: change from notrun to 0 failed: /home/tim/backups/test returned 1 instead of one of [0] at / etc/puppet/manifests/nodes.pp:117 An example of success looks like this: debug: //Node[uranustest]/Exec[initMysql]: Changing returns debug: //Node[uranustest]/Exec[initMysql]: 1 change(s) debug: //Node[uranustest]/Exec[initMysql]: Executing ''/home/tim/ backups/test 2>&1'' debug: Executing ''/home/tim/backups/test 2>&1'' notice: //Node[uranustest]/Exec[initMysql]/returns: executed successfully I''m pretty sure that I shouldn''t need to redirect the output to get the command to work. Any thoughts? Tim -- 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.
Here''s an idea: the first one is probably not run by the shell, as there is no shell meta-characters in it. The latter three all have shell meta-characters in them. I don''t know for certain that puppet does it this way, but it is common to do things in this manner in scripting languages all over the place. Is this possible? If this is true, then using any shell meta-character (such as backquotes, wildcards, pipes, or other things) will cause your script to succeed. -- David Douthitt ddouthitt@acm.org On Monday, September 19, 2011 8:52 AM, "Tim Coote" <tim.coote1@googlemail.com> wrote:> I''ve clearly not approaching this correctly, so would appreciate some > advice. > > I have a trivial shell script to execute. I''ve whittled this down to a > one line invocation of true. The file is called test and has mode 755 > > I''m testing with: > sudo puppetd --debug --test > > I''m using puppet-0.25.5-2.fc15.noarch on the client and > puppet-0.25.5-1.fc14.noarch on the server. > > I have an exec component that looks like this: > > exec { "initMysql": > cwd => "/home/tim/backups", > path => ["/usr/bin", "/bin"], > command => "/home/tim/backups/test", # fails > # command => "/home/tim/backups/test 2>&1", # works > # command => "/home/tim/backups/test > /tmp/wibble", # works > # command => "/home/tim/backups/test 2> /tmp/wibble", # works > logoutput => true, > creates => "/home/tim/backups/inited", > } > > Failure looks like this: > > debug: //Node[uranustest]/Exec[initMysql]: Changing returns > debug: //Node[uranustest]/Exec[initMysql]: 1 change(s) > debug: //Node[uranustest]/Exec[initMysql]: Executing ''/home/tim/ > backups/test'' > debug: Executing ''/home/tim/backups/test'' > err: //Node[uranustest]/Exec[initMysql]/returns: change from notrun to > 0 failed: /home/tim/backups/test returned 1 instead of one of [0] at / > etc/puppet/manifests/nodes.pp:117 > > > An example of success looks like this: > > debug: //Node[uranustest]/Exec[initMysql]: Changing returns > debug: //Node[uranustest]/Exec[initMysql]: 1 change(s) > debug: //Node[uranustest]/Exec[initMysql]: Executing ''/home/tim/ > backups/test 2>&1'' > debug: Executing ''/home/tim/backups/test 2>&1'' > notice: //Node[uranustest]/Exec[initMysql]/returns: executed > successfully > > I''m pretty sure that I shouldn''t need to redirect the output to get > the command to work. > > Any thoughts? > > Tim > > -- > 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. > >-- 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.
On Sep 19, 2011, at 8:52 AM, Tim Coote wrote:> I''ve clearly not approaching this correctly, so would appreciate some > advice. > > I have a trivial shell script to execute. I''ve whittled this down to a > one line invocation of true. The file is called test and has mode 755 > > I''m testing with: > sudo puppetd --debug --test > > I''m using puppet-0.25.5-2.fc15.noarch on the client and > puppet-0.25.5-1.fc14.noarch on the server. > > I have an exec component that looks like this: > > exec { "initMysql": > cwd => "/home/tim/backups", > path => ["/usr/bin", "/bin"], > command => "/home/tim/backups/test", # fails > # command => "/home/tim/backups/test 2>&1", # works > # command => "/home/tim/backups/test > /tmp/wibble", # works > # command => "/home/tim/backups/test 2> /tmp/wibble", # works > logoutput => true, > creates => "/home/tim/backups/inited", > } > > Failure looks like this: > > debug: //Node[uranustest]/Exec[initMysql]: Changing returns > debug: //Node[uranustest]/Exec[initMysql]: 1 change(s) > debug: //Node[uranustest]/Exec[initMysql]: Executing ''/home/tim/ > backups/test'' > debug: Executing ''/home/tim/backups/test'' > err: //Node[uranustest]/Exec[initMysql]/returns: change from notrun to > 0 failed: /home/tim/backups/test returned 1 instead of one of [0] at / > etc/puppet/manifests/nodes.pp:117 > > > An example of success looks like this: > > debug: //Node[uranustest]/Exec[initMysql]: Changing returns > debug: //Node[uranustest]/Exec[initMysql]: 1 change(s) > debug: //Node[uranustest]/Exec[initMysql]: Executing ''/home/tim/ > backups/test 2>&1'' > debug: Executing ''/home/tim/backups/test 2>&1'' > notice: //Node[uranustest]/Exec[initMysql]/returns: executed > successfully > > I''m pretty sure that I shouldn''t need to redirect the output to get > the command to work. > > Any thoughts?---- Do you recognize that puppet executions are performed by user ''root''? Does this file have 777 permissions? Is the first line of ''test'' something like "#!/bin/bash" ? Probably a good idea to get in the practice of naming shell script files with a recognizable extension (i.e. test.sh) I suppose that the reason the other commands success is simply because the redirection exists so the redirection occurs and the command is true, regardless of anything that occurs or fails in your shell script itself. Craig -- 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.
That''s it! I was getting lazy and not putting the #! /bin/bash at the top of the shell script. This was a pig to pull out tho'': when run under the debugger I flushed out an ''Exec format error'', which just didn''t make it to the log when run normally. Google found the ''Exec format error'' on a unix bash blog as a side comment that ''some scripting languages won''t use the shell to run a script unless you''re specific in the source file''. Good shout David. Disappointing that I had to learn a/ ruby, b/ the ruby debugger, to pin this down. Do you think that I should record a bug/feature request that all errors get logged? On 19 Sep, 16:58, "David Douthitt" <ddouth...@acm.org> wrote:> Here''s an idea: the first one is probably not run by the shell, as there > is no shell meta-characters in it. The latter three all have shell > meta-characters in them. > > I don''t know for certain that puppet does it this way, but it is common > to do things in this manner in scripting languages all over the place. > Is this possible? > > If this is true, then using any shell meta-character (such as > backquotes, wildcards, pipes, or other things) will cause your script to > succeed. > -- > David Douthitt > ddouth...@acm.org > > On Monday, September 19, 2011 8:52 AM, "Tim Coote" > > > > > > > > <tim.coo...@googlemail.com> wrote: > > I''ve clearly not approaching this correctly, so would appreciate some > > advice. > > > I have a trivial shell script to execute. I''ve whittled this down to a > > one line invocation of true. The file is calledtestand has mode 755 > > > I''m testing with: > > sudo puppetd --debug --test > > > I''m using puppet-0.25.5-2.fc15.noarch on the client and > > puppet-0.25.5-1.fc14.noarch on the server. > > > I have anexeccomponent that looks like this: > > > exec{ "initMysql": > > cwd => "/home/tim/backups", > > path => ["/usr/bin", "/bin"], > > command => "/home/tim/backups/test", # fails > > # command => "/home/tim/backups/test2>&1", # works > > # command => "/home/tim/backups/test> /tmp/wibble", # works > > # command => "/home/tim/backups/test2> /tmp/wibble", # works > > logoutput => true, > > creates => "/home/tim/backups/inited", > > } > > > Failure looks like this: > > > debug: //Node[uranustest]/Exec[initMysql]: Changing returns > > debug: //Node[uranustest]/Exec[initMysql]: 1 change(s) > > debug: //Node[uranustest]/Exec[initMysql]: Executing ''/home/tim/ > > backups/test'' > > debug: Executing ''/home/tim/backups/test'' > > err: //Node[uranustest]/Exec[initMysql]/returns: change from notrun to > > 0 failed: /home/tim/backups/testreturned 1 instead of one of [0] at / > > etc/puppet/manifests/nodes.pp:117 > > > An example of success looks like this: > > > debug: //Node[uranustest]/Exec[initMysql]: Changing returns > > debug: //Node[uranustest]/Exec[initMysql]: 1 change(s) > > debug: //Node[uranustest]/Exec[initMysql]: Executing ''/home/tim/ > > backups/test2>&1'' > > debug: Executing ''/home/tim/backups/test2>&1'' > > notice: //Node[uranustest]/Exec[initMysql]/returns: executed > > successfully > > > I''m pretty sure that I shouldn''t need to redirect the output to get > > the command to work. > > > Any thoughts? > > > Tim > > > -- > > 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.-- 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.