Puppet – Restore File

So I was updating configuration file on the server for one of the services without updating through puppet. Though I did take care of stopping the puppet before making any changes but did not disable the agent.

After updating configuration file as a habit I ran puppet manually “puppet agent -t” erasing the changes and keeping the version present on puppet server. But guys who developed puppet realized “these things” can happen so puppet actually keeps the version of file it replaced in client bucket.

Find where puppet is storing the changes on the server:

#puppet print config | grep clientbucket

In general you should see in /var/lib/puppet/clientbucket

Run the command to restore the file

puppet filebucket restore -b <bucketdirectory> <path where file should be present> <MD5 checksum of file that we wanted>

But how do you get the checksum ? You can see it in the logs

Notice:/Stage[main]/File[/etc/nginx/nginx.conf]/content: content changed ‘{md5}3dffdokk9894ff4150ec2ffd234324’ to ‘{md5}943njdfnjd2304328iojfdhd

You can also see all the modified files and update/restore it manually.

find /var/lib/puppet/clientbucket/ -type f -mtime +45 -atime +45 -print0




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s