# Creates a single user on a server
- name: Create a single user
  hosts: all
  become: True
  gather_facts: True
  pre_tasks:
    - fail: msg="You must pass a user into this play"
      when: user is not defined
    - name: give access with no sudo
      set_fact:
        CUSTOM_USER_INFO:
          - name: "{{ user }}"
            github: true
            state: "{{ state | default('present') }}"
      when: give_sudo is not defined
    - name: give access with sudo
      set_fact:
        CUSTOM_USER_INFO:
          - name: "{{ user }}"
            type: admin
            github: true
            state: "{{ state | default('present') }}"
      when: give_sudo is defined
  roles:
    - role: user
      user_info: "{{ CUSTOM_USER_INFO }}"
