Reputation: 12628
I'm shipping a specific config file with puppet to all my computers. Let's call this class class A
:
class A {
# ship lightdm file
file {
"/etc/lightdm/lightdm.conf":
mode => 644,
owner => root,
group => root,
ensure => file,
require => Package["lightdm"],
source => "puppet:///modules/my_module/lightdm.conf";
}
}
class A
will actually be loaded through some other class:
node 'somecomputer' {
include role::my_role #(will load class A)
}
Now, some user needs a special version of that particular config file. So I thought about writing a class B
(which would look the same as A
except for the source
part) and include that class for the node config of that particular computer:
node 'specialcomputer' {
include role::my_role #(will load class A)
include B
}
However, I'm wondering how puppet will determine which file to ship in the end. Since there's no order of execution in puppet, it seems to me like my current approach won't work (plus the resource file
will be defined twice which won't work either)
I also can not use inheritance on class A
because class A
is included by some top level class. So how should I deal with this case? any pointers?
Upvotes: 1
Views: 987
Reputation: 1232
If you provide multiple sources, it will select the first that is available:
file {
"/etc/lightdm/lightdm.conf":
mode => 644,
owner => root,
group => root,
ensure => file,
require => Package["lightdm"],
source => [ "puppet:///modules/my_module/lightdm-${::fqdn}.conf",
"puppet:///modules/my_module/lightdm.conf" ],
}
Then you would have 2 files in the files directory:
files/lightdm.conf (for all hosts)
files/lightdm-specialcomputer.domain.com.conf (for the exception)
It's not exactly what you asked for, but I think that is what you want...
Upvotes: 2