Ask Your Question
0

Is it possible to specify a source for an array of files

asked 2016-04-13 09:32:47 -0500

abqkawi1000 gravatar image

updated 2016-04-13 09:33:59 -0500

I would like to manage the attributes for an array of files but cannot figure out how to set the source. What I have tried so far bombs with the error:

Parameter source failed on File[/foo1]: Could not understand source puppet:///modules/foo/[foo1, foo2, foo3, foo4]: bad URI (is not URI?):puppet:///modules/foo/[/etc/foo1,%20/etc/foo2,%20/etc/foo3,%20/etc/oo4,%20/..........


class foo::config {

  $files_for_foo = [ '/etc/foo1', '/etc/foo2', '/etc/foo3', '/etc/foo4']

  file {
    $files_for_foo
          ensure  => file,
          source  => "puppet:///modules/foo/${files_for_foo}",
          owner   => 'root',
          group   => 'root',
          mode    => '0644';
    }
}

I was hoping to not have to manage each of these files individually.

Thanks for any guidance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-04-13 10:04:31 -0500

Is this what you mean?

class foo::config {
  $files = {
    '/etc/foo1' => { source => 'puppet:///modules/foo/foo1' },
    '/etc/foo2' => { source => 'puppet:///modules/foo/foo2' },
    '/etc/foo3' => { source => 'puppet:///modules/foo/foo3' },
    '/etc/foo4' => { source => 'puppet:///modules/foo/foo4' },
  }
  create_resources(file, $files, {
    owner => 'root',
    group => 'root',
    mode  => '0644',
  })
}
edit flag offensive delete link more

Comments

This works well. Thanks for your help!

abqkawi1000 gravatar imageabqkawi1000 ( 2016-04-13 13:31:04 -0500 )edit

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

Stats

Asked: 2016-04-13 09:32:47 -0500

Seen: 57 times

Last updated: Apr 13 '16