Git Product home page Git Product logo

ansible-role-ruby's Introduction

Ansible Role: Ruby

CI

Installs Ruby and bundler gem on Linux.

Requirements

None.

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

workspace: /root

The location where temporary files will be downloaded in preparation for Ruby installation.

ruby_install_bundler: true

Whether this role should install Bundler.

ruby_install_gems: []

A list of Ruby gems to install (just the name of the gem to be installed). This is meant as a simple convenience, and will only install the latest version of the gem. If you need to install gems with more options or specificity, you can do so elsewhere in your playbook.

You can also use a dictionary for each gem that allows setting the version and user_install keys for the gem Ansible module. For example:

ruby_install_gems:
  - name: bundler
    version: '< 2'
    user_install: false

You can mix the two syntaxes, using either a dict or a string (the gem name) for each gem.

ruby_install_gems_user: username

The user account under which Ruby gems will be installed. Defaults to the ansible_ssh_user if not set.

ruby_install_from_source: false

By default, this role will install whatever version of ruby is available through your system's package manager (apt or yum). You can install whatever version you like (including the latest release) by setting this to true and/or updating the ruby_download_url and ruby_version.

ruby_download_url: http://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz

The URL from which Ruby will be downloaded (only used if ruby_install_from_source is true).

ruby_version: 3.0.0

The version of ruby that will be installed (only used if ruby_install_from_source is true).

ruby_source_configure_command: ./configure --enable-shared

The configure command that will be run (only used if ruby_install_from_source is true).

ruby_rubygems_package_name: rubygems

The name of the rubygems package. Generally, the default should work; but it will be set to rubygems-integration automatically on Ubuntu Trusty (14.04).

Dependencies

None.

Example Playbook

- hosts: server
  roles:
    - role: geerlingguy.ruby

License

MIT / BSD

Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.

ansible-role-ruby's People

Contributors

benchoncy avatar captn3m0 avatar codisart avatar geerlingguy avatar jdelstrother avatar lenage avatar nkakouros avatar oxyc avatar seuros avatar sumeetpareek avatar t4k avatar vkill avatar wesgarrison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-role-ruby's Issues

Rubygems option removed from Ruby 2.5.x

So some checks are failing, e.g.:

Traceback (most recent call last):
	1: from /usr/local/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/local/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- ubygems (LoadError)
which: no sass in (/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin)

See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890751#19

This commit removes the call to the dropped option '-rubygems' in ruby
2.5, makes the run of the testsuite verbose, and, drops the fixed seed,
again. This was introduced in 213d8513e32320b84584066069d0d78bc47f713f,
but now fixed upstream.

And also https://bbs.archlinux.org/viewtopic.php?id=233309

Ruby required to build Ruby from source

On the ubuntu/bionic64 Vagrant box, installing Ruby from source fails because Ruby isn't installed. #wtf I fixed this by installing the system Ruby package first, but maybe you'd like to include it into the role.

---
- hosts: all

  tasks:
    - name: Install missing packages to ensure Ruby role succeeds
      apt:
        name:
          - git
          - ruby
        state: present

    - name: Install Ruby from source
      include_role:
        name: geerlingguy.ruby
      vars:
        ruby_install_from_source: true
        ruby_download_url: http://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.2.tar.gz
        ruby_version: 2.5.2

Run as non root user

When I try to use this role on Ubuntu 16.04, I get the following error:

TASK [geerlingguy.ruby : Install packages required to build ruby (Debian).] *************************
failed: [rs-wh-webhead0] (item=[u'build-essential', u'zlib1g-dev', u'libssl-dev', u'libyaml-dev', u'libreadline6-dev', u'zlib1g-dev', u'libncurses5-dev', u'libffi-dev', u'libgdbm3', u'libgdbm-dev']) => {"cache_update_time": 1517631114, "cache_updated": false, "changed": false, "item": ["build-essential", "zlib1g-dev", "libssl-dev", "libyaml-dev", "libreadline6-dev", "zlib1g-dev", "libncurses5-dev", "libffi-dev", "libgdbm3", "libgdbm-dev"], "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"     install 'build-essential' 'zlib1g-dev' 'libssl-dev' 'libyaml-dev' 'libreadline6-dev' 'zlib1g-dev' 'libncurses5-dev' 'libffi-dev' 'libgdbm-dev'' failed: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root?\n", "rc": 100, "stderr": "E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root?\n", "stderr_lines": ["E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)", "E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?"], "stdout": "", "stdout_lines": []}

Is the role written so that it must be run by the root user?

Allow Ruby gems to be installed by role

To make gem installation a little more convenient (so you don't have to do it in your own playbook if you're just installing a gem or two...), add the ability to install a set of gems via this role (default it to []).

Install the Bundler Gem failed on Ubuntu 14.04

Running this on a totally pristine vagrant box, got the following:

TASK: [geerlingguy.ruby | Install the Bundler Gem.] ***************************
failed: [10.10.10.2] => {"cmd": "/usr/local/bin/gem install --no-user-install --no-rdoc --no-ri bundler", "failed": true, "rc": 1}
stderr: ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

msg: ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

FATAL: all hosts have already failed -- aborting

ansible_ssh_user is not defined when running via packer

Saw this when I added this to a recent packer build.

    amazon-ebs: TASK [geerlingguy.ruby : Define ruby_install_gems_user.] ***********************
    amazon-ebs: task path: /opt/ansible/third-party-roles/geerlingguy.ruby/tasks/main.yml:17
    amazon-ebs: fatal: [127.0.0.1]: FAILED! => {"failed": true, "msg": "'ansible_ssh_user' is undefined"}

Define ruby_install_gems_user fails because ansible_ssh_user is undefined

Issue
The task Define ruby_install_gems_user fails because ansible_ssh_user is undefined.

TASK [geerlingguy.ruby : Define ruby_install_gems_user.] ***********************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "'ansible_ssh_user' is undefined"}

According to the Ansible documentation, the variable was deprecated in Ansible 2.0

Ansible 2.0 has deprecated the “ssh” from ansible_ssh_user, ansible_ssh_host, and ansible_ssh_port to become ansible_user, ansible_host, and ansible_port. If you are using a version of Ansible prior to 2.0, you should continue using the older style variables (ansible_ssh_*). These shorter variables are ignored, without warning, in older versions of Ansible.

Investigation shows that, as of Ansible 2.0, ansible_user is not set when the --user option isn't provided.

Steps to reproduce
Playbook:


---
- hosts: localhost
  become: yes
  roles:
    - geerlingguy.ruby
  1. Create a new a new Vagrant virtual machine with Ansible 2.0.2.0 installed
  2. Install the geerlingguy.ruby role, version 2.3.1
  3. ansible-playbook playbook.yml (note: no options specified)

Version
Ansible installed via package in ppa:ansible/ansible, role installed via ansible-galaxy

vagrant@vagrant-ubuntu-trusty-64:~$ ansible-playbook --version
ansible-playbook 2.0.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ansible-galaxy list -p roles/ geerlingguy.ruby
- geerlingguy.ruby, 2.3.1

RH7 openssl-static missing, causes role to fail

Running the role on a RH7.4 (AWS instance) gives:

TASK [geerlingguy.ruby : Install ruby and rubygems.] *************************************************************************************************
skipping: [34.242.36.252] => (item=[]) 

TASK [geerlingguy.ruby : Update apt cache.] **********************************************************************************************************
skipping: [34.242.36.252]

TASK [geerlingguy.ruby : Set rubygems package name for Ubuntu 14.04.] ********************************************************************************
skipping: [34.242.36.252]

TASK [geerlingguy.ruby : Install ruby and rubygems.] *************************************************************************************************
skipping: [34.242.36.252] => (item=[]) 

TASK [geerlingguy.ruby : Install packages required to build ruby (RedHat).] **************************************************************************
failed: [34.242.36.252] (item=[u'zlib-devel', u'openssl-static']) => {"changed": false, "failed": true, "item": ["zlib-devel", "openssl-static"], "msg": "No package matching 'openssl-static' found available, installed or updated", "rc": 126, "results": ["No package matching 'openssl-static' found available, installed or updated"]}

PLAY RECAP *******************************************************************************************************************************************
34.242.36.252              : ok=18   changed=1    unreachable=0    failed=1  

changing this task allows the role to complete:

# geerlingguy.ruby/tasks/install-from-source.yml

- name: Install packages required to build ruby (RedHat).
  yum: "name={{ item }} state=present"
  with_items:
    - zlib-devel
    - openssl-devel
#    - openssl-static
  when: ansible_os_family == 'RedHat'

I'm making an assumption that the -devel rpm is what ruby needs, but I'm not 100% sure that's the only (or a good) fix for this. I think openssl-static works for RH6, but it was dropped in RH7.

cheers,

install_from_source does not upgrade ruby

In the task install_from_source.yml the following step should install ruby on your host:

- name: Build ruby.
  command: >
    {{ item }}
    chdir={{ workspace }}/ruby-{{ ruby_version }}
    creates=/usr/local/bin/ruby
  with_items:
    - "{{ ruby_source_configure_command }}"
    - make
    - make install

However, if you installed Ruby once e.g. in version 2.4 and now want to upgrade to version 2.5 the task will be marked as ok because the path /usr/local/bin/ruby was created with version 2.4.

Extract from the https://docs.ansible.com/ansible/latest/modules/command_module.html docs

creates: A filename or (since 2.0) glob pattern. If it already exists, this step won't be run. 

"couldn't resolve module/action 'gem'" with ansible 2.10.9

Hey!

Ive got the following error using this role (v3.0.0) with ansible 2.10.9:

$ ansible-playbook -v -i ansible/staging ansible/site.yml 
Using /etc/ansible/ansible.cfg as config file
ERROR! couldn't resolve module/action 'gem'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/<user>/.ansible/roles/geerlingguy.ruby/tasks/main.yml': line 32, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

# Install Bundler and configured gems.
- name: Install Bundler.
  ^ here

The used gem task is not installed automatically anymore so we need to ansible-galaxy collection install community.general first as per https://docs.ansible.com/ansible/latest/collections/community/general/gem_module.html

Maybe there is a possibility to define this dependency in this galaxy role to simplify this.

Ruby installed gems non-root user?

I used Vagrant and Ansible as provision. There is options to install gems or give access for non-root users?

I set:

ruby_install_gems: ['compass:0.12.6', 'sass:3.4.9']

All works fine, but gems installed in /root/.gem/ruby/2.1.0/bin and vagrant user doesn't has access for binary files like compass.

Solution for me, instead of using ruby_install_gems i wrote task:

  - name: Install Ruby gems
    sudo: no
    gem: name={{ item.name }} version={{ item.version }} state=present
    with_items: ruby_gems

Failed to build gem native extension

Hi, Jeff.

I found an error on CentOS 6.6 and Ruby role. Here is the error log:

TASK: [geerlingguy.ruby | Install configured gems.] ***************************
failed: [185.86.76.75] => (item=compass) => {"cmd": "/usr/bin/gem install --user-install --no-rdoc --no-ri compass", "failed": true, "item": "compass", "rc": 1}
stderr: WARNING:  You don't have /root/.gem/ruby/1.8/bin in your PATH,
      gem executables will not run.
ERROR:  Error installing compass:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby -r ./siteconf20150624-25661-xtsd0c-0.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /root/.gem/ruby/1.8/gems/ffi-1.9.8 for inspection.
Results logged to /root/.gem/ruby/1.8/extensions/x86_64-linux/1.8/ffi-1.9.8/gem_make.out

stdout: Building native extensions.  This could take a while...

msg: WARNING:  You don't have /root/.gem/ruby/1.8/bin in your PATH,
      gem executables will not run.
ERROR:  Error installing compass:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby -r ./siteconf20150624-25661-xtsd0c-0.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /root/.gem/ruby/1.8/gems/ffi-1.9.8 for inspection.
Results logged to /root/.gem/ruby/1.8/extensions/x86_64-linux/1.8/ffi-1.9.8/gem_make.out

FATAL: all hosts have already failed -- aborting

My configuration is the following:

# Ruby.
ruby_install_gems:
  - compass

Gems are not installing with user permissions

I'm still pretty new to Ruby and Ansible, but I think I've got a halfway-decent grasp of the basics.

That said, I don't know what to do to get gems like colorls and lolcat to work. I've installed them using this role:

# vars.yml
ruby_install_gems:
  - colorls
  - lolcat
ruby_install_gems_user: "sturm"

However, when I SSH into the machine where this role was run, I cannot run colorls I cannot even run any gem installation:

 sturm@ansible-test  ~  colorls

 sturm@ansible-test  ~  gem which colorls
/home/sturm/.gem/ruby/2.5.0/gems/colorls-1.4.1/lib/colorls.rb

 sturm@ansible-test  ~  gem install colorls
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.5.0 directory.

 sturm@ansible-test  ~ 

This is on a DigitalOcean freshly-created Ubuntu 18.04 droplet. It was even created with Ansible. If it helps, here's the playbook containing tasks for after the provisioning of the droplet:

---
# digitalocean.yml
- hosts: do
  remote_user: root
  gather_facts: false

  vars_files:
    - vars.yml

  pre_tasks:
    - name: Wait for port 22 to become available
      local_action: "wait_for port=22 host={{ inventory_hostname }}"
    
    - name: Gathering Facts
      setup:

  tasks:
    - name: Ensure user is created
      include_role:
        name: weareinteractive.users

    - name: Ensure git is installed
      import_role:
        name: geerlingguy.git

    - name: Ensure zsh and all plugins are installed
      include_role:
        name: viasite-ansible.zsh

    - name: Ensure Ruby and gems are installed
      include_role:
        name: geerlingguy.ruby

- hosts: do
  remote_user: "{{ users[0].username }}"
  gather_facts: false

  vars_files:
    - vars.yml

  tasks:
    - name: Ensure SSH key pair is created
      openssh_keypair:
        path: ~/.ssh/id_github
        state: present
        type: "ed25519"
        comment: "test@digitalocean"
      register: keys

    - name: Ensure SSH key is on GitHub
      github_key:
        name: "test@digitalocean"
        token: "{{ github_access_token }}"
        state: present
        pubkey: "{{ keys.public_key }}"

Please let me know if you need any more information.

Clean up syntax

There are some things like using pkg for package install (instead of name), and the folded scalar syntax, which should be cleaned up.

workspace role variable not namespaced

Since Ansible role variables have play scope, the workspace role variable should be namespaced like the rest of the role variables to avoid a name collision. For example, it could be renamed to ruby_workspace.

failing to execute make and sudo make install

First of all, thanks so much for putting this together. This is super helpful!
I use this role as part of preparing a docker image.

I came across a failure to execute make and sudo make install when I got to the build task:

...
TASK: [geerlingguy.ruby | Install packages required to build ruby (Debian).] ***
... (output omitted) ...
checking for pthread.h... yes
checking if make is GNU make... no
checking for safe null command for make... 
failed: [localhost] => (item=make) => {"cmd": "make", "failed": true, "item": "make", "rc": 2}
msg: [Errno 2] No such file or directory
failed: [localhost] => (item=sudo make install) => {"changed": true, "cmd": ["sudo", "make", "install"], "delta": "0:00:00.084430", "end": "2015-03-13 02:03:22.352892", "item": "sudo make install", "rc": 1, "start": "2015-03-13 02:03:22.268462", "warnings": []}
stderr: sudo: make: command not found

The docker base image I am using is ansible/ubuntu14.04-ansible:stable. Presumably this base image has minimal packages pre-installed. So I looked into the packages required to install ruby from source on ubuntu. After installing build-essential libffi-dev libgdbm-dev libncurses5-dev libreadline-dev libssl-dev libyaml-dev zlib1g-dev, the make error from the build task went away.

So, I think the role depends on the build tools being available in order to install ruby from source. Thoughts?

User installed gems are not available in PATH

The binaries provided from packages installed with ruby_install_gems are not available in the users shell.

vagrant@drupalvm-project:~$ gem list -d | grep 'compass ' -A 4
compass (1.0.3)
    Authors: Chris Eppstein, Scott Davis, Eric M. Suzanne, Brandon
    Mathis, Nico Hagenburger
    Homepage: http://compass-style.org
    Installed at: /home/vagrant/.gem/ruby/1.9.1
vagrant@drupalvm-project:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/vagrant/.composer/vendor/bin

According the ruby FAQ the path needs to be added to ~/.bashrc

if which ruby >/dev/null && which gem >/dev/null; then
    PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi

CentOS 7 build failing sass gem test install due to old Ruby version

TASK [geerlingguy.ruby : Install configured gems.] *****************************
    failed: [instance] (item=sass) => {"changed": false, "cmd": "/bin/gem install --user-install --no-document sass", "item": "sass", "msg": "WARNING:  You don't have /root/.gem/ruby/bin in your PATH,
    gem executables will not run.
ERROR:  Error installing sass:
  rb-inotify requires Ruby version >= 2.2.", "rc": 1, "stderr": "WARNING:  You don't have /root/.gem/ruby/bin in your PATH,
    gem executables will not run.
ERROR:  Error installing sass:
  rb-inotify requires Ruby version >= 2.2.
", "stderr_lines": ["WARNING:  You don't have /root/.gem/ruby/bin in your PATH,", "    gem executables will not run.", "ERROR:  Error installing sass:", "  rb-inotify requires Ruby version >= 2.2."], "stdout": "Successfully installed rb-fsevent-0.10.3
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.25
", "stdout_lines": ["Successfully installed rb-fsevent-0.10.3", "Building native extensions.  This could take a while...", "Successfully installed ffi-1.9.25"]}

See failed build: https://travis-ci.org/geerlingguy/ansible-role-ruby/jobs/468516715#L765

ruby-2.5.1 install fails

It looks like the tar file downloaded extracts to a directory to 2.4.1...

TASK [geerlingguy.ruby : Build ruby.] ******************************************
failed: [34.240.2.49] (item=./configure --enable-shared) => {"changed": false, "item": "./configure --enable-shared", "module_stderr": "Shared connection to 34.240.2.49 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_h2woCs/ansible_module_command.py\", line 248, in <module>\r\n    main()\r\n  File \"/tmp/ansible_h2woCs/ansible_module_command.py\", line 192, in main\r\n    os.chdir(chdir)\r\nOSError: [Errno 2] No such file or directory: '/root/ruby-2.5.1'\r\n", "msg": "MODULE FAILURE", "rc": 1}
failed: [34.240.2.49] (item=make) => {"changed": false, "item": "make", "module_stderr": "Shared connection to 34.240.2.49 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_b9_nz9/ansible_module_command.py\", line 248, in <module>\r\n    main()\r\n  File \"/tmp/ansible_b9_nz9/ansible_module_command.py\", line 192, in main\r\n    os.chdir(chdir)\r\nOSError: [Errno 2] No such file or directory: '/root/ruby-2.5.1'\r\n", "msg": "MODULE FAILURE", "rc": 1}
failed: [34.240.2.49] (item=make install) => {"changed": false, "item": "make install", "module_stderr": "Shared connection to 34.240.2.49 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_Sdx7dr/ansible_module_command.py\", line 248, in <module>\r\n    main()\r\n  File \"/tmp/ansible_Sdx7dr/ansible_module_command.py\", line 192, in main\r\n    os.chdir(chdir)\r\nOSError: [Errno 2] No such file or directory: '/root/ruby-2.5.1'\r\n", "msg": "MODULE FAILURE", "rc": 1}
	to retry, use: --limit @/home/lloyd/Sites/provisioning/api/setup/production.retry

PLAY RECAP *********************************************************************
34.240.2.49                : ok=15   changed=12   unreachable=0    failed=1   

lloyd@xps13:~/Sites/provisioning/api$ ssg -i ~/Dropbox/keys/olio-api-production.pem [email protected]
No command 'ssg' found, did you mean:
 Command 'stg' from package 'stgit' (universe)
 Command 'ss' from package 'iproute2' (main)
 Command 'sng' from package 'sng' (universe)
 Command 'sg' from package 'login' (main)
 Command 'ssh' from package 'openssh-client' (main)
 Command 'srg' from package 'srg' (universe)
 Command 'ssr' from package 'soundscaperenderer-common' (universe)
ssg: command not found
lloyd@xps13:~/Sites/provisioning/api$ ssh -i ~/Dropbox/keys/olio-api-production.pem [email protected]
Welcome to Ubuntu 17.10 (GNU/Linux 4.13.0-31-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


*** System restart required ***
Last login: Fri Apr 20 10:26:59 2018 from 82.69.59.244
ubuntu@ip-10-0-0-80:~$ sudo ls /root/
ruby-2.4.1  ruby-2.5.1.tar.gz

ruby_install_gems_user does not have effect

Hi,

I set the ruby_install_gems_user variable to a user on my vars/main.yml archive, like this

ruby_install_gems_user: "deploy"
ruby_version: 2.6.4
ruby_install_from_source: true 
ruby_download_url: http://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.4.tar.gz
ruby_install_bundler: true

I set the variable with and without quotes but the result is the same. This is the gem environment output

gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.6.4 (2019-08-28 patchlevel 104) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.6.0
  - USER INSTALLATION DIRECTORY: /home/nomar/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /home/nomar/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.6.0
     - /home/nomar/.gem/ruby/2.6.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/local/games
     - /usr/games

The ssh user is nomar

Some advice?

Thanks in advance

Allow Ruby to be installed from packages

...at least on all the popular distributions. Change this role to work like the geerlingguy.git role; basically install from packages by default, but allow ruby_install_from_source to be set to true, triggering the source install.

installation fails on Ubuntu 20.04 for Ruby 2.5.2

Running the role on a Ubuntu 20.04 fails.

Configuration values are

ruby_install_gems_user: deploy
ruby_version: 2.5.2
ruby_install_from_source: true
ruby_download_url: "https://cache.ruby-lang.org/pub/ruby/{{ ruby.main_version }}/ruby-{{ ruby.specific_version }}.tar.gz"
TASK [geerlingguy.ruby : Build ruby.] *************************************************************************************************
failed: [linode] (item=./configure --enable-shared) => {"ansible_loop_var": "item", "changed": true, "cmd": ["./configure", "--enable-shared"], "delta": "0:00:00.298521", "end": "2021-07-05 16:08:44.201176", "item": "./configure --enable-shared", "msg": "non-zero return code", "rc": 127, "start": "2021-07-05 16:08:43.902655", "stderr": "configure: error: cannot run /bin/bash tool/config.sub", "stderr_lines": ["configure: error: cannot run /bin/bash tool/config.sub"], "stdout": "checking for ruby... false", "stdout_lines": ["checking for ruby... false"]}
failed: [linode] (item=make) => {"ansible_loop_var": "item", "changed": true, "cmd": ["make"], "delta": "0:00:00.010114", "end": "2021-07-05 16:08:45.349582", "item": "make", "msg": "non-zero return code", "rc": 2, "start": "2021-07-05 16:08:45.339468", "stderr": "make: *** No targets specified and no makefile found.  Stop.", "stderr_lines": ["make: *** No targets specified and no makefile found.  Stop."], "stdout": "", "stdout_lines": []}
failed: [linode] (item=make install) => {"ansible_loop_var": "item", "changed": true, "cmd": ["make", "install"], "delta": "0:00:00.006554", "end": "2021-07-05 16:08:46.621562", "item": "make install", "msg": "non-zero return code", "rc": 2, "start": "2021-07-05 16:08:46.615008", "stderr": "make: *** No rule to make target 'install'.  Stop.", "stderr_lines": ["make: *** No rule to make target 'install'.  Stop."], "stdout": "", "stdout_lines": []}

Ubuntu 16.04 builds failing with 'Error installing sass: Failed to build gem native extension.

Failed build: https://travis-ci.org/geerlingguy/ansible-role-ruby/jobs/338313098

"WARNING:  You don't have /root/.gem/ruby/2.3.0/bin in your PATH,
    gem executables will not run.
ERROR:  Error installing sass:
  ERROR: Failed to build gem native extension.

    current directory: /root/.gem/ruby/2.3.0/gems/ffi-1.9.21/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20180207-1796-yci6zh.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /root/.gem/ruby/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.21/mkmf.log

current directory: /root/.gem/ruby/2.3.0/gems/ffi-1.9.21/ext/ffi_c
make \"DESTDIR=\" clean

current directory: /root/.gem/ruby/2.3.0/gems/ffi-1.9.21/ext/ffi_c
make \"DESTDIR=\"
Running autoreconf for libffi
/root/.gem/ruby/2.3.0/gems/ffi-1.9.21/ext/ffi_c/libffi/autogen.sh: 2: exec: autoreconf: not found
libffi.mk:6: recipe for target '\"/root/.gem/ruby/2.3.0/gems/ffi-1.9.21/ext/ffi_c/libffi-x86_64-linux-gnu\"/.libs/libffi_convenience.a' failed
make: *** [\"/root/.gem/ruby/2.3.0/gems/ffi-1.9.21/ext/ffi_c/libffi-x86_64-linux-gnu\"/.libs/libffi_convenience.a] Error 127

make failed, exit code 2

Gem files will remain installed in /root/.gem/ruby/2.3.0/gems/ffi-1.9.21 for inspection.
Results logged to /root/.gem/ruby/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.21/gem_make.out

Updating ruby version does not work.

I used role to install ruby from source on a given machine. Later, I changed ruby version/url to a newer release and re-ran the role against the machine. I was expecting new version of ruby to be installed on the system. However role skips installation of ruby from source if there is any ruby already present on the system.

Is this an expected and correct behaviour for the role? If not, I can try to fix it and submit a PR for it.

Thanks,
Iuri

Ruby 2.3 builds from source fail on Ubuntu 18

Using Ansible 2.7:

ansible 2.7.0
  config file = None
  configured module search path = ['/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.0 (default, Jun 29 2018, 20:13:13) [Clang 9.1.0 (clang-902.0.39.2)]

Provisioning against Ubuntu 18:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"

Attempting to build/use ruby 2.3.7:

ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux]

When using the role, ruby would build fine but this error would occur for the install of bundler:

2018-10-18 10:18:26,695 p=1026 u=shane |  TASK [ruby : Install Bundler.] ***********************************************************************************
2018-10-18 10:18:26,695 p=1026 u=shane |  Thursday 18 October 2018  10:18:26 -0400 (0:00:00.765)       0:04:46.810 ******
2018-10-18 10:18:27,478 p=1026 u=shane |  fatal: [ubuntu18]: FAILED! => {
    "changed": false,
    "cmd": "/usr/local/bin/gem install --no-user-install --no-document bundler",
    "rc": 1
}

STDERR:

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources



MSG:

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

I did some tire kicking and google fuing and found out that libssl-dev package is not compatible with ruby2.3. Being able to specify different ruby build packages and ensuring that libssl1.0-dev was installed first and that libssl-dev was not present resolved this for me on Ubuntu 18, building ruby 2.3.7 from source.

refs:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.