Ask Your Question

What is the right way to have multiple file resources with the same path?

asked 2016-07-15 18:35:39 -0500

Tundra gravatar image

Hey Everybody! I'm trying to figure out the best way to have multiple file resources with the same path. Here is what I have:

I have a set of files that go on every linux machine that live in the /etc directory:

file { '/etc':
  ensure => directory,
  recurse => remote,
  source => 'puppet:///modules/linux_base/etc',

Then I have some specific nodes that need additional files also inside the /etc directory:

node 'host1', 'host2' {
  file { '/etc':
        ensure => directory,
        recurse => remote,
        source => 'puppet:///modules/app_servers/etc',

If I do this, it gives me an error about how I have a duplicate path. I feel like I can't be the only person that wants to do something like this, so what is the right way to do it?

edit retag flag offensive close merge delete



Duplicate resource( same title ) declaration will not work in Puppet. You need to list/declare the specific files/directories that will vary from host to host you need to create a resource declaration for each.

lupin gravatar imagelupin ( 2016-07-16 01:23:00 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-07-17 04:57:19 -0500

yo61 gravatar image

As lupin has already said, you can not use duplicate resource declarations.

Also, using "recurse" like this is generally a bad idea - performance is poor, especially if it's a large tree.

A better approach would be to bundle up the various contents of /etc as tarballs and use the archive module to deploy them.


edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-07-15 18:35:39 -0500

Seen: 123 times

Last updated: Jul 15 '16