Antidot SAS
2012-Dec-14 09:44 UTC
[Puppet Users] Duplicate declaration for invoking a class
Hi everyone, Here are the manifest I am using: In file ''*modules/test/manifest/init.pp*'': class test ( $test = undef, ) { notice("Here is the message: ${test}") } Now in ''*modules/saas/manifests/client/sudo.pp*'': class saas::client::sudo { class { ''test'': } } Now in ''*manifests/sites.pp*'': import "nodes" And finally in ''*manifests/nodes.pp*'': node ''linux-install.fqdn'' { include saas::client::sudo } And I am getting the following error on the client: Info: Retrieving plugin Info: Loading facts in /var/lib/puppet/lib/facter/antidot_suite_version.rb Info: Loading facts in /var/lib/puppet/lib/facter/meminbytes.rb Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb Info: Loading facts in /var/lib/puppet/lib/facter/sudo.rb Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Class[Saas::Client::Sudo] is already declared; cannot redeclare on node linux-install.fqdn Using cached catalog Of course this works: node ''linux-install.vitry.exploit.anticorp'' { class{ ''test'': test => ''alors?'', } } Any idea what could be the issue because right now I have no clue... And I am a bit lost. Note: Puppet version: 3.0.1 for both client and server # puppet --version 3.0.1 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2012-Dec-14 14:46 UTC
[Puppet Users] Re: Duplicate declaration for invoking a class
What you have presented does not explain the problem. Though you do not recognize it, there is more to this than you are telling us. On Friday, December 14, 2012 3:44:51 AM UTC-6, A_SAAS wrote:> > Hi everyone, > > > Here are the manifest I am using: > In file ''*modules/test/manifest/init.pp*'': > > class test ( > $test = undef, > ) { > notice("Here is the message: ${test}") > } > > >Is that the complete contents of the file?> Now in ''*modules/saas/manifests/client/sudo.pp*'': > > class saas::client::sudo { > class { ''test'': } > } > >And is that the complete contents of *that* file?> Now in ''*manifests/sites.pp*'': > > import "nodes" > >Complete contents?> And finally in ''*manifests/nodes.pp*'': > > node ''linux-install.fqdn'' { > include saas::client::sudo > } > >And the error occurs when that''s the only contents of its file?> > And I am getting the following error on the client: > > Info: Retrieving plugin > Info: Loading facts in /var/lib/puppet/lib/facter/antidot_suite_version.rb > Info: Loading facts in /var/lib/puppet/lib/facter/meminbytes.rb > Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb > Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb > Info: Loading facts in /var/lib/puppet/lib/facter/sudo.rb > Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb > Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb > Error: Could not retrieve catalog from remote server: Error 400 on SERVER: > Duplicate declaration: Class[Saas::Client::Sudo] is already declared; > cannot redeclare on node linux-install.fqdn > Using cached catalog > > >Puppet rejects parametrized-style class declarations for classes that have already been declared (whether the original declaration is parametrized-style or not). This is an excellent reason to rigorously avoid using parametrized-style class declarations. To find your problem, find the other place(s) where you declare Class["test"]. Such a declaration might have any of these forms: class { ''test'': ... } class { ''::test'': ... } include ''test'' include ''::test'' require ''test'' require ''::test'' Be especially watchful for top-level declarations (outside any class or node). In principle, those apply to all nodes, but in practice, they may not actually be parsed for every node. You can get those by mixing up the syntax for defining a class with the parametrized-form syntax for declaring one. That is, at top level you might write class { ''test'': } when you meant class ''test'' { } If your node declarations have nothing other than you presented, then saas/manifests/client/sudo.pp is very likely where the extra declaration appears, or some other manifest parsed as a result of it. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/4fuYUdvxBiwJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Antidot SAS
2012-Dec-14 16:20 UTC
Re: [Puppet Users] Re: Duplicate declaration for invoking a class
Hi john, thx for replying and you made a good call regarding the top scope, but even with smaller structure I have an issue: site.pp: # site.pp filebucket { ''main'': server => ''puppetmaster.fqdn'', path => false, # Due to a known issue, path must be set to false for remote filebuckets. } # global defaults File { backup => main } Exec { path => ''/usr/bin:/usr/sbin/:/bin:/sbin'' } $info = true # --[ Working directory ]-- $puppet_script_dir = ''/var/lib/puppet/scripts'' $puppet_tmp_dir = ''/var/lib/puppet/tmp'' # --[ Stages ]-- stage { ''first'': before => Stage[''main''] } # Tous les configurations lies au utilisateurs doivent etre faite en dernier stage { ''last'': require => Stage[''main''] } # --[ Loading ]-- # Directory ''templates'' part of modulepath #import "templates/*.pp" #import "nodes" node ''linux-install.fqdn { include foo::sudo } modules/foo/manifests/sudo.pp: # # Sample Usage: class foo::sudo { class { ''sudo'': } } modules/sudo/manifest/init.pp: # Sample Usage: # class { ''locales'': # locales => [ ''en_US.UTF-8 UTF-8'', ''de_DE.UTF-8 UTF-8'', ''en_GB.UTF-8 UTF-8'', ], # } # # [Remember: No empty lines between comments and class definition] class sudo( $ensure = ''present'', $autoupgrade = false, $package = $sudo::params::package, $config_file = $sudo::params::config_file, $config_file_replace = true, $config_dir = $sudo::params::config_dir, $source = $sudo::params::source, ) inherits sudo::params { notice(">>> Launching Module: ${module_name}") } Here are the logs: Dec 14 17:05:51 puppetmaster puppet-master[7880]: Handling request: POST /production/catalog/linux-install.fqdn Dec 14 17:05:51 puppetmaster puppet-master[7880]: ''replace facts'' command for linux-install.fqdn submitted to PuppetDB with UUID 9d7bad7a-0960-498e-8400-428e249b3ce9 Dec 14 17:05:51 puppetmaster puppet-master[7880]: Using cached facts for linux-install.fqdn Dec 14 17:05:51 puppetmaster puppet-master[7880]: importing ''/etc/puppet/modules/foo/manifests/sudo.pp'' in environment production Dec 14 17:05:51 puppetmaster puppet-master[7880]: Automatically imported foo::sudo from foo/sudo into production Dec 14 17:05:51 puppetmaster puppet-master[7880]: Duplicate declaration: Class[Foo::Sudo] is already declared; cannot redeclare on node linux-install.fqdn Dec 14 17:05:51 puppetmaster puppet-master[7880]: Duplicate declaration: Class[Foo::Sudo] is already declared; cannot redeclare on node linux-install.fqdn Dec 14 17:05:51 puppetmaster puppet-master[7880]: Duplicate declaration: Class[Foo::Sudo] is already declared; cannot redeclare on node linux-install.fqdn Dec 14 17:05:51 puppetmaster puppet-master[7880]: Handling request: PUT /production/report/linux-install.fqdn Dec 14 17:05:51 puppetmaster puppet-master[7880]: Received report to process from linux-install.fqdn Dec 14 17:05:51 puppetmaster puppet-master[7880]: Processing report from linux-install.fqdn with processor Puppet::Reports::Store Dec 14 17:05:51 puppetmaster puppet-master[7880]: Processing report from linux-install.fqdn with processor Puppet::Reports::Http Dec 14 17:05:51 puppetmaster puppet-master[7880]: Processing report from linux-install.fqdn with processor Puppet::Reports::Tagmail -- Info: Retrieving plugin Debug: file_metadata supports formats: b64_zlib_yaml pson raw yaml; using pson Debug: Finishing transaction 70313822650700 Info: Loading facts in /var/lib/puppet/lib/facter/antidot_suite_version.rb Info: Loading facts in /var/lib/puppet/lib/facter/meminbytes.rb Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb Info: Loading facts in /var/lib/puppet/lib/facter/sudo.rb Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb Debug: catalog supports formats: b64_zlib_yaml dot pson raw yaml; using pson Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Class[Foo::Sudo] is already declared; cannot redeclare on node linux-install.fqdn Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run Debug: Value of ''preferred_serialization_format'' (pson) is invalid for report, using default (yaml) Debug: report supports formats: b64_zlib_yaml raw yaml; using yaml But when I put the same file (modules/foo/manifests/sudo.pp) in to modules/sudo/manifests/saas as follow: class sudo::saas::client { class { ''sudo'': } } and change site.pp into: node ''linux-install.vitry.exploit.anticorp'' { include sudo::saas::client } No error: Dec 14 17:17:43 puppetmaster puppet-master[8838]: ''replace facts'' command for linux-install.fqdn submitted to PuppetDB with UUID 43b04801-1b84-4989-9ff4-9dc04305c151 Dec 14 17:17:43 puppetmaster puppet-master[8838]: Using cached facts for linux-install.fqdn Dec 14 17:17:43 puppetmaster puppet-master[8838]: importing ''/etc/puppet/modules/sudo/manifests/init.pp'' in environment production Dec 14 17:17:43 puppetmaster puppet-master[8838]: importing ''/etc/puppet/modules/sudo/manifests/saas/client.pp'' in environment production Dec 14 17:17:43 puppetmaster puppet-master[8838]: Automatically imported sudo::saas::client from sudo/saas/client into production Dec 14 17:17:43 puppetmaster puppet-master[8838]: importing ''/etc/puppet/modules/sudo/manifests/params.pp'' in environment production Dec 14 17:17:43 puppetmaster puppet-master[8838]: Automatically imported sudo::params from sudo/params into production Dec 14 17:17:43 puppetmaster puppet-master[8838]: Config file /etc/puppet/conf/hiera.yaml not found, using Hiera defaults Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Hiera YAML backend starting Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking up sudo::autoupgrade in YAML backend Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking for data source common Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking up sudo::package in YAML backend Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking for data source common Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking up sudo::config_dir in YAML backend Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking for data source common Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking up sudo::config_file_replace in YAML backend Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking for data source common Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking up sudo::config_file in YAML backend Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking for data source common Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking up sudo::ensure in YAML backend Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking for data source common Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking up sudo::source in YAML backend Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Looking for data source common Dec 14 17:17:43 puppetmaster puppet-master[8838]: hiera(): Cannot find datafile /var/lib/hiera/common.yaml, skipping Dec 14 17:17:43 puppetmaster puppet-master[8838]: (Scope(Class[Sudo])) >>> Launching Module: sudo Dec 14 17:17:43 puppetmaster puppet-master[8838]: Compiled catalog for linux-install.fqdn in environment production in 0.06 seconds Dec 14 17:17:43 puppetmaster puppet-master[8838]: Caching catalog for linux-install.fqdn On Fri, Dec 14, 2012 at 3:46 PM, jcbollinger <John.Bollinger@stjude.org>wrote:> > What you have presented does not explain the problem. Though you do not > recognize it, there is more to this than you are telling us. > > > On Friday, December 14, 2012 3:44:51 AM UTC-6, A_SAAS wrote: >> >> Hi everyone, >> >> >> Here are the manifest I am using: >> In file ''*modules/test/manifest/init.pp***'': >> >> class test ( >> $test = undef, >> ) { >> notice("Here is the message: ${test}") >> } >> >> >> > > Is that the complete contents of the file? > > > >> Now in ''*modules/saas/manifests/client/sudo.pp*'': >> >> class saas::client::sudo { >> class { ''test'': } >> } >> >> > > And is that the complete contents of *that* file? > > > >> Now in ''*manifests/sites.pp*'': >> >> import "nodes" >> >> > > Complete contents? > > > >> And finally in ''*manifests/nodes.pp*'': >> >> node ''linux-install.fqdn'' { >> include saas::client::sudo >> } >> >> > > And the error occurs when that''s the only contents of its file? > > > >> >> And I am getting the following error on the client: >> >> Info: Retrieving plugin >> Info: Loading facts in /var/lib/puppet/lib/facter/** >> antidot_suite_version.rb >> Info: Loading facts in /var/lib/puppet/lib/facter/**meminbytes.rb >> Info: Loading facts in /var/lib/puppet/lib/facter/**root_home.rb >> Info: Loading facts in /var/lib/puppet/lib/facter/**facter_dot_d.rb >> Info: Loading facts in /var/lib/puppet/lib/facter/**sudo.rb >> Info: Loading facts in /var/lib/puppet/lib/facter/**concat_basedir.rb >> Info: Loading facts in /var/lib/puppet/lib/facter/**puppet_vardir.rb >> Error: Could not retrieve catalog from remote server: Error 400 on >> SERVER: Duplicate declaration: Class[Saas::Client::Sudo] is already >> declared; cannot redeclare on node linux-install.fqdn >> Using cached catalog >> >> >> > > Puppet rejects parametrized-style class declarations for classes that have > already been declared (whether the original declaration is > parametrized-style or not). This is an excellent reason to rigorously > avoid using parametrized-style class declarations. > > To find your problem, find the other place(s) where you declare > Class["test"]. Such a declaration might have any of these forms: > > class { ''test'': ... } > class { ''::test'': ... } > include ''test'' > include ''::test'' > require ''test'' > require ''::test'' > > Be especially watchful for top-level declarations (outside any class or > node). In principle, those apply to all nodes, but in practice, they may > not actually be parsed for every node. You can get those by mixing up the > syntax for defining a class with the parametrized-form syntax for declaring > one. That is, at top level you might write > > class { ''test'': > } > > when you meant > > class ''test'' { > } > > > If your node declarations have nothing other than you presented, then > saas/manifests/client/sudo.pp is very likely where the extra declaration > appears, or some other manifest parsed as a result of it. > > > John > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/4fuYUdvxBiwJ. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.