[Puppet Users] Exported/Collect resource not working?

Brice Figureau
2008-07-30T15:39:31Z

Hi,

I''m running debianized puppet 0.24.4-8 (both puppetmaster and puppets).

I''m having issues with exported/collected resources.
I have two nodes corp1 and corp2, each are using the following manifest
from the module test:

modules_dir { ["test","test/test.d"]: }
class test {

	concatenated_file {
		"/var/lib/puppet/modules/test/test.txt":
			dir => "/var/lib/puppet/modules/test/test.d";
	}

	@@concatenated_file_part {
		"${fqdn}-part":
			dir => "/var/lib/puppet/modules/test/test.d",
			tag => "test";
	}


	Concatenated_file_part <<| tag == ''test'' |>>

}

concatenated_file is David Schmitt''s define to build-up files by
concatenating subfiles. The concatenated_file_part is basically a
wrapper around file{} which notifies the exec which does the
concatenation.

then in site.pp:
node "corp1" inherits "server" {
 ... various other definition...
 include test
}

node "corp2" inherits "server" {
 ... same various other definition...
 include test
}

Starting with a fresh database (ie corp1 and corp2 cleanly removed with
kill_node_in_storedconfig.rb).

Then I run manually puppet on corp1. It creates
the /var/lib/puppet/modules/test/test.d/corp1-part file without any
issues.
The database is also populated with exported entries:
| 20452 | /var/lib/puppet/modules/test/test.d/corp1-part | File
|      11 |              2 |        1 |   99 | 2008-07-30 16:30:17 |
| 20501 | corp1-part                                     |
Concatenated_file_part |      11 |             46 |        1 |   14 | 2008-07-30
16:30:19 |

Next, doing the same thing on corp2, it
creates /var/lib/puppet/modules/test/test.d/corp1-part but
not /var/lib/puppet/modules/test/test.d/corp2-part (notice the
corp2/corp1 mismatch). The corp1-part could come from the collected
resource, but why doesn''t it create the corp2-part?
I suspect puppet for an unknown reason thinks it is the same resource
even though its title is different.

Note that the database contains the right resources for this host:
| 20812 | corp2-part                                     |
Concatenated_file_part |      12 |             46 |        1 |   14 | 2008-07-30
16:34:32 |
| 20841 | /var/lib/puppet/modules/test/test.d/corp2-part | File
|      12 |              2 |        1 |   99 | 2008-07-30 16:34:32 |

OK, back to corp1, and re-running puppet (with the hope the corp2-part
will be collected) I get the following error:
err: Could not retrieve catalog: Puppet::Parser::AST::Resource failed
with error ArgumentError: Duplicate definition:
File[/var/lib/puppet/modules/test/test.d/corp2-part] is already defined;
cannot redefine
at /etc/puppet/modules/common/manifests/defines/concatenated_file.pp:99
on node corp1.daysofwonder.com

Here is the full stack trace printed on the puppetmaster:
/usr/lib/ruby/1.8/puppet/node/catalog.rb:466:in `fail_unless_unique''
/usr/lib/ruby/1.8/puppet/node/catalog.rb:67:in `add_resource''
/usr/lib/ruby/1.8/puppet/node/catalog.rb:62:in `each''
/usr/lib/ruby/1.8/puppet/node/catalog.rb:62:in `add_resource''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:35:in `add_resource''
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:54:in `evaluate''
/usr/lib/ruby/1.8/puppet/util/errors.rb:25:in `exceptwrap''
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:31:in `evaluate''
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:30:in `collect''
/usr/lib/ruby/1.8/puppet/parser/ast/resource.rb:30:in `evaluate''
/usr/lib/ruby/1.8/puppet/parser/ast.rb:54:in `safeevaluate''
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate''
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect''
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate''
/usr/lib/ruby/1.8/puppet/parser/ast.rb:54:in `safeevaluate''
/usr/lib/ruby/1.8/puppet/parser/ast/definition.rb:44:in `evaluate_code''
/usr/lib/ruby/1.8/puppet/parser/resource.rb:61:in `evaluate''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:272:in
`evaluate_definitions''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:270:in `each''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:270:in
`evaluate_definitions''
/usr/lib/ruby/1.8/puppet/util/errors.rb:25:in `exceptwrap''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:267:in
`evaluate_definitions''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:295:in
`evaluate_generators''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:290:in `loop''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:290:in
`evaluate_generators''
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:92:in `compile''
/usr/lib/ruby/1.8/puppet/parser/interpreter.rb:29:in `compile''
/usr/lib/ruby/1.8/puppet/network/handler/configuration.rb:107:in
`compile''
/usr/lib/ruby/1.8/puppet/util.rb:217:in `benchmark''
/usr/lib/ruby/1.8/puppet/network/handler/configuration.rb:105:in
`compile''
/usr/lib/ruby/1.8/puppet/network/handler/configuration.rb:40:in
`configuration''
/usr/lib/ruby/1.8/puppet/network/handler/master.rb:69:in `getconfig''
/usr/lib/ruby/1.8/puppet/util.rb:212:in `benchmark''
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime''
/usr/lib/ruby/1.8/puppet/util.rb:211:in `benchmark''
/usr/lib/ruby/1.8/puppet/network/handler/master.rb:68:in `getconfig''
/usr/share/rails/activerecord/lib/../../activesupport/lib/active_support/inflector.rb:257:in
`to_proc''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:52:in `call''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:52:in
`protect_service''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:85:in
`setup_processor''
/usr/lib/ruby/1.8/xmlrpc/server.rb:336:in `call''
/usr/lib/ruby/1.8/xmlrpc/server.rb:336:in `dispatch''
/usr/lib/ruby/1.8/xmlrpc/server.rb:323:in `each''
/usr/lib/ruby/1.8/xmlrpc/server.rb:323:in `dispatch''
/usr/lib/ruby/1.8/xmlrpc/server.rb:366:in `call_method''
/usr/lib/ruby/1.8/xmlrpc/server.rb:378:in `handle''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:44:in `process''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/webrick_servlet.rb:68:in
`service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start''
/usr/lib/ruby/1.8/puppet.rb:336:in `start''
/usr/lib/ruby/1.8/puppet.rb:187:in `newthread''
/usr/lib/ruby/1.8/puppet.rb:186:in `initialize''
/usr/lib/ruby/1.8/puppet.rb:186:in `new''
/usr/lib/ruby/1.8/puppet.rb:186:in `newthread''
/usr/lib/ruby/1.8/puppet.rb:334:in `start''
/usr/lib/ruby/1.8/puppet.rb:333:in `each''
/usr/lib/ruby/1.8/puppet.rb:333:in `start''
/usr/sbin/puppetmasterd:284
/usr/lib/ruby/1.8/puppet/parser/interpreter.rb:32:in `compile''
/usr/lib/ruby/1.8/puppet/network/handler/configuration.rb:107:in
`compile''
/usr/lib/ruby/1.8/puppet/util.rb:217:in `benchmark''
/usr/lib/ruby/1.8/puppet/network/handler/configuration.rb:105:in
`compile''
/usr/lib/ruby/1.8/puppet/network/handler/configuration.rb:40:in
`configuration''
/usr/lib/ruby/1.8/puppet/network/handler/master.rb:69:in `getconfig''
/usr/lib/ruby/1.8/puppet/util.rb:212:in `benchmark''
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime''
/usr/lib/ruby/1.8/puppet/util.rb:211:in `benchmark''
/usr/lib/ruby/1.8/puppet/network/handler/master.rb:68:in `getconfig''
/usr/share/rails/activerecord/lib/../../activesupport/lib/active_support/inflector.rb:257:in
`to_proc''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:52:in `call''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:52:in
`protect_service''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:85:in
`setup_processor''
/usr/lib/ruby/1.8/xmlrpc/server.rb:336:in `call''
/usr/lib/ruby/1.8/xmlrpc/server.rb:336:in `dispatch''
/usr/lib/ruby/1.8/xmlrpc/server.rb:323:in `each''
/usr/lib/ruby/1.8/xmlrpc/server.rb:323:in `dispatch''
/usr/lib/ruby/1.8/xmlrpc/server.rb:366:in `call_method''
/usr/lib/ruby/1.8/xmlrpc/server.rb:378:in `handle''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:44:in `process''
/usr/lib/ruby/1.8/puppet/network/xmlrpc/webrick_servlet.rb:68:in
`service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread''
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each''
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start''
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start''
/usr/lib/ruby/1.8/puppet.rb:336:in `start''
/usr/lib/ruby/1.8/puppet.rb:187:in `newthread''
/usr/lib/ruby/1.8/puppet.rb:186:in `initialize''
/usr/lib/ruby/1.8/puppet.rb:186:in `new''
/usr/lib/ruby/1.8/puppet.rb:186:in `newthread''
/usr/lib/ruby/1.8/puppet.rb:334:in `start''
/usr/lib/ruby/1.8/puppet.rb:333:in `each''
/usr/lib/ruby/1.8/puppet.rb:333:in `start''
/usr/sbin/puppetmasterd:284


I changed the ${fqdn} in the exported resource title to something not as
dynamic (ie a fixed string defined in the node definition), but this
does the exact same thing.

I also tried to collect File instead of Concatenated_file_part, but then
it doesn''t collect anything anywhere.

The bad news is that I''m relying on this pattern for lots of thing, so
that could be great if it works (even with a workaround).

Hum, what''s wrong?
Any idea or work-around?