Any way to specify SSH key file for EC2 host using EC2 inventory

92 views
Skip to first unread message

Do Hoang Khiem

unread,
May 30, 2015, 2:06:10 PM5/30/15
to ansible...@googlegroups.com
I'm using Ansible to manage multiple EC2 instance that could be launched dynamically, keypair is generated for each instance then store in local machine. 

Previously I use default inventory file and in Ansible I can use lineinfile module to add new EC2 host to hosts file with additional vars like ansible_ssh_user, ansible_ssh_private_key_file, that's very convenient as each time I run Ansible playbook I dont have to explicitly specify SSH key. 

But now with change to use EC2 inventory, I can't find a way to add such kind of vars to EC2 host, I know using ssh-agent is a solution, but I would look for a more explicit method that I can manage keys better than just add every generated key to ssh-agent.

Any suggestions? 

Brian Coca

unread,
Jun 1, 2015, 10:09:27 AM6/1/15
to ansible...@googlegroups.com
create host_vars/<hostname> yaml files with the same info, in a
directory adjacent to the dynamic inventory.
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f02e66be-f40e-4b7a-b10a-b51706532e55%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages