chroot.yml 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. - name: enable chroot for local users
  2. lineinfile:
  3. dest: /etc/vsftpd.conf
  4. line: 'chroot_local_user=YES'
  5. regexp: '#? *chroot_local_user=.*'
  6. become: yes
  7. notify: reload vsftpd
  8. - name: chroot listed users only
  9. lineinfile:
  10. dest: /etc/vsftpd.conf
  11. # option only takes effect if chroot_local_user is activated
  12. line: 'chroot_list_enable=NO'
  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. dest: /etc/vsftpd.chroot_list
  34. content: |
  35. {% for user in vsftpd_allowed_users %}
  36. {{user}}
  37. {% endfor %}
  38. mode: u=rw,g=,o=
  39. become: yes