I'm trying to use Ansible to install compass, which is needed for one of our services, on an EC2 server. Usually we install it manually using the following commands -
curl -L https://get.rvm.io | bash -s stable
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.2
rvm use 2.1.2 --default
gem install compass
And then run compass compile successfully. Now when I try to run these commands with an Ansible playbook (using the shell module) the compass command is not found by the system.
I have tried using RVM official Ansible role (https://github.com/rvm/rvm1-ansible), and all I got is more errors.
I've tried installing rubydev and rubygems-integration using apt and then installing the gem using the gem module. This does recognise the compass command but when I try to compile or even show the compass version it returns errors. Here is the error for running compass -v, for example:
Errno::ENOENT on line ["25"] of /usr/lib/ruby/vendor_ruby/compass/version.rb: No such file or directory - /usr/lib/ruby/vendor_ruby/compass/../../VERSION.yml
Run with --trace to see the full backtrace
This is the playbook that managed to install compass, but left me with the errors I've mentioned:
---
- hosts: "{{ host_name }}"
become: yes
become_method : sudo
tasks:
- name: install ruby-dev
apt:
name: ruby-dev
- name: install rubygems
apt:
name: rubygems-integration
- name: install ruby compass
apt:
name: ruby-compass
...
Would love some help.
This is the playbook that eventually worked for me for installing compass -
---
- hosts: "{{ host_name }}"
become: yes
become_user : deploy3
tasks:
#- name: get gpg
# shell: "gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3"
- name: install rvm
shell: "curl -L https://get.rvm.io | bash -s stable"
- name: install rvm 2.1.2
shell: "/home/deploy2/.rvm/bin/rvm install 2.1.2"
- name: use rvm 2.1.2 by default and install compass
shell: "bash -lc \"/home/deploy2/.rvm/bin/rvm use 2.1.2 --default && /home/deploy3/.rvm/rubies/ruby-2.1.2/bin/gem install compass\""
...