# simple rails app (login shell command)

**URL:** <https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149>\
**Category:** Ansible Project\
**Created:** [May 2, 2015, 4:36pm UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149 "2015-05-02T16:36:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Muller](https://avatars.discourse-cdn.com/v4/letter/i/ad7895/32.png) [@Ivan\_Muller](https://forum.ansible.com/u/Ivan_Muller)\
**Post date:** [May 2, 2015, 4:36pm UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/1 "2015-05-02T16:36:25Z")

</div>

Hi there before all thanks fot the amazing work that you already done

Is only one thing that keep make me noise when I use Ansible, normally I use RVM to handle different versions of ruby and every time that i need to run a simple bundle to install al the gems from every app I get struggled with it

failed: [ingenyo] =\> {“changed”: true, “cmd”: “bundle”, “delta”: “0:00:00.002008”, “end”: “2015-05-02 16:08:49.070874”, “rc”: 127, “start”: “2015-05-02 16:08:49.068866”, “warnings”: }  
stderr: /bin/sh: 1: bundle: not found  
FATAL: all hosts have already failed – aborting

I know that is because is a login shell command and ansible don’t use that, but how is the Pretty way to fix that problems? I’m down to help in anything that is necessary for that

here my 2 playbooks!

Deploy.yml

- name: Clone repositorio  
git: repo=[https://github.com/mullerivan/myapp.git](https://github.com/mullerivan/myapp.git) dest=/home/vagrant/myapp accept\_hostkey=yes  
sudo: false

- name: bundle install (install the rest of the gems)  
shell: bundle  
chdir=/home/vagrant/myapp  
sudo: false

rvm.yml

- name: downloading the GPG signature  
shell: gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

- name: Installing rvm ruby and rails take 16m5.124s up to your internet conection  
shell: \curl -sSL [https://get.rvm.io](https://get.rvm.io) | bash -s stable --rails

# Ruby from source playbook ([GitHub - jgrowl/ansible-playbook-ruby-from-src: Ansible playbook to deploy ruby from source](https://github.com/jgrowl/ansible-playbook-ruby-from-src))

- name: upgrade  
action: apt update\_cache=yes upgrade=yes

- name: install ruby dependencies  
action: apt pkg={{item}} state=installed  
with\_items:

- build-essential

- automake

- bison

- autoconf

- pkg-config

- libreadline6

- libreadline6-dev

- openssl

- libssl-dev

- curl

- git-core

- zlib1g

- zlib1g-dev

- libyaml-dev

- libsqlite3-dev

- libxml2-dev

- libxslt1-dev

- curl

- name: Install app dependencies  
action: apt pkg={{item}} state=installed  
with\_items:

- libpq-dev

- nodejs

- imagemagick  
tags: package

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [May 8, 2015, 10:47am UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/2 "2015-05-08T10:47:27Z")

</div>

> Hi there before all thanks fot the amazing work that you already done
> 
> Is only one thing that keep make me noise when I use Ansible, normally I use RVM to handle different versions of ruby and every time that i need to run a simple bundle to install al the gems from every app I get struggled with it
> 
> failed: [ingenyo] =\> {“changed”: true, “cmd”: “bundle”, “delta”: “0:00:00.002008”, “end”: “2015-05-02 16:08:49.070874”, “rc”: 127, “start”: “2015-05-02 16:08:49.068866”, “warnings”: }  
> stderr: /bin/sh: 1: bundle: not found  
> FATAL: all hosts have already failed – aborting

Are you sure you already have bundler installed when you execute this? This error shows that it’s not found on remote host.

> I know that is because is a login shell command and ansible don’t use that, but how is the Pretty way to fix that problems? I’m down to help in anything that is necessary for that
> 
> here my 2 playbooks!
> 
> Deploy.yml
> 
> - name: Clone repositorio  
> git: repo=[https://github.com/mullerivan/myapp.git](https://github.com/mullerivan/myapp.git) dest=/home/vagrant/myapp accept\_hostkey=yes  
> sudo: false
> 
> - name: bundle install (install the rest of the gems)  
> shell: bundle  
> chdir=/home/vagrant/myapp  
> sudo: false

Another thing that might create you further issues: you suppose you need an argument to “bundle”, e.g. “bundle install” (no quotes).

> rvm.yml
> 
> - name: downloading the GPG signature  
> shell: gpg --keyserver hkp://[keys.gnupg.net](http://keys.gnupg.net) --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
> 
> - name: Installing rvm ruby and rails take 16m5.124s up to your internet conection  
> shell: \curl -sSL [https://get.rvm.io](https://get.rvm.io) | bash -s stable --rails

The backslash before curl – why do you need that?

> # Ruby from source playbook ([https://github.com/jgrowl/ansible-playbook-ruby-from-src](https://github.com/jgrowl/ansible-playbook-ruby-from-src))
> 
> - name: upgrade  
> action: apt update\_cache=yes upgrade=yes
> 
> - name: install ruby dependencies  
> action: apt pkg={{item}} state=installed

I think latest apt syntax requires “state=present” (no quotes)

> with\_items:
> 
> - build-essential
> 
> - automake
> 
> - bison
> 
> - autoconf
> 
> - pkg-config
> 
> - libreadline6
> 
> - libreadline6-dev
> 
> - openssl
> 
> - libssl-dev
> 
> - curl
> 
> - git-core
> 
> - zlib1g
> 
> - zlib1g-dev
> 
> - libyaml-dev
> 
> - libsqlite3-dev
> 
> - libxml2-dev
> 
> - libxslt1-dev
> 
> - curl
> 
> - name: Install app dependencies  
> action: apt pkg={{item}} state=installed

same here (“state=present”)

HTH,  
-Y.

---

<div class="post-metadata">

**Author:** ![Ivan\_Muller](https://avatars.discourse-cdn.com/v4/letter/i/ad7895/32.png) [@Ivan\_Muller](https://forum.ansible.com/u/Ivan_Muller)\
**Post date:** [May 9, 2015, 11:16pm UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/3 "2015-05-09T23:16:35Z")

</div>

**Thanks for answer but… I’ll answer between the lines**

> > Hi there before all thanks fot the amazing work that you already done
> > 
> > Is only one thing that keep make me noise when I use Ansible, normally I use RVM to handle different versions of ruby and every time that i need to run a simple bundle to install al the gems from every app I get struggled with it
> > 
> > failed: [ingenyo] =\> {“changed”: true, “cmd”: “bundle”, “delta”: “0:00:00.002008”, “end”: “2015-05-02 16:08:49.070874”, “rc”: 127, “start”: “2015-05-02 16:08:49.068866”, “warnings”: }  
> > stderr: /bin/sh: 1: bundle: not found  
> > FATAL: all hosts have already failed – aborting
> 
> Are you sure you already have bundler installed when you execute this? This error shows that it’s not found on remote host.

**Yes bundle is installed you can see that in the “- name: Installing rvm ruby and rails take 16m5.124s up to your internet conection” is part of rails and rails is installed to**  
**To make it work i use the HORRIBLE thing like that: because how i said is inside of RVM(login shell) and i use wrapper to access it**

**that way my question “how is the Pretty way to fix that problems?” I would like to create the login shell and say bundle install**

**- name: bundle install (install the rest of the gems)**  
**shell: /usr/local/rvm/wrappers/default/bundle**  
**chdir={{app\_path}}**  
**sudo: false**

> > I know that is because is a login shell command and ansible don’t use that, but how is the Pretty way to fix that problems? I’m down to help in anything that is necessary for that
> > 
> > here my 2 playbooks!
> > 
> > Deploy.yml
> > 
> > - name: Clone repositorio  
> > git: repo=[https://github.com/mullerivan/myapp.git](https://github.com/mullerivan/myapp.git) dest=/home/vagrant/myapp accept\_hostkey=yes  
> > sudo: false
> > 
> > - name: bundle install (install the rest of the gems)  
> > shell: bundle  
> > chdir=/home/vagrant/myapp  
> > sudo: false
> 
> Another thing that might create you further issues: you suppose you need an argument to “bundle”, e.g. “bundle install” (no quotes).

**No. Not really u dont need with just bundle is enough, i do it work but in a HORRIBLE way, that way my question “how is the Pretty way to fix that problems?”**

> > rvm.yml
> > 
> > - name: downloading the GPG signature  
> > shell: gpg --keyserver hkp://[keys.gnupg.net](http://keys.gnupg.net) --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
> > 
> > - name: Installing rvm ruby and rails take 16m5.124s up to your internet conection  
> > shell: \curl -sSL [https://get.rvm.io](https://get.rvm.io) | bash -s stable --rails
> 
> The backslash before curl – why do you need that?

**I know that it works with out it but for some reason is included in the official documentation can you check here [https://rvm.io/rvm/install](https://rvm.io/rvm/install)**

> > # Ruby from source playbook ([https://github.com/jgrowl/ansible-playbook-ruby-from-src](https://github.com/jgrowl/ansible-playbook-ruby-from-src))
> > 
> > - name: upgrade  
> > action: apt update\_cache=yes upgrade=yes
> > 
> > - name: install ruby dependencies  
> > action: apt pkg={{item}} state=installed
> 
> I think latest apt syntax requires “state=present” (no quotes)

**Well is working well but i gonna take the suggestion and change it to see what’s the different**

> > with\_items:
> > 
> > - build-essential
> > 
> > - automake
> > 
> > - bison
> > 
> > - autoconf
> > 
> > - pkg-config
> > 
> > - libreadline6
> > 
> > - libreadline6-dev
> > 
> > - openssl
> > 
> > - libssl-dev
> > 
> > - curl
> > 
> > - git-core
> > 
> > - zlib1g
> > 
> > - zlib1g-dev
> > 
> > - libyaml-dev
> > 
> > - libsqlite3-dev
> > 
> > - libxml2-dev
> > 
> > - libxslt1-dev
> > 
> > - curl
> > 
> > - name: Install app dependencies  
> > action: apt pkg={{item}} state=installed
> 
> same here (“state=present”)
> 
> HTH,  
> -Y.

**Thanks for your time**!

---

<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:** [May 10, 2015, 6:40am UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/4 "2015-05-10T06:40:29Z")

</div>

Hello,

if you have access to private Debian repositories I would suggest to leave the git clone and bundler part to some ci server and create a deb package from you application using fpm as packaging tool.

Use bundle install with a local vendor path, this way all gems are installed in you application directory.

It will heavily reduce your 16 minutes deployment. And you may have to install less dev packages in production…

Regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![Ivan\_Muller](https://avatars.discourse-cdn.com/v4/letter/i/ad7895/32.png) [@Ivan\_Muller](https://forum.ansible.com/u/Ivan_Muller)\
**Post date:** [May 10, 2015, 8:55pm UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/5 "2015-05-10T20:55:40Z")

</div>

Thanks, is a good idea, i’ll test it  
by the way i still interesting in how to write that feature in ansible, because i use ansible tu update my app and to run the different commands like rake: db:migrate or rake assets:precompile

But your idea for the deploy sounds good

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [May 11, 2015, 11:33am UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/6 "2015-05-11T11:33:55Z")

</div>

Ivan, I have difficulties understanding you, so can you please help me clarify the issue (if it is still relevant):

1. Can you confirm that your primary issue is running bundle to install rails app dependencies?

2. Can you confirm that you now solve the issue via creating a wrapper script located at **/usr/local/rvm/wrappers/default/bundle** , that actually does the bundle invocation? If so, can you please paste it here (consider removing sensitive information first)?

Thanks,  
-Y.

---

<div class="post-metadata">

**Author:** ![Ivan\_Muller](https://avatars.discourse-cdn.com/v4/letter/i/ad7895/32.png) [@Ivan\_Muller](https://forum.ansible.com/u/Ivan_Muller)\
**Post date:** [May 11, 2015, 11:40am UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/7 "2015-05-11T11:40:05Z")

</div>

Hi Yassen. I already solved it with that wrapper  
Code:

- name: bundle install (install the rest of the gems)  
shell: /usr/local/rvm/wrappers/default/bundle  
chdir={{rails\_app\_path}}  
sudo: false

I just want to know how is the proper way to use ansible in this case, would be nice that ansible can just detect the shell login on chdir={{rails\_app\_path}}, let me do just **bundle**

**(if a go by ssh to the server and run just bundle that works, why ansible cant do that?)**

Thanks for you time and your answers 🙂

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [May 11, 2015, 2:24pm UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/8 "2015-05-11T14:24:09Z")

</div>

Please find comments inline below:

---

<div class="post-metadata">

**Author:** ![Ivan\_Muller](https://avatars.discourse-cdn.com/v4/letter/i/ad7895/32.png) [@Ivan\_Muller](https://forum.ansible.com/u/Ivan_Muller)\
**Post date:** [May 11, 2015, 2:32pm UTC](https://forum.ansible.com/t/simple-rails-app-login-shell-command/18149/9 "2015-05-11T14:32:13Z")

</div>

never mind , is working i just want to know if is a proper way to write that…  
i dont like to write the full path of bundle, because each app will have a different one (that way i use RVM), i want to write something generic
