From 4aa6a08a9537f11005e618de7531a1c18e1f23ad Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Sun, 23 Jan 2022 03:09:02 +0100 Subject: [PATCH] Fix user creation --- tasks/users.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tasks/users.yml b/tasks/users.yml index b3e54fa..026ba81 100644 --- a/tasks/users.yml +++ b/tasks/users.yml @@ -4,7 +4,8 @@ ansible.builtin.user: name: "{{ user.username }}" state: "{{ user.state | default(omit) }}" - groups: "{{ user.groups | default(omit) | join(',') }}" + group: "{{ user.group | default(omit) }}" + groups: "{{ user.groups | default(omit) }}" comment: "{{ user.comment | default(omit) }}" shell: "{{ user.shell | default(omit) }}" password: "{{ user.password | default(omit) }}" @@ -72,24 +73,26 @@ - name: "Install antigen for '{{ user.username }}'." tags: users - become: true - become_user: "{{ user.username }}" ansible.builtin.get_url: url: https://git.io/antigen dest: "{{ user.home_dir | default('/home/' + user.username) }}/.zsh/antigen.zsh" mode: 0600 - when: - - user.shell is defined - - "'/zsh' in user.shell" - name: "Install tpm for user '{{ user.username }}'." tags: users - become: true - become_user: "{{ user.username }}" ansible.builtin.git: repo: "https://github.com/tmux-plugins/tpm" dest: "{{ user.home_dir | default('/home/' + user.username) }}/.tmux/plugins/tpm" version: v3.0.0 + - name: "Fix permissions for user '{{ user.username }}'" + ansible.builtin.file: + path: "{{ item }}" + owner: "{{ user.username }}" + recurse: yes + with_items: + - "{{ user.home_dir | default('/home/' + user.username) }}/.tmux/plugins/tpm" + - "{{ user.home_dir | default('/home/' + user.username) }}/.zsh" + when: - user.state | default('present') == 'present'