On 06.09.2017 23:00, David Reagan wrote:
I've tried the following code:
- name: ensure users exist.
when: item.value.state is defined
user:
state: "{{ item.value.state }}"
name: "{{ item.value.username }}"
comment: "{{ item.value.fullname }}"
password: "{{ item.value.crypted_pass }}"
createhome: "yes"
*home: "{{ item.value.home|default(/home/{{ item.value.username }})
}}"*
shell: "{{ item.value.shell }}"
uid: "{{ item.value.uid }}"
with_dict: "{{ aspects_local_users }}"
tags:
- aspects_local_users
Basically, if aspects_local_users.user.home is set, I want to use that
value. Otherwise I want to use /home/<username>.
As I expected, you can't nest {{ }} to get the value out of
item.value.username. I, obviously, can get the value if I just do this:
Correct syntax should be:
home: "{{ item.value.home | default('/home/' + item.value.username) }}"
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/94aa10fc34f6919d1392418cfe02f8e9%40olstad.com.
For more options, visit https://groups.google.com/d/optout.