Set Environment help

22 views
Skip to first unread message

Pushparaj BS

unread,
Apr 14, 2016, 10:09:03 AM4/14/16
to Ansible Project
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

Pushparaj BS

unread,
Apr 16, 2016, 3:11:29 AM4/16/16
to Ansible Project
The last trailing / was removed from the variable and it worked .

Pushparaj BS

unread,
Apr 16, 2016, 10:30:06 PM4/16/16
to Ansible Project
The /etc/environment still does not reflect the new path
Reply all
Reply to author
Forward
0 new messages