Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 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
share|improve this answer
1  
Why is that @apt-dater::register and not @@apt-dater::register? Aren't we exporting this resource? Or have I misunderstood the Puppet docs? Also, does concat::fragment resource in apt-dater::server need a target key? –  larsks Nov 28 '12 at 1:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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