scripts

20 views
Skip to first unread message

Cathal O Mul

unread,
Aug 6, 2014, 3:21:05 PM8/6/14
to puppet...@googlegroups.com
I have a file call pr.sh it is a scrip I would like puppet to run it how would I go about doing this

Steven VanDevender

unread,
Aug 6, 2014, 3:33:01 PM8/6/14
to puppet...@googlegroups.com
Cathal O Mul writes:
> I have a file call pr.sh it is a scrip I would like puppet to run it
> how would I go about doing this

This is what Puppet "exec" resources are for, although one should use
those sparingly and only if what you want to accomplish can't be done
using some other resource type. In particular unless you specify the
"exec" carefully, Puppet may run the exec multiple times, even within
the same Puppet agent invocation, so the script should be written to
handle that case cleanly.

So you would start with something like:

exec { "/path/to/pr.sh":
}

And then add one or more attributes to ensure the script is run only
when the necessary conditions apply. These might include:

refreshonly => true,

# run the exec when the specified file resource is updated
subscribe => File["/some/input/file"],
# alternatively the file resource can have
# notify => Exec["/path/to/pr.sh"],

# run another command and do this exec only if it exits successfully
onlyif => "..."

Dan White

unread,
Aug 6, 2014, 5:07:27 PM8/6/14
to puppet...@googlegroups.com
And this is the second time you have asked almost the same question in rapid succession. 

You might want to read some of the Puppet documentation. 

"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."

Bill Waterson (Calvin & Hobbes)


On Aug 6, 2014, at 3:21 PM, Cathal O Mul <cathal....@mycit.ie> wrote:

I have a file call pr.sh it is a scrip I would like puppet to run it how would I go about doing this

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/89249850-5b92-407c-b01a-ff8b2ee9c01f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xav Paice

unread,
Aug 6, 2014, 5:24:01 PM8/6/14
to puppet...@googlegroups.com
On 07/08/14 09:07, Dan White wrote:
And this is the second time you have asked almost the same question in rapid succession. 

You might want to read some of the Puppet documentation. 

On Aug 6, 2014, at 3:21 PM, Cathal O Mul <cathal....@mycit.ie> wrote:

I have a file call pr.sh it is a scrip I would like puppet to run it how would I go about doing this


RTFM is an important reminder, since the answer to the original (two) questions is clearly documented already.  Cathal, look at https://docs.puppetlabs.com/references/latest/type.html#exec - but please don't think that's an answer.  The reality is, exec is not an ideal thing to do, and nearly all of what people should do with Puppet is best done with either existing or custom types and providers. The link above also has a listing of the current types.  Dan's first response was exactly the way you should ensure a file is removed using Puppet, not with a script performing rm.

I wonder if you might want to look at the problem in a different way, rather than attempt to get something to run a shell script.  You need to look well beyond running a program, and get the concept of describing the end result you're looking for.

There's an excellent lot of stuff to get started at https://puppetlabs.com/learn - I really recommend making use of the learning VM, and the Puppetlabs training is excellent, well worth the money.
Reply all
Reply to author
Forward
0 new messages