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 <jumpe...@gmx.de
>:

> 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.

Reply via email to