Problem with exported ressource file.

50 views
Skip to first unread message

Albert Shih

unread,
Mar 29, 2024, 9:37:38 AMMar 29
to puppet...@googlegroups.com
Hi,

I'm not 100% sure it's a bug, just 99%. What do you think ?

If I do something like

$group_hosts.each | String $host | {
@@file { "file for ${host}":
ensure => present,
path => '/etc/something.conf',
tag => "File for ${host}",
etc.
}
}

I got a error

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Cannot alias File[file for host1] to ["/etc/something.conf"] at (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72); resource ["File", "/etc/something.conf"] already declared (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72) (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72, column: 5) on node XYZ

I don't see why I cannot export the same file name (with different
ressource name) to different hosts.

puppet client : 7.29.1 (Debian/puppetlabs official package)
puppet server: 7.16.0 (Debian/puppetlabs official package)

Regards


--
Albert SHIH 🦫 🐸
France
Heure locale/Local time:
ven. 29 mars 2024 14:21:14 CET

Martin Alfke

unread,
Mar 29, 2024, 1:47:05 PMMar 29
to Puppet Users

> On 29. Mar 2024, at 14:37, Albert Shih <Alber...@obspm.fr> wrote:
>
> Hi,
>
> I'm not 100% sure it's a bug, just 99%. What do you think ?
>
> If I do something like
>
> $group_hosts.each | String $host | {
> @@file { "file for ${host}":
> ensure => present,
> path => '/etc/something.conf',
> tag => "File for ${host}",
> etc.
> }
> }
>
> I got a error
>
> Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Cannot alias File[file for host1] to ["/etc/something.conf"] at (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72); resource ["File", "/etc/something.conf"] already declared (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72) (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72, column: 5) on node XYZ
>
> I don't see why I cannot export the same file name (with different
> ressource name) to different hosts.

The combination of resource type, title and namevar must be unique.
path is the namevar of the file resource type.

>
> puppet client : 7.29.1 (Debian/puppetlabs official package)
> puppet server: 7.16.0 (Debian/puppetlabs official package)
>
> Regards
>
>
> --
> Albert SHIH 🦫 🐸
> France
> Heure locale/Local time:
> ven. 29 mars 2024 14:21:14 CET
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ZgbEFHrNHUQHQi3g%40io.chezmoi.fr.

Albert Shih

unread,
Mar 30, 2024, 4:35:13 AMMar 30
to puppet...@googlegroups.com
Le 29/03/2024 à 18:46:47+0100, Martin Alfke a écrit
>
Hi,

> > If I do something like
> >
> > $group_hosts.each | String $host | {
> > @@file { "file for ${host}":
> > ensure => present,
> > path => '/etc/something.conf',
> > tag => "File for ${host}",
> > etc.
> > }
> > }
> >
> > I got a error
> >
> > Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Cannot alias File[file for host1] to ["/etc/something.conf"] at (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72); resource ["File", "/etc/something.conf"] already declared (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72) (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72, column: 5) on node XYZ
> >
> > I don't see why I cannot export the same file name (with different
> > ressource name) to different hosts.
>
> The combination of resource type, title and namevar must be unique.
> path is the namevar of the file resource type.

Agree. But the title is "file for ${host}" so the combination are unique (I
don't have two same values in $group_host, in fact the value inside this
array come from the key of hash table).

Regards.

--
Albert SHIH 🦫 🐸
France
Heure locale/Local time:
sam. 30 mars 2024 09:33:38 CET

Martin Alfke

unread,
Mar 30, 2024, 6:05:15 AMMar 30
to Puppet Users
To be more precise:

1. the combination of resource type and title must be unique
AND
2. the combination of resource type and namevar must be unique

hth,
Martin

Albert Shih

unread,
Apr 8, 2024, 6:17:42 AMApr 8
to puppet...@googlegroups.com, tux...@gmail.com
Le 30/03/2024 à 11:04:55+0100, Martin Alfke a écrit
>

Hi,

> >>>
> >>> Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Cannot alias File[file for host1] to ["/etc/something.conf"] at (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72); resource ["File", "/etc/something.conf"] already declared (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72) (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72, column: 5) on node XYZ
> >>>
> >>> I don't see why I cannot export the same file name (with different
> >>> ressource name) to different hosts.
> >>
> >> The combination of resource type, title and namevar must be unique.
> >> path is the namevar of the file resource type.
> >
> > Agree. But the title is "file for ${host}" so the combination are unique (I
> > don't have two same values in $group_host, in fact the value inside this
> > array come from the key of hash table).
>
> To be more precise:
>
> 1. the combination of resource type and title must be unique
> AND
> 2. the combination of resource type and namevar must be unique

OK. But with that I still got the same error

$group_hosts.each | String $host | {
@@file { "file for ${host}":
ensure => present,
name => "file for ${host}",
path => '/etc/something.conf',
tag => "File for ${host}",
etc.
}
}

In this situation the namevar or the ressource change at each host. So
for me the both condition are validate. But I still got the same error

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Cannot alias File[file for host1] to ["/etc/something.conf"] at (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72); resource ["File", "/etc/something.conf"] already declared (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72) (file: /etc/puppetlabs/code/environments/x/modules/thing/manifests/thing.pp, line: 72, column: 5) on node XYZ


Regards.

--
Albert SHIH 🦫 🐸
France
Heure locale/Local time:
lun. 08 avril 2024 12:11:10 CEST

Dirk Heinrichs

unread,
Apr 8, 2024, 7:01:47 AMApr 8
to puppet...@googlegroups.com, tux...@gmail.com
Am Montag, dem 08.04.2024 um 12:17 +0200 schrieb Albert Shih:

> $group_hosts.each | String $host | {
>   @@file { "file for ${host}":
>     ensure => present,
>     name   => "file for ${host}",
>     path   => '/etc/something.conf',
>     tag    => "File for ${host}",
>     etc.
>     }
> }

You create multiple resources here (one for each host), which ALL try
to manage the SAME file ("/etc/something.conf"). But one file can only
be managed by one resource. That needs to be something like
"/etc/something_${host}.conf"

HTH...

Dirk
--
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Email: dhei...@opentext.com
Website: www.recommind.de
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu
Ranganathan, Christian Waida, 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.

Albert Shih

unread,
Apr 8, 2024, 7:41:47 AMApr 8
to 'Dirk Heinrichs' via Puppet Users, tux...@gmail.com
Le 08/04/2024 à 11:01:27+0000, 'Dirk Heinrichs' via Puppet Users a écrit
Hi

>
> > $group_hosts.each | String $host | {
> >   @@file { "file for ${host}":
> >     ensure => present,
> >     name   => "file for ${host}",
> >     path   => '/etc/something.conf',
> >     tag    => "File for ${host}",
> >     etc.
> >     }
> > }
>
> You create multiple resources here (one for each host), which ALL try
> to manage the SAME file ("/etc/something.conf"). But one file can only
> be managed by one resource. That needs to be something like

Yes...I know that but I'm also using “@@” who export the file to «others
host». So even I can understand why it's not working I think that would be
nice if it does.

Be re-reading the doc of file ressource I understand that

$namevar = $path

but IMHO it should be

if $name is underf
$namevar = $path
else
$namevar = $name

I find another solution but it need a little more configuration from the
user of the module.

>
> HTH...

Thanks.

Regards.

--
Albert SHIH 🦫 🐸
France
Heure locale/Local time:
lun. 08 avril 2024 13:36:58 CEST

Mike Langhorst

unread,
Apr 9, 2024, 12:01:42 PMApr 9
to Puppet Users
So, assuming that you were to export this resource on 2 different hosts.  How could you collect it <<| |>>, as there could only be one /etc/something.conf on that collecting host.  That's why the exported resource path needs to be unique, can't just name it something unique if the resulting file would be in conflict.

Albert Shih

unread,
Apr 12, 2024, 3:38:53 AMApr 12
to puppet...@googlegroups.com
Le 09/04/2024 à 09:01:42-0700, Mike Langhorst a écrit
Hi,

> So, assuming that you were to export this resource on 2 different hosts.  How
> could you collect it <<| |>>, as there could only be one /etc/something.conf on
> that collecting host.  That's why the exported resource path needs to be
> unique, can't just name it something unique if the resulting file would be in
> conflict.

Well...I'm not a dev maybe it's way I don't understand.... if I export to
two differents host/tags those files are on two differents hosts. How can
they be in conflict ?

For example, if I have «something» let's say a service/daemon running on

«master-host»

and for each

«slave-host»

I need to put a config file who depend on a token distributed by the
master. For me the most «natural» method would be to exported the «token»
to each slave host from the master.

I don't see how can that be conflict.

regards
--
Albert SHIH 🦫 🐸
France
Heure locale/Local time:
ven. 12 avril 2024 09:32:07 CEST

Dirk Heinrichs

unread,
Apr 12, 2024, 4:28:48 AMApr 12
to puppet...@googlegroups.com
Am Freitag, dem 12.04.2024 um 09:38 +0200 schrieb Albert Shih:

Well...I'm not a dev maybe it's way I don't understand.... if I export to
two differents host/tags those files are on two differents hosts. How can
they be in conflict ?

That's not the point. Puppet doesn't know your usecase. In general, exported resources are used to distribute data from one set of hosts to another one. Most prominent example being SSH host keys, which are usually exported by all your hosts and then imported by all others.

So it is generally possible that an exported file resource is being

  1. exported by multiple hosts
  2. used by multiple (other) hosts

Thus, Puppet needs to take some precautions to avoid possible conflicts. That being said, I don't think that "file" resources are a good fit for exporting at all.

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, 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.
Reply all
Reply to author
Forward
0 new messages