Re: [Puppet Users] Duplicate declaration: Exec

2020-09-01 Thread Daniel Krämer
That is a limitation of ensure_resource() i'm also experiencing.

For example:
❯ cat modules/profile/manifests/test1.pp
class profile::test1 {
  include profile::test3
  include profile::test2
}
❯ cat modules/profile/manifests/test2.pp
class profile::test2 {
  notify{"i'm a test":}
}
❯ cat modules/profile/manifests/test3.pp
class profile::test3 {
  ensure_resource("notify", "i'm a test")
}
This will produce a duplicate declaration error:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER:
Server Error: Evaluation Error: Error while evaluating a Resource
Statement, Evaluation Error: Error while evaluating a Resource Statement,
Duplicate declaration: Notify[i'm a test] is already declared at (file:
/etc/puppetlabs/code/environments/production/modules/profile/manifests/test3.pp,
line: 2); cannot redeclare (file:
/etc/puppetlabs/code/environments/production/modules/profile/manifests/test2.pp,
line: 2) (file:
/etc/puppetlabs/code/environments/production/modules/profile/manifests/test2.pp,
line: 2, column: 3) on node buster.local.solutetech.net

But when i change the include order in test1.pp it will work

I guess it has something to do with what is parsed first.

Am Di., 1. Sept. 2020 um 12:19 Uhr schrieb Helmut Schneider :

> Hi,
>
> /etc/puppetlabs/code/modules/amavisd/manifests/init.pp
>
> ensure_resource('exec', '/usr/local/bin/amavisd.sh -sP', {
>path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin',
>refreshonly => true,
>command => 'su -l root -c "/usr/local/bin/amavisd.sh -sP"',
> })
>
> One client reports:
>
> Server Error: Could not find resource 'Exec[/usr/local/bin/amavisd.sh
> -sP]' in parameter 'notify' (file:
> /etc/puppetlabs/code/modules/spamassassin/manifests/init.pp, line: 49)
>
> So I add the same block also to
> /etc/puppetlabs/code/modules/spamassassin/manifests/init.pp
>
> But then another client reports:
>
> Server Error: Evaluation Error: Error while evaluating a Function Call,
> Duplicate declaration: Exec[/usr/local/bin/amavisd.sh -sP] is already
> declared at (file:
> /etc/puppetlabs/code/modules/amavisd/manifests/init.pp, line: 26);
> cannot redeclare (file:
> /etc/puppetlabs/code/modules/spamassassin/manifests/init.pp, line: 16)
>
> I thought that "ensure_resource" should avoid such conflicts? Or am I
> doing something wrong?
>
> Thank you!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/ril76c%24bs8%241%40ciao.gmane.io
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CA%2B%3DxqaAdfMNjWKMEbYbNbsn%3D_DSjNsYPrhobou97%2B5WcEcqNjg%40mail.gmail.com.


[Puppet Users] Duplicate declaration: Exec

2020-09-01 Thread Helmut Schneider

Hi,

/etc/puppetlabs/code/modules/amavisd/manifests/init.pp

ensure_resource('exec', '/usr/local/bin/amavisd.sh -sP', {
  path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin',
  refreshonly => true,
  command => 'su -l root -c "/usr/local/bin/amavisd.sh -sP"',
})

One client reports:

Server Error: Could not find resource 'Exec[/usr/local/bin/amavisd.sh 
-sP]' in parameter 'notify' (file: 
/etc/puppetlabs/code/modules/spamassassin/manifests/init.pp, line: 49)


So I add the same block also to 
/etc/puppetlabs/code/modules/spamassassin/manifests/init.pp


But then another client reports:

Server Error: Evaluation Error: Error while evaluating a Function Call, 
Duplicate declaration: Exec[/usr/local/bin/amavisd.sh -sP] is already 
declared at (file: 
/etc/puppetlabs/code/modules/amavisd/manifests/init.pp, line: 26); 
cannot redeclare (file: 
/etc/puppetlabs/code/modules/spamassassin/manifests/init.pp, line: 16)


I thought that "ensure_resource" should avoid such conflicts? Or am I 
doing something wrong?


Thank you!

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ril76c%24bs8%241%40ciao.gmane.io.


Re: [Puppet Users] Duplicate declaration

2018-09-09 Thread Ugo Bellavance


On Friday, September 7, 2018 at 5:37:29 PM UTC-4, LinuxDan wrote:
>
> Separate the client base directory resource from the application directory 
> resource. 
>
> When declaring each application directory, add a “require” parameter with 
> a value of the client base directory. 
>
>
Thank you for your quick response.

Do you mean that I should create the clients directory separately, feeding 
it with the list of clients? 

I do that already with my devs directories:

  atqapache::varwwwdevuser { [ 'user1', 'user2', 'user3', 'user4', 'user5', 
'user6', 'user7', 'user8', ] :}

Class defined like this:

define atqapache::varwwwdevuser {

  file {
"/var/www/dev/${title}":
  ensure => directory,
  owner  => "${title}",
  group  => "${title}",
  mode   => 0744,
  require => User["${title}"],
  }
}

Thanks,

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/aa3a562a-3f24-4d9f-b11e-20c4af21931a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration

2018-09-07 Thread 'Dan White' via Puppet Users
Separate the client base directory resource from the application directory 
resource. 

When declaring each application directory, add a “require” parameter with a 
value of the client base directory. 

"Sometimes I think the surest sign that intelligent life exists elsewhere in 
the universe is that none of it has tried to contact us."
Bill Waterson (Calvin & Hobbes)

> On Sep 7, 2018, at 5:05 PM, Ugo Bellavance  wrote:
> 
> Hi,
> 
> I have made a module, a long time ago, that allows me to create directories 
> and httpd config files.
> 
> My pattern is /var/www/dev/$devuser/$clientname/$appname/
> 
> It worked perfectly until I ended up having more than one $appname for the 
> same $clientname. Here's the error message I get:
> 
> Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
> Duplicate declaration: File[/var/www/dev/user1/client1] is already declared 
> in file /etc/puppet/modules/atqapache/manifests/vhost.pp:146; cannot 
> redeclare at /etc/puppet/modules/myapache/manifests/vhost.pp:146 on node 
> server1.example.com
> 
> The directive responsible for the creation of the folder is this one:
> 
> file { [ "$client_base", ]:
>   ensure  => 'directory',
>   owner   => "$owner",
>   group   => "$group",
>   mode=> 0744,
> }
> 
> This line defines the variable: 
> 
> $vhost_base = 
> "${atqapache::params::home}/$envstage/$client-${application}"
> 
> Here's my declaration:
> 
>   atqapache::vhost { 'client1-user1app1dev1' :
> client => 'client1',
> envstage   => 'dev',
> application=> 'app1',
> devuser=> 'user1',
>   }
> 
>   atqapache::vhost { 'client1-user1app2dev11' :
> client => 'clien1',
> envstage   => 'dev',
> application=> 'app2',
> devuser=> 'user1',
>   }
> 
> Does anyone know how I could modify my code so that I can have more than one 
> app per client?
> 
> Thanks,
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/6a2b9af3-0fb9-4c38-b0a1-7245b2762d38%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/4F07EDE9-211A-4D02-855D-4FDE3E731732%40icloud.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Duplicate declaration

2018-09-07 Thread Ugo Bellavance
Hi,

I have made a module, a long time ago, that allows me to create directories 
and httpd config files.

My pattern is /var/www/dev/$devuser/$clientname/$appname/

It worked perfectly until I ended up having more than one $appname for the 
same $clientname. Here's the error message I get:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
Duplicate declaration: File[/var/www/dev/user1/client1] is already declared 
in file /etc/puppet/modules/atqapache/manifests/vhost.pp:146; cannot 
redeclare at /etc/puppet/modules/myapache/manifests/vhost.pp:146 on node 
server1.example.com

The directive responsible for the creation of the folder is this one:

file { [ "$client_base", ]:
  ensure  => 'directory',
  owner   => "$owner",
  group   => "$group",
  mode=> 0744,
}

This line defines the variable: 

$vhost_base = 
"${atqapache::params::home}/$envstage/$client-${application}"

Here's my declaration:

  atqapache::vhost { 'client1-user1app1dev1' :
client => 'client1',
envstage   => 'dev',
application=> 'app1',
devuser=> 'user1',
  }

  atqapache::vhost { 'client1-user1app2dev11' :
client => 'clien1',
envstage   => 'dev',
application=> 'app2',
devuser=> 'user1',
  }

Does anyone know how I could modify my code so that I can have more than 
one app per client?

Thanks,


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/6a2b9af3-0fb9-4c38-b0a1-7245b2762d38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration error

2018-06-08 Thread Priyo Phan
I think it is due to the Apache class being called inside your defined
type, it is being called more than once when you try to create more than 1
vhost.

On Fri, Jun 8, 2018, 15:40 Clemens Bergmann  wrote:

> Hi There,
>
> I have a "can not redeclare" error that I do not understand.
>
> I try to write my own apache::vhost defined type with sane defaults for my
> environment.
>
> The general class layout is as follows:
>
> class vhost::vhost1 {
> custom::apache::vhost{
>#parameters
>  }
> }
> class vhost::vhost2 {
>  custom::apache::vhost{
>#parameters
>  }
> }
> define custom::apache::vhost () {
>  include custom::apache
> }
> class custom::apache {
>  class { '::apache':
>#parameters
>  }
>  class { '::apache::mod::ssl':
>#parameters
>  }
>  include apache::mod::authnz_ldap
>  include apache::mod::headers
>  include apache::mod::rewrite
>  include apache::mod::fastcgi
>  apache::listen { '443': }
> }
>
>
>
> When I define only one custom::vhost then everything works fine.
> But when I define multiple custom::vhost then I get the error "Duplicate
> declaration: Class[Apache] is already declared;" which refers to the line
> in class "custom::apache" where the "class { '::apache':" is defined.
>
> Can someone explain to me why I get this error?
>
> Thanks.
> Clemens
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/045a13d7-7bf0-4523-9067-8bbf73c26c89%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CADZKzzbdn%3DrdydkFY7s3F%3DCRgFWzQ2LJ0TfR2dwBGm97o5m8xQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Duplicate declaration error

2018-06-08 Thread Clemens Bergmann
Hi There,

I have a "can not redeclare" error that I do not understand.

I try to write my own apache::vhost defined type with sane defaults for my 
environment.

The general class layout is as follows:

class vhost::vhost1 {
custom::apache::vhost{
   #parameters
 }
}
class vhost::vhost2 {
 custom::apache::vhost{
   #parameters
 }
}
define custom::apache::vhost () {
 include custom::apache
}
class custom::apache {
 class { '::apache':
   #parameters
 }
 class { '::apache::mod::ssl':
   #parameters
 }
 include apache::mod::authnz_ldap
 include apache::mod::headers
 include apache::mod::rewrite
 include apache::mod::fastcgi
 apache::listen { '443': }
}



When I define only one custom::vhost then everything works fine.
But when I define multiple custom::vhost then I get the error "Duplicate 
declaration: Class[Apache] is already declared;" which refers to the line 
in class "custom::apache" where the "class { '::apache':" is defined.

Can someone explain to me why I get this error?

Thanks.
Clemens

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/045a13d7-7bf0-4523-9067-8bbf73c26c89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration error - what's the correct approach to avoid this?

2017-11-24 Thread Dirk Heinrichs
Am 23.11.2017 um 15:47 schrieb buoyant_puppy:
> That's is a simplified version of my actual use case:
>   $mythings.each | String $x | {    # for each x in list 'mythings'
>     notify { "gonna do something with $x": }
>   

Not sure, but I think you need to use ${x} in the resource declaration
to actually have the variable interpolated.

HTH...

    Dirk
-- 
*Dirk Heinrichs*
Senior Systems Engineer, Delivery Pipeline
OpenText^TM Discovery | Recommind
*Email*: dirk.heinri...@recommind.com 
*Website*: www.recommind.de 

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon
Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer
HRB 10646

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie
die unbefugte Weitergabe dieser Mail sind nicht gestattet.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/9022423f-007b-a7a8-a615-98686e8721e7%40opentext.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration error - what's the correct approach to avoid this?

2017-11-23 Thread Dirk Heinrichs
Am 23.11.2017 um 15:47 schrieb buoyant_puppy:
> That's is a simplified version of my actual use case:
>   $mythings.each | String $x | {    # for each x in list 'mythings'
>     notify { "gonna do something with $x": }
>   

Not sure, but I think you need to use ${x} in the resource declaration
to actually have the variable interpolated.

HTH...

    Dirk
-- 
*Dirk Heinrichs*
Senior Systems Engineer, Delivery Pipeline
OpenText^TM Discovery | Recommind
*Email*: dirk.heinri...@recommind.com 
*Website*: www.recommind.de 

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon
Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer
HRB 10646

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie
die unbefugte Weitergabe dieser Mail sind nicht gestattet.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/0ff870ae-131f-a044-9565-744f54224fbe%40opentext.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Duplicate declaration error - what's the correct approach to avoid this?

2017-11-23 Thread buoyant_puppy
Why does this:  
  class mymodule {
notify { "booboo": }
notify { "booboo": }

provoke the error:
  Error while evaluating a Resource Statement, Duplicate declaration: 
Notify[booboo] is already declared in file 

That's is a simplified version of my actual use case:
  $mythings.each | String $x | {# for each x in list 'mythings'
notify { "gonna do something with $x": }
  

In plain english, for example, I may have a list of rpms and want to loop 
through them to ensure all are installed.

What would be the correct way to do this, if not the above?


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/8b3de960-9f07-403e-838b-1b44409539fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration - hard to find...

2016-09-21 Thread Ugo Bellavance
I found the problem by making the classe temporarily non-parameterized and 
it threw an error "Invalid parameter application".  I called this class in 
another file.  I'll fix that up.

Thanks for your help!

Ugo

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/66d35eb1-a22f-4e7a-a6d4-7fdfeb870720%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration - hard to find...

2016-09-21 Thread R.I.Pienaar


- Original Message -
> From: "Ugo Bellavance" <u...@lubik.ca>
> To: "puppet-users" <puppet-users@googlegroups.com>
> Sent: Wednesday, 21 September, 2016 14:51:00
> Subject: Re: [Puppet Users] Duplicate declaration - hard to find...

>>
>>
>> in a define all resources have to have unique names, error says in some
>> case
>> you do not. So you're either attempting to make 2 instances where
>> application
>> is 'agtweb' or something else,
>>
>> Show the actual code.  And the actual code where you make 'agtweb'
>> application.
>>
>>
> Sorry here's the code:

which one produced the actual error you had? Computer doesnt really have
a concept of 'or' about code here.

Again though, your file{} resources need to be unique, so when you have
the first case you have to do:

  apache::varwwwatdsrcapp{"foo":
application => "foo"
  }

  apache::varwwwatdsrcapp{"bar":
application => "baz"
  }

these are fine, but:

  apache::varwwwatdsrcapp{"foo":
application => "foo"
  }

  apache::varwwwatdsrcapp{"bar":
application => "foo"
  }

is not because it would cause a duplicate file of the same name

likewise

  apache::varwwwatdsrcapp{"foo": }
  apache::varwwwatdsrcapp{"bar": }

would fail because you set a default on 'application' which would
cause duplicates.

> 
> Either:
> 
> define apache::varwwwatdsrcapp (
> 
>$application  = 'agtweb',
>$client   = '',
>$envstage = '',
> 
> ) {
> 
>  file {
>  "/var/www/atd/src/${application}":
>  ensure => directory,
>  owner  => "deploy",
>  group  => "deploy",
>  mode   => 0755,
>  require => Class['apache::varwwwatdsrc'],
>  }
> 
> }
> 
> Or
> 
> define apache::varwwwatdsrcapp (
> 
>$application  = 'agtweb',
>$client   = '',
>$envstage = '',
> 
> ) {
> 
>  file {
>  '/var/www/atd/src/agtweb':
>  ensure => directory,
>  owner  => "deploy",
>  group  => "deploy",
>  mode   => 0755,
>  require => Class['apache::varwwwatdsrc'],
>  }
> 
> }
> 
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email
> to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/79dff55f-e972-4a9c-9636-3a0f5f44b84c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/638693790.228597.1474462516945.JavaMail.zimbra%40devco.net.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration - hard to find...

2016-09-21 Thread Ugo Bellavance

>
>
> in a define all resources have to have unique names, error says in some 
> case 
> you do not. So you're either attempting to make 2 instances where 
> application 
> is 'agtweb' or something else, 
>
> Show the actual code.  And the actual code where you make 'agtweb' 
> application. 
>
>
Sorry here's the code:

Either:

define apache::varwwwatdsrcapp (

$application  = 'agtweb',
$client   = '',
$envstage = '',

) {

  file {
  "/var/www/atd/src/${application}":
  ensure => directory,
  owner  => "deploy",
  group  => "deploy",
  mode   => 0755,
  require => Class['apache::varwwwatdsrc'],
  }

}

Or

define apache::varwwwatdsrcapp (

$application  = 'agtweb',
$client   = '',
$envstage = '',

) {

  file {
  '/var/www/atd/src/agtweb':
  ensure => directory,
  owner  => "deploy",
  group  => "deploy",
  mode   => 0755,
  require => Class['apache::varwwwatdsrc'],
  }

}

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/79dff55f-e972-4a9c-9636-3a0f5f44b84c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration - hard to find...

2016-09-21 Thread R.I.Pienaar


- Original Message -
> From: "Ugo Bellavance" <u...@lubik.ca>
> To: "puppet-users" <puppet-users@googlegroups.com>
> Sent: Wednesday, 21 September, 2016 14:29:50
> Subject: [Puppet Users] Duplicate declaration - hard to find...

> Hi,
> 
> I'm getting this error message when I run a puppet noop:
> 
> Error 400 on SERVER: Duplicate declaration: File[/var/www/atd/src/agtweb]
> is already declared in file
> /etc/puppet/modules/apache/manifests/varwwwatdsrcapp.pp at line 17; cannot
> redeclare at /etc/puppet/modules/apache/manifests/varwwwatdsrcapp.pp:17
> 
> Here's the contents of the file (I tried with the app1 directly or using
> the ${application} variable

not really useful to show code other than the code producing the error.

in a define all resources have to have unique names, error says in some case
you do not. So you're either attempting to make 2 instances where application
is 'agtweb' or something else,

Show the actual code.  And the actual code where you make 'agtweb' application.

> 
> define apache::varwwwatdsrcapp (
> 
>$application  = 'app1',
>$client   = '',
>$envstage = '',
> 
> ) {
> 
>  file {
> #"/var/www/atd/src/${application}":
>'/var/www/atd/src/app1':
>  ensure => directory,
>  owner  => "deploy",
>  group  => "deploy",
>  mode   => 0755,
>  require => Class['apache::varwwwatdsrc'],
>  }
> 
> }
> 
> Contents of the file containing the required class:
> 
> class apache::varwwwatdsrc {
> 
>  file { '/var/www/atd/src':
>  ensure => directory,
>  owner  => "root",
>  group  => "root",
>  mode   => 0755,
>  require => File["/var/www/atd"],
>  }
> 
> }
> 
> Contents of the file containing the required File:
> 
> class apache::varwwwatd {
> 
>  file { '/var/www/atd':
>  ensure => 'directory',
>  owner  => 'root',
>  group  => 'root',
>  mode   => 0744,
>  }
> 
> }
> 
> I realize that I use double quotes where I shouldn't, but I don't think
> that affects the logic.
> 
> Any ideas where the problem may be?
> 
> Thanks,
> 
> Ugo
> 
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email
> to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/4b843ccb-c2ba-4f4d-9b9b-6ae7da9d16b0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/1063999239.209562.1474461266280.JavaMail.zimbra%40devco.net.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Duplicate declaration - hard to find...

2016-09-21 Thread Ugo Bellavance
Hi,

I'm getting this error message when I run a puppet noop:

Error 400 on SERVER: Duplicate declaration: File[/var/www/atd/src/agtweb] 
is already declared in file 
/etc/puppet/modules/apache/manifests/varwwwatdsrcapp.pp at line 17; cannot 
redeclare at /etc/puppet/modules/apache/manifests/varwwwatdsrcapp.pp:17

Here's the contents of the file (I tried with the app1 directly or using 
the ${application} variable

define apache::varwwwatdsrcapp (

$application  = 'app1',
$client   = '',
$envstage = '',

) {

  file {
#"/var/www/atd/src/${application}":
'/var/www/atd/src/app1':
  ensure => directory,
  owner  => "deploy",
  group  => "deploy",
  mode   => 0755,
  require => Class['apache::varwwwatdsrc'],
  }

}

Contents of the file containing the required class:

class apache::varwwwatdsrc {

  file { '/var/www/atd/src':
  ensure => directory,
  owner  => "root",
  group  => "root",
  mode   => 0755,
  require => File["/var/www/atd"],
  }

}

Contents of the file containing the required File:

class apache::varwwwatd {

  file { '/var/www/atd':
  ensure => 'directory',
  owner  => 'root',
  group  => 'root',
  mode   => 0744,
  }

}

I realize that I use double quotes where I shouldn't, but I don't think 
that affects the logic.

Any ideas where the problem may be?

Thanks,

Ugo

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/4b843ccb-c2ba-4f4d-9b9b-6ae7da9d16b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration - class is already declared

2015-09-16 Thread jcbollinger


On Tuesday, September 15, 2015 at 2:33:16 PM UTC-5, Julian Meier wrote:
>
> Thanks you! The explanation about private and public classes is just great!
>
> So, there seems to be no way to define IN the module how public classes 
> get evaluated (order), right?
>


Evaluation order is deterministic, as governed by the order of DSL 
statements in your manifests.  Manifests are evaluated in document order, 
left-to-right, top-to-bottom.  In that sense, yes, you can define in a 
module in what order classes are evaluated.  You cannot, however, use 
declarations in one manifest to influence the order of evaluation of 
declarations in a different manifest.  This is why the differentiation 
between public and private classes is so important.  For private classes, 
you can control evaluation order because you can control all the places 
where a declaration may be evaluated, but for public classes, all bets are 
off.


I really want to use some params from `::ospuppet` in `::ospuppet::master` 
> and `::ospuppet::server` (
> https://github.com/juame/juame-ospuppet/tree/0.3.0).
>
>

That's fine.  Then rely on automated data binding to set those parameter 
values.  If class ::ospuppet serves *only* to house such shared data, then 
as a bonus, you will no longer need to declare it from outside the module 
at all.  In that case you could make it private, but if you do so then I 
would rename it to avoid confusion, maybe to ::ospuppet::data.

Or if you're going that far, then you could also consider getting rid of 
the shared data class altogether.  Your two other classes could instead 
obtain the data directly from Hiera, by calling one of its data-access 
functions.  You then obtain data sharing / deduplication by having each 
class that wants the data look it up in Hiera via the same key.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/4aa89f72-b662-41ec-a81f-ab371824374f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Duplicate declaration - class is already declared

2015-09-15 Thread Julian Meier
Thanks you! The explanation about private and public classes is just great!

So, there seems to be no way to define IN the module how public classes get 
evaluated (order), right?
I really want to use some params from `::ospuppet` in `::ospuppet::master` and 
`::ospuppet::server` (https://github.com/juame/juame-ospuppet/tree/0.3.0 
).

Julian

> On 14 Sep 2015, at 15:52, jcbollinger  wrote:
> 
> 
> 
> On Friday, September 11, 2015 at 4:31:40 PM UTC-5, Julian Meier wrote:
> Hi all 
> 
> I’ve got three classes (example): 
> 
> ``` 
> class mymodule ( 
>   $user = 'foobar', 
> ) {} 
> 
> class mymodule::classone ( 
>   $foo = 'bar', 
> ) inherits ::mymodule::classone::params { 
>   require mymodule 
>   notify { "username: ${::mymodule::user}": } 
> } 
> 
> class mymodule::classtwo ( 
>   $foo = 'bar', 
> ) inherits ::mymodule::classtwo::params { 
>   require mymodule 
>   notify { "username: ${::mymodule::user}": } 
> } 
> 
> class mymodule::classone::params {} 
> class mymodule::classtwo::params {} 
> ``` 
> 
> My idea is to have a class `mymodule` with parameters used by any other 
> class. If someone would like to change the default parameters of `mymodule` 
> he can do it like (or with hiera and autolookup): 
> ``` 
> class { ::mymodule: user => 'foo', } 
> class { ::mymodule::classone: } 
> ``` 
> And for `classtone` and `classtwo` there is a specific `params.pp` 
> (inherits)… 
> 
> My problem: the declaration above can cause dependency cycles… If `classone` 
> gets used before class `mymodule`. :-( 
> 
> 
> 
> What you are observing is not a dependency cycle, it is an evaluation-order 
> dependency.
> 
>  
> Do you have a better idea or design? 
> 
> 
> Yes: never use a resource-like class declaration 
> 
>  to declare any public class of any module.
> 
> A "public class" is one that is intended to be declared from outside the 
> module, which appears to include at least classes ::Mymodule and 
> ::Mymodule::Classone in your example.  Do not use a resource-like class 
> declaration for such a class either outside its module or inside.  Instead 
> use include-like declarations for such classes, and rely on automated data 
> binding via Hiera to assign non-default class parameter values to them.
> 
> The particular problem in this case is that if the catalog builder evaluates 
> a resource-like declaration of a given class, that declaration must be the 
> very first declaration of the given class it sees.  The 'require mymodule' 
> appearing in ::Mymodule::Classone and ::Mymodule::Classtwo is an include-like 
> declaration of class ::Mymodule, and it is evaluated as part of evaluating 
> the declaration of either of those classes.  When a resource-like declaration 
> of the same class is encountered later, the catalog builder objects.
> 
> This constraint is basically about determining the applicable class parameter 
> values: Puppet permits the same class to be declared multiple times, with the 
> second and subsequent ones being no-ops.  Class parameter values must be 
> determined at the first declaration.  And that's why you must avoid 
> resource-like declarations of public classes -- it is very difficult to 
> predict where another declaration of such a class may be (since it's public), 
> or the relative order in which such a declaration may be evaluated.
> 
> As a secondary design consideration, it rarely makes sense to have one public 
> class of a module that depends on another public class of the same module.  
> Many modules have only a single public class, and a few have multiple, 
> independent public classes, but I can't name any off the top of my head that 
> use the type of pattern you presented, with dependent public classes.  Those 
> I can think of that have something like that provide defined resource types 
> instead of dependent public classes.  Indeed, it may be that your 
> Mymodule::Classone and Mymodule::Classtwo really want to be different 
> instances of one defined type.  That's not going to get you around a 
> class-declaration issue such as the one you presented, however.
> 
> 
> John
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/3ab543f5-1b7b-412d-b942-1edf1f5d5c66%40googlegroups.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message 

[Puppet Users] Duplicate declaration - class is already declared

2015-09-11 Thread Julian Meier
Hi all

I’ve got three classes (example):

```
class mymodule (
  $user = 'foobar',
) {}

class mymodule::classone (
  $foo = 'bar',
) inherits ::mymodule::classone::params {
  require mymodule
  notify { "username: ${::mymodule::user}": }
}

class mymodule::classtwo (
  $foo = 'bar',
) inherits ::mymodule::classtwo::params {
  require mymodule
  notify { "username: ${::mymodule::user}": }
}

class mymodule::classone::params {}
class mymodule::classtwo::params {}
```

My idea is to have a class `mymodule` with parameters used by any other class. 
If someone would like to change the default parameters of `mymodule` he can do 
it like (or with hiera and autolookup):
```
class { ::mymodule: user => 'foo', }
class { ::mymodule::classone: }
```
And for `classtone` and `classtwo` there is a specific `params.pp` (inherits)…

My problem: the declaration above can cause dependency cycles… If `classone` 
gets used before class `mymodule`. :-(

Do you have a better idea or design?
Thanks for any input and your help!
Julian

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/156F5D16-F2C8-423D-A565-4DBA089D24B7%40mailtower.ch.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Duplicate declaration with nested create_resources

2014-07-10 Thread Joao Morais

Hello list, I have some services that may be duplicated in some machines. 
They are much like an Apache vhost. In order to remove details from my 
manifests, I moved the service names to ENC because they are 
machine-dependent. Here are my datasources and manifests:

ENC:
parameters:
  myservices:
host1:
  myperserviceconfig
host2:
  myperserviceconfig

Hiera:
myservice_host:
  myproblematicconfig:
config1:
  data
config2:
  data
  myotherconfig:
  ...

Manifests:
  class profile::my::myservice {
# ENC: $myservices
$hiera_myservice_host = hiera(myservice_host)
# ENC has per-host/service and hiera has per-environment configurations
create_resources(::myservice::host, $myservices, $hiera_myservice_host)
  }

  define myservice::host (myconfigs...) {
...
if $myproblematicconfig {
  create_resources(::myservice::myconfig, $myproblematicconfig)
}
  }

Each myproblematicconfig key is a new resource and I can have zero to N 
keys. This configuration is working nice if I have only one service, but if 
I have two or more services, Puppet Master correctly says:

  Error: Could not retrieve catalog from remote server: Error 400 on 
SERVER: Duplicate declaration: myservice::myconfig[config1] is already 
declared

Tried prefix (from puppetlabs/stdlib) in order to change the resource name 
but it only supports arrays. Changing create_resources to $var.each should 
help but it requires parser=future which I cannot use right now. Do you see 
another approach I could try?

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/23c7967c-f732-4d6a-b2d4-a8c4347f48a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Duplicate declaration problem

2014-04-21 Thread Sean Korten
So, I am trying to do something with a list (array) of users from hieara. 
 Here is the yaml:

profile::sysconfig::sftp_users: [ joe, bill, nancy ]


In my profile I have a defined class debugUsers that I am calling with 
the array I got from hiera:

class profile::sysconfig::sftpserver {
   define debugUsers {
 notify { username: \${user}\: }
   }
   class doWork {
 $users = hiera('profile::sysconfig::sftp_users')
 validate_array($users)
 debugUsers { $users: }
   }
   include doWork

}


From everything I know and have read that should give me a notify line for 
user in my array.  But it doesn't.  Instead I get this error from the agent:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
 Duplicate declaration: Notify[username: ] is already declared in file 
 /etc/puppetlabs/puppet/environments/r10k/dev_users/modules/profile/manifests/sysconfig/sftpserver.pp:5;
  
 cannot redeclare at 
 /etc/puppetlabs/puppet/environments/r10k/dev_users/modules/profile/manifests/sysconfig/sftpserver.pp:5
  


Why am I getting duplicate null declarations?  If I call out specific 
elements of the array I get back exactly what I would expect:

class profile::sysconfig::sftpserver {
   class doWork {
 $users = hiera('profile::sysconfig::sftp_users')
 validate_array($users)
 notify { user1: \${users[0]}\: }
 notify { user2: \${users[1]}\: }
 notify { user3: \${users[2]}\: }
   }
   include doWork

} 


returns this:

Notice: user1: joe
 Notice: /Stage[main]/Profile::Sysconfig::Sftpserver::Dowork/Notify[user1: 
 joe]/message: defined 'message' as 'user1: joe'
 Notice: user3: nancy
 Notice: /Stage[main]/Profile::Sysconfig::Sftpserver::Dowork/Notify[user3: 
 nancy]/message: defined 'message' as 'user3: nancy'
 Notice: user2: bill
 Notice: /Stage[main]/Profile::Sysconfig::Sftpserver::Dowork/Notify[user2: 
 bill]/message: defined 'message' as 'user2: bill' 


I am sure this is something really stupid, but can someone point out what 
I'm doing wrong here?

Thanks,
--Sean

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/4477ce95-b58e-4ead-80bc-5ae9ef0b5bda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Duplicate declaration

2013-11-27 Thread Raj kumar V
I have module, for which if I add the class in the UI and run the agent 
with --test it fails with the following error. But If I just add the 
include classname in the init class and run, it works. Any idea?


Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
Duplicate declaration: Class[classname] is already declared; cannot 
redeclare on node nfaxen-ubu1.fqdn
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/142a44e2-e6bc-4658-82b5-a616275466ac%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Puppet Users] Duplicate declaration for files.

2013-10-11 Thread mike
Hello,
I'm configuring my linux server with puppet open and is ok. My question is 
the next; I've a declared in mi nodes.pp the next: 

[.]
node 'basenode' {
include 'baseos'
include 'motd'
import 'useradd.pp'
}

#All nodes for my domain
node /.*\.example\.com/ inherits basenode {
}

[.]

All nodes inherit basenode, Inside the class baseos i've declared the 
archive host table and various other parameters

[.]

file { /etc/hosts:
ensure  = present,
owner   = root,
group   = root,
mode= '664',
source  = puppet:///modules/baseos/hosts,
}

[.]


But I need add other node in nodes.pp  and this need apply the class baseos 
but without /etc/hots because this use other hosts table that I declared as 
follows:

[.]

node 'newnode.example.com' inherits basenode {
file { /etc/hosts:
ensure = file,
source = puppet:///modules/baseos/newnode/hosts,
mode   = 644,
}
}
[.]

But when I go newnode and run puppet give error for duplicate /etc/hosts 
declaration  

[.]
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
Duplicate declaration: File[/etc/hosts] is already declared in file 
/etc/puppet/modules/baseos/manifests/config.pp:21; cannot redeclare at 
/etc/puppet/manifests/nodes.pp:55 on node newnode.example.com
[.]

How I can assign different tables hosts for different nodes in this case?


Thanks.



-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.


[Puppet Users] Duplicate Declaration of resource (editing contents of same file in two diiferent module)

2013-04-11 Thread Rahul Khengare
Hi all,
 I am writing two modules abc and xyz. In both the modules i have to 
change common test.txt file,here i use template (.erb) file to changing 
the contents.
In both abc and xyz the contents of test.txt file is different, if i 
declare file resource for test.txt file in two different modules it gives 
duplicate declaration of resource error. 
For the correct working of modules abc and xyz, i have to change the 
test.txt file twice.
How i overcome this situation ?   
I  am new to community, so i am not very familiar to format of query 
posting,sorry about that.
Thanks in advance for answers.

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.