{"id":80,"date":"2008-07-12T20:16:07","date_gmt":"2008-07-13T01:16:07","guid":{"rendered":"http:\/\/blogs.cae.tntech.edu\/mwr\/2008\/07\/12\/stupid-puppet-trick-poor-mans-undo\/"},"modified":"2024-10-27T14:26:19","modified_gmt":"2024-10-27T14:26:19","slug":"stupid-puppet-trick-poor-mans-undo","status":"publish","type":"post","link":"https:\/\/sites.tntech.edu\/renfro\/2008\/07\/12\/stupid-puppet-trick-poor-mans-undo\/","title":{"rendered":"Stupid Puppet Trick: Poor Man&#8217;s Undo"},"content":{"rendered":"<p>If I apply a set of classes to a puppet client, I may need to roll back those classes&#8217; changes later. Granted, I could just edit out those classes, reformat the system, and rebuild it from scratch, but there may be times when I want to undo my changes in a more granular fashion. So here&#8217;s my latest revelation (which is undoubtedly documented elsewhere already, but I didn&#8217;t find anything sufficiently simple last time I looked).<\/p>\n<p>Along the lines of <a href=\"http:\/\/reductivelabs.com\/trac\/puppet\/wiki\/PuppetBestPractice\">Puppet Best Practice 2.0<\/a>, I&#8217;m trying to compartmentalize all my building blocks into separate modules, even the really simple ones that just install a package or two. So here&#8217;s the contents of a trivial hello module for Debian:<\/p>\n<pre>\n# \/etc\/puppet\/modules\/hello\/manifests\/init.pp\nclass hello {\n  package { \"hello\":\n    ensure =&gt; latest;\n  }\n}\n<\/pre>\n<p>Nothing complicated here: install this package via the default package provider. Add an <code>include hello<\/code> to my node&#8217;s manifest, and the hello package gets installed.<\/p>\n<p>Now for the &#8220;undo&#8221; class:<\/p>\n<pre>\n# \/etc\/puppet\/modules\/hello\/manifests\/disabled.pp\nclass hello::disabled inherits hello {\n  Package[\"hello\"] {\n    ensure =&gt; purged\n  }\n}\n<\/pre>\n<p>And this is neat. Properly written, the disabling class can undo all the changes made by the parent class. Modify my node&#8217;s manifest from <code>include hello<\/code> to <code>include hello::disabled<\/code> and I can switch that class on and off like, well, a switch.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If I apply a set of classes to a puppet client, I may need to roll back those classes&#8217; changes later. Granted, I could just edit out those classes, reformat the system, and rebuild it from scratch, but there may be times when I want to undo my changes in a more granular fashion. So &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/sites.tntech.edu\/renfro\/2008\/07\/12\/stupid-puppet-trick-poor-mans-undo\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Stupid Puppet Trick: Poor Man&#8217;s Undo&#8221;<\/span><\/a><\/p>\n","protected":false},"author":87,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,16],"tags":[],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-infrastructures","category-puppet","entry"],"_links":{"self":[{"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":1,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":461,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/posts\/80\/revisions\/461"}],"wp:attachment":[{"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}