Here's how I did it. Created a directory with the public keys in it. For
instance:

base-ami/files/public_ssh_keys/jack.pub
base-ami/files/public_ssh_keys/jill.pub

- name: Create basic users
  user: name={{ item }} shell=/bin/bash groups=grabtaxi
  with_items:
    - jack
    - jill

And then used lookup to populate the keys:

- name: Use the public keys from the users for the their login
  authorized_key:  user={{ item }} key="{{ lookup('file',
'public_ssh_keys/' + item + '.pub') }}"
  with_items:
    - jack
    - jill

You could make it fancier using vars and all but I think you get the gist
of it.






On Tue, Oct 14, 2014 at 5:09 AM, Wawrzek Niewodniczanski <[email protected]>
wrote:

>
>
> On Friday, 10 October 2014 08:50:11 UTC+1, Navid Paya wrote:
>>
>> Hi all
>> Not sure if this is even the right tile. So I have a set of SSH keys, I
>> want to be used as authorized keys for users. I've put all of them in a
>> directory and am trying to do the job but nothing happens.
>>
>
> Hi Navid,
>
> I 'm trying something similar, based on:
> http://blather.michaelwlucas.com/archives/1819
>
> Do you mind share your approach?
>
> Thanks,
> Wawrzek
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/E6--MjSuBJ8/unsubscribe.
> To unsubscribe from this group and all its topics, 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/3fc7e3fe-8278-49e7-a84a-29b24da097eb%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/3fc7e3fe-8278-49e7-a84a-29b24da097eb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAFsFwzu2vK%3DuC7DoEvaOdTz9LyRLQSLjQ7C2AdEinasXiHgscg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to