3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'manifests/config.pp', line 3
class proftpd::config {
# Should we manage the configuration at all?
if ( $::proftpd::manage_config_file == true ) {
$modules_config = "${::proftpd::base_dir}/modules.conf"
# check if anonymous access should be enabled
if ( $::proftpd::anonymous_enable == true ) {
$real_defaults = deep_merge($::proftpd::default_options,
$::proftpd::anonymous_options)
}
# do not include options for anonymous access
else { $real_defaults = $::proftpd::default_options }
# check if defaults should be included
# re-hash due to hiera 1.x known limitation
$hash_options = hiera_hash('proftpd::options',$::proftpd::options)
if ( $::proftpd::default_config == true ) {
$real_options = deep_merge($real_defaults, $hash_options)
}
# do not include defaults
else { $real_options = $hash_options }
# required variables
$base_dir = $::proftpd::base_dir
$load_modules = $::proftpd::load_modules
# create AuthUserFile/AuthGroupFile to allow the configtest to succeed
if $real_options['ROOT'] and $real_options['ROOT']['AuthUserFile'] {
$authuser_require = File[$real_options['ROOT']['AuthUserFile']]
if !defined(File[$real_options['ROOT']['AuthUserFile']]) {
file { $real_options['ROOT']['AuthUserFile']:
ensure => present,
source => $::proftpd::authuserfile_source,
owner => $::proftpd::user,
group => $::proftpd::group,
mode => '0600',
before => File[$::proftpd::config],
}
}
} elsif $real_options['Global'] and
$real_options['Global']['AuthUserFile'] {
# get the first argument and only use that for creating the file (don't use spaces in filename)
$__AuthUserFileParts = split($real_options['Global']['AuthUserFile'], ' ')
$__AuthUserFile = $__AuthUserFileParts[0]
$authuser_require = File[$real_options['Global']['AuthUserFile']]
if !defined(File[$real_options['Global']['AuthUserFile']]) {
file { $real_options['Global']['AuthUserFile']:
ensure => present,
source => $::proftpd::authuserfile_source,
owner => $::proftpd::user,
group => $::proftpd::group,
mode => '0600',
before => File[$::proftpd::config],
}
}
}
if $real_options['ROOT'] and $real_options['ROOT']['AuthGroupFile'] {
# get the first argument and only use that for creating the file (don't use spaces in filename)
$__AuthGroupFileParts = split($real_options['Global']['AuthGroupFile'], ' ')
$__AuthGroupFile = $__AuthUserFileParts[0]
$authgroup_require = File[$__AuthGroupFile]
if !defined(File[$__AuthGroupFile]) {
file { $__AuthGroupFile:
ensure => present,
source => $::proftpd::authgroupfile_source,
owner => $::proftpd::user,
group => $::proftpd::group,
mode => '0600',
before => File[$::proftpd::config],
}
}
} elsif $real_options['Global'] and
$real_options['Global']['AuthGroupFile'] {
$authgroup_require = File[$real_options['Global']['AuthGroupFile']]
if !defined(File[$real_options['Global']['AuthGroupFile']]) {
file { $real_options['Global']['AuthGroupFile']:
ensure => present,
source => $::proftpd::authgroupfile_source,
owner => $::proftpd::user,
group => $::proftpd::group,
mode => '0600',
before => File[$::proftpd::config],
}
}
}
if $authuser_require and $authgroup_require {
$config_require = [Concat[$modules_config], $authuser_require,
$authgroup_require]
} elsif $authuser_require {
$config_require = [Concat[$modules_config], $authuser_require]
} elsif $authgroup_require {
$config_require = [Concat[$modules_config], $authgroup_require]
} else { $config_require = Concat[$modules_config] }
File {
ensure => present,
require => Class['::proftpd::install'],
}
file {
$::proftpd::base_dir:
ensure => directory,
owner => $::proftpd::config_user,
group => $::proftpd::config_group;
$::proftpd::log_dir:
ensure => directory,
owner => $::proftpd::config_user,
group => $::proftpd::config_group;
$::proftpd::run_dir:
ensure => directory,
owner => $::proftpd::config_user,
group => $::proftpd::config_group;
$::proftpd::config:
ensure => file,
mode => $::proftpd::config_mode,
content => template($::proftpd::config_template),
validate_cmd => "${::proftpd::prefix_bin}/proftpd -t -c %",
owner => $::proftpd::config_user,
group => $::proftpd::config_group,
require => $config_require,
notify => Class[::proftpd::service];
}
concat { $modules_config:
owner => $::proftpd::config_user,
group => $::proftpd::config_group,
# modules may be required for validate_cmd to succeed
before => File[$::proftpd::config],
notify => Class[::proftpd::service],
}
concat::fragment { 'proftp_modules_header':
target => "${::proftpd::base_dir}/modules.conf",
content => "# File is managed by Puppet\n",
order => '01',
}
}
}
|