Open nlvw opened 2 years ago
@nlvw thank you for reporting this issue.
I think it should be handled properly like the user
module. So I will set a bug label for this issue.
---
- hosts: all
gather_facts: false
become: yes
vars:
users:
- name: foo
comment: "Test User Foo"
- name: bar
comment: "Test User Bar"
- name: baz
tasks:
- user:
name: "{{ item.name }}"
comment: "{{ item.comment | default(omit) }}"
state: present
$ ansible-playbook -i inventory/issue_328 playbook/issue_328/test_omit.yml
PLAY [all] *************************************************************************************************************
TASK [user] ************************************************************************************************************
changed: [server10] => (item={'name': 'foo', 'comment': 'Test User Foo'})
changed: [server10] => (item={'name': 'bar', 'comment': 'Test User Bar'})
changed: [server10] => (item={'name': 'baz'})
PLAY RECAP *************************************************************************************************************
server10 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[server10] $ cat /etc/passwd
...snip...
foo:x:1004:1004:Test User Foo:/home/foo:/bin/bash
bar:x:1005:1005:Test User Bar:/home/bar:/bin/bash
baz:x:1006:1006::/home/baz:/bin/bash
...snip...
In addition, the omit string __omit_place_holder_[HASH]
, [HASH]
string is generated each playbook run, so I think this is the cause of https://github.com/ansible-collections/ansible.posix/issues/327#issuecomment-1046146238 that you reported in #327
SUMMARY
With the following task the
comment
value it is not correctly omitted.Using a list item such as:
Results in:
if I instead provide:
Results are:
So the jinja
default(omit)
functionality does not work correctly with thecomment
option.ISSUE TYPE
COMPONENT NAME
ansible.posix.authorized_key
ANSIBLE VERSION
COLLECTION VERSION