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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'manifests/init.pp', line 27
class ipset (
Array[String[1]] $packages,
String[1] $service,
Boolean $service_ensure,
Boolean $enable,
Enum['present', 'absent', 'latest'] $package_ensure,
Stdlib::Absolutepath $config_path,
Optional[Pattern[/\.service$/]] $firewall_service = undef,
Hash $sets = {},
) {
package { $ipset::packages:
ensure => $package_ensure,
}
# create the config directory
file { $config_path:
ensure => 'directory',
}
# setup the helper scripts
file { '/usr/local/bin/ipset_sync':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0754',
content => file("${module_name}/ipset_sync"),
}
file { '/usr/local/bin/ipset_init':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0754',
content => file("${module_name}/ipset_init"),
}
# configure custom unit file
case $facts['service_provider'] {
'systemd': {
systemd::unit_file { "${service}.service":
enable => $enable,
active => $service_ensure,
content => epp("${module_name}/ipset.service.epp", {
'firewall_service' => $firewall_service,
'config_path' => $config_path,
}),
subscribe => [File['/usr/local/bin/ipset_init'], File['/usr/local/bin/ipset_sync']],
}
}
default: {
fail('The ipset module only supports systemd based distributions')
}
}
$sets.each |$set, $attributes| {
ipset::set { $set:
* => $attributes,
}
}
}
|