rvm1-ansible icon indicating copy to clipboard operation
rvm1-ansible copied to clipboard

Gem install package failed, and Symlink is not work

Open zarr12steven opened this issue 8 years ago • 4 comments

ENVIORNMENT

remote server: CentOS Linux release 7.2.1511 (Core)

PURPOSE

After install rvm, and I want to use gem install compass

Ansible Config

I always use run root, my playbook is below there

---
- name: CentOS | Basic Setup
  hosts: app
  roles:
    - { role: rvm_io.ruby,
        tags: ruby,
        rvm1_rubies: ['ruby-2.0.0'],
        rvm1_user: 'root',
        become: True,
        rvm1_install_flags: '--auto-dotfiles'
      }

I add new file in rvm_io.ruby/tasks/gem.yml

---
- name: Install Compass
  gem: name=compass  state=present

and i add this file to rvm_io.ruby/tasks/main.yml

---

- name: Install RVM
  include: 'rvm.yml'
  become: yes
  become_user: '{{ rvm1_user }}'

- name: Install Ruby and Gems
  include: 'rubies.yml'
  become: yes
  become_user: '{{ rvm1_user }}'

- name: Install Gem Packages
  include: 'gem.yml'
  become: yes
  become_user: '{{ rvm1_user }}'

First error:

TASK [rvm_io.ruby : Install Compass] *******************************************
task path: /etc/ansible/roles/rvm_io.ruby/tasks/gem.yml:2
fatal: [192.168.1.10]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to find required executable gem"}

so I fixed rvm_io.ruby/tasks/gem.yml

---
- name: Install Compass
  gem: name=compass  state=present executable=/root/.rvm/rubies/ruby-2.0.0-p648/bin/gem

Secondary error

TASK [rvm_io.ruby : Install Compass] *******************************************
fatal: [192.168.1.10]: FAILED! => {"changed": false, "cmd": "/root/.rvm/rubies/ruby-2.0.0-p648/bin/ruby query -n '^compass$'", "failed": true, "msg": "/root/.rvm/rubies/ruby-2.0.0-p648/bin/ruby: No such file or directory -- query (LoadError)", "rc": 1, "stderr": "/root/.rvm/rubies/ruby-2.0.0-p648/bin/ruby: No such file or directory -- query (LoadError)\n", "stdout": "", "stdout_lines": []}

Question1: but I don't have any idea, what can I do ?

Question2: and I want to know why the symlink not works ?

TASK [rvm_io.ruby : Symlink ruby related binaries on the system path] **********
task path: /etc/ansible/roles/rvm_io.ruby/tasks/rubies.yml:45
skipping: [192.168.1.10] => (item=erb)  => {"changed": false, "item": "erb", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=executable-hooks-uninstaller)  => {"changed": false, "item": "executable-hooks-uninstaller", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=gem)  => {"changed": false, "item": "gem", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=irb)  => {"changed": false, "item": "irb", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=rake)  => {"changed": false, "item": "rake", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=rdoc)  => {"changed": false, "item": "rdoc", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=ri)  => {"changed": false, "item": "ri", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=ruby)  => {"changed": false, "item": "ruby", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=testrb)  => {"changed": false, "item": "testrb", "skip_reason": "Conditional check failed", "skipped": true}

TASK [rvm_io.ruby : Symlink bundler binaries on the system path] ***************
task path: /etc/ansible/roles/rvm_io.ruby/tasks/rubies.yml:55
skipping: [192.168.1.10] => (item=bundle)  => {"changed": false, "item": "bundle", "skip_reason": "Conditional check failed", "skipped": true}
skipping: [192.168.1.10] => (item=bundler)  => {"changed": false, "item": "bundler", "skip_reason": "Conditional check failed", "skipped": true}

zarr12steven avatar Dec 16 '16 11:12 zarr12steven

@zarr12steven Did you tried adding the installation path rvm1_install_path?

lpaulmp avatar Dec 20 '16 00:12 lpaulmp

@lpaulmp I use default rvm1_install_path in rvm_io.ruby/defaults/main.yml

# Install path for rvm (defaults to user based install)
rvm1_install_path: '~/.rvm'

but when I added rvm1_symlink_to: '/bin' into my playbook file /etc/asnible/playbooks/centos.yml, then TASK [rvm_io.ruby : Symlink ruby related binaries on the system path] is working,below is my playbook

---
- name: CentOS | Basic Setup
  hosts: app
  roles:
    - { role: rvm_io.ruby,
        tags: ruby,
        rvm1_rubies: ['ruby-2.0.0'],
        rvm1_user: 'root',
        become: True,
        rvm1_rvm_check_for_updates: False,
        rvm1_symlink_to: '/bin',
        rvm1_install_flags: '--auto-dotfiles'
      }

zarr12steven avatar Dec 27 '16 03:12 zarr12steven

@zarr12steven Did you ever resolve this?

haslinger avatar Sep 29 '17 12:09 haslinger

I've spent a couple days fighting with the gem ansible module and environment configuration. Frustrated I've changed to just using shell invocations. With the stock gem module I never get my gems installed under ~/.rvm but always at ~/.gem.

I've needed to explicit a correct PATH too, in my case:

  environment:
    PATH: /home/deploy/.rvm/gems/ruby-2.3.1/bin:/home/deploy/.rvm/gems/ruby-2.3.1@global/bin:/home/deploy/.rvm/rubies/ruby-2.3.1/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/deploy/.rvm/bin:/home/deploy/.local/bin:/home/deploy/bin:/home/deploy/.gem/ruby/2.3.0/bin

Please consider add something about this to the documentation.

Other than this, thanks for the job!

olea avatar Jul 12 '19 09:07 olea