--- # tasks file for user - name: set facts set_fact: username: "{{ user.username }}" # Create user - name: Ensure wheel group exists group: name: "{{ item }}" state: present with_items: "{{ user.groups | replace(' ', '') | split(',') }}" - name: "{{ username }} -- create user " ansible.builtin.user: name: "{{ user.username }}" update_password: on_create password: "{{ user.password | password_hash('sha512')}}" group: "{{ user.group | default('users') }}" groups: "{{ user.groups | default('') }}" shell: "{{ user.shell | default('/bin/bash') }}" state: present system: "{{ user.system | default('no') }}" create_home: true - name: "{{ username }} -- Add public key" authorized_key: user: "{{ user.username }}" key: "{{ lookup('file', item.keyfile) }}" state: present with_items: "{{ user.public_key | default([]) }}" - name: "{{ username }} -- set dotfiles" import_tasks: dotfiles.yml - name: "{{ username }}: gtk_settings" dconf: key: "{{ item.key }}" value: "{{ item.value }}" state: present with_items: "{{ user.gtk_settings | default([]) }}" become: true become_user: "{{ user.username }}" - name: "{{ username }} -- user owns its create_home" file: path: "/home/{{ user.username }}/.dotfiles" owner: "{{ user.username }}" group: users