yet another question about loops

I want to be able to merge users across servers.
For example,
I want user1 to be on all of my hosts
and I want user_special_at_office to be only at my office's servers

So I made inventory file, where I specified all of the groups.
I made group_vars for *all* and for *office*

As I've read I can merge only dictionaries.

file group_vars/all
---
users:
  user1:
    comment: 'user1'
    authorized:
     - 'ssh-rsa 123'
     - 'ssh-rsa 999'
     - 'ssh-rsa 345'

file group_vars/office
---
users:
  user_special_at_office:
    comment: 'user_special_at_office'
    authorized:
     - 'ssh-rsa 555'
     - 'ssh-rsa 444'

with this play
---
- hosts: all
  tasks:
    - name: add users
      user: name={{ item.key }} comment="{{ item.value.comment }}"
      with_dict: users
      tags: user

    - name: add sshkey for users
      authorized_key: user={{ item.0.key }} key="{{ item.1 }}"
      with_subelements:
       - users
       - authorized
      tags: user_key

When I run this play with  *--tags user* I get two users - so the merging 
is working.
But I'm completely hopeless to get the task "add sshkey for users" working.
*One or more undefined variables: 'dict object' has no attribute 'key'*

Please advise me how can I accoplish what I want

-- 
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/3efc11db-a240-4011-91f4-c7e97efc7878%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to