Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #13 from Temelio/fix_virtual_users
Browse files Browse the repository at this point in the history
Fix virtual users
  • Loading branch information
achaussier committed Feb 6, 2016
2 parents 5ab988a + ff0bbca commit 2da4c11
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tasks/manage_virtual_users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,31 @@
state: absent
when: vsftpd_virtual_users_clean_database

- name: Generate user list
become: True
template:
src: templates/user_tmp_list.j2
dest: /root/vsftpd_user_list_tmp.txt
owner: root
group: root
mode: '0400'

- name: Create or update database
become: True
shell: "echo -e \"{{ item.username }}\n{{ item.password }}\" \
| db5.3_load -T -t hash \
{{ vsftpd_virtual_users_database_file_name }}"
with_items: "{{ vsftpd_virtual_users }}"
shell: "db5.3_load -T -t hash \
-f /root/vsftpd_user_list_tmp.txt \
{{ vsftpd_virtual_users_database_file_name }}.db"
changed_when: False

- name: Delete temp user list
file:
path: /root/vsftpd_user_list_tmp.txt
state: absent

- name: Set database permissions
become: True
file:
path: "{{ vsftpd_virtual_users_database_file_name }}"
path: "{{ vsftpd_virtual_users_database_file_name }}.db"
owner: "{{ vsftpd_virtual_users_database_file_owner }}"
group: "{{ vsftpd_virtual_users_database_file_group }}"
mode: "{{ vsftpd_virtual_users_database_file_mode }}"
Expand Down
5 changes: 5 additions & 0 deletions templates/user_tmp_list.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% for account in vsftpd_virtual_users %}
{{ account.username }}
{{ account.password }}
{% endfor %}

0 comments on commit 2da4c11

Please sign in to comment.