Browse Source

Install kernel modules loader for FTP server

Emmanuel Bouthenot 8 years ago
parent
commit
b7fc31c88b

+ 2 - 0
roles/ftpserver/handlers/common.yml

@@ -0,0 +1,2 @@
+- name: 'Load kernel modules for ftp server'
+  raw: egrep -v  '^(\s*#|$)' /etc/modules-load.d/ftpd.conf | xargs --no-run-if-empty --max-args 1 modprobe

+ 2 - 1
roles/ftpserver/handlers/main.yml

@@ -1 +1,2 @@
-- include: pure-ftpd.yml
+- include: 'common.yml'
+- include: 'pure-ftpd.yml'

+ 4 - 2
roles/ftpserver/handlers/pure-ftpd.yml

@@ -1,2 +1,4 @@
-- name: Restart pure-ftpd
-  service: name=pure-ftpd state=restarted
+- name: 'Restart pure-ftpd'
+  service:
+    name: 'pure-ftpd'
+    state: 'restarted'

+ 10 - 0
roles/ftpserver/tasks/common.yml

@@ -0,0 +1,10 @@
+- name: 'Install kernel modules loader for FTP server'
+  template:
+    src: 'common/modules_ftpd.conf.j2'
+    dest: '/etc/modules-load.d/ftpd.conf'
+    owner: 'root'
+    group: 'root'
+    mode: '0644'
+  notify:
+    - 'Load kernel modules for ftp server'
+  when: with_ftp

+ 2 - 1
roles/ftpserver/tasks/main.yml

@@ -1 +1,2 @@
-- include: pure-ftpd.yml
+- include: 'common.yml'
+- include: 'pure-ftpd.yml'

+ 22 - 14
roles/ftpserver/tasks/pure-ftpd.yml

@@ -1,10 +1,13 @@
-- name: Install pure-ftpd related packages
-  apt: pkg={{ item }} state=installed update_cache=yes
+- name: 'Install pure-ftpd related packages'
+  apt:
+    pkg: '{{ item }}'
+    state: 'installed'
+    update_cache: 'yes'
   with_items:
-    - pure-ftpd
+    - 'pure-ftpd'
   when: with_ftp
 
-- name: Install pure-ftpd configuration
+- name: 'Install pure-ftpd configuration'
   lineinfile:
     dest: '/etc/pure-ftpd/conf/{{ item.dest }}'
     regexp: '{{ item.regexp }}'
@@ -20,20 +23,23 @@
     - { dest: 'VerboseLog', regexp: '^(yes|no)', line: 'no' }
     - { dest: 'MinUID', regexp: '^[0-9]+$', line: '34' } # Debian's uid(backup) = 34
   notify:
-    - Restart pure-ftpd
+    - 'Restart pure-ftpd'
   when: with_ftp
 
-- name: Enable pure-ftpd internal DB
-  file: src=/etc/pure-ftpd/conf/PureDB path=/etc/pure-ftpd/auth/80puredb state=link
+- name: 'Enable pure-ftpd internal DB'
+  file:
+    src: '/etc/pure-ftpd/conf/PureDB'
+    path: '/etc/pure-ftpd/auth/80puredb'
+    state: 'link'
   notify:
-    - Restart pure-ftpd
+    - 'Restart pure-ftpd'
   when: with_ftp
 
-- name: Clean up pure-ftpd internal DB
+- name: 'Clean up pure-ftpd internal DB'
   raw: pure-pw list 2>/dev/null | sed -r 's/^(\S+)\s.*$/\1/' | while read u ; do pure-pw userdel "${u}" ; done
   when: with_ftp
 
-- name: Create FTP accounts home directory
+- name: 'Create FTP accounts home directory'
   file:
     path: '{{item.home}}'
     owner: '{{item.uid}}'
@@ -43,15 +49,17 @@
   with_items: ftp_accounts
   when: ftp_accounts and with_ftp
 
-- name: Add FTP accounts in pure-ftpd
+- name: 'Add FTP accounts in pure-ftpd'
   raw: printf "{{item.password}}\n{{item.password}}\n" | pure-pw useradd "{{item.user}}" -d "{{item.home}}" -u "{{item.uid}}" -g "{{item.gid}}"
   with_items: ftp_accounts
   when: ftp_accounts and with_ftp
 
-- name: Rebuild pure-ftpd internal DB
+- name: 'Rebuild pure-ftpd internal DB'
   raw: pure-pw mkdb 2>/dev/null
   when: with_ftp
 
-- name: Ensure pure-ftpd is running
-  service: name=pure-ftpd state=started
+- name: 'Ensure pure-ftpd is running'
+  service:
+    name: 'pure-ftpd'
+    state: 'started'
   when: with_ftp

+ 6 - 0
roles/ftpserver/templates/common/modules_ftpd.conf.j2

@@ -0,0 +1,6 @@
+#
+# Modules to load for FTP server
+#
+
+nf_conntrack_ftp
+nf_nat_ftp