Puppet is great for “implementing” server infrastructure. Puppet has a concept of nodes and classes.

node 'webserver.testing.com' { 
        include apache 

class apache { 

$packagelist = ["httpd", "webalizer", "mod_ssl"] 

package { $packagelist: 
       ensure => "installed" 

This example shows how the hostname webserver.testing.com is bound to the class apache. This approach is a kind of static. To get to a more dynamic nature of implementing things we can use icpuppet which is bundled with iClassify. To enable it in puppet include

    external_nodes = "/path/to/icpuppet"
    node_terminus = exec
in you /etc/puppet/puppet.conf. I modified my icpuppet to include my iClassify credentials directly:

config = {
  :server    => 'http://localhost:5000',
  :user      => 'admin',
  :passwd    => 'admin'
I also modified the search string to fit my needs

 results = client.search("hostname:\"#{hostname}\" OR fqdn:\"#{hostname}\" OR puppet_host_id:\"#{hostname}\"")
Here you can implement ANYTHING which gives back the node you are searching for.
To test it, just invoke the icpuppet binary with a potential hostname. Already registered hostnames can be retrieved from puppet with

puppetca --list --all

+ domu-XX-XX-XX-00-XX-c6.compute-1.internal

an invocation of icpuppet yields:

icpuppet domu-XX-XX-38-00-8d-XX.compute-1.internal
  processorcount: "1"
  kernel: Linux
  puppet_host_id: domu-XX-XX-38-00-8d-XX.compute-1.internal

- base
- apache

This result gets interpreted by puppet as if we would define a node domu-XX-XX-38-00-8d-XX.compute-1.internal including the classes base and apache

node 'domu-XX-XX-38-00-8d-XX.compute-1.internal' { 
        include base
        include apache 
Additionally all parameters can be accessed directly in puppet as normal variables. E.g. puppet_host_id can be accessed with $puppet_host_id. Another great feature is that all nodes are “tagged” with their classes. which enables for statements like:

 if tagged(apache){
                notice("This is a webserver")


Interested in Cloud or Chef Trainings? Have a look at our Commandemy Trainings page. Need help migrating to the cloud? Check out Infralovers.

comments powered by Disqus
Blog Tags