Skip to content

Commit

Permalink
Support arbitrary extra directives and empty/custom template
Browse files Browse the repository at this point in the history
  • Loading branch information
thias committed Oct 14, 2013
1 parent b83b292 commit 5bfc135
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Add support for arbitrary extra directives (#6).
* Add support for using an empty or a custom template for vsftpd.conf.

2013-09-04 - 0.1.5
* Add support for userlist_deny (Dennis Laumen).

Expand Down
56 changes: 46 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,50 @@ This module enables and configures a vsftpd FTP server instance.

With all of the module's default settings :

include vsftpd

Tweaking a few settings :

class { 'vsftpd':
anonymous_enable => 'NO',
write_enable => 'YES',
ftpd_banner => 'Marmotte FTP Server',
chroot_local_user => 'YES',
}
```puppet
include vsftpd
```

Tweaking a few settings (have a look at `manifests/init.pp` to know which
directives are supported as parameters) :

```puppet
class { 'vsftpd':
anonymous_enable => 'NO',
write_enable => 'YES',
ftpd_banner => 'Marmotte FTP Server',
chroot_local_user => 'YES',
}
```

For any directives which aren't directly supported by the module, use the
additional `directives` hash parameter :

```puppet
class { 'vsftpd':
ftpd_banner => 'ASCII FTP Server',
directives => {
'ascii_download_enable' => 'YES',
'ascii_upload_enable' => 'YES',
},
}
```

And if you really know what you are doing, you can use your own template or
start with an empty one which is provided (see `vsftpd.conf(5)`) in order
to have **all** configuration passed in the `directives` hash :

```puppet
class { 'vsftpd':
template => 'vsftpd/empty.conf.erb',
directives => {
'ftpd_banner' => 'Upload FTP Server',
'listen' => 'YES',
'tcp_wrappers' => 'YES',
'anon_upload_enable' => 'YES',
'dirlist_enable' => 'NO',
'download_enable' => 'NO',
},
}
```

6 changes: 4 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
class vsftpd (
$confdir = $::vsftpd::params::confdir,
$template = 'vsftpd/vsftpd.conf.erb',
# vsftpd.conf options
$anonymous_enable = 'YES',
$local_enable = 'YES',
Expand Down Expand Up @@ -55,7 +56,8 @@
$pasv_min_port = undef,
$pasv_max_port = undef,
$ftp_username = undef,
$banner_file = undef
$banner_file = undef,
$directives = {},
) inherits ::vsftpd::params {

package { 'vsftpd': ensure => installed }
Expand All @@ -69,7 +71,7 @@

file { "${confdir}/vsftpd.conf":
require => Package['vsftpd'],
content => template('vsftpd/vsftpd.conf.erb'),
content => template($template),
notify => Service['vsftpd'],
}

Expand Down
9 changes: 9 additions & 0 deletions templates/empty.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is vsftpd.conf created from scratch by puppet.
#
# *** DO NOT EDIT HERE ***
#

<% @directives.sort_by {|key,value| key}.each do |key,value| -%>
<%= key %>=<%= value %>
<% end -%>

3 changes: 3 additions & 0 deletions templates/vsftpd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,6 @@ ftp_username=<%= @ftp_username %>
<% if @banner_file -%>
banner_file=<%= @banner_file %>
<% end -%>
<% @directives.sort_by {|key,value| key}.each do |key,value| -%>
<%= key %>=<%= value %>
<% end -%>

0 comments on commit 5bfc135

Please sign in to comment.