The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #4792

Duplicate definition since 2.6.1 upgrade

Added by James Turnbull almost 4 years ago. Updated over 1 year ago.

Status:ClosedStart date:09/17/2010
Priority:HighDue date:
Assignee:Radosław Antoniuk% Done:

100%

Category:parser
Target version:-
Affected Puppet version:2.7.5 Branch:http://github.com/stereotype441/puppet/tree/ticket/2.6.x/4792
Keywords: customer

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

Class, users::virtual which has all the user{} statements for all users. Then have classes like users::cms and users::developers that inherit users::virtual and then realize some of the users. This all worked perfectly fine in 2.5 but since 2.6.1 runs now fail with:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: User[apen 
ney] is already defined in file /etc/puppet/modules/testing/users/manifests/virtual.pp at line 19; canno 
t redefine at /etc/puppet/modules/testing/users/manifests/virtual.pp:19 on node hlslinutil1.law.harvard. 
edu
realize( 
User['user'], 
) 
}

# cat virtual.pp 
class users::virtual {

## 
## Sysadmins 
##

@user { "user": 
ensure => "present", 
uid => 35421, 
gid => 100, 
groups => "wheel", 
comment => "User Name", 
home => "/home/user", 
shell => "/bin/zsh", 
password => password, 
managehome => true, 
} 
}

Related issues

Related to Puppet - Bug #5447: Fix duplicate definition error Duplicate 12/02/2010

History

#1 Updated by James Turnbull almost 4 years ago

  • Priority changed from Normal to High

#2 Updated by Markus Roberts almost 4 years ago

  • Assignee set to Jesse Wolfe

I’m setting this to Jesse since he was working on trying to reproduce it when I left the office.

#3 Updated by Jesse Wolfe almost 4 years ago

  • Status changed from Accepted to Needs More Information
  • Assignee changed from Jesse Wolfe to James Turnbull

OK, I’ve been completely unable to reproduce this, and I’ve tried several variations on the above example and the examples from the original user.

Is it possible that there’s some other problem in their manifests?

Unfortunately, I still don’t have a theory on what could cause the definition on virtual.pp:19 to conflict with itself.

#4 Updated by James Turnbull almost 4 years ago

Another example from the support ticket:

-sh-3.2# cat service.pp

## 
## Set up postfix to run. 
##

class postfix::service { 

service { "postfix": 
ensure => "running", 
enable => "true", 
hasrestart => "true", 
hasstatus => "true", 
require => Package["postfix"], 
}

exec { "newaliases": 
require => Package["postfix"], 
} 
} 

-sh-3.2# cat init.pp

## 
## Setup postfix. 
## 
class postfix { 
include postfix::install 
include postfix::service 
}

## 
## Relay class for forwarding only. 
## 
class postfix::relay inherits postfix::install { 

File["/etc/postfix/main.cf"] { 
source => "puppet:///modules/postfix/main.cf", 
}

file { "/etc/postfix/master.cf": 
ensure => present, 
source => "puppet:///modules/postfix/master.cf", 
require => Package['postfix'], 
notify => Service['postfix'], 
}

}
info: Retrieving plugin 
info: Loading facts in location 
info: Loading facts in rhythmyx 
info: Loading facts in apache-ports 
info: Loading facts in dell 
info: Loading facts in convera 
info: Loading facts in location 
info: Loading facts in rhythmyx 
info: Loading facts in apache-ports 
info: Loading facts in dell 
info: Loading facts in convera 
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Package[postfix] is already defined in file /etc/puppet/modules/production/postfix/manifests/install.pp at line 9; cannot redefine at /etc/puppet/modules/production/postfix/manifests/install.pp:9 on node hlsrelay1.law.harvard.edu 
warning: Not using cache on failed catalog 
err: Could not retrieve catalog; skipping run

#5 Updated by Jesse Wolfe almost 4 years ago

I’ve still had no luck reproducing it.

#6 Updated by Chuck Schweizer almost 4 years ago

I am seeing the same problem. (works fine if the Puppetmaster is 0.25.5)

Puppetmaster 2.6.1
Puppetclient 0.25.5 (fails as 2.6.1 client also)

updated with correct error message Sep 18, 2010 at 10:33 CDT

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Exec[/bin/sed -i '/\[components\]/ a\${line}' /opt/data/trac/sandbox/conf/trac.ini] is already defined in file /var/opt/puppet/environments/production/modules/trac/manifests/definitions/tracini.iv1_0.pp at line 20; cannot redefine at /var/opt/puppet/environments/production/modules/trac/manifests/definitions/tracini.iv1_0.pp:20 on node client1

        trac::tracinicomponentline {"iniadmin_$name" :
        file=> "$trac_ini",
                line=> "iniadmin.* = enabled",
                require => Trac::Traciniline["components_$name"],
        }
  
        trac::tracinicomponentline {"tracrpcini_$name" :
                file=> "$trac_ini",
                line=> "tracrpc.* = enabled",
                require => Trac::Traciniline["components_$name"],
        }

        trac::tracinicomponentline {"breadcrumbsini_$name" :
                file=> "$trac_ini",
                line=> "breadcrumbsnavplugin.* = enabled",
                require => Trac::Traciniline["components_$name"],
        }
define trac::tracinicomponentline($line, $file) {
        exec { "/bin/sed -i /\\[components\\]/ a\\${line} ${file}":
        unless => "/bin/grep -Fx '${line}' '${file}'"
        }
}

#7 Updated by Chuck Schweizer almost 4 years ago

Looks like I might be having a different issue. Looks like the parser on the 2.6.1 puppetmaster is not dealing with the a\\${line} correctly in this code.

exec { "/bin/sed -i /\\[components\\]/ a\\${line} ${file}":
unless => "/bin/grep -Fx '${line}' '${file}'"
}

#8 Updated by James Turnbull almost 4 years ago

Chuck – why do you think this is the same error? Your error message suggests a syntax error somewhere in your code?

#9 Updated by James Turnbull almost 4 years ago

Chuck – can you check for a ticket for that and if not can you open please?

#10 Updated by Chuck Schweizer almost 4 years ago

Opened Bug #4804 for my parse issue. Also updated my error message above, accidentally grabbed the wrong one when adding my original update.

#11 Updated by Ohad Levy almost 4 years ago

I’m seeing similar issue, when applying to a node two classes that inherits the same parent, for example:

class puppet::cron inherits puppet::common {
  Service["puppet"] {
    enable => false
  }
..
}

class puppet::master inherits puppet::common {
..
  File["/etc/puppet/puppet.conf"] {content => template("puppet/puppetmaster.conf")}
..
}

#12 Updated by Stefan Goethals almost 4 years ago

I’m having the same issue

angel:~ # puppet agent --test
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Group[suroot] is already defined in file /etc/puppet/modules/user/manifests/virtual.pp at line 12; cannot redefine at /etc/puppet/modules/user/manifests/virtual.pp:12 on node angel
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run

modules/user/manifests/virtual.pp

# virtual.pp
#
# People accounts
# ordered by uid

class user::virtual {
    # Groups
    
    @group{ "suroot":
        ensure => "present",
        gid    => 11
    }

modules/user/manifests/productions.pp

class user::productions inherits user::virtual {
    
    realize(
        User["root"],
        Group["suroot"],

modules/user/manifests/mailandsite.pp

class user::mailandsite inherits user::virtual {
    
    realize(
        Usercommit:"victor"],
        Group["victor",

Worked perfectly in 0.25.x

Regards,

Stefan.

#13 Updated by Jesse Wolfe almost 4 years ago

  • Status changed from Needs More Information to Investigating
  • Assignee changed from James Turnbull to Jesse Wolfe

#14 Updated by Jesse Wolfe almost 4 years ago

Ohad, Stefan – when you’re applying these classes to a node, what mechanism are you using: the include keyword in a .pp file? the external node classifier? foreman? dashboard?

#15 Updated by Jesse Wolfe almost 4 years ago

  • Status changed from Investigating to Needs More Information

Theorizing that this might only affect the external node classifier, I attempted to reproduce the issue using Stefan’s example, putting the classes in modules as he described, and using a node classification script that assigned both classes to the node. I didn’t get the error.

Is there anything I could be missing? Do any of you have a minimal manifest that exhibits the problem that you could post?

#16 Updated by Ohad Levy almost 4 years ago

hmm.. I was not able to reproduce in a simple manifest with puppet directly, did you try with a master as well?

#17 Updated by Stefan Goethals almost 4 years ago

I apply both classes via puppet-dashboard, with a group ‘productions’ containing class ‘user::productions’ and class ‘user::mailandsite’ applied directly to the node.

Stefan.

#18 Updated by Stefan Goethals almost 4 years ago

I have just tried making a minimal config with only the user module files and i don’t get the error…..

Putting the original, full puppet tree back produces the error. :–(

Stefan.

#19 Updated by Dan Bode almost 4 years ago

can someone post a stacktrace?

#20 Updated by Stefan Goethals almost 4 years ago

Can this help?

# puppet master —no-daemonize —debug —verbose —trace

/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:519:in `fail_on_duplicate_type_and_title'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:74:in `add_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:72:in `each'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:72:in `add_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:57:in `add_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:56:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/util/errors.rb:35:in `exceptwrap'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:39:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:38:in `collect'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:38:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb:70:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:255:in `evaluate_definitions'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:255:in `each'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:255:in `evaluate_definitions'
/usr/lib/ruby/site_ruby/1.8/puppet/util/errors.rb:35:in `exceptwrap'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:254:in `evaluate_definitions'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:270:in `evaluate_generators'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:265:in `loop'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:265:in `evaluate_generators'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:107:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:18:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:175:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:174:in `benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:34:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:193:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector.rb:50:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:101:in `do_find'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:68:in `send'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:68:in `process'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick/rest.rb:23: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/site_ruby/1.8/puppet/network/http/webrick.rb:45:in `listen'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `call'
/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/site_ruby/1.8/puppet/network/http/webrick.rb:42:in `listen'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `initialize'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `new'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `listen'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:38:in `synchronize'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:38:in `listen'
/usr/lib/ruby/site_ruby/1.8/puppet/network/server.rb:127:in `listen'
/usr/lib/ruby/site_ruby/1.8/puppet/network/server.rb:142:in `start'
/usr/lib/ruby/site_ruby/1.8/puppet/daemon.rb:124:in `start'
/usr/lib/ruby/site_ruby/1.8/puppet/application/master.rb:114:in `main'
/usr/lib/ruby/site_ruby/1.8/puppet/application/master.rb:46:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:300:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:397:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:300:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:55:in `execute'
/usr/bin/puppet:4
err: Duplicate definition: Group[suroot] is already defined in file /etc/puppet/modules/user/manifests/virtual.pp at line 12; cannot redefine at /etc/puppet/modules/user/manifests/virtual.pp:12 on node angel.zipkid.eu
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:21:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:175:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:174:in `benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:34:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:193:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/indirector.rb:50:in `find'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:101:in `do_find'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:68:in `send'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:68:in `process'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick/rest.rb:23: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/site_ruby/1.8/puppet/network/http/webrick.rb:45:in `listen'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `call'
/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/site_ruby/1.8/puppet/network/http/webrick.rb:42:in `listen'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `initialize'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `new'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `listen'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:38:in `synchronize'
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:38:in `listen'
/usr/lib/ruby/site_ruby/1.8/puppet/network/server.rb:127:in `listen'
/usr/lib/ruby/site_ruby/1.8/puppet/network/server.rb:142:in `start'
/usr/lib/ruby/site_ruby/1.8/puppet/daemon.rb:124:in `start'
/usr/lib/ruby/site_ruby/1.8/puppet/application/master.rb:114:in `main'
/usr/lib/ruby/site_ruby/1.8/puppet/application/master.rb:46:in `run_command'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:300:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:397:in `exit_on_fail'
/usr/lib/ruby/site_ruby/1.8/puppet/application.rb:300:in `run'
/usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:55:in `execute'
/usr/bin/puppet:4
err: Duplicate definition: Group[suroot] is already defined in file /etc/puppet/modules/user/manifests/virtual.pp at line 12; cannot redefine at /etc/puppet/modules/user/manifests/virtual.pp:12 on node angel.zipkid.eu

#21 Updated by Jesse Wolfe almost 4 years ago

Thanks, Stefan. I’m trying to debug from here, but my fear is that the data structures may already be corrupted before we reach the point of failure.

#22 Updated by Paul Berry almost 4 years ago

Jesse and I found a possible explanation.

Using this manifest:

class foo
{
  include bar
}

class bar
{
  notify { barf: }
}

and this “external node classifier” script:

#!/usr/bin/ruby

require 'yaml'

puts (({'parameters' => {}, 'classes' => ['foo', 'bar']}).to_yaml)

We can produce a duplicate definition error:

[puppet] ~/puppet_labs/notes/tests/bug4792$ puppet init.pp --external_nodes ~/puppet_labs/notes/tests/bug4792/node_classifier.rb --node_terminus exec
Duplicate definition: Notify[barf] is already defined in file /Users/pberry/puppet_labs/notes/tests/bug4792/init.pp at line 8; cannot redefine at /Users/pberry/puppet_labs/notes/tests/bug4792/init.pp:8 on node paul-berrys-macbook-pro-2.local

More details to follow.

#23 Updated by Paul Berry almost 4 years ago

  • Branch set to http://github.com/stereotype441/puppet/tree/ticket/2.6.x/4792

Here’s our suspicion as to what’s going on:

  • The external node classifier returns classes A and B
  • class A happens to include class B
  • evaluate_definitions determines that classes A and B need to be evaluated.
  • first it evaluates class A. Since class A includes class B, this causes class B to be evaluated too.
  • then, evaluate_definitions tries to evaluate class B. But since class B has already been evaluated, it gets evaluated again.
  • consequently, any resources defined in class B get duplicated.

We’ve uploaded an experimental patch to http://github.com/stereotype441/puppet/tree/ticket/2.6.x/4792 that causes evaluate_definitions to check each class in turn before evaluating it, rather than figuring out which classes to evaluate first and then evaluating all of them.

Can someone please try this patch on site to see if it addresses the problem?

#24 Updated by Stefan Goethals almost 4 years ago

Hi Paul,

I have installed your version on the master and i am not getting the error any more! My setup is quite limited (2 nodes of which one is also master) so this is not a very extensive test.

It does look good nonetheless!

Thank you for your efforts.

Stefan.

#25 Updated by Paul Berry almost 4 years ago

  • Status changed from Needs More Information to Accepted
  • Assignee changed from Jesse Wolfe to Paul Berry

Great! Considering that what Jesse and I found is a real bug, and addresses the problem for at least one of the reporters of this ticket (Stefan), I’m going to assume for now that we have the culprit, and I’ll go ahead and clean up the patch so that it’s up to our coding standards. Hopefully it will be ready for inclusion in 2.6.2 later today.

To the others who experienced this bug, let us know if the patch doesn’t work for you, and we can keep investigating.

#26 Updated by Paul Berry almost 4 years ago

  • Status changed from Accepted to In Topic Branch Pending Review
  • % Done changed from 0 to 100

Ok, I’ve cleaned up the patch and I believe it is ready to go.

#27 Updated by Markus Roberts almost 4 years ago

  • Status changed from In Topic Branch Pending Review to Ready For Checkin

Whoot!

#28 Updated by Markus Roberts almost 4 years ago

  • Status changed from Ready For Checkin to In Topic Branch Pending Review

I’ve posted a question about the specific solution on the list…

#29 Updated by Markus Roberts almost 4 years ago

  • Status changed from In Topic Branch Pending Review to Ready For Checkin

#30 Updated by Markus Roberts almost 4 years ago

Revised version (making Resource#evaluate idempotent as discussed on puppet-dev) pushed to 2.6.x as commit:0aaa742e0f09c25fb5591b72c9073bb1fee59ece

#31 Updated by Markus Roberts almost 4 years ago

  • Status changed from Ready For Checkin to Closed

#32 Updated by Jos Boumans over 3 years ago

  • Status changed from Closed to Re-opened
  • Target version changed from 2.6.2 to 69

I’m encountering what looks to be the same issue in 2.6.3:

Nov 30 20:08:27 ip-10-204-53-197 node_classifier.py[1730]: DEBUG: Node configuration
(riak.example.com.137d3603-a0dc-432c-a0d6-08878dd81d39): {'classes': ['s_riak']}
Nov 30 20:08:27 ip-10-122-246-108 puppet-agent[6149]: Could not retrieve catalog from
remote server: Error 400 on SERVER: Duplicate definition: Class[Kbase] is already
defined; cannot redefine at puppet/env/production/krux-modules/kbase/manifests/init.pp:3 

Changing the following line works around the issue:

class s_riak inherits kbase {

to:

class s_riak {
    include kbase

Below are the relevant files I’m using:

ubuntu@cc002:~/sources/git/krux_interchange.2/puppet-new/puppet/env/production$ find . -type f | grep manifests | grep -P 'kbase|s_riak' | xargs -I% perl -le'$_=shift; print "*** FILE: $_ ***"; print `cat $_`' % 
*** FILE: ./services/s_riak/manifests/init.pp ***
# Class: s_riak
#
# This module manages s_riak
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# [Remember: No empty lines between comments and class definition]

include kbase::stages

class { "s_riak": stage => "puppet1" }

class s_riak inherits kbase {

    file { "/usr/local/krux/services/s_riak/":
        source  => "puppet:///modules/s_riak",
        ensure  => directory,
        recurse => true,
        mode    => 755,
        owner   => root,
        group   => root,
        purge   => true,
    }

    ### Arch dependant    
    $deb = $architecture ? {
        i386    => "riak-ee_0.13.0-1_i386.deb",
        amd64   => "riak-ee_0.13.0-1_amd64.deb",
        x86_64  => "riak-ee_0.13.0-1_amd64.deb",
    }

    package { "riak-ee":
        provider => dpkg,
        ensure   => latest,
        source   => "/usr/local/krux/services/s_riak/sources/$deb",
        require  => File["/usr/local/krux/services/s_riak/"],
    }

    ########################
    ### configuration files
    ########################

    ### this is a template because the -name variable depends on the fqdn
    file { "/usr/local/krux/services/s_riak/etc/riak/vm.args":
        content => template( "s_riak/etc/riak/vm.args.erb" ),
        ensure  => present,
    }

    ### symlink it from /etc/riak
    file { "/etc/riak/vm.args":
        ensure  => "/usr/local/krux/services/s_riak/etc/riak/vm.args",
        backup  => ".orig",
        require => File["/usr/local/krux/services/s_riak/etc/riak/vm.args"],
    }        

    ### symlink it from /etc/riak
    file { "/etc/riak/app.config":
        ensure  => "/usr/local/krux/services/s_riak/etc/riak/app.config",
        backup  => ".orig",
    }        

    ###################
    ### run the service
    ###################

    service { riak:
        ensure      => running,
        enable      => true,
        hasstatus   => true,
        hasrestart  => true,
        subscribe   => [ File["/etc/riak/app.config"], 
                         File["/etc/riak/vm.args"],
                         Package["riak-ee"],
                       ],
    }

}

*** FILE: ./krux-modules/kbase/manifests/stages.pp ***
class kbase::stages {
    stage { "bootstrap": before  => Stage[main]    } # bootstrap phase
    stage { "puppet1":   require => Stage[main]    } # first puppet controlled phase
    stage { "script1":   require => Stage[puppet1] } # first manual script phase
    stage { "puppet2":   require => Stage[script1] } # second puppet controlled phase
    stage { "script2":   require => Stage[puppet2] } # second manual script phase
    stage { "puppet3":   require => Stage[script2] } # third puppet controlled phase
    stage { "script3":   require => Stage[puppet3] } # third manual script phase
}    

*** FILE: ./krux-modules/kbase/manifests/init.pp ***
include kbase::stages

class { "kbase": stage => "bootstrap" }

class kbase {
    include kbase::packages
    include kbase::users

    ######################################################
    ### base directory for all krux related files & kbase
    ######################################################

    file { ["/usr/local/krux", "/usr/local/krux/services"]:
        ensure  => directory,
        mode    => 755,
        owner   => root,
        group   => root,
    }

    ######################################################
    ### scripts to run as part of the base setup procedure
    ######################################################

    # can not copy everything under kbase/files in one go, has to 
    # be a subdir -jib
    file { "/usr/local/krux/kbase/":
        source  => "puppet:///modules/kbase",
        ensure  => directory,
        recurse => true,
        mode    => 755,
        owner   => root,
        group   => root,
        purge   => true,    # content changes must be propogated
    }       
}

*** FILE: ./krux-modules/kbase/manifests/users.pp ***
###################################################
### essential system users for the following stages
###################################################

class { "kbase::users": stage => "bootstrap" }

class kbase::users {

    user { "ubuntu":
        ensure  => "present",
        uid     => "1000",
        groups  => ["adm", "admin"],
        comment => "Ubuntu System User",
        shell   => "/bin/bash",
        home    => "/home/ubuntu",
    }

    file { "/home/ubuntu":
        ensure  => directory,
        mode    => 755,
        owner   => ubuntu,
        group   => ubuntu,
        require => User["ubuntu"],
    }

    exec { "/usr/local/krux/kbase/scripts/bootstrap/02_setup_system_user.sh":
        user    => "ubuntu",
        require => [ File["/usr/local/krux/kbase"], File["/home/ubuntu"] ]
    }
}

*** FILE: ./krux-modules/kbase/manifests/packages.pp ***
class { "kbase::packages": stage => "bootstrap" }

class kbase::packages {
    include kbase

    exec { "/usr/local/krux/kbase/scripts/bootstrap/01_packages.sh": 
        require => File["/usr/local/krux/kbase"]
    }

    ### packages to install the puppet way
    package { ["s3cmd"]:
        ensure  => latest,
    }        
}

#33 Updated by Jos Boumans over 3 years ago

Update:

The above work around only works once after the puppet master is restarted. Subsequent connections by the individual nodes get the same error message/failure again.

#34 Updated by James Turnbull over 3 years ago

  • Target version changed from 69 to 2.6.5

#35 Updated by Matt Robinson over 3 years ago

  • Status changed from Re-opened to Closed
  • Assignee deleted (Paul Berry)

The reason for reopening this ticket was separated out into it’s own ticket #5447. The orignal manifest to reproduce the error doesn’t currently cause it, but we were able to pare down Jos’s reported manifest to reproduce the issue, and that manifest code is in the new ticket.

#36 Updated by Radosław Antoniuk almost 3 years ago

  • Status changed from Closed to Re-opened
  • Target version deleted (2.6.5)
  • Affected Puppet version changed from 2.6.1 to 2.7.5

I am reopening that as I am experiencing the same after upgrading from 2.7.1 to 2.7.5.

err: Duplicate definition: Exec[] is already defined in file /etc/puppet/manifests/classes/users.pp at line 158; cannot redefine at /etc/puppet/manifests/classes/users.pp:158 on node srv2

debug: template[/etc/puppet/templates/home/bash_login]: Bound template variables for /etc/puppet/templates/home/bash_login in 0.00 seconds
debug: template[/etc/puppet/templates/scripts/email-key.sh]: Bound template variables for /etc/puppet/templates/scripts/email-key.sh in 0.00 seconds
debug: template[/etc/puppet/templates/home/bash_login]: Interpolated template /etc/puppet/templates/home/bash_login in 0.00 seconds
debug: template[/etc/puppet/templates/scripts/email-key.sh]: Interpolated template /etc/puppet/templates/scripts/email-key.sh in 0.00 seconds
debug: Scope(User_homedir[xxx]): Retrieving template scripts/email-key.sh/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:580:in `fail_on_duplicate_type_and_title'

/usr/lib/ruby/site_ruby/1.8/puppet/resource/catalog.rb:73:in `add_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:58:in `add_resource'debug: template[/etc/puppet/templates/scripts/email-key.sh]: Bound template variables for /etc/puppet/templates/scripts/email-key.sh in 0.00 seconds

/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:59:in `evaluate'
debug: template[/etc/puppet/templates/scripts/email-key.sh]: Interpolated template /etc/puppet/templates/scripts/email-key.sh in 0.00 seconds/usr/lib/ruby/site_ruby/1.8/puppet/util/errors.rb:35:in `exceptwrap'

/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:43:in `evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:42:in `collect'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:42:in `evaluate'
debug: Scope(User_homedir[yyy]): Retrieving template home/bash_login/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `collect'

/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/branch.rb:16:in `each'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/branch.rb:15:in `each'debug: template[/etc/puppet/templates/home/bash_login]: Bound template variables for /etc/puppet/templates/home/bash_login in 0.00 seconds

/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:25:in `collect'
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/resource.rb:25:in `evaluate'debug: template[/etc/puppet/templates/home/bash_login]: Interpolated template /etc/puppet/templates/home/bash_login in 0.00 seconds

#37 Updated by James Turnbull almost 3 years ago

  • Status changed from Re-opened to Needs More Information
  • Assignee set to Radosław Antoniuk

Are you sure you’re not seeing #5447?

#38 Updated by Radosław Antoniuk almost 3 years ago

seen it, actually I am not, but I don’t have too many ideas how to verify that… any hints/ideas?

#39 Updated by James Turnbull almost 3 years ago

  • Status changed from Needs More Information to Closed

The best approach is to continue in that ticket – I suspect that’s more likely to be the problem given the error message. I’ll move your report over there and close this one again.

#40 Updated by Charlie Sharpsteen over 1 year ago

  • Keywords set to customer

Also available in: Atom PDF