On Tue, 14 Dec 2010, Tim Watts wrote:
> Are there any magic variables that allow me to do something like:
> 
> source => [ "puppet:///files/resolv.conf/$mostspecificclass
>             "puppet:///files/resolv.conf/BASE"
> ]

Well, there are variables like $fqdn, $hostname, $environment,
or you can add your own.

I use a definition roughly like this:

    define my_file (ensure = "file", $user, $group, $mode,
                    $source_prefix)
    {
        file { $name:
            ensure => $ensure,
            user => $user,
            group => $group,
            mode => $mode,
            source => [
                "${source_prefix}.$fqdn",
                "${source_prefix}.$hostname",
                "${source_prefix}.$environment",
                "${source_prefix}.BASE",
            ],
    }

Usage is like this:

    my_file { "/etc/resolv.conf":
        user => root, group => root, mode => 0644,
        source_prefix => "puppet:///modules/my_module/resolv.conf",
    }

You can easily adapt this to use a different list of sources.  With more
trouble, you can generate the list of sources at run time depending on
some other conditions (and I actually do that).

> class syslog {
>       file { "/etc/syslog-ng/syslog-ng.conf":
>               path => "/etc/syslog-ng/syslog-ng.conf",
>               ensure => file,
>               mode => 644,
>               owner => root,
>               group => root,
>               notify => Service[syslog],
>               source => "puppet:///files/etc/syslog-ng/syslog-ng.conf"
>       }
> }
> 
> is there no variable for the first instance of
> "/etc/syslog-ng/syslog-ng.conf"
> ???

No, but you can define your own variable and use that, or you can wrap
it in a definition and use $name inside the definition.

> Is there a simple way to say "just create any directories you need
> to with default modes"?

No.  You need to specify each level explicitly.  See issue #86
<http://projects.puppetlabs.com/issues/86> for discussion of how such a
new feature might eventually work.

--apb (Alan Barrett)

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to