# Set Environment help

**URL:** <https://forum.ansible.com/t/set-environment-help/21161>\
**Category:** Ansible Project\
**Created:** [April 14, 2016, 1:56pm UTC](https://forum.ansible.com/t/set-environment-help/21161 "2016-04-14T13:56:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pushparaj\_BS](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Pushparaj\_BS](https://forum.ansible.com/u/Pushparaj_BS)\
**Post date:** [April 14, 2016, 1:56pm UTC](https://forum.ansible.com/t/set-environment-help/21161/1 "2016-04-14T13:56:07Z")

</div>

Hi ,

I’m using the following to set the environment for an already extracted package to append to PATH

`

- name: Set Environment  
lineinfile: dest=‘/etc/environment’ state=present backrefs=yes regexp=‘PATH=(["]_)((?!._?{{append\_var}})._?)(["]_)$’ line=“PATH=\1\2:{{append\_var}}\3”  
`

The append\_var has been declared as follows  
`append_var:'/srv/chat/erlang/bin:/srv/chat/erlang/lib:/srv/chat/ejabberd/bin:/srv/chat/ejabberd/etc:/srv/chat/ejabberd/lib:/srv/chat/ejabberd/sbin:/srv/chat/ejabberd/share:/srv/chat/ejabberd/var/'`

While the playbook is executed it returns the below error

`  
Note: The error may actually appear before this position: line 7, column 15

- name: Set Environment  
lineinfile: dest=‘/etc/environment’ state=present backrefs=yes regexp=‘PATH=(["]_)((?!._?{{append\_var}})._?)(["]_)$’ line=“PATH=\1\2:{{append\_var}}\3”  
^  
We could be wrong, but this one looks like it might be an issue with  
missing quotes. Always quote template expression brackets when they  
start a value. For instance:  
with\_items:
- {{ foo }}  
Should be written as:  
with\_items:
- “{{ foo }}”  
`

Please guide if I’m missing some expressions

---

<div class="post-metadata">

**Author:** ![Pushparaj\_BS](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Pushparaj\_BS](https://forum.ansible.com/u/Pushparaj_BS)\
**Post date:** [April 16, 2016, 7:11am UTC](https://forum.ansible.com/t/set-environment-help/21161/2 "2016-04-16T07:11:29Z")

</div>

The last trailing / was removed from the variable and it worked .

---

<div class="post-metadata">

**Author:** ![Pushparaj\_BS](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Pushparaj\_BS](https://forum.ansible.com/u/Pushparaj_BS)\
**Post date:** [April 17, 2016, 2:30am UTC](https://forum.ansible.com/t/set-environment-help/21161/3 "2016-04-17T02:30:06Z")

</div>

The /etc/environment still does not reflect the new path
