---
# tasks file for ansible-vsftpd
- name: install vsftpd
  apt: name={{ item }} state=latest cache_valid_time=3600 update_cache=yes
  with_items:
    - vsftpd
    - libpam-pwdfile

- name: create directory for user configuration
  command: mkdir {{ vsftpd_user_config_dir }} creates={{ vsftpd_user_config_dir }}

- name: create directory for key local_root from vsftpd.conf
  command: mkdir {{ vsftpd_local_root }} creates={{ vsftpd_local_root }}

- name: set permissions for local_root
  command: chown root:root {{ vsftpd_local_root }}

- name: copy file for PAM service
  template: src=vsftpd.pam.j2 dest=/etc/pam.d/vsftpd mode=644 backup=yes

- name: copy script the vsftpd-user
  template: src=vsftpd-user.j2 dest=/sbin/vsftpd-user mode=755

- name: add test user of the ftp
  tags: testuser
  command: /sbin/vsftpd-user add {{ test_user }} {{ test_user_password }} creates=/etc/vsftpd
  when: test_user_is_enable

# will be create backup file if already exist
- name: copy config file of the vsftpd
  template: src=vsftpd.conf.j2 dest=/etc/vsftpd.conf mode=644 backup=yes
  notify:
    - restart vsftpd

---
# tasks file for ansible-vsftpd
- name: install vsftpd
  apt: name={{ item }} state=latest cache_valid_time=3600 update_cache=yes
  with_items:
    - vsftpd
    - libpam-pwdfile

- name: create directory for user configuration
  file:
    path: "{{ vsftpd_user_config_dir }}"
    owner: root
    group: root
    state: directory

- name: reate directory for key local_root from vsftpd.conf
  file:
    path: "{{ vsftpd_local_root }}"
    owner: root
    group: root
    state: directory

- name: copy file for PAM service
  template: src=vsftpd.pam.j2 dest=/etc/pam.d/vsftpd mode=644 backup=yes

- name: copy script the vsftpd-user
  template: src=vsftpd-user.j2 dest=/sbin/vsftpd-user mode=755

- name: add test user of the ftp
  tags: testuser
  command: /sbin/vsftpd-user add {{ test_user }} {{ test_user_password }} creates=/etc/vsftpd
  when: test_user_is_enable

# will be create backup file if already exist
- name: copy config file of the vsftpd
  template: src=vsftpd.conf.j2 dest=/etc/vsftpd.conf mode=644 backup=yes
  notify:
    - restart vsftpd

Fix idempotency for directory operations
Fix idempotency for directory operations