Hello, I''m using puppet via a bash script when I spin up a machine to configure it. I''d like to restart the instance after puppet''s run is complete. In my bash script I have: puppet agent --test shutdown -r now Puppet runs to completion, but "shutdown -r now" never executes. I''m not sure why not - these are the last two lines in my bash script and everything else executes successfully. Any help would be greatly appreciated. -Harish -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/LRQu7aiD9q8J. 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.
I''m not sure where you execute this, but this sound like a problem with your path. For initialization script and such, where you''re unsure of the path, I suggest using the complete path for the command. For example /usr/bin/puppet and /sbin/shutdown. RuneSt. On 11 Nov, 20:40, Harish Agarwal <har...@octopart.com> wrote:> Hello, > > I''m using puppet via a bash script when I spin up a machine to configure > it. I''d like to restart the instance after puppet''s run is complete. In > my bash script I have: > > puppet agent --test > shutdown -r now > > Puppet runs to completion, but "shutdown -r now" never executes. I''m not > sure why not - these are the last two lines in my bash script and > everything else executes successfully. Any help would be greatly > appreciated. > > -Harish-- 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 Fri, Nov 11, 2011 at 18:40, Harish Agarwal <harish@octopart.com> wrote:> Hello, > > I''m using puppet via a bash script when I spin up a machine to configure > it. I''d like to restart the instance after puppet''s run is complete. In > my bash script I have: > > puppet agent --test > shutdown -r now > > > Puppet runs to completion, but "shutdown -r now" never executes. I''m not > sure why not - these are the last two lines in my bash script and > everything else executes successfully. Any help would be greatly > appreciated. > > -Harish > > > Can you get the exit code of the puppet run and then, based on success orfailure, do the reboot? puppet agent --test ANSW=$? if [[ ${ANSW} -eq 0 ]] then echo "Puppet successful - Exit code ${ANSW}" /sbin/shutdown -r now else echo "No puppet run - Exit code ${ANSW} fi This may tell you if puppet is cancelling the shutdown... -- 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.
I did the echo above and didn''t get any output.... It''s as if this command is never encountered. If there are errors thrown during the puppet run, will it throw an error and prevent the next command from executing? BTW, I do have the full path of the binaries in my shell script now. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/YQwIsn2GjGgJ. 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.
Try adding -x to the bash (first line) to output each command as they are run... What if you removed everything in the script but the shutdown command.. does it work? Mohamed. On Sat, Nov 19, 2011 at 11:25 AM, Harish Agarwal <harish@octopart.com> wrote:> I did the echo above and didn''t get any output.... It''s as if this command > is never encountered. If there are errors thrown during the puppet run, > will it throw an error and prevent the next command from executing? > BTW, I do have the full path of the binaries in my shell script now. > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/YQwIsn2GjGgJ. > 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 Sat, Nov 19, 2011 at 08:25:18AM -0800, Harish Agarwal wrote:> I did the echo above and didn''t get any output.... It''s as if this command > is never encountered. If there are errors thrown during the puppet run, > will it throw an error and prevent the next command from executing?If the shell is configured that way: Yes. Try to write the output of »set -o« somewhere and look if »errexit« is set. If that is the case bash will leave the script as soon as a command returns a non-true value.> > BTW, I do have the full path of the binaries in my shell script now. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/YQwIsn2GjGgJ. > 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. >
Caution: puppet agent --test will return non-zero exit code if any resources needed changing. If in doubt, prefer puppet agent --one-time --no-daemonize (typos notwithstanding). On 11/14/2011 01:01 PM, John Kennedy wrote:> puppet agent --test > ANSW=$?Otherwise, I''m stumped, this shouldn''t happen. You could try and execute puppet in a subshell and see if the rest of the script is run then. ( puppet agent --test ) Cheers, Felix -- 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.