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?