Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible sudo_user not using the correct $HOME directory

I have a git directory that is owned by a user that I cannot ssh as. I'm currently using sudo_user: user which is working but does not seem to be setting $HOME correctly. My user account has github in the ~/.ssh/known_hosts file but it is being added to my ~ssh_user/.ssh/known_hosts file (from the accept_hostkey=yes).

http://docs.ansible.com/git_module.html

- hosts: myhost
  sudo_user: user
  tasks:
    - name: git
      git: [email protected]:user/repo.git dest=/home/user/repo update=no accept_hostkey=yes

Is there something I need to do to tell ansible to use $HOME correctly?

I'm running on Solaris off of Joyent but I don't think that's directly applicable to this problem.

like image 259
Jason Axelson Avatar asked Apr 04 '14 21:04

Jason Axelson


1 Answers

add sudo_flags in your ansible.cfg file

[defaults]
sudo_flags = -i

this will run you sudo user's login script to populate environemt variables like $HOME

like image 148
Nextlink Avatar answered Sep 22 '22 05:09

Nextlink