Hi,
I’m trying to set optional values only if they are specified for the “user” module.
So with:
- name: Add users
user:
name: “{{ item.username }}”
comment: “{{ item.comment }}”
state: present
shell: “{{ (item.shell) | default(‘/bin/bash’) }}”
password: “{{ item.password }}”
update_password: always
with_items: “{{ merged_users }}”
tags: users
I only have to add an optional shell variable with anotehr value such as ‘/bin/ksh’ to override the default bash value.
How can I do the same for:
home: “{{ item.home }}”
group: “{{ item.group }}”
groups: “{{ item.groups }}”
As the home directory defaults to ‘/home/username’, group defaults to ‘username’ and groups also defaults to ‘username’.
I’ve tried something like:
group: “{{ (item.group) | default(‘/bin/bash’) }}”
but no joy.
So please help with these 3 values - how do I define defaults for “home”, “group” and “groups”?
Regards,
Suhail.