Skip to content

Commit f5fc23b

Browse files
author
Joshua Hoblitt
committed
add config param to class pureftpd
To allow passing a hash of pure-ftpd.conf configuration values through to class pureftpd::config
1 parent a22b60a commit f5fc23b

File tree

4 files changed

+170
-70
lines changed

4 files changed

+170
-70
lines changed

README.md

+32-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
1-
# puppet-pureftpd
1+
Puppet pureftpd Module
2+
======================
23

34
[![Build Status](https://travis-ci.org/jhoblitt/puppet-pureftpd.png)](https://travis-ci.org/jhoblitt/puppet-pureftpd)
45

5-
Manage Pure-FTPd via Puppet on RHEL systems
66

7-
## How to use
7+
Description
8+
-----------
89

9-
### Unix authentication with default configuration
10+
This is a puppet module for installation and configuration of the `pure-ftpd`
11+
software.
1012

11-
```
12-
class { 'pureftpd': }
13-
```
1413

15-
### Different authentication type
14+
Examples
15+
--------
1616

17-
```
18-
pureftpd::config{ 'ftp':
19-
auth_type => mysql,
20-
}
21-
```
17+
### Basic
18+
19+
Install `pure-ftpd` with an empty `pure-ftpd.conf` config file (accepting all
20+
defaults) and start `pure-ftpd` as a stand alone daemon.
21+
22+
class { 'pureftpd': }
23+
24+
### Selinux support
25+
26+
class { 'pureftpd':
27+
use_selinux => true,
28+
}
29+
30+
### Setting configuration options
31+
32+
class { 'pureftpd':
33+
use_selinux => true,
34+
config => {
35+
ipv4only => 'Yes',
36+
passiveportrange => '49999:59999',
37+
}
38+
}
39+
40+
### Enabling LDAP authentication
2241

2342
```
2443
pureftpd::config_ldap { 'ftp-server':

manifests/config.pp

+52-53
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,59 @@
99
# 5Ub-Z3r0
1010
# Joshua Hoblitt <[email protected]>
1111
#
12-
1312
class pureftpd::config(
14-
$IPV4Only = undef,
15-
$IPV6Only = undef,
16-
$ChrootEveryone = undef,
17-
$BrokenClientsCompatibility = undef,
18-
$Daemonize = undef,
19-
$VerboseLog = undef,
20-
$DisplayDotFiles = undef,
21-
$AnonymousOnly = undef,
22-
$NoAnonymous = undef,
23-
$DontResolve = undef,
24-
$AnonymousCanCreateDirs = undef,
25-
$NATmode = undef,
26-
$CallUploadScript = undef,
27-
$AntiWarez = undef,
28-
$AllowUserFXP = undef,
29-
$AllowAnonymousFXP = undef,
30-
$ProhibitDotFilesWrite = undef,
31-
$ProhibitDotFilesRead = undef,
32-
$AllowDotFiles = undef,
33-
$AutoRename = undef,
34-
$AnonymousCantUpload = undef,
35-
$LogPID = undef,
36-
$NoChmod = undef,
37-
$KeepAllFiles = undef,
38-
$CreateHomeDir = undef,
39-
$NoRename = undef,
40-
$CustomerProof = undef,
41-
$NoTruncate = undef,
42-
$FileSystemCharset = undef,
43-
$ClientCharset = undef,
44-
$SyslogFacility = undef,
45-
$FortunesFile = undef,
46-
$ForcePassiveIP = undef,
47-
$Bind = undef,
48-
$AnonymousBandwidth = undef,
49-
$UserBandwidth = undef,
50-
$TrustedIP = undef,
51-
$AltLog = undef,
52-
$PIDFile = undef,
53-
$MaxIdleTime = undef,
54-
$MaxDiskUsage = undef,
55-
$TrustedGID = undef,
56-
$MaxClientsNumber = undef,
57-
$MaxClientsPerIP = undef,
58-
$MaxLoad = undef,
59-
$MinUID = undef,
60-
$TLS = undef,
61-
$LimitRecursion = undef,
62-
$PassivePortRange = undef,
63-
$AnonymousRatio = undef,
64-
$UserRatio = undef,
65-
$Umask = undef,
13+
$ipv4only = undef,
14+
$ipv6only = undef,
15+
$chrooteveryone = undef,
16+
$brokenclientscompatibility = undef,
17+
$daemonize = undef,
18+
$verboselog = undef,
19+
$displaydotfiles = undef,
20+
$anonymousonly = undef,
21+
$noanonymous = undef,
22+
$dontresolve = undef,
23+
$anonymouscancreatedirs = undef,
24+
$natmode = undef,
25+
$calluploadscript = undef,
26+
$antiwarez = undef,
27+
$allowuserfxp = undef,
28+
$allowanonymousfxp = undef,
29+
$prohibitdotfileswrite = undef,
30+
$prohibitdotfilesread = undef,
31+
$allowdotfiles = undef,
32+
$autorename = undef,
33+
$anonymouscantupload = undef,
34+
$logpid = undef,
35+
$nochmod = undef,
36+
$keepallfiles = undef,
37+
$createhomedir = undef,
38+
$norename = undef,
39+
$customerproof = undef,
40+
$notruncate = undef,
41+
$filesystemcharset = undef,
42+
$clientcharset = undef,
43+
$syslogfacility = undef,
44+
$fortunesfile = undef,
45+
$forcepassiveip = undef,
46+
$bind = undef,
47+
$anonymousbandwidth = undef,
48+
$userbandwidth = undef,
49+
$trustedip = undef,
50+
$altlog = undef,
51+
$pidfile = undef,
52+
$maxidletime = undef,
53+
$maxdiskusage = undef,
54+
$trustedgid = undef,
55+
$maxclientsnumber = undef,
56+
$maxclientsperip = undef,
57+
$maxload = undef,
58+
$minuid = undef,
59+
$tls = undef,
60+
$limitrecursion = undef,
61+
$passiveportrange = undef,
62+
$anonymousratio = undef,
63+
$userratio = undef,
64+
$umask = undef,
6665
) inherits pureftpd::params {
6766

6867
$conf_options = [

manifests/init.pp

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@
88
# Optional, defaults to false.
99
# Manages whether or not to enable the selinux extensions.
1010
#
11+
# [*config*]
12+
# Optional, defaults to `{}`.
13+
#
1114
# === Authors
1215
#
1316
# 5Ub-Z3r0
1417
#
1518
class pureftpd (
16-
$use_selinux=false
19+
$use_selinux = false,
20+
$config = {},
1721
) {
18-
include pureftpd::config, pureftpd::service
22+
validate_bool($use_selinux)
23+
validate_hash($config)
24+
25+
include pureftpd::service
1926

2027
class{ 'pureftpd::install': use_selinux => $use_selinux }
2128

29+
create_resources( 'class', { 'pureftpd::config' => $config } )
30+
2231
Class[ 'pureftpd::install' ] ->
2332
Class[ 'pureftpd::config' ] ->
2433
Class[ 'pureftpd::service' ] ->

spec/classes/pureftpd_spec.rb

+75-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
22

3-
describe 'pureftpd' do
3+
describe 'pureftpd', :type => :class do
44
let(:facts) { {:osfamily=> 'RedHat'} }
55

66
describe 'with no params' do
@@ -19,7 +19,7 @@
1919
end
2020
end
2121

22-
describe 'with $use_selinux' do
22+
describe 'with $use_selinux => true' do
2323
let(:params) {{ :use_selinux => true }}
2424
it do
2525
should include_class('pureftpd')
@@ -35,4 +35,77 @@
3535
})
3636
end
3737
end
38+
39+
describe 'with $use_selinux => false' do
40+
let(:params) {{ :use_selinux => false }}
41+
it do
42+
should include_class('pureftpd')
43+
should include_class('pureftpd::install')
44+
should include_class('pureftpd::config')
45+
should include_class('pureftpd::service')
46+
should contain_package('pure-ftpd').with_ensure('present')
47+
should_not contain_package('pure-ftpd-selinux')
48+
should contain_file('/etc/pure-ftpd/pure-ftpd.conf').with_ensure('file')
49+
should contain_service('pure-ftpd').with({
50+
'ensure' => 'running',
51+
'enable' => 'true',
52+
})
53+
end
54+
end
55+
56+
describe 'with $use_selinux => not-a-bool' do
57+
let(:params) {{ :use_selinux => 'not-a-bool' }}
58+
it 'should fail' do
59+
expect {
60+
should include_class('pureftpd')
61+
}.to raise_error(Puppet::Error, /is not a boolean/)
62+
end
63+
end
64+
65+
describe 'with $config => {}' do
66+
let(:params) {{ :config => {} }}
67+
it do
68+
should include_class('pureftpd')
69+
should include_class('pureftpd::install')
70+
should include_class('pureftpd::config')
71+
should include_class('pureftpd::service')
72+
should contain_package('pure-ftpd').with_ensure('present')
73+
should_not contain_package('pure-ftpd-selinux')
74+
should contain_file('/etc/pure-ftpd/pure-ftpd.conf').with_ensure('file')
75+
should contain_service('pure-ftpd').with({
76+
'ensure' => 'running',
77+
'enable' => 'true',
78+
})
79+
end
80+
end
81+
82+
describe 'with $config keys' do
83+
let(:params) {{ :config => { 'daemonize' => 'Yes', 'ipv4only' => 'No'} }}
84+
it do
85+
should include_class('pureftpd')
86+
should include_class('pureftpd::install')
87+
should include_class('pureftpd::config')
88+
should include_class('pureftpd::service')
89+
should contain_package('pure-ftpd').with_ensure('present')
90+
should_not contain_package('pure-ftpd-selinux')
91+
should contain_file('/etc/pure-ftpd/pure-ftpd.conf').with_ensure('file')
92+
.with_content(<<-END.gsub(/^\s+/, ""))
93+
IPV4Only No
94+
Daemonize Yes
95+
END
96+
should contain_service('pure-ftpd').with({
97+
'ensure' => 'running',
98+
'enable' => 'true',
99+
})
100+
end
101+
end
102+
103+
describe 'with $config => not-a-hash' do
104+
let(:params) {{ :config => 'not-a-bool' }}
105+
it 'should fail' do
106+
expect {
107+
should include_class('pureftpd')
108+
}.to raise_error(Puppet::Error, /is not a Hash/)
109+
end
110+
end
38111
end

0 commit comments

Comments
 (0)