# Working with rbenv-sudo (environmental variables)

**URL:** <https://forum.ansible.com/t/working-with-rbenv-sudo-environmental-variables/13183>\
**Category:** Ansible Project\
**Created:** [July 23, 2013, 9:45pm UTC](https://forum.ansible.com/t/working-with-rbenv-sudo-environmental-variables/13183 "2013-07-23T21:45:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Peck](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@Daniel\_Peck](https://forum.ansible.com/u/Daniel_Peck)\
**Post date:** [July 23, 2013, 9:45pm UTC](https://forum.ansible.com/t/working-with-rbenv-sudo-environmental-variables/13183/1 "2013-07-23T21:45:19Z")

</div>

Hi everyone,

new to ansible and loving it so far, trying to get yaml files for my standard rails deployments built and I’m very close.

The last piece of the puzzle is figuring out how to use rbenv-sudo from ansible to install nginx, a hack of a plugin that sets/allows the user to use their own rbenv environment while acting with privilege, [https://github.com/dcarley/rbenv-sudo](https://github.com/dcarley/rbenv-sudo). I know environmental variables tend to be a reoccuring question around here.

Currently my tasks look like:

vars:  
user: deployer  
nginx\_prefix: /opt/nginx

tasks:

- name: initialize rbenv  
action: shell bash /home/$user/.bashrc

- name: installing nginx  
action: shell /home/$user/.rbenv/bin/rbenv sudo passenger-install-nginx-module --auto --auto-download --extra-configure-flags=none --prefix=$nginx\_prefix

No luck though. I’ve also tried calling things more explicitly with PATH set manually (and messily I know), such as:

action: shell PATH=/home/$user/.rbenv/bin:$PATH /home/deployer/.rbenv/bin/rbenv sudo passenger-install-nginx-module --auto --auto-download --extra-configure-flags=no --prefix=$nginx\_prefix

Without any luck.

Thanks,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 24, 2013, 1:05am UTC](https://forum.ansible.com/t/working-with-rbenv-sudo-environmental-variables/13183/2 "2013-07-24T01:05:54Z")

</div>

So you can easily set the environ. on any module like so:

- modulename: foo …  
environment: splat

Where environment variable “splat” is a hash defined elsewhere

or even broken out like so:

environment:  
key1: value1  
key2: value2

Others can probably provide rbenv specific examples.
