I have about 200 more or less identical Linux VMs. There is a class for all common configuration:
class my_packages {
class { "::ntp":
servers => [ "de.pool.ntp.org" ],
}
....
}
which I include in each node in site.pp.
Now I want to run my own local time server, which is trivial using the puppetlabs/ntp package. I simply have to replace the servers entry in my_packages with the ip address of the new time server VM, and that VM now has the same ntp class entry that was previously used in my_packages.
node 'mytime' {
# include my_packages
class { '::ntp':
servers => [
'de.pool.ntp.org',
'ptbtime1.ptb.de',
'ptbtime2.ptb.de',
'ptbtime3.ptb.de',
],
}
...
}
However since the class "::ntp" entry is now defined in the node, I can't include my_packages in the node entry for my new time server VM, because I get a "Duplicate declaration" error in this case.
A similar problem has occurred when using a local name server. Each VM has an /etc/resolv.conf file pointing to the local name server, so there is a file resource for that in my_packages. But the local name server itself must have a different /etc/resolv.conf file - it can't point to itself until its installation is complete, which is not the case during installation.
What is the best practise for using a common set of resources, but allowing for occasional exceptions?