# Execute eval from shell module to set up environment variables

**URL:** <https://forum.ansible.com/t/execute-eval-from-shell-module-to-set-up-environment-variables/29695>\
**Category:** Ansible Project\
**Created:** [February 16, 2019, 9:12pm UTC](https://forum.ansible.com/t/execute-eval-from-shell-module-to-set-up-environment-variables/29695 "2019-02-16T21:12:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user116](https://avatars.discourse-cdn.com/v4/letter/u/9fc29f/32.png) [@user116](https://forum.ansible.com/u/user116)\
**Post date:** [February 16, 2019, 9:12pm UTC](https://forum.ansible.com/t/execute-eval-from-shell-module-to-set-up-environment-variables/29695/1 "2019-02-16T21:12:23Z")

</div>

Is it possible to execute eval command from a shell module to set up environment variables ?

This is a snippet from a playbook which tries to set up environment variables by executing eval command

`  
eval $(docker-machine env DEV-MACHINE)

`

This is the result of the eval command

`

export DOCKER\_TLS\_VERIFY=“1”  
export DOCKER\_HOST=“tcp://192.168.99.100:2376”  
export DOCKER\_CERT\_PATH=“/home/user/.docker/machine/machines/DEV-MACHINE”  
export DOCKER\_MACHINE\_NAME=“DEV-MACHINE”

`

When this is executed from an ansible playbook environment variables are not set

Best Regards to the team !

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [February 18, 2019, 5:18pm UTC](https://forum.ansible.com/t/execute-eval-from-shell-module-to-set-up-environment-variables/29695/2 "2019-02-18T17:18:57Z")

</div>

You need to put those export commands in the shell initialization files. Running export will set it just for the current session, which will close when the playbook ends.

---

<div class="post-metadata">

**Author:** ![Darkhan](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Darkhan](https://forum.ansible.com/u/Darkhan)\
**Post date:** [February 18, 2019, 5:19pm UTC](https://forum.ansible.com/t/execute-eval-from-shell-module-to-set-up-environment-variables/29695/3 "2019-02-18T17:19:43Z")

</div>

You need to put those export commands in the shell initialization files. Running export will set it just for the current session, which will close when the playbook ends.

---

<div class="post-metadata">

**Author:** ![user116](https://avatars.discourse-cdn.com/v4/letter/u/9fc29f/32.png) [@user116](https://forum.ansible.com/u/user116)\
**Post date:** [February 24, 2019, 6:54pm UTC](https://forum.ansible.com/t/execute-eval-from-shell-module-to-set-up-environment-variables/29695/4 "2019-02-24T18:54:38Z")

</div>

Adrian could you be more specific what do we call shell initialization files.
