Creating puppet recursive catalogs

I am trying to create recursive directories with the same structure:

I have the following modes:

/ some-1 / some-2 / some-3 / some-4

and inside each of them I would like to create the same structure, let it call its pool:

/ some-1 / pool / some-2 / pool / some-3 / pool / some-4 / pool

as suggested by Albert, an elegant solution can be implemented using the method of determining puppets.

define create_pool {
file { "/some-$title/pool":
    ensure => "directory",
    recurse => "true",
 }
}   

create_pool { [1,2,3,4]: }

Fortunately, this solution "loops" around the list:

+4
source share
3 answers
define create_pool {
  file { "/some-$title":
    ensure => "directory"
  }
  file { "/some-$title/pool":
    ensure => "directory"
  }
}

create_pool { ["a", "b", "c", "d"]: }

a automatically determines loops over its "arguments" :)

+2
source

First you can create an array of directories that you need either manually or:

$directories = split('/some/path/to/somewhere', '/')

:

each($directories) |$directory| {
  if ! defined (File[$directory]) {
    file { $directory: ensure => directory }
  }
}

, , , /, .

: = puppet.conf .

+2

so far what i found and it works comes from this other SO Question , I can create and make sure that the file is present in every directory in this way, but I was hoping to find a way to loop over [some-1, some-2, some-3, some-4]

file{[ "/some-1/pool" , "/some-2/pool" , "/some-3/pool" , "/some-4/pool" ] :
    ensure   => "directory",
    recurse  => "true",
     [ "/some-1/pool/setup" , "/some-2/pool/setup" , "/some-3/pool/setup" , "/some-4/pool/setup" ] :
    ensure   => "present",
    content  => template("some/setupPool.erb");
}
0
source

Source: https://habr.com/ru/post/1527716/


All Articles