Files
ansible-role-unix-users/tasks/create_unix_group.yaml
T
volker.raschekandCopilot 41a645f748 fix(tasks): accept an integer gid when creating a unix group
The two group tasks differed only in whether `gid` was passed, and the branch between them tested
`unix_group.value.gid | length`. The length filter has no meaning for an integer and raises "object of type 'int' has no
len()". The example in defaults/main.yaml declares `gid: 1001` unquoted, so the documented usage aborted the run, while
the quoted variant in the README happened to work.

Both tasks are merged into one that passes the gid through `default(omit, true)`. The boolean form of the filter is
required to keep the previous meaning of an empty gid, which is to let the system assign one. The only value that
changes semantics is gid 0, which is the root group and outside the scope of this role.

Co-authored-by: Copilot <copilot@github.com>
2026-09-09 21:39:42 +02:00

9 lines
334 B
YAML

---
- name: "Create unix group: {{ unix_group.key }}"
ansible.builtin.group:
name: "{{ unix_group.key }}"
# The boolean form of default also omits an empty gid, which means let the system assign one.
gid: "{{ unix_group.value.gid | default(omit, true) }}"
state: "{{ unix_group.value.state | default('present') }}"