Ansible playbook to install compass

140 views
Skip to first unread message

yaron idan

unread,
Feb 21, 2016, 12:05:37 PM2/21/16
to Ansible Project
'm receiving an error when trying to install compass using a playbook (on an AWS EC2 instance)
Usually we use the following script to install compass - 

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

I've tried converting this to script to the following playbook -
---
- 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 && /usr/bin/gem install compass\""
...

deploy is not a sudoer, but when I try to install compass manually it succeeds, and as a playbook I receive the following error - You don't have write permissions into the /var/lib/gems/1.9.1 directory.

I've tried installing compass any other way, including the one suggested here - https://groups.google.com/forum/#!searchin/ansible-project/compass/ansible-project/Xg9OC0eA3xo/Jd1hqEJb1v4J, but everything I try fails with various errors.
Has anyone encountered this issue and prevailed?

Brian Coca

unread,
Feb 21, 2016, 7:06:00 PM2/21/16
to ansible...@googlegroups.com
​for /var/lib/gems you probably need root, not deploy3​, remote the become_user line (it defaults to root).


----------
Brian Coca

yaron idan

unread,
Feb 22, 2016, 6:03:21 AM2/22/16
to Ansible Project
Brian, if you're ever in Israel, please do let me buy you a beer.
I indeed need root access to this gem path, but I acually intended to use a different executible (owned by deploy3) and forgot to use the correct path.
Thanks!
Reply all
Reply to author
Forward
0 new messages