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.
You can just use “~/” on the path name for the “dest” file, the homedir will expand on the remote side as you expect.
Ah, thanks for the quick response.
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
Hi :
I am a newbie . Would the user subtitution from vars file also i.e ~{{user}}/ .
I guess I’ll find out and report back .
Thanks anyways .