Your dict has a key called "ssh_key" but the "when" clause in the task
says: "- item.value.ssh_key*s*.exists == true"
Notice the extra 's' in ssh_keys. Is that correct?
On Tuesday, 31 January 2017 13:50:27 UTC, Raphael Rabelo de Oliveira wrote:
>
> Hi guys,
>
> I'm trying to use a loop and with_dict together, but I have an issue with
> the value of some of key are missing, for example the value 'ssh_key':
> It's is proposital because i don't wanna any key in file.
>
> The 'when' conditional don't can evaluate if my variable exists
> 'item.value.ssh_key.exists':
>
>
> *My dict:*
>
> users:
> user1:
> home: "/home/user1"
> uid: 5000
> gid: 5000
> ssh_key: "{{ role_path }}/files/keys/user1.pub"
> key_options :
> 'from="192.168.1.2",no-agent-forwarding,no-port-forwarding,no=X11-forwarding'
> user2:
> home: "/var/www/user2"
> uid: 8000
> gid: 8000
> key_options :
> 'from="192.168.1.2",no-agent-forwarding,no-port-forwarding,no=X11-forwarding'
>
>
> *My task:*
>
> - name: Configuring authorized_keys
> authorized_key:
> user : "{{ item.key }}"
> key : "{{ lookup('file', '{{ item.value.ssh_key }}') }}"
> key_options : "{{ item.value.key_options }}"
> with_dict: "{{ users }}"
> when:
> - item.value.ssh_keys.exists == true
>
> Is there some way to make it work properly ?
>
> Thanks!
>
--
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/5a887012-56bb-4771-ab90-735689d9bf5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.