Ask Your Question
0

Is Puppet Apply the correct way to run a "one time", on-demand action?

asked 2015-10-05 10:04:08 -0500

tmhudg gravatar image

updated 2015-10-05 16:56:08 -0500

Hi,

We are relatively new users of Puppet. We are using Hiera to do our node classification to take care of installing software and getting the nodes in the proper end state. We would also like to use Puppet to manage periodic, user requested actions on selected nodes. For example, an ad hoc backup of a node and restore to another node. The UI for asking for the parameters will be taken care of via another Orchestration layer and I know I can get the parameters, I'm just interested in the best way to structure this in Puppet.

I've seen lots of suggestions for "run once" questions that involve just adding your module to the node and using the existence or contents of various gate files to control whether an exec in that module has run already or not. I don't really like this approach as I don't like the idea of Puppet continually "trying" to backup and copy the database and only being prevented by the presence of some file.

It seems like Puppet Apply might be a better way. Assuming I have a script that will do the backup and copy action, I could use my node classification to ensure that the script is actually on the node but then invoke "puppet apply ..." locally on the node to actually apply the module/run the script on user demand.

Does that make sense? Am I missing anything in this approach?

[Edit: Never mind. Upon further reflection, this is silly. If I'm going to do an SSH to the box to run "puppet apply <module>" to run the script, I might as well just run the script myself. ]

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-05 15:23:39 -0500

lupin gravatar image

Hello,

The Puppet design is to model your system into your desired state. The way it achieve this is by applying whatever resources(files/package/service/command) you state in your module/manifest. To make sure that it will only "apply once", it query the existing state of your resources(file or package) for example. Now, for the case of executable/command there's no way of knowing if that have been applied unless there's a file that changed or process that been running.

The puppet apply command is usually used in a masterless setup, whereby a standalone system will apply catalog/manifest to itself by either manual or periodic invocation. So for you requirement if you have a module that execute the backup script, every time you execute the puppet apply in will run that backup script.

Hope this helps, Lupin

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

Stats

Asked: 2015-10-05 10:04:08 -0500

Seen: 179 times

Last updated: Oct 05 '15