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 </pre>
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' } </pre>
I also modified the search string to fit my needs
results = client.search("hostname:\"#{hostname}\" OR fqdn:\"#{hostname}\" OR puppet_host_id:\"#{hostname}\"") </pre>
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-12-XX-38-XX-42-XX.compute-1.internal
+ 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 --- parameters: processorcount: "1" kernel: Linux puppet_host_id: domu-XX-XX-38-00-8d-XX.compute-1.internal .....
classes:
- base
- apache
This result gets interpreted by puppet as if we would define a nodedomu-XX-XX-38-00-8d-XX.compute-1.internal
including the classesbase
andapache
node 'domu-XX-XX-38-00-8d-XX.compute-1.internal' { include base include apache } </pre>
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