Setting the private SSH key from variables in a play?

401 views
Skip to first unread message

Mark

unread,
Jul 29, 2013, 5:06:55 AM7/29/13
to ansible...@googlegroups.com
I want to be able to set the path to the private SSH key in a playbook so I don't need to pass it on the command line all the time.

My use-case is having 10+ AWS accounts for dev/test/prod, etc. with separate keys for each. I'm not using EIPs so I can't use host vars. Instead, in my plays I pass an 'environment' variable that specifies whether I'm in dev01, test02, etc., and variables for the relevant environment get loaded using vars_files (I'm using ansible for provisioning new instances and snapshotting them as AMIs).

I know how to set the SSH user in playbooks, but how can I set the private SSH key path as well?

Mark

Michael DeHaan

unread,
Jul 29, 2013, 9:49:59 AM7/29/13
to ansible...@googlegroups.com
Sure!

You can set ansible_ssh_private_keyfile as an inventory variable with the path to your key.






Mark

--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Mark

unread,
Jul 29, 2013, 10:52:02 AM7/29/13
to ansible...@googlegroups.com
Thanks, I'll try it.
Reply all
Reply to author
Forward
0 new messages