Kim Gert Nielsen
2009-Dec-01 08:04 UTC
[Puppet Users] Duplicate definition on the same line and in the same file ?
Hi, I''m trying to add libapache2-mod-php5 as a dependency in my php5 module here is what I get info: Loading facts in raidcontroller info: Loading facts in raidcontroller debug: Format s not supported for Puppet::Resource::Catalog; has not implemented method ''from_s'' err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Package[libapache2-mod-php5] is already defined in file /etc/puppet/modules/php5/manifests/init.pp at line 18; cannot redefine at /etc/puppet/modules/php5/manifests/init.pp:18 on node webserver1.example.com warning: Not using cache on failed catalog err: Could not retrieve catalog; skipping run I do not have defined Package[libapache2-mod-php5] anywhere else in any file (According to grep -ir) The class looks like this: class php5::debian { file { "/etc/php5/apache2/php.ini": owner => root, group => root, mode => 644, source => [ "puppet:///php5/$operatingsystem/$lsbdistcodename/$fqdn/php.ini", "puppet:///php5/$operatingsystem/$lsbdistcodename/$hostname/php.ini", "puppet:///php5/$operatingsystem/php.ini.$hostname", "puppet:///php5/php.ini.$hostname", "puppet:///php5/php.ini", ], notify => Exec["force-reload-apache2"], } define enablemodule($ensure=''present'') { package { [''libapache2-mod-php5'']: ensure => installed } case $ensure { present: { package { [$name]: ensure => installed } } } } define enablecli($ensure=''present'') { case $ensure { present: { package { [php5-cli]: ensure => installed } file { "/etc/php5/cli/php.ini": owner => root, group => root, mode => 644, source => [ "puppet:///php5/$operatingsystem/$lsbdistcodename/$fqdn/php.ini.cli", "puppet:///php5/$operatingsystem/$lsbdistcodename/$hostname/php.ini.cli", "puppet:///php5/$operatingsystem/php.ini.$hostname", "puppet:///php5/php.ini.cli.$hostname", "puppet:///php5/php.ini.cli", ] } } } } } can any one explain this behavior ? /Kim -- 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.
David Schmitt
2009-Dec-01 08:21 UTC
Re: [Puppet Users] Duplicate definition on the same line and in the same file ?
Kim Gert Nielsen wrote:> Hi, > > I''m trying to add libapache2-mod-php5 as a dependency in my php5 module here is what I get > > info: Loading facts in raidcontroller > info: Loading facts in raidcontroller > debug: Format s not supported for Puppet::Resource::Catalog; has not implemented method ''from_s'' > err: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate definition: Package[libapache2-mod-php5] is already defined in file /etc/puppet/modules/php5/manifests/init.pp at line 18; cannot redefine at /etc/puppet/modules/php5/manifests/init.pp:18 on node webserver1.example.com > warning: Not using cache on failed catalog > err: Could not retrieve catalog; skipping run > > I do not have defined Package[libapache2-mod-php5] anywhere else in any file (According to grep -ir) > define enablemodule($ensure=''present'') { > > package { [''libapache2-mod-php5'']: ensure => installed } > > case $ensure { > present: { > package { [$name]: ensure => installed } > } > } > }If you use this define twice, eg "enablemodule{[a,b]:}", then the Package[libapache2-mod-php5] will be defined twice and the compilation will fail with the error you''re using. to solve this, create a little class containing this package and include the class instead of defining the resource directly. Regards, DavidS -- 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.
Peter Meier
2009-Dec-01 08:31 UTC
Re: [Puppet Users] Duplicate definition on the same line and in the same file ?
> can any one explain this behavior ?You define a package resource in your define. Everytime you manage a resource with this define also an instance of the package resource is managed, so you only need to manage two resources with this define and you end up with a duplicate definition. As puppet tries to apply the same package resource definition twice you end up with a duplicate definition on the same line. Solution: manage your package resource in its very own class and include this class into the define. This apply in general to every other managed resource in defines which are unique amongst the whole system. Which means that you don''t differentiate it with an own deviated name, containing for examle $name of the define. For an example have a look at: http://git.puppet.immerda.ch/?p=module-git.git;a=blob;f=manifests/clone.pp;h=1d6a298f985aa6b79851e31b4b63403d7b2f7a9b;hb=7b1f9a68e95cd9dc877145eda08c18e233603bb8 We include the class git, which will manage the package-resource git, hence we can reference to it in the deviated exec for this define. cheers pete -- 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.
Kim Gert Nielsen
2009-Dec-04 07:37 UTC
Re: [Puppet Users] Duplicate definition on the same line and in the same file ?
On Dec 1, 2009, at 9:21 AM, David Schmitt wrote:> If you use this define twice, eg "enablemodule{[a,b]:}", then the > Package[libapache2-mod-php5] will be defined twice and the compilation > will fail with the error you''re using. > > to solve this, create a little class containing this package and include > the class instead of defining the resource directly. > >Thanks :) This works /Kim -- 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.
Maybe Matching Threads
- The way Puppet installs things fail
- Puppet requires second run to execute some catalog items.
- Puppet fails to install package, whilst it's okay to do manually
- Some php5 extensions not installed until a second run
- wyrie/puppet-nagiosql -- anyone have experience with this module?