Ask Your Question
0

How can I exec a script stored in a module?

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

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
2

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

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

Comments

Thank you. That makes sense.

drupsspen gravatar imagedrupsspen ( 2014-06-26 09:29:20 -0500 )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

Stats

Asked: 2014-06-26 08:25:36 -0500

Seen: 2,578 times

Last updated: Jun 26 '14