pure-ftpd.yml 2.0 KB

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