pure-ftpd.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. notify:
  21. - Restart pure-ftpd
  22. when: with_ftp
  23. - name: Enable pure-ftpd internal DB
  24. file: src=/etc/pure-ftpd/conf/PureDB path=/etc/pure-ftpd/auth/80puredb state=link
  25. notify:
  26. - Restart pure-ftpd
  27. when: with_ftp
  28. - name: Clean up pure-ftpd internal DB
  29. raw: pure-pw list 2>/dev/null | sed -r 's/^(\S+)\s.*$/\1/' | while read u ; do pure-pw userdel "${u}" ; done
  30. when: with_ftp
  31. - name: Add FTP accounts in pure-ftpd
  32. raw: printf "{{item.password}}\n{{item.password}}\n" | pure-pw useradd "{{item.user}}" -d "{{item.home}}" -u "{{item.uid}}" -g "{{item.gid}}"
  33. with_items: ftp_accounts
  34. when: ftp_accounts and with_ftp
  35. - name: Rebuild pure-ftpd internal DB
  36. raw: pure-pw mkdb 2>/dev/null
  37. when: with_ftp
  38. - name: Ensure pure-ftpd is running
  39. service: name=pure-ftpd state=started
  40. when: with_ftp