{"id":3468,"date":"2011-11-02T17:55:41","date_gmt":"2011-11-03T01:55:41","guid":{"rendered":"http:\/\/www.chesnok.com\/daily\/?p=3468"},"modified":"2012-03-26T02:21:10","modified_gmt":"2012-03-26T10:21:10","slug":"puppet-faces-defaults-and-puppet-node-clean","status":"publish","type":"post","link":"https:\/\/www.chesnok.com\/daily\/2011\/11\/02\/puppet-faces-defaults-and-puppet-node-clean\/","title":{"rendered":"Puppet Faces: defaults and &#8216;puppet node clean&#8217;"},"content":{"rendered":"<p>Puppet Faces are an extendable API for tricking out your Puppet instances. (&#8220;Faces&#8221; is just short for &#8220;Interfaces&#8221;.) Just a couple days ago I wrote about <a href=\"http:\/\/www.chesnok.com\/daily\/2011\/10\/28\/going-from-vagrant-and-puppet-into-ec2-a-short-survey-of-5-tools-and-two-i-didnt-bother-trying\/\">my survey of puppet + ec2 provisioning tools<\/a>.<\/p>\n<p>The problem I&#8217;m trying to solve, which I don&#8217;t feel like I&#8217;ve solved well, is how to give a type to a new system at bootstrap time, without using DNS. The type variable maps to a node manifest group, and determines the personality of a host &#8211; is it a database, webserver or development instance?<br \/>\n<!--more--><br \/>\nWhat I&#8217;d like to do is pass a type to puppet at install time and have the puppetmaster and the agent remember that mapping between host and type. <\/p>\n<p>I did it with a really simple Facter plugin, install scripts named by type (passed in to <code>puppet node install<\/code>), and a file created by the install script in <code>\/etc\/puppet<\/code>.<\/p>\n<p>Then, I wanted to be able to see which hosts were configured with which install type. Facter was aware of the type, so this seemed like it should be pretty easy&#8230;<\/p>\n<p>I wrote a quick and dirty Face that pulls information out of <code>$varlib\/nodes\/*.yaml<\/code> on the puppet master. I imagine there are better ways to do this, but in the absence of documentation or someone to tell me not to do this, I forged ahead!<\/p>\n<p>There were two things that I spent quite a bit of time chewing on before figuring it out: <\/p>\n<ol>\n<li>If you want to make an <code>:action<\/code> in your Face the default, you just add <code>default<\/code> in the body of your <code>:action<\/code> block. I had to dig through a few cloudpack files before I found it!<\/li>\n<li>If you are creating and terminating hosts frequently, you may end up with a bunch of certs and other annoying metadata laying around. To clean it up, the Puppet Node Face has a command you can run:<br \/>\n<code><br \/>\n# puppet node clean [hostname]<br \/>\n<\/code><\/p>\n<p>You&#8217;ll probably need to be the user that&#8217;s running puppet for this to work &#8212; it affects things that the puppetmaster owns in <code>$varlib<\/code>. <\/p>\n<p>If you&#8217;re doing this with code, it&#8217;s:<br \/>\n<code><br \/>\nPuppet::Face[:node, :current].clean('hostname')<br \/>\n<\/code>\n<\/li>\n<\/ol>\n<p>I put <a href=\"https:\/\/github.com\/selenamarie\/puppetlabs-cloud-provisioner\/commit\/44e7300e1097d8a9290f864154ad591689feadc7\">a little patch<\/a> into a recent version of cloudprovisioner that invokes clean during a terminate. It&#8217;s quick and dirty, and only for AWS. <\/p>\n<p>The resources I&#8217;ve found useful are: <\/p>\n<ul>\n<li><a href=\"http:\/\/www.youtube.com\/watch?v=C9k9lF4cskg\">Kelsey&#8217;s talk at PuppetConf about Faces<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/khightower\/puppet-dashboard-face\/\">Kelsey Hightower&#8217;s Git repo for Puppet Dashboard Face<\/a><\/li>\n<li><a href=\"http:\/\/www.kartar.net\/2011\/05\/puppet-github-face\/\">Kartar&#8217;s Github face<\/a><\/li>\n<\/ul>\n<p>And to a lesser extent, these blog posts were helpful for filling in a few gaps: <\/p>\n<ul>\n<li><a href=\"http:\/\/puppetlabs.com\/blog\/puppet-faces-what-the-heck-are-faces\/\">What the heck are Faces?<\/a>\n<li><a href=\"http:\/\/puppetlabs.com\/blog\/about-faces-until-we-go-in-the-right-direction\/\">Creating a simple &#8220;backup&#8221; Face<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Puppet Faces are an extendable API for tricking out your Puppet instances. (&#8220;Faces&#8221; is just short for &#8220;Interfaces&#8221;.) Just a couple days ago I wrote about my survey of puppet + ec2 provisioning tools. The problem I&#8217;m trying to solve, &hellip; <a href=\"https:\/\/www.chesnok.com\/daily\/2011\/11\/02\/puppet-faces-defaults-and-puppet-node-clean\/\">Continue reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[216,508],"class_list":["post-3468","post","type-post","status-publish","format-standard","hentry","category-sysadmin","tag-puppet","tag-puppet-faces"],"_links":{"self":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/3468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/comments?post=3468"}],"version-history":[{"count":10,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/3468\/revisions"}],"predecessor-version":[{"id":3901,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/3468\/revisions\/3901"}],"wp:attachment":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/media?parent=3468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/categories?post=3468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/tags?post=3468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}