---
- name: Create {{ nextcloud_user }} unix group
  group:
    name: "{{ nextcloud_user | mandatory }}"
    state: present
  tags:
    - nextcloud

- name: Create {{ nextcloud_user | mandatory }} unix user
  user:
    name: "{{ nextcloud_user | mandatory }}"
    group: "{{ nextcloud_user | mandatory }}"
    home: "{{ nextcloud_home | mandatory }}"
    shell: '/bin/bash'
    create_home: True
    state: present
#    mode: "0755"
  tags:
  - nextcloud

- name: Create top-level directories
  file:
    dest: "{{ item }}"
    state: directory
    mode: "0700"
    owner: "{{ nextcloud_user }}"
    group: "{{ nextcloud_user }}"
  loop:
    - "{{ nextcloud_home }}/log"
    - "{{ nextcloud_home }}/tmp"
    - "{{ nextcloud_home }}/data"
  tags:
    - nextcloud
