I'm trying to have puppet build a configuration file that looks like this:

[All]
Hosts=apt-dater@puppetmaster;apt-dater@blaster; (etc...)

Basically, this file needs an entry for each node that includes the apt-dater class. I've been experimenting with exported resources, but I can't find a clean way of putting it together. How should I go about creating this file?

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

I assume that you already understand the principles of exporting and collecting individual type resources. Just not how to translate these individual resources into a single file. Puppet has two methods for doing this:

Augeas is a very clever tool but it can prove complex if you have to start writing and distributing your own lenses. However puppet-concat is very simple to grasp. I haven't tested the following for syntax but it should set you on the right track:

# apt-dater/manifests/server.pp
class apt-dater::server {
    file { "/somepath/apt-dater/hosts.conf": }
    concat::fragment{ "apt-dater_hosts_header":
        content => "[All]\nHosts=",
        order   => 1,
    }
    Apt-dater::Client <<| |>>
}

# apt-dater/manifests/defines/register.pp
define apt-dater::register($order=10) {
    concat::fragment{ "apt-dater_hosts_$name":
        target  => "/somepath/apt-dater/hosts.conf",
        content => "apt-dater@${name};",
    }
}

# apt-dater/manifests/client.pp
class apt-dater::client {
    @apt-dater::register{ "$hostname": }
}

Then setup the nodes:

# On the central server.
include apt-dater::server

# On each of the client nodes.
include apt-dater::client
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.