So on the heels of the ENC discussion in another thread I figured I''d
put up
what I''m currently working on from an external nodes perspective as a
simple
example. Then let everyone tear into it... :)
I have a very basic external_nodes script:
--start--
#!/usr/bin/perl
use strict;
use warnings;
use YAML qw( Dump LoadFile );
my $vardir = ''/etc/puppet'';
my $manifest_dir = "$vardir/manifests/nodes";
my $hostname = shift || die "No hostname passed";
# initialize
my $params;
# build parameters based on files
$params = build_yaml("$hostname/init.yaml") or exit 0;
# always add the default class
# we add them to the front
unshift @{$params->{''classes''}}, ''base'';
# dump yaml back to puppetmasterd
print Dump($params);
sub build_yaml {
my $file = shift;
$file = "$manifest_dir/$file";
return unless ( -f $file );
my $data = eval { LoadFile($file) };
return $data;
}
--end--
Currently I don''t classify nodes that don''t have a specific
file, this is by
design and may change (drop the or exit)
in my node directory I have the following structure:
nodes/$FQDN/
nodes/$FQDN/init.yaml
nodes/$FQDN/interfaces.pp
init.yaml is straight yaml that allows for definition of node variables and
defining classes at the node level.
--start--
---
classes:
parameters:
puppetserver: puppet.example.com
--end--
The way I''m handling node level defines is by defining custom classes
at the
node level.
For example my ''network'' module (which handles interfaces etc)
defines a class called
${safe_fqdn}_interfaces
${safe_fqdn} is the fqdn with illegal chars stripped out to
''_'' since puppet
doesn''t let me define classes with ''.,-'' and so on.
interfaces.pp defines the ${safe_fqdn}_interfaces class and contains the
custom defines that setup interface aliases.
As I add other functionality that needs to be defined at the host level
I''ll
follow the same scheme.
For example:
mounts.pp will contain the node specific mount types if I decide to support
that, then the appropriate module will include that custom class.
My ''base'' class gets defined for all hosts (that exist) and
provides a
mechanism for including other classes that are applicable to all servers.
I may add a location class at the ENC level at some point to allow for
things to be defined based on their specific geographic location.
Thoughts, comments, questions.
C
--
stickm@gmail.com
-==< Stick >==-
_______________________________________________
Puppet-users mailing list
Puppet-users@madstop.com
https://mail.madstop.com/mailman/listinfo/puppet-users