How to append to the PATH

22 views
Skip to first unread message

Jonty Needham

unread,
Feb 7, 2017, 11:14:23 AM2/7/17
to Ansible Project
I need to update the PATH variable on the target machine. Yet I have no idea how to do it.

I could update /etc/environment with an ansible play, but does that do what I want without overwriting the user's PATH instead of appending to it?

What's the best way of doing this?

Kai Stian Olstad

unread,
Feb 7, 2017, 3:04:46 PM2/7/17
to ansible...@googlegroups.com
It depends on your shell, interactive or non interactive shell, your
distribution and for which user you would like to change the path for.

Interactive Bash support files in /etc/profile.d/ and this will be added
to all users.

To add to the path just create a file like this.

- name: My custom path
copy:
dest: /etc/profile.d/my_custom_path.sh
content: "PATH=PATH:/my/custom/path"

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages