Add support for users without a group of the same name
ollie1 opened this issue · comments
I'm using this role in my playbook and it's working nicely to install intellij. However, I'm now trying to add some specific config for a user, and in my particular setup, my linux user doesn't have a group of the same name (can't add this group because my username contains an "@" character as it's part of a domain). With a role setup as follows:
- role: gantsign.intellij
intellij_edition: ultimate
users:
- username: "myusername@domain"
I get the following error:
TASK [gantsign.intellij : create IntelliJ IDEA user config directory]
failed: [localhost] (item=myusername@mydomain) => {"ansible_loop_var": "username", "changed": false, "gid": 1005, "group": "domain users@mydomain", "mode": "0750", "msg": "chgrp failed: failed to look up group myusername@mydomain", "owner": "myusername@mydomain", "path": "/home/myusername@mydomain/.IntelliJIdea2019.3/config", "secontext": "system_u:object_r:user_home_t:s0", "size": 23, "state": "directory", "uid": 1002, "username": "myusername@mydomain"}
This seems to be because of code like the following where we assume that the group is the same as the username.
- name: create IntelliJ IDEA user config directory
become: yes
file:
dest: '~{{ username }}/{{ intellij_user_dir }}/config'
state: directory
owner: '{{ username }}'
group: '{{ username }}'
mode: 'ug=rwx,o=rx'
with_items: "{{ users | map(attribute='username') | list }}"
loop_control:
loop_var: username
Please can we allow overriding of the group to allow this kind of scenario?
@ollie1 thanks for reporting this issue. Due to the custom Ansible modules this role has this isn't a quick fix. Unfortunately, I won't have time to work on it until next weekend, but I hope to have a solution for you then.
Awesome. Just tested and it works very nicely - thanks so much for your quick fix!