Re:Why Puppet Should Manage Your Infrastructure
by uggedal on Saturday March 12, 2011 @07:10AM
(#2316675)
Or you could override the default file resource attributes in sites.pp:
File {
owner => root,
group => root,
mode => 644,
}
Then you could override that again in individual file resources. If you need several file resources with the same attributes you can override them within the scope of a class: class postgresql {
File {
owner => "postgres",
group => "postgres",
mode => 640,
}
$pgsql_root = "/etc/postgresql/8.4/main"
file { "$pgsql_root/postgresql.conf":
content => template("postgresql/postgresql.conf.erb"),
require => Package["postgresql"],
}
file { "$pgsql_root/pg_hba.conf":
content => template("postgresql/pg_hba.conf.erb"),
require => Package["postgresql"],
}
}
You can define a custom resource, for example "system_file" that provides a default "root:root, mask 444" permissions such that you just have to define a source and destination for every file, overriding the default permissions when you want.
define system_file($mode = 444, $owner = root, $group = root, $content = '', $source = '', $ensure = 'present') {
So in the article's example, it would look like this: Or even Where $configfiles might be the puppet server or some other location. One of the things you get with puppet is access to any of the local host properties that can be discovered with facter, so you can dynamically configure something like a source file.