# How to setup PATH variable in an Ansible task using the environment module?

**URL:** <https://forum.ansible.com/t/how-to-setup-path-variable-in-an-ansible-task-using-the-environment-module/25819>\
**Category:** Ansible Project\
**Created:** [October 25, 2017, 3:36pm UTC](https://forum.ansible.com/t/how-to-setup-path-variable-in-an-ansible-task-using-the-environment-module/25819 "2017-10-25T15:36:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [October 25, 2017, 3:36pm UTC](https://forum.ansible.com/t/how-to-setup-path-variable-in-an-ansible-task-using-the-environment-module/25819/1 "2017-10-25T15:36:13Z")

</div>

I’m running Ansble v2.4.0.0 in a RHEL7.2 box.

I’m trying to setup the PATH variable with the following simple task, but I’m getting a syntax error.

`  
tasks/main.yml

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 25, 2017, 3:44pm UTC](https://forum.ansible.com/t/how-to-setup-path-variable-in-an-ansible-task-using-the-environment-module/25819/2 "2017-10-25T15:44:55Z")

</div>

environment is NOT a module, its a keyword that test the environment  
for your task/action.

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [October 25, 2017, 3:59pm UTC](https://forum.ansible.com/t/how-to-setup-path-variable-in-an-ansible-task-using-the-environment-module/25819/3 "2017-10-25T15:59:34Z")

</div>

Doesn’t this say that it is?

[http://docs.ansible.com/ansible/latest/playbooks\_environment.html](http://docs.ansible.com/ansible/latest/playbooks_environment.html)

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [October 25, 2017, 5:26pm UTC](https://forum.ansible.com/t/how-to-setup-path-variable-in-an-ansible-task-using-the-environment-module/25819/4 "2017-10-25T17:26:43Z")

</div>

I asked the same question in Stack Overflow [How to set existing linux environment variables with ansible?](https://stackoverflow.com/questions/46936896/how-to-set-existing-linux-environment-variables-with-ansible) and the answer there makes sense, which is the same answer Brian was alluding to. Thanks!
