Thought I''d share this with the list. Todo: write in Ruby (force of habit writing it in perl) #!/usr/bin/perl # use Parallel::ForkManager; # # Global Run # Initiates a global run of the Puppet system, on all parsed nodes. 5 Simultaneous nodes. # Requires: SSH keys to all target nodes, shortname DNS == nodename # Optional: Uncomment the forkmanager stuff if you want parallel execution. # my $command = "sudo puppetd"; # my $pm = new Parallel::ForkManager(5); my @args; if (($#ARGV + 1) > 0) { print "Your arguments: @ARGV\n"; @args = ("--test", "--pluginsync", "--vardir /var/lib/puppet", "--ssldir /var/lib/puppet/ssl", "--factpath /var/lib/puppet/lib/facter", ); push(@args, @ARGV); } else { @args = ("--test", "--pluginsync", "--vardir /var/lib/puppet", "--ssldir /var/lib/puppet/ssl", "--factpath /var/lib/puppet/lib/facter" ); } my $output = `grep ^node -r manifests`; @nodes = split(''\n'', $output); foreach (@nodes) { # $pm->start and next; @words = split('' '', $_); $node = @words[1]; my $header = "\n**\n* Beginning Puppet run on node: $node\n* $command @args\n**\n"; my $sshoutput = `ssh $node $command @args`; print $header; print $sshoutput; # $pm->finish; } # $pm->wait_all_children; Regards, Arjuna Christensen | Systems Engineer Maximum Internet Ltd 7a Parkhead Pl, Albany, North Shore, 0632 | PO Box 8006, Auckland, 1150, NZ DDI: + 64 9 913 9683 | Ph: +64 9 915 1825 | Fax:: +64 9 300 7227 arjuna.christensen@maxnet.co.nz <mailto:arjuna.christensen@maxnet.co.nz> | www.maxnet.co.nz <http://www.maxnet.co.nz/> ________________________________ Maxnet | mission critical internet ________________________________ This email (including any attachments) is confidential and intended only for the person to whom it is addressed. If you have received this email in error, please notify the sender immediately and erase all copies of this message and attachments. The views expressed in this email do not necessarily reflect those held by Maxnet. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
#!/usr/bin/perl use strict; use warnings; # use Parallel::ForkManager; # # Global Run # Initiates a global run of the Puppet system, on all parsed nodes. 5 Simultaneous nodes. # Requires: SSH keys to all target nodes, shortname DNS == nodename # Optional: Uncomment the forkmanager stuff if you want parallel execution. # my @command = (''sudo'', ''puppetd''); my $manifest=''manifests''; # my $pm = new Parallel::ForkManager(5); my @args = ("--test", "--pluginsync", "--vardir /var/lib/puppet", "--ssldir /var/lib/puppet/ssl", "--factpath /var/lib/puppet/lib/facter", ); if ($#ARGV >= 0 ) { print "Your arguments: @ARGV\n"; push(@args, @ARGV); } open my $output, ''<'', $manifest or die "Couldn''t open $manifest: $!\n"; foreach (<$output>) { next unless /^node\s+(\w+)/; my $host=$1; # $pm->start and next; print "\n**\n* Beginning Puppet run on node: $host\n* @command @args\n**\n"; # yeah, all you ruby people can laugh about the reverse logic here... system(''ssh'', $host, @command, @args) and print "something bad happened when trying to ssh to $host\n"; # $pm->finish; } close $output; # $pm->wait_all_children; On 01/04/2008, Arjuna Christensen <arjuna.christensen@maxnet.co.nz> wrote:> > Thought I''d share this with the list. > > > > Todo: write in Ruby (force of habit writing it in perl) > > > > #!/usr/bin/perl > > # use Parallel::ForkManager; > > > > # > > # Global Run > > # Initiates a global run of the Puppet system, on all parsed nodes. 5 > Simultaneous nodes. > > # Requires: SSH keys to all target nodes, shortname DNS == nodename > > # Optional: Uncomment the forkmanager stuff if you want parallel > execution. > > # > > > > my $command = "sudo puppetd"; > > # my $pm = new Parallel::ForkManager(5); > > my @args; > > if (($#ARGV + 1) > 0) { > > print "Your arguments: @ARGV\n"; > > @args = ("--test", > > "--pluginsync", > > "--vardir /var/lib/puppet", > > "--ssldir /var/lib/puppet/ssl", > > "--factpath /var/lib/puppet/lib/facter", > > ); > > push(@args, @ARGV); > > } > > else { > > @args = ("--test", > > "--pluginsync", > > "--vardir /var/lib/puppet", > > "--ssldir /var/lib/puppet/ssl", > > "--factpath /var/lib/puppet/lib/facter" > > ); > > } > > > > my $output = `grep ^node -r manifests`; > > @nodes = split(''\n'', $output); > > foreach (@nodes) { > > # $pm->start and next; > > @words = split('' '', $_); > > $node = @words[1]; > > my $header = "\n**\n* Beginning Puppet run on node: $node\n* $command > @args\n**\n"; > > my $sshoutput = `ssh $node $command @args`; > > print $header; > > print $sshoutput; > > # $pm->finish; > > } > > # $pm->wait_all_children; > > > > > > Regards, > > *Arjuna Christensen** **| Systems Engineer* > Maximum Internet Ltd > 7a Parkhead Pl, Albany, North Shore, 0632 | PO Box 8006, Auckland, 1150, > NZ > DDI: + 64 9 913 9683 | Ph: +64 9 915 1825 | Fax:: +64 9 300 7227 > arjuna.christensen@maxnet.co.nz| www.maxnet.co.nz > ________________________________ > > *Maxnet* | mission critical internet > ________________________________ > > This email (including any attachments) is confidential and intended only > for the person to whom it is addressed. > If you have received this email in error, please notify the sender > immediately and erase all copies of this message > and attachments. The views expressed in this email do not necessarily > reflect those held by Maxnet. > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What the hell? Arjuna Christensen | Systems Engineer Maximum Internet Ltd 7a Parkhead Pl, Albany, North Shore, 0632 | PO Box 8006, Auckland, 1150, NZ DDI: + 64 9 913 9683 | Ph: +64 9 915 1825 | Fax:: +64 9 300 7227 arjuna.christensen@maxnet.co.nz| www.maxnet.co.nz <http://www.maxnet.co.nz/> ________________________________ Maxnet | mission critical internet ________________________________ This email (including any attachments) is confidential and intended only for the person to whom it is addressed. If you have received this email in error, please notify the sender immediately and erase all copies of this message and attachments. The views expressed in this email do not necessarily reflect those held by Maxnet. From: puppet-users@googlegroups.com [mailto:puppet-users@googlegroups.com] On Behalf Of RijilV Sent: Wednesday, 2 April 2008 3:43 p.m. To: puppet-users@googlegroups.com Subject: [Puppet Users] Re: ''global run'' script. #!/bin/sh echo FIXED.2 exit #!/usr/bin/perl use strict; use warnings; # use Parallel::ForkManager; # # Global Run # Initiates a global run of the Puppet system, on all parsed nodes. 5 Simultaneous nodes. # Requires: SSH keys to all target nodes, shortname DNS == nodename # Optional: Uncomment the forkmanager stuff if you want parallel execution. # my @command = (''sudo'', ''puppetd''); my $manifest=''manifests''; # my $pm = new Parallel::ForkManager(5); my @args = ("--test", "--pluginsync", "--vardir /var/lib/puppet", "--ssldir /var/lib/puppet/ssl", "--factpath /var/lib/puppet/lib/facter", ); if ($#ARGV >= 0 ) { print "Your arguments: @ARGV\n"; push(@args, @ARGV); } open my $output, ''<'', $manifest or die "Couldn''t open $manifest: $!\n"; foreach (<$output>) { next unless /^node\s+(\w+)/; my $host=$1; # $pm->start and next; print "\n**\n* Beginning Puppet run on node: $host\n* @command @args\n**\n"; # yeah, all you ruby people can laugh about the reverse logic here... system(''ssh'', $host, @command, @args) and print "something bad happened when trying to ssh to $host\n"; # $pm->finish; } close $output; # $pm->wait_all_children; On 01/04/2008, Arjuna Christensen <arjuna.christensen@maxnet.co.nz> wrote: Thought I''d share this with the list. Todo: write in Ruby (force of habit writing it in perl) #!/usr/bin/perl # use Parallel::ForkManager; # # Global Run # Initiates a global run of the Puppet system, on all parsed nodes. 5 Simultaneous nodes. # Requires: SSH keys to all target nodes, shortname DNS == nodename # Optional: Uncomment the forkmanager stuff if you want parallel execution. # my $command = "sudo puppetd"; # my $pm = new Parallel::ForkManager(5); my @args; if (($#ARGV + 1) > 0) { print "Your arguments: @ARGV\n"; @args = ("--test", "--pluginsync", "--vardir /var/lib/puppet", "--ssldir /var/lib/puppet/ssl", "--factpath /var/lib/puppet/lib/facter", ); push(@args, @ARGV); } else { @args = ("--test", "--pluginsync", "--vardir /var/lib/puppet", "--ssldir /var/lib/puppet/ssl", "--factpath /var/lib/puppet/lib/facter" ); } my $output = `grep ^node -r manifests`; @nodes = split(''\n'', $output); foreach (@nodes) { # $pm->start and next; @words = split('' '', $_); $node = @words[1]; my $header = "\n**\n* Beginning Puppet run on node: $node\n* $command @args\n**\n"; my $sshoutput = `ssh $node $command @args`; print $header; print $sshoutput; # $pm->finish; } # $pm->wait_all_children; Regards, Arjuna Christensen | Systems Engineer Maximum Internet Ltd 7a Parkhead Pl, Albany, North Shore, 0632 | PO Box 8006, Auckland, 1150, NZ DDI: + 64 9 913 9683 | Ph: +64 9 915 1825 | Fax:: +64 9 300 7227 arjuna.christensen@maxnet.co.nz| www.maxnet.co.nz <http://www.maxnet.co.nz/> ________________________________ Maxnet | mission critical internet ________________________________ This email (including any attachments) is confidential and intended only for the person to whom it is addressed. If you have received this email in error, please notify the sender immediately and erase all copies of this message and attachments. The views expressed in this email do not necessarily reflect those held by Maxnet. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---