pure-ftpd.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. - name: 'Install pure-ftpd related packages'
  2. apt:
  3. pkg: '{{ item }}'
  4. state: 'present'
  5. with_items:
  6. - 'pure-ftpd'
  7. tags:
  8. - 'ftp'
  9. - 'pure-ftpd'
  10. - name: 'Install pure-ftpd configuration (TLS settings)'
  11. lineinfile:
  12. dest: '/etc/pure-ftpd/conf/{{ item.dest }}'
  13. regexp: '{{ item.regexp }}'
  14. line: '{{ item.line }}'
  15. create: yes
  16. with_items:
  17. - { dest: 'TLS', regexp: '^[0-9]+$', line: '3' }
  18. - { 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' }
  19. notify:
  20. - 'Restart pure-ftpd'
  21. when: with_ftp_tls
  22. tags:
  23. - 'ftp'
  24. - 'pure-ftpd'
  25. - name: 'Create pure-ftpd SSL bundle certificate symlink'
  26. file:
  27. src: '/etc/ssl/local/certs/{{ ftp_tls_domain }}/bundle.pem'
  28. path: '/etc/ssl/private/pure-ftpd.pem'
  29. state: 'link'
  30. notify:
  31. - 'Restart pure-ftpd'
  32. when: with_ftp_tls and ftp_tls_domain
  33. tags:
  34. - 'ftp'
  35. - 'pure-ftpd'
  36. - name: 'Create pure-ftpd Diffie Hellman Param file symlink'
  37. file:
  38. src: '/etc/ssl/private/dh2048.pem'
  39. path: '/etc/ssl/private/pure-ftpd-dhparams.pem'
  40. state: 'link'
  41. notify:
  42. - 'Restart pure-ftpd'
  43. when: with_ftp_tls
  44. tags:
  45. - 'ftp'
  46. - 'pure-ftpd'
  47. - name: 'Install pure-ftpd configuration'
  48. lineinfile:
  49. dest: '/etc/pure-ftpd/conf/{{ item.dest }}'
  50. regexp: '{{ item.regexp }}'
  51. line: '{{ item.line }}'
  52. create: yes
  53. with_items:
  54. - { dest: 'BrokenClientsCompatibility', regexp: '^(yes|no)', line: 'yes' }
  55. - { dest: 'ChrootEveryone', regexp: '^(yes|no)', line: 'yes' }
  56. - { dest: 'DontResolve', regexp: '^(yes|no)', line: 'yes' }
  57. - { dest: 'NoAnonymous', regexp: '^(yes|no)', line: 'yes' }
  58. - { dest: 'NoChmod', regexp: '^(yes|no)', line: 'yes' }
  59. - { dest: 'PAMAuthentication', regexp: '^(yes|no)', line: 'yes' }
  60. - { dest: 'VerboseLog', regexp: '^(yes|no)', line: 'no' }
  61. - { dest: 'MinUID', regexp: '^[0-9]+$', line: '34' } # Debian's uid(backup) = 34
  62. - { dest: 'PassivePortRange', regexp: '^[0-9]+ [0-9]+$', line: '64000 65000' }
  63. notify:
  64. - 'Restart pure-ftpd'
  65. tags:
  66. - 'ftp'
  67. - 'pure-ftpd'
  68. - name: 'Enable pure-ftpd internal DB'
  69. file:
  70. src: '/etc/pure-ftpd/conf/PureDB'
  71. path: '/etc/pure-ftpd/auth/80puredb'
  72. state: 'link'
  73. notify:
  74. - 'Restart pure-ftpd'
  75. tags:
  76. - 'ftp'
  77. - 'pure-ftpd'
  78. - name: 'Clean up pure-ftpd internal DB'
  79. raw: pure-pw list 2>/dev/null | sed -r 's/^(\S+)\s.*$/\1/' | while read u ; do pure-pw userdel "${u}" ; done
  80. changed_when: False
  81. tags:
  82. - 'ftp'
  83. - 'pure-ftpd'
  84. - name: 'Create FTP accounts home directory'
  85. file:
  86. path: '{{ item.home }}'
  87. owner: '{{ item.uid }}'
  88. group: '{{ item.gid }}'
  89. mode: 0755
  90. state: 'directory'
  91. with_items: '{{ ftp_accounts }}'
  92. when: ftp_accounts
  93. tags:
  94. - 'ftp'
  95. - 'pure-ftpd'
  96. - name: 'Add FTP accounts in pure-ftpd'
  97. raw: printf "{{ item.password }}\n{{ item.password }}\n" | pure-pw useradd "{{ item.user }}" -d "{{ item.home }}" -u "{{ item.uid }}" -g "{{ item.gid }}"
  98. with_items: '{{ ftp_accounts }}'
  99. changed_when: False
  100. when: ftp_accounts and with_ftp
  101. tags:
  102. - 'ftp'
  103. - 'pure-ftpd'
  104. - name: 'Rebuild pure-ftpd internal DB'
  105. raw: pure-pw mkdb 2>/dev/null
  106. changed_when: False
  107. tags:
  108. - 'ftp'
  109. - 'pure-ftpd'
  110. - name: 'Ensure pure-ftpd is running'
  111. service:
  112. name: 'pure-ftpd'
  113. state: 'started'
  114. tags:
  115. - 'ftp'
  116. - 'pure-ftpd'
  117. # vim: ft=yaml.ansible