---
  - name: (Prod) Generate AzuraCast Password
    command: pwgen 8 -sn 1
    register: prod_azuracast_user_password
    when: app_env == "production"

  - name: Assign User Password
    set_fact:
      azuracast_user_password: "{{ prod_azuracast_user_password.stdout if app_env == 'production' else dev_azuracast_user_password }}"

  - name: Create AzuraCast User
    become: true
    user:
      name: azuracast
      home: "{{ app_base }}"
      comment: "AzuraCast"
      shell: /bin/bash
      groups: 'sudo,admin,www-data'
      password: "{{ azuracast_user_password|password_hash('sha512') }}"

  - name: Create www-data group
    become: true
    group: name=www-data state=present

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

  - name: (Dev) Modify vagrant User
    become: true
    user: name=vagrant groups="www-data" append=yes
    when: app_env == "development"

  - name: (Dev) Modify www-data User
    become: true
    user: name=www-data groups="vagrant" append=yes
    when: app_env == "development"

  - name: (Dev) Add azuracast User to vagrant Group
    become: true
    user: name=azuracast groups="vagrant" append=yes
    when: app_env == "development"
---
  - name: (Prod) Generate AzuraCast Password
    command: pwgen 8 -sn 1
    register: prod_azuracast_user_password
    when: app_env == "production"

  - name: Create Groups
    become: true
    group: name="{{ item }}" state=present
    with_items:
     - www-data
     - admin

  - name: Assign User Password
    set_fact:
      azuracast_user_password: "{{ prod_azuracast_user_password.stdout if app_env == 'production' else dev_azuracast_user_password }}"

  - name: Create AzuraCast User
    become: true
    user:
      name: azuracast
      home: "{{ app_base }}"
      comment: "AzuraCast"
      shell: /bin/bash
      groups: 'sudo,admin,www-data'
      password: "{{ azuracast_user_password|password_hash('sha512') }}"

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

  - name: (Dev) Modify vagrant User
    become: true
    user: name=vagrant groups="www-data" append=yes
    when: app_env == "development"

  - name: (Dev) Modify www-data User
    become: true
    user: name=www-data groups="vagrant" append=yes
    when: app_env == "development"

  - name: (Dev) Add azuracast User to vagrant Group
    become: true
    user: name=azuracast groups="vagrant" append=yes
    when: app_env == "development"
Move group creation up and ensure existence of "admin" group.
Move group creation up and ensure existence of "admin" group.
