I'm having trouble figuring out how Puppet does inheritence and auto-inclusion of modules.
I have a Puppet class that works as expect when I test it "locally" but fails when I push it to my nodes via the Puppet server.
"Locally" means running via puppet apply
and sending in the correct local module path.
Here is an example of the classes and what happens. I've tried to strip this down to the least number of things that produce this problem, however I admit I'm not positive that I could be omitting something important.
What I'm trying to achieve is writing new components for an existing module without breaking backward compatibility to nodes that already include the old module. I'm migrating a poorly written module to a be more appropriately written, and I want to push it out in stages without breaking existing installations.
My node declaration is as follows:
node /myserver.*/ {
include myclass::server
}
The manifests are declared as follows:
# File "myclass/manifests/init.pp"
class myclass {
file { '/etc/oldconfig.conf':
ensure => file,
owner => root,
group => root,
mode => '0644',
source => 'puppet:///files/oldconfig.conf',
}
}
# File "myclass/manifests/server.pp"
class myclass::server {
include myclass::next
}
# File "myclass/manifests/next.pp"
class myclass::next {
# Remove clutter
file { '/etc/oldconfig.conf':
ensure => absent
}
... more stuff, not relevant ...
}
To sum up, the original init.pp includes a file, "oldconfig.conf". The new module class, "next", deletes this file.
When I run the module using "puppet apply", (i.e. locally), I do not get any conflicts and the run ends with a zero exit status.
But when I run puppet agent -t
on the real node, which is pulling the manifests from the puppet server, I get the following:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: File[/etc/oldconfig.conf] is already declared in file /etc/puppet/environments/common/myclass/manifests/init.pp:48; cannot redeclare at /etc/puppet/environments/common/myclass/manifests/next.pp:4 on node mynode01.example.com
Is there some sort of Puppet manifest inheritance and/or auto-include that happens on runs from the puppetmaster that differ from local puppet apply
runs?
If I include just a sub-class -- e.g. include myclass::my_subclass
-- in a Puppet manifest's node declaration, should I expect that the subclass is always going to reference the parent class? I don't recall seeing this behavior before this example, and I also couldn't find explicit documentation answering this question. (It's kinda hard to Google for this though)