Put a file into users home directory

12,908 views
Skip to first unread message

Oscar Korz

unread,
Apr 19, 2013, 12:52:56 PM4/19/13
to ansible...@googlegroups.com
I've got a very silly question that I haven't been able to find a simple solution to:

I want to copy a config file into users' home directories but I don't know their home directories on the controller (and they may vary from host to host). What's the best way to look up a user's home directory on the host? I know that I could capture the output from a shell command, but this feels hacky. I'd prefer a solution that doesn't get flagged as "changed" every time.

Thanks,
Oscar.

Michael DeHaan

unread,
Apr 19, 2013, 1:35:25 PM4/19/13
to ansible...@googlegroups.com
You can just use "~/" on the path name for the "dest" file, the homedir will expand on the remote side as you expect.






--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Oscar Korz

unread,
Apr 19, 2013, 1:40:40 PM4/19/13
to ansible...@googlegroups.com
Ah, thanks for the quick response.

Serge van Ginderachter

unread,
Apr 19, 2013, 2:17:39 PM4/19/13
to ansible...@googlegroups.com

On 19 April 2013 19:35, Michael DeHaan <michael...@gmail.com> wrote:
You can just use "~/" on the path name for the "dest" file, the homedir will expand on the remote side as you expect.

​Be aware that this is the home directory or the user you are logging on to the remote host with.​
If you need to copy to other users home directory, knowing their usernames, you can use "~username/".
You probably will need root permissions to do that, and don't orget to set the file's permissions to the target user.


Serge

Rohit Dubey

unread,
Nov 4, 2015, 9:01:50 AM11/4/15
to Ansible Project
Hi : 

I am a newbie .   Would the  user subtitution from vars file also i.e  ~{{user}}/<sub-dir> .
I guess I'll find out and report back . 

Thanks anyways .  
Reply all
Reply to author
Forward
0 new messages