Git private repo, and ssh agent forwarding

This problem sounds like a very similar issues to what some others are experiencing and have been able to resolve. However, looking at those examples I do not see a clear and compete answer on the solution.

I am trying to use ansible to clone a private repo. I can login to the remote machine and manually clone the repo as my user. I can also go on the ansible master and do the clone via ssh forwarding:

ssh -Y remote-machine “git clone me@someserver.com:/home/git/secrets.git /home/me/secrets”

However, the ansible CLI does not work when implementing this same circumstance:

ansible -v -i hosts molmicro-devel -K -m git -a “repo=jester.labmed.uw.edu:/home/git/secrets.git dest=/home/robinsac/secrets” --connection=ssh

I have tried adding the connection flag but this did not change the output. The above command will hang as if it is looking for input from the user.

I feel certain there is something I am missing with forwarding the ssh credentials but how to first get the CLI to work and then employ it in a playbook still alludes me. Any information on getting the above to work would be much appreciated.

Thanks,

-Aaron

Hi Aaron,

I think its hangs because its asking you to add the host to .ssh/known_hosts. For me to get private repos working all I do is login to the user and do the following
ssh git@privaterepo.com this prompts me to accept authenticity and updates known_hosts. After that I can call ansible to clone repo.

you can also set ssh config to StrictHostKeyChecking no http://askubuntu.com/questions/123072/ssh-automatically-accept-keys. I don think this is safe though.

While I haven’t tried the turning off strict hosting, I have assured the known host works. I can physically log onto the machine and do the clone without being asked for a password which should be a way of verify that the known_hosts file is not the issue.

Thanks for your suggestion.

Just to quickly recap the scope of this issue, we have now reproduced this on a completely fresh install of Ubuntu 12.04. Only one of our severs is able to actually perform the ansible command via the ‘git’ module. However, we are unable to probe specifically how this machine is different from the other servers. Beyond that we have spun up a new AWS instance (sense I did not do this piece, I cannot speak about what stack was used) and this machine did not exemplify the problematic behaviour we are seeing.

So from our perspective, a regular fresh install of Ubuntu 12.04 is configured in such a way that it does not allow the ‘git’ module to work properly. We have a work around and the workaround highlights once again that this is some strange configuration issue:

robinsac@robinsac-x220:~/UWMC/uwmc_ansible$ ansible -v -i hosts molmicro-devel -m shell -a “git clone jester.labmed.uw.edu:/home/git/secrets.git”
mdp | success | rc=0 >>
Cloning into ‘secrets’…

So it seems rather clear this is not a known_hosts problem but rather a system configuration issue. We have no more time to troubleshoot this issue and will be deploy the work around for the time being (which falls quite short of the full functionality behind the git module).

-A

you could compare via verbose ssh

-m shell -a “ssh -v jester.labmed.uw.edu”

I would recommend reading up on GIT_SSH and how you can use that, we use the git module on 12.04 quite often.

(You can also enable SSH agent forwarding in your SSH config if you want)

"So it seems rather clear this is not a known_hosts problem but rather a system configuration issue. "

This doesn’t really seem clear to me what it is.

Thanks for your help everyone.

This issue was caused by a strange key forwarding issue. The script did two hops and this caused the agent to not get forwarded. I was able to ssh into Jester from Molmicro-devel because the credentials were being forwarded via SSH. Thus follows I was also able to do the git pull manually. When I ran the script the key was not forwarded and it was looking for credentials on Molmicro-devel. However, I had no credentials there and instead my credentials were on my machine (the ansible master). Therefore ansible was hanging at a password prompt.

So it works fine for SSHing between the machine but not for Ansible. If there is some way to fix that issue I am describing were credentials are not forwarded, that would be appreciated. Otherwise, we have solved the issue.

Thanks again,

-Aaron

ANSIBLE_SSH_ARGS and your ~/.ssh/config can both be used to control forwarding.

If you are using paramiko (because it’s the default on Enterprise Linux, who still ships an unfortunately downlevel SSH), it’s using paramiko by default though and not openssh.

The solution there is to specify -c ssh or so configure it in your configuration file.