I'm attempting to create an Ansible Role to create users... I want it to be able to accept a list of dicts and if a key is missing from the dict, it will fall back to Ansible's default.
For example, given the following data:
---
users:
- { name: foo, group: bar, create_home: no }
{ name: goo, group: bar }
I'd normally loop over the list with something like:
- name: Add users
ansible.builtin.user:
name: "{{ item.name }}"
groups: "{{ item.group }}"
create_home: "{{ item.create_home }}"
state: present
loop: "{{ users }}"
However, because create_home
doesn't exist for the second user, it'd throw an error. How could I get it to fall back to Ansible's default for keys that don't exist?