Loading rvm in remote server before a playbook starts

32 views
Skip to first unread message

Derrick Mar

unread,
Aug 19, 2015, 10:02:19 PM8/19/15
to Ansible Project
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

Brian Coca

unread,
Aug 20, 2015, 10:34:58 PM8/20/15
to Ansible Project
>- name: Deploy my app
> environment:
> 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.



--
Brian Coca

Derrick Mar

unread,
Aug 22, 2015, 6:15:40 PM8/22/15
to Ansible Project
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.

Marcus Franke

unread,
Aug 23, 2015, 7:29:16 AM8/23/15
to ansible...@googlegroups.com
On Sat, Aug 22, 2015 at 03:15:40PM -0700, Derrick Mar wrote:
> 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.
>

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

--
may you always grok in fullness

Derrick Mar

unread,
Aug 23, 2015, 4:41:23 PM8/23/15
to Ansible Project
I see thanks Marcus. I'll go ahead keep fiddling with this and see what I come up with.
Reply all
Reply to author
Forward
0 new messages