Open matburt opened 6 years ago
What should be the interface if I want to add several keys? Do you have something in mind?
I have two thoughts on this:
a) Have a directory that contains a single key per file OR b) Support multiple private key stanzas in a single file.
The latter would be easier to deal with when doing something like... creating named pipes (which we support reading from)... it also fits the .ssh directory semantics better the former may be easier from a client management perspective.
There is a var for this that can be set in ansible.cfg, inventory, group_vars, host_vars: ansible_ssh_private_key_file
@matburt any new ideas about this? This should be quite easy to add (just adding new ssh-add commands at https://github.com/ansible/ansible-runner/blob/master/ansible_runner/runner_config.py#L503) but we need to get a clear interface. Maybe we could have env/ssh_key be a file or a folder, and if it is a folder we assume that the contents are all keys that must be added? I think that this could be cleaner that several keys on a single file, in the case that some issue needs to be tracked down.
I'm good with the file vs folder distinction. The other bit is changing the module interface to be able to accept a list rather than just a big string and then maintaining backwards compatibility for it.
@matburt please check the PR I opened. I refactored the code a little to support both cases (obviously it changes the class structure a little) and seems to work. Please give me some feedback, and let me know if this is the right path to follow.
Just as an FYI, when designing a solution for this issue, please consider that in order to support SSH certificates, Ansible-runner will need to take pairs of files: https://github.com/ansible/ansible-runner/issues/488
@john-westcott-iv has started some research into the options for managing multiple ssh keys. By that, I mean the tradeoffs of mapping groups/hosts to specific SSH keys versus letting it try multiple keys for every host.
We also had a really good idea from @shanemcd to put the ssh-agent and ssh-add commands into a separate script to make this feel more manageable. That could be done separately from this to pave some groundwork.
Currently runner assumes a single private key be provided through the module interface and via
env/ssh_key
. We should support multiples since behind the scenes we are using ssh-agent.