# Loading rvm in remote server before a playbook starts

**URL:** <https://forum.ansible.com/t/loading-rvm-in-remote-server-before-a-playbook-starts/19060>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 19, 2015, 5:20pm UTC](https://forum.ansible.com/t/loading-rvm-in-remote-server-before-a-playbook-starts/19060 "2015-08-19T17:20:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derrick\_Mar](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Derrick\_Mar](https://forum.ansible.com/u/Derrick_Mar)\
**Post date:** [August 19, 2015, 5:20pm UTC](https://forum.ansible.com/t/loading-rvm-in-remote-server-before-a-playbook-starts/19060/1 "2015-08-19T17:20:38Z")

</div>

Hello! Does anyone know how to load rvm in a playbook so that it’s available in {{ ansible\_env.PATH }} ?

- name: Deploy my app  
environment:  
PATH: "{{ ansible\_env.PATH }}

This does not include /home/ubuntu/.rvm/gems/ruby-2.2.2/wrappers

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 21, 2015, 2:34am UTC](https://forum.ansible.com/t/loading-rvm-in-remote-server-before-a-playbook-starts/19060/2 "2015-08-21T02:34:52Z")

</div>

> - name: Deploy my app  
> environment:  
> &nbsp;&nbsp;&nbsp;PATH: "{{ ansible\_env.PATH }}

This is basically a noop, you are assigning the PATH ansible normally  
gets to the PATH, also environment is not a task, it is a play/task  
directive.

---

<div class="post-metadata">

**Author:** ![Derrick\_Mar](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Derrick\_Mar](https://forum.ansible.com/u/Derrick_Mar)\
**Post date:** [August 22, 2015, 10:15pm UTC](https://forum.ansible.com/t/loading-rvm-in-remote-server-before-a-playbook-starts/19060/3 "2015-08-22T22:15:40Z")

</div>

Hey Brian. Thanks for the response. Yeah I definitely agree this is a noop. My question is how do I make is so that it loads RVM and ansible\_env.PATH will include paths such as /home/ubuntu/.rvm/gems/ruby-2.2.2/wrappers. For example, immediately when I SSH into my EC2 instance it automatically loads RVM. I’d like to do the same with ansible when I ssh.

---

<div class="post-metadata">

**Author:** ![Marcus\_Franke](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@Marcus\_Franke](https://forum.ansible.com/u/Marcus_Franke)\
**Post date:** [August 23, 2015, 11:29am UTC](https://forum.ansible.com/t/loading-rvm-in-remote-server-before-a-playbook-starts/19060/4 "2015-08-23T11:29:05Z")

</div>

Hi,

the problem with this is, that you are loading your .rvm environment probably  
from some kind of .profile or the login shell you are using.

When Ansible does its login into the destination server it is running in an  
empty environment like a cron job.

You have to wrap your script in a wrapper script, that would enable your rvm  
environment inside your task. Maybe you should reconsider using a ruby version  
from rvm for system tasks, you may be trying to perform.

Greetings,  
/mf

---

<div class="post-metadata">

**Author:** ![Derrick\_Mar](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Derrick\_Mar](https://forum.ansible.com/u/Derrick_Mar)\
**Post date:** [August 23, 2015, 8:41pm UTC](https://forum.ansible.com/t/loading-rvm-in-remote-server-before-a-playbook-starts/19060/5 "2015-08-23T20:41:23Z")

</div>

I see thanks Marcus. I’ll go ahead keep fiddling with this and see what I come up with.
