---
- name: Generate AzuraCast Password
  command: >-
    pwgen 8 -sn 1
  register: prod_azuracast_user_password

- name: Create Groups
  group:
    name: "{{ azuracast_user_sys_group }}"
    state: present
  loop:
    - www-data
    - admin
  loop_control:
    loop_var: azuracast_user_sys_group

- name: Create AzuraCast User
  user:
    name: azuracast
    home: "{{ app_base }}"
    comment: "AzuraCast"
    shell: /bin/bash
    groups: 'sudo,admin,www-data'
    password: "{{ prod_azuracast_user_password.stdout|password_hash('sha512') }}"
  notify: send user notification

- name: Modify www-data User
  user:
    name: www-data
    groups: "azuracast"
    append: true
