# setting env variables causing syntax error

**URL:** <https://forum.ansible.com/t/setting-env-variables-causing-syntax-error/34728>\
**Category:** Ansible Project\
**Created:** [March 5, 2021, 8:38pm UTC](https://forum.ansible.com/t/setting-env-variables-causing-syntax-error/34728 "2021-03-05T20:38:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VB\_C](https://avatars.discourse-cdn.com/v4/letter/v/b4bc9f/32.png) [@VB\_C](https://forum.ansible.com/u/VB_C)\
**Post date:** [March 5, 2021, 8:38pm UTC](https://forum.ansible.com/t/setting-env-variables-causing-syntax-error/34728/1 "2021-03-05T20:38:23Z")

</div>

hello folks I am unable to set env variables, so that app\_user is able to run app as a linux service. can someone help ?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [March 5, 2021, 9:27pm UTC](https://forum.ansible.com/t/setting-env-variables-causing-syntax-error/34728/2 "2021-03-05T21:27:34Z")

</div>

Have a good look at  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_environment.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html) and make sure you understand what it says.

> ## hello folks I am unable to set env variables, so that app\_user is able to run app as a linux service. can someone help ?
> 
> # tasks file for dvmt {{ app\_name }}
> 
> - name: include per-app variables  
> include\_vars:  
> file: …/…/…/vars/{{ ENV }}-{{platform\_type}}.yml
> 
> - name: create app user {{ app\_user }}  
> user:  
> name: “{{ app\_user }}”  
> state: present
> 
> - name: install packages  
> yum:  
> name: “{{ item }}”  
> state: present  
> with\_items:
> 
> - “python36u”
> 
> - “python36u-pip”
> 
> - “{{ packages }}”
> 
> - include\_tasks: replace-freetds.yml  
> when: use\_isrg\_freetds or use\_isrg\_freetds\_force
> 
> - name: create directories  
> file:  
> path: “{{ item }}”  
> state: directory  
> owner: “{{ app\_user }}”  
> group: “{{ app\_user }}”  
> mode: 0755  
> with\_items:
> 
> - “{{ directories }}”
> 
> - name: copy extra packages  
> unarchive:  
> src: “{{ [item.name](http://item.name) }}”  
> dest: “{{ item.dest }}”  
> with\_items:
> 
> - “{{ extra\_packages }}”  
> when: extra\_packages|length \> 0
> 
> - name: remove existing virtual environment  
> file:  
> path: /opt/intuitive/{{ app\_name }}/{{ app\_version }}  
> state: absent  
> when: remove\_first is defined and remove\_first  
> notify: restart {{ servicename }}
> 
> - debug:  
> msg: "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* pip\_server {{ pip\_server }} \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* pip\_serverport {{ pip\_serverport }} "
> 
> - name: install pip packages  
> pip:  
> name: “{{[item.name](http://item.name)}}”  
> version: “{{item.version}}”  
> extra\_args: “–index-url=http://{{ pip\_server }}:{{ pip\_serverport }} --trusted-host {{ pip\_server }}”  
> virtualenv: /opt/intuitive/{{ app\_name }}/{{ app\_version }}  
> virtualenv\_command: “{{ virtualenv\_cmd }}”  
> with\_items:
> 
> - “{{ pip\_packages }}”
> 
> - name: set current symlink to this version  
> file:  
> src: /opt/intuitive/{{ app\_name }}/{{ app\_version }}  
> dest: /opt/intuitive/{{ app\_name }}/current  
> state: link  
> notify: restart {{ servicename }}
> 
> - name: configure the config file  
> template:  
> src: templates/{{ app\_config\_template }}  
> dest: /etc/intuitive/{{ app\_name }}/{{ app\_config\_name }}  
> owner: “{{ app\_user }}”  
> mode: 0600  
> notify: restart {{ servicename }}
> 
> - name: setup certificate file  
> copy:  
> content: “{{trusted\_certs}}”  
> dest: “{{cert\_file}}”  
> when: trusted\_certs is defined and cert\_file is defined  
> notify: restart {{ servicename }}
> 
> - name: copy service file  
> template:  
> src: templates/{{ service\_config\_template }}  
> dest: /etc/systemd/system/{{ servicename }}  
> notify: restart {{ servicename }}
> 
> - name: enforce directory permissions  
> file:  
> dest: “{{ item }}”  
> owner: “{{ app\_user }}”  
> group: “{{ app\_user }}”  
> recurse: yes  
> with\_items:
> 
> - “{{ directories }}”
> 
> - name: “enforce write permissions on /var/tmp/intuitive/dvmt-file-manager to file-sender”  
> command: “setfacl -R -m g:app-user:rwx /var/tmp/intuitive/dvmt-file-manager/ & setfacl -R -d -m g:app-user:rwX /var/tmp/intuitive/dvmt-file-manager/”  
> when: (app\_user == “app-user”)
> 
> - name: setup environment variable  
> environment:  
> db\_url: “mssql+pymssql://{{app\_db\_user}}:{{app\_db\_password}}@{{app\_db\_server}}:{{app\_db\_port}}/{{app\_db\_name}}”  
> pki\_client\_cacert\_password: “{{pki\_client\_cacert\_password}}”

This means nothing, there is no such module ‘environment’.
