Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / concat / manifests / fragment.pp
1 # Creates a concat_fragment in the catalogue
2 #
3 # @param target The file that these fragments belong to
4 # @param content If present puts the content into the file
5 # @param source If content was not specified, use the source
6 # @param order
7 #   By default all files gets a 10_ prefix in the directory you can set it to
8 #   anything else using this to influence the order of the content in the file
9 #
10 define concat::fragment(
11   String                             $target,
12   Optional[String]                   $content = undef,
13   Optional[Variant[String, Array]]   $source  = undef,
14   Variant[String, Integer]           $order   = '10',
15 ) {
16   $resource = 'Concat::Fragment'
17
18   if (is_string($order) and $order =~ /[:\n\/]/) {
19     fail("${resource}['${title}']: 'order' cannot contain '/', ':', or '\n'.")
20   }
21
22   if ! ($content or $source) {
23     crit('No content, source or symlink specified')
24   } elsif ($content and $source) {
25     fail("${resource}['${title}']: Can't use 'source' and 'content' at the same time.")
26   }
27
28   $safe_target_name = regsubst($target, '[/:~\n\s\+\*\(\)@]', '_', 'GM')
29
30   concat_fragment { $name:
31     target  => $target,
32     tag     => $safe_target_name,
33     order   => $order,
34     content => $content,
35     source  => $source,
36   }
37 }