Ask Your Question

How can I exec a script stored in a module?

asked 2014-06-26 08:25:36 -0600

drupsspen gravatar image

I have a module where I want to execute a program, but only if a script that I have returns zero. Is it possible to put this script inside the module and call it? I've tried using onlyif => "puppet:///modules/mymodule/thescript" with the script store under files.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-06-26 09:25:26 -0600

TerriHaber gravatar image

Even if Puppet had a mechanism to do this, it would literally translate to executing the script on the master, since the "puppet:///" refers to something on the master. I do not think that's your intended result.

What you'll need to do is put the script somewhere on the target node first. So you'll have to manage the file that's in the module using a file resource type.

file { '/tmp/thescript': ensure => file, source => 'puppet:///modules/mymodule/thescript', }

Then, you could use the script in the exec as normal. BUT you'd need to use a metaparameter to make sure the file has been managed before the script has executed.

exec { '/usr/bin/foo': onlyif => '/tmp/thescript', require => File['/tmp/thescript'], }

edit flag offensive delete link more


Thank you. That makes sense.

drupsspen gravatar imagedrupsspen ( 2014-06-26 09:29:20 -0600 )edit

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: 2014-06-26 08:25:36 -0600

Seen: 2,796 times

Last updated: Jun 26 '14