Get remote_user's home directory

88 views
Skip to first unread message

Jordan

unread,
Mar 9, 2014, 1:25:17 PM3/9/14
to ansible...@googlegroups.com
I have a playbook that installs oh-my-zsh:

---

- name: install zsh
  apt: pkg=zsh update_cache=yes

- name: install oh-my-zsh
       dest=/home/{{ username }}/.oh-my-zsh
       depth=1

- name: copy zshrc
  template: src=zshrc.j2 dest=/home/{{ username }}/.zshrc owner={{ username }}

- name: setting zsh as default shell
  user: name={{ username }} shell=/bin/zsh


Ideally I wouldn't have a username variable, since I simply want to add everything to the remote_user's home directory. Is there a way to do this?

Brian Coca

unread,
Mar 9, 2014, 9:36:28 PM3/9/14
to ansible...@googlegroups.com
if you gathered facts as that user, it should be at: ansible_env['HOME']

Adam Morris

unread,
Mar 9, 2014, 10:39:23 PM3/9/14
to ansible...@googlegroups.com
You also have ansible_user_id which might be useful.

Adam

Reply all
Reply to author
Forward
0 new messages