Ask Your Question

want run script on puppet agent

asked 2017-09-27 10:57:43 -0500

smasoom5217 gravatar image

I have script on puppet master and want to run on puppet agent without saving on puppet agent. Please let me know.

Thanks in advance.

edit retag flag offensive close merge delete


What do you mean by ‘without saving’?

DarylW gravatar imageDarylW ( 2017-09-30 11:59:42 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2017-09-29 12:18:20 -0500

yodermk gravatar image

I believe you would need a File resource to copy the script to the agent nodes, then an Exec resource to run it (which should be set up to depend on the File resource). Be sure to set the Exec up as idempotently as possible, using the creates or onlyif attribute to only run the command if its condition applies.

And hopefully not heresy here, but you might want to think about Ansible for such a thing depending on the need and use case. Ansible and Puppet serve different purposes and work very well together.

edit flag offensive delete link more

answered 2017-09-28 13:14:52 -0500

Uhm, well, with the exec resource type and the file() function, quick and dirty:

class my_module {
  exec { 'do_some_hilarious_stuff':
    # put your script into your module's 'files/' directory
    command  => file('my_module/'),
    provider => shell,

  exec { 'perform_some_evil_things':
    # or put your script somewhere on the Puppet server
    command  => file('/opt/bin/'),
    provider => shell,

At our site, we got a central file server. It is mounted via network on all clients. The file server also hosts a couple (shell) scripts (and/or binaries). That's definitely a better approach.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-09-27 10:57:43 -0500

Seen: 90 times

Last updated: Sep 29