Working with rbenv-sudo (environmental variables)

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. 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,

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.