Dynamically deploying multiple exclusive SSH authorized_keys

Hi all,

Further misunderstandings on my part for iterating over varied YAML structures, but here’s the deal:
I’m writing a super tiny role with the intent of dynamically deploying any authorized_keys defined in a host/group’s vars.
That is to say, I need a task that will deploy keys to varied users, and the keys all need to be exclusive.

The use of files or templates will not suffice in this case - this needs to be scalable and in a sane structure.

Right now here’s the approach I’m taking.
I have my keys defined like so:

`

Try using with_subelements https://docs.ansible.com/ansible/playbooks_loops.html#looping-over-subelements and change the structure. Something like :

`

ssh_authorized_keys:

  • root:
  • foo
  • other_user:
  • bar
  • baz

`

Awesome, thanks Raghu! This definitely looks like the right approach. I’ll try this out and report back how I get on.