Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ansible/roles/baseline/tasks/sudo_account.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,11 @@
key: "{{ item }}"
state: present
loop: "{{ sudo_account['keys'] }}"
# fail_key:false stores a missing user as {user: None}, so test the value, not `in`.
when: not ansible_check_mode or (getent_passwd | default({})).get(sudo_account['name'])
# fail_key:false stores a missing user as {user: None}, so test the value, not `in`
# — and compare it explicitly: the hit is the passwd field LIST, and ansible-core
# 2.19+ rejects a non-boolean conditional outright. Only check mode reaches this
# operand (a real run short-circuits on the left), which is why it fails solely
# under --check.
when: >-
not ansible_check_mode
or (getent_passwd | default({})).get(sudo_account['name']) is not none
Loading