chroot.yml 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. - name: disable default chroot for local users
  2. lineinfile:
  3. dest: /etc/vsftpd.conf
  4. line: 'chroot_local_user=NO'
  5. regexp: '#? *chroot_local_user=.*'
  6. become: yes
  7. notify: reload vsftpd
  8. - name: enable chroot for explicitly listed users
  9. lineinfile:
  10. dest: /etc/vsftpd.conf
  11. # option only takes effect if chroot_local_user is activated
  12. line: 'chroot_list_enable=YES'
  13. regexp: '#? *chroot_list_enable=.*'
  14. become: yes
  15. notify: reload vsftpd
  16. - name: set path to chroot list
  17. lineinfile:
  18. dest: /etc/vsftpd.conf
  19. # vsftpd default: /etc/vsftpd.user_list
  20. line: 'chroot_list_file=/etc/vsftpd.chroot_list'
  21. regexp: '#? *chroot_list_file=.*'
  22. become: yes
  23. notify: reload vsftpd
  24. - name: restrict write permissions on home of chrooted user
  25. file:
  26. path: '~{{item}}'
  27. owner: root
  28. mode: u=rw,g-w,o-w
  29. become: yes
  30. with_items: '{{vsftpd_allowed_users}}'
  31. - name: create chroot list
  32. copy:
  33. # changes in chroot list do not require a reload of the vsftpd service
  34. dest: /etc/vsftpd.chroot_list
  35. content: |
  36. {% for user in vsftpd_allowed_users %}
  37. {{user}}
  38. {% endfor %}
  39. mode: u=rw,g=,o=
  40. become: yes