Restore files after Puppet apply the changes

Sometimes, unknowingly you run the puppet agent which is stopped by some other teammate for some sort of testing which enforce Puppet to apply the changes which are changed in Puppet agent and configured in Puppet Master.

Puppet

It’s really horrible and can create lots of confusion, issues and conflicts

But don’t worry, just like your Version Control Systems, Puppet does log all the changes for a certain time period and manage the reports of all the changes

So here I am going to demonstrate how to restore file through Puppet report.

You need to find these two files which will be stored in /var/lib/puppet/state directory in your puppet agent

  • last_run_summary.yaml
  •  last_run_report.yaml

then fetch the exact message through grep like below :- it will report all the changes

[root@appvm001]/var/lib/puppet/state# grep Filebucketed  last_run_report.yaml
message: "Filebucketed /local/home/ahs_bgauth/conf/dispatcher.any to puppet with sum a9f8826d181ffebb316179da81933fe6"
message: "Filebucketed /usr/share/wurfl/wurfl.xml to puppet with sum 780b3179c2435472cdda02453e3233a3"
message: "Filebucketed /local/home/ahs_bg/conf.d/ssl.conf to puppet with sum 42eb7df44739e688c85b0f8bfc235610"
message: "Filebucketed /local/home/ahs_bg/conf.d/vhost.conf to puppet with sum e870dc80bac0192740f24e004b4d5604"

Wowww …you just got all the Filebuckets

You can restore whichever file you need to restore with below command :

[root@appvm001]/var/lib/puppet/clientbucket# puppet filebucket -l --bucket /var/lib/puppet/clientbucket restore /local/home/ahs_bg/conf.d/ssl.conf 42eb7df44739e688c85b0f8bfc235610

[root@ appvm001]/var/lib/puppet/clientbucket# puppet filebucket -l --bucket /var/lib/puppet/clientbucket restore /local/home/ahs_bg/conf.d/vhost.conf e870dc80bac0192740f24e004b4d5604

[root@ appvm001]/var/lib/puppet/clientbucket# puppet filebucket -l --bucket /var/lib/puppet/clientbucket restore /usr/share/wurfl/wurfl.xml 780b3179c2435472cdda02453e3233a3

[root@appvm001]/var/lib/puppet/clientbucket# puppet filebucket -l --bucket /var/lib/puppet/clientbucket restore /local/home/ahs_bgauth/conf/dispatcher.any a9f8826d181ffebb316179da81933fe6

That’s it …all the files are restored to the previous version which you are looking for 🙂

Happy Learning …

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top