kalaniS
2012-Jun-28 11:24 UTC
[Puppet Users] Execute a shell script residing in puppet master
I''m a newbie to puppet and have been trying to execute a shell script residing in puppet master machine in a puppet agent, with no luck so far. Would appreciate any ideas on how to do this. -- 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.
Christopher Wood
2012-Jun-28 12:28 UTC
Re: [Puppet Users] Execute a shell script residing in puppet master
As far as technique, assuming your myscript module (so in init.pp), you install the file using puppet and then run it: class myscript { $filesource = "puppet:///modules/myscript" $script1 = ''/usr/local/bin/myscript.sh'' $script1source = "$filesource/myscript.sh" file { $script1: source => $script1source, mode => ''755'', } exec { $script1: refreshonly => true, require => File[$script1], subscribe => File[$script1], } } And then use that module in your node declarations: node "myhost.com" { class { ''myscript'': } } Read: http://docs.puppetlabs.com/guides/language_guide.html http://docs.puppetlabs.com/references/stable/type.html http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html (You could also package the script in a deb/rpm and install the package, or template the script, and so forth.) On Thu, Jun 28, 2012 at 04:24:13AM -0700, kalaniS wrote:> I''m a newbie to puppet and have been trying to execute a shell script > residing in puppet master machine in a puppet agent, with no luck so > far. Would appreciate any ideas on how to do this. > > -- > 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.
Denmat
2012-Jun-28 22:58 UTC
Re: [Puppet Users] Execute a shell script residing in puppet master
On 28/06/2012, at 21:24, kalaniS <ksamarawickrema@gmail.com> wrote:> I''m a newbie to puppet and have been trying to execute a shell script > residing in puppet master machine in a puppet agent, with no luck so > far. Would appreciate any ideas on how to do this. >It does depend on what you mean, can you clarify further? If you have a script on your master, say /tmp/coolscript.sh and during a puppet run you want the client to call out to the master and execute coolscript.sh then no. Puppet won''t do that. Maybe here is a good place to start: http://docs.puppetlabs.com/learning/agent_master_basic.html You can set up file and exec resources to first pull the script to the client and then run it. Something like: file {''/tmp/coolscript.sh'': source => ''puppet:///<path> } exec {''exec_coolness'': command => ''/tmp/coolscript.sh'', require => File[''''/tmp/coolscript.sh''] } You can also perform different commands on the master during compile time for the client manifest. I''ll leave you to your own investigations on that. http://docs.puppetlabs.com/references/stable/function.html#generate Cheers, Den -- 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.