is there a way to run a command before puppet implements a change?
Posted
by
Patrick
on Server Fault
See other posts from Server Fault
or by Patrick
Published on 2012-08-31T03:10:20Z
Indexed on
2012/08/31
3:39 UTC
Read the original article
Hit count: 198
I want to have puppet run a specific command before performing any type of change. I am aware of the prerun_command
option in the main puppet.conf, but this is not what I'm looking for. I want the command to only run if something is about to change, not on every puppet run.
Here's the scenario. Let's say I have a bunch of web servers behind a load balancer. I then want puppet to update the web site files. But in order to prevent issues where some files have been updated, but other files haven't, and the mixed versions causing problems, I want to take the server out of the load balancer pool.
I could write a script which when run will tell the load balancer to remove the box from the pool. Then puppet can do the change, and use postrun_command
to put the box back in the pool once complete. But I need a way to run that script to remove the server from the pool.
The only solution I can think of is to keep 2 copies of the files on the box. One a staging copy, and when puppet updates that, use a notify action to trigger the removal script, and then copy from staging into the live location. But I was hoping for something a little more generic that would work on any change being performed (upgrading a package, restarting a service, creating a user, anything).
© Server Fault or respective owner