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/f123a9a2-34e9-400a-bea5-b5d70ef7bbe7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to