18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'manifests/snippet.pp', line 18
define bird::snippet (
Boolean $manage_v6 = false,
Boolean $validate = true,
Optional[Variant[String[1], Sensitive[String[1]]]] $content = undef,
Optional[Stdlib::Filesource] $source = undef,
) {
include bird
if $content =~ NotUndef and $source =~ NotUndef {
fail('you can only set $content or $source')
}
if $content =~ Undef and $source =~ Undef {
fail('you need to set $content or $source')
}
if $manage_v6 {
$additional_config_path = $bird::additional_config_path_v6
$validate_cmd = "${bird::v6_path} -p -c ${bird::config_path_v6}"
$require_filepath = File[$bird::config_path_v6]
$daemon_name = Service[$bird::daemon_name_v6]
} else {
$additional_config_path = $bird::additional_config_path_v4
$validate_cmd = "${bird::v4_path} -p -c ${bird::config_path_v4}"
$require_filepath = File[$bird::config_path_v4]
$daemon_name = Service[$bird::daemon_name_v4]
}
$filepath = "${additional_config_path}/${title}"
# we cannot validate the snippets, only the whole config
# the main config file includes the snippets, hence we validate the main config for each snippet
# because of that, the snippets require the main file
if $validate {
$_validate_cmd = $validate_cmd
} else {
$_validate_cmd = undef
}
file { $filepath:
ensure => 'file',
source => $source,
content => $content,
owner => 'root',
group => 'root',
mode => '0644',
validate_cmd => $_validate_cmd,
require => $require_filepath,
}
if $bird::manage_service {
File[$filepath] ~> $daemon_name
}
}
|