pure-ftpd.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. - name: 'Install pure-ftpd related packages'
  2. apt:
  3. pkg: '{{ item }}'
  4. state: 'installed'
  5. with_items:
  6. - 'pure-ftpd'
  7. - name: 'Install pure-ftpd configuration (TLS settings)'
  8. lineinfile:
  9. dest: '/etc/pure-ftpd/conf/{{ item.dest }}'
  10. regexp: '{{ item.regexp }}'
  11. line: '{{ item.line }}'
  12. create: yes
  13. with_items:
  14. - { dest: 'TLS', regexp: '^[0-9]+$', line: '3' }
  15. - { dest: 'TLSCipherSuite', regexp: '^.*$', line: 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK:!SSLv3:!SSLv2:!TLSv1' }
  16. notify:
  17. - 'Restart pure-ftpd'
  18. when: with_ftp_tls
  19. - name: 'Create pure-ftpd SSL bundle certificate symlink'
  20. file:
  21. src: '/etc/ssl/local/certs/{{ ftp_tls_domain }}/bundle.pem'
  22. path: '/etc/ssl/private/pure-ftpd.pem'
  23. state: 'link'
  24. notify:
  25. - 'Restart pure-ftpd'
  26. when: with_ftp_tls and ftp_tls_domain
  27. - name: 'Create pure-ftpd Diffie Hellman Param file symlink'
  28. file:
  29. src: '/etc/ssl/private/dh2048.pem'
  30. path: '/etc/ssl/private/pure-ftpd-dhparams.pem'
  31. state: 'link'
  32. notify:
  33. - 'Restart pure-ftpd'
  34. when: with_ftp_tls
  35. - name: 'Install pure-ftpd configuration'
  36. lineinfile:
  37. dest: '/etc/pure-ftpd/conf/{{ item.dest }}'
  38. regexp: '{{ item.regexp }}'
  39. line: '{{ item.line }}'
  40. create: yes
  41. with_items:
  42. - { dest: 'BrokenClientsCompatibility', regexp: '^(yes|no)', line: 'yes' }
  43. - { dest: 'ChrootEveryone', regexp: '^(yes|no)', line: 'yes' }
  44. - { dest: 'DontResolve', regexp: '^(yes|no)', line: 'yes' }
  45. - { dest: 'NoAnonymous', regexp: '^(yes|no)', line: 'yes' }
  46. - { dest: 'NoChmod', regexp: '^(yes|no)', line: 'yes' }
  47. - { dest: 'PAMAuthentication', regexp: '^(yes|no)', line: 'yes' }
  48. - { dest: 'VerboseLog', regexp: '^(yes|no)', line: 'no' }
  49. - { dest: 'MinUID', regexp: '^[0-9]+$', line: '34' } # Debian's uid(backup) = 34
  50. - { dest: 'PassivePortRange', regexp: '^[0-9]+ [0-9]+$', line: '64000 65000' }
  51. notify:
  52. - 'Restart pure-ftpd'
  53. - name: 'Enable pure-ftpd internal DB'
  54. file:
  55. src: '/etc/pure-ftpd/conf/PureDB'
  56. path: '/etc/pure-ftpd/auth/80puredb'
  57. state: 'link'
  58. notify:
  59. - 'Restart pure-ftpd'
  60. - name: 'Clean up pure-ftpd internal DB'
  61. raw: pure-pw list 2>/dev/null | sed -r 's/^(\S+)\s.*$/\1/' | while read u ; do pure-pw userdel "${u}" ; done
  62. changed_when: False
  63. - name: 'Create FTP accounts home directory'
  64. file:
  65. path: '{{item.home}}'
  66. owner: '{{item.uid}}'
  67. group: '{{item.gid}}'
  68. mode: 0755
  69. state: 'directory'
  70. with_items: '{{ ftp_accounts }}'
  71. when: ftp_accounts
  72. - name: 'Add FTP accounts in pure-ftpd'
  73. raw: printf "{{item.password}}\n{{item.password}}\n" | pure-pw useradd "{{item.user}}" -d "{{item.home}}" -u "{{item.uid}}" -g "{{item.gid}}"
  74. with_items: '{{ ftp_accounts }}'
  75. changed_when: False
  76. when: ftp_accounts and with_ftp
  77. - name: 'Rebuild pure-ftpd internal DB'
  78. raw: pure-pw mkdb 2>/dev/null
  79. changed_when: False
  80. - name: 'Ensure pure-ftpd is running'
  81. service:
  82. name: 'pure-ftpd'
  83. state: 'started'