pure-ftpd.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. - name: Install pure-ftpd related packages
  2. apt: pkg={{ item }} state=installed update_cache=yes
  3. with_items:
  4. - pure-ftpd
  5. when: with_ftp
  6. - name: Install pure-ftpd configuration
  7. lineinfile:
  8. dest: '/etc/pure-ftpd/conf/{{ item.dest }}'
  9. regexp: '{{ item.regexp }}'
  10. line: '{{ item.line }}'
  11. create: yes
  12. with_items:
  13. - { dest: 'BrokenClientsCompatibility', regexp: '^(yes|no)', line: 'yes' }
  14. - { dest: 'ChrootEveryone', regexp: '^(yes|no)', line: 'yes' }
  15. - { dest: 'DontResolve', regexp: '^(yes|no)', line: 'yes' }
  16. - { dest: 'NoAnonymous', regexp: '^(yes|no)', line: 'yes' }
  17. - { dest: 'NoChmod', regexp: '^(yes|no)', line: 'yes' }
  18. - { dest: 'PAMAuthentication', regexp: '^(yes|no)', line: 'yes' }
  19. - { dest: 'VerboseLog', regexp: '^(yes|no)', line: 'no' }
  20. - { dest: 'MinUID', regexp: '^[0-9]+$', line: '34' } # Debian's uid(backup) = 34
  21. notify:
  22. - Restart pure-ftpd
  23. when: with_ftp
  24. - name: Enable pure-ftpd internal DB
  25. file: src=/etc/pure-ftpd/conf/PureDB path=/etc/pure-ftpd/auth/80puredb state=link
  26. notify:
  27. - Restart pure-ftpd
  28. when: with_ftp
  29. - name: Clean up pure-ftpd internal DB
  30. raw: pure-pw list 2>/dev/null | sed -r 's/^(\S+)\s.*$/\1/' | while read u ; do pure-pw userdel "${u}" ; done
  31. when: with_ftp
  32. - name: Create FTP accounts home directory
  33. file:
  34. path: '{{item.home}}'
  35. owner: '{{item.uid}}'
  36. group: '{{item.gid}}'
  37. mode: 0755
  38. state: 'directory'
  39. with_items: ftp_accounts
  40. when: ftp_accounts and with_ftp
  41. - name: Add FTP accounts in pure-ftpd
  42. raw: printf "{{item.password}}\n{{item.password}}\n" | pure-pw useradd "{{item.user}}" -d "{{item.home}}" -u "{{item.uid}}" -g "{{item.gid}}"
  43. with_items: ftp_accounts
  44. when: ftp_accounts and with_ftp
  45. - name: Rebuild pure-ftpd internal DB
  46. raw: pure-pw mkdb 2>/dev/null
  47. when: with_ftp
  48. - name: Ensure pure-ftpd is running
  49. service: name=pure-ftpd state=started
  50. when: with_ftp