ansible/ansible — pull request #6527 by patrickheeney (2014-03-17 16:04:22+00:00)
Title: Fix for hostkey directory

I am using the new `accept_hostkey=yes` on the `git` module and I am getting the following error: `msg: /root/.ssh/ does not exist`. I tracked this down to the `add_host_key` method.

The environment I am running this in looks like this:
```
"SUDO_USER": "root",
"USER": "vagrant",
"USERNAME": "vagrant"
```

So it should not be looking into the `/root/.ssh` because I do not use `sudo` on the playbook or the play. I checked the `not_in_host_file` method and it looks check within the `${USER}` known_hosts but when adding it, it does not.

This solution will first check the USER environment variable or fallback to the old way, similar to the other methods. I have not been able to fully test this yet. Also, this could use some regression tests.