# How to append to the PATH

**URL:** <https://forum.ansible.com/t/how-to-append-to-the-path/23670>\
**Category:** Ansible Project\
**Created:** [February 7, 2017, 4:14pm UTC](https://forum.ansible.com/t/how-to-append-to-the-path/23670 "2017-02-07T16:14:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonty\_Needham](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Jonty\_Needham](https://forum.ansible.com/u/Jonty_Needham)\
**Post date:** [February 7, 2017, 4:14pm UTC](https://forum.ansible.com/t/how-to-append-to-the-path/23670/1 "2017-02-07T16:14:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 7, 2017, 8:04pm UTC](https://forum.ansible.com/t/how-to-append-to-the-path/23670/2 "2017-02-07T20:04:23Z")

</div>

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  
&nbsp;&nbsp;&nbsp;copy:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest: /etc/profile.d/my\_custom\_path.sh  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content: "PATH=PATH:/my/custom/path"
