From 460ffb1428efcd9e41ce01ad76b13740e792fcc8 Mon Sep 17 00:00:00 2001 From: Oleg Vivtash Date: Thu, 26 Mar 2015 03:39:42 +0200 Subject: [PATCH 1/3] Works with ruby2.2.1 on Ubuntu 14.10; Prereqs setup refactored; More compilation steps --- .gitignore | 1 + tasks/main.yml | 73 ++++++++++++++++++++------------------- tasks/setup-debian.yml | 14 ++++++++ tasks/setup-redhat.yml | 10 ++++++ templates/install-ruby.j2 | 8 ----- vars/main.yml | 7 +++- 6 files changed, 68 insertions(+), 45 deletions(-) create mode 100644 .gitignore create mode 100644 tasks/setup-debian.yml create mode 100644 tasks/setup-redhat.yml delete mode 100644 templates/install-ruby.j2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 59a55da..7b48638 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,52 +1,46 @@ --- -- name: Update APT cache - apt: update_cache=yes - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Retrieve the number of cores that are available for compilation - command: nproc - register: cores -- name: Install APT prerequisite packages that are necessary to compile applications and gems with native extensions - apt: pkg={{ item }} - with_items: - - autoconf - - build-essential +- include: setup-debian.yml when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' -- name: Install yum prerequisite packages that are necessary to compile applications and gems with native extensions - yum: name="{{ item }}" - with_items: - - autoconf - - "@Developer tools" +- include: setup-redhat.yml when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'Amazon' -- name: Install APT Ruby dependencies - apt: pkg={{ item }} - state=present - with_items: ruby_apt_dependencies - when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' - -- name: Install yum Ruby dependencies - yum: name={{ item }} - with_items: ruby_yum_dependencies - when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'Amazon' +- name: Retrieve the number of cores that are available for compilation + command: nproc + register: cores - name: Download the Ruby source code get_url: url={{ ruby_download_location }} dest=/usr/local/src/ sha256sum={{ ruby_checksum }} -- name: Generate the Ruby installation script - template: src=install-ruby.j2 - dest=/usr/local/src/install-ruby.sh - owner=root - group=root - mode=700 -- name: Run the Ruby installation script - command: /usr/local/src/install-ruby.sh - creates={{ ruby_location }}/bin/ruby +- name: Extract Ruby source code + command: tar xvfz {{ ruby_source_location }}/{{ ruby_version }}.tar.gz + args: + chdir: "{{ ruby_source_location }}" + creates: "{{ ruby_source_location }}/{{ ruby_version }}" + + +- name: Configure Ruby + command: ./configure --enable-shared --prefix={{ ruby_location }} --disable-install-doc + args: + chdir: "{{ ruby_source_location }}/{{ ruby_version }}" + creates: "{{ ruby_source_location }}/{{ ruby_version }}/Makefile" + + +- name: Compile Ruby + command: make --jobs {{ cores.stdout }} + args: + chdir: "{{ ruby_source_location }}/{{ ruby_version }}" + creates: "{{ ruby_source_location }}/{{ ruby_version }}/ruby" + +- name: Install Ruby + command: make install + args: + chdir: "{{ ruby_source_location }}/{{ ruby_version }}" + creates: "{{ ruby_location }}/bin/ruby" - name: Generate the script that allows you to easily run Rake tasks with the correct RAILS_ENV environment variable, and the wrapper script that contains GC settings template: src={{ item }}.j2 @@ -62,6 +56,13 @@ command: "{{ ruby_location }}/bin/gem install bundler {{ ruby_bundler_flags }} creates={{ ruby_location }}/bin/bundle" + +- name: Delete old Ruby binaries/symlinks + file: path=/usr/local/bin/{{ item }} state=absent + with_items: ruby_symlinks + ignore_errors: yes + + - name: Make Ruby symlinks file: path=/usr/local/bin/{{ item }} src={{ ruby_location }}/bin/{{ item }} diff --git a/tasks/setup-debian.yml b/tasks/setup-debian.yml new file mode 100644 index 0000000..cf554bc --- /dev/null +++ b/tasks/setup-debian.yml @@ -0,0 +1,14 @@ +--- +- name: Update APT cache + apt: update_cache=yes + +- name: Install APT prerequisite packages that are necessary to compile applications and gems with native extensions + apt: pkg={{ item }} + with_items: + - autoconf + - build-essential + +- name: Install APT Ruby dependencies + apt: pkg={{ item }} + state=present + with_items: ruby_apt_dependencies diff --git a/tasks/setup-redhat.yml b/tasks/setup-redhat.yml new file mode 100644 index 0000000..f4dfad2 --- /dev/null +++ b/tasks/setup-redhat.yml @@ -0,0 +1,10 @@ +--- +- name: Install yum prerequisite packages that are necessary to compile applications and gems with native extensions + yum: name="{{ item }}" + with_items: + - autoconf + - "@Developer tools" + +- name: Install yum Ruby dependencies + yum: name={{ item }} + with_items: ruby_yum_dependencies diff --git a/templates/install-ruby.j2 b/templates/install-ruby.j2 deleted file mode 100644 index a58e427..0000000 --- a/templates/install-ruby.j2 +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -cd /usr/local/src/ -tar xvfz {{ ruby_version }}.tar.gz -cd {{ ruby_version }} -./configure --prefix={{ ruby_location }} --disable-install-doc -make --jobs {{ cores.stdout }} -make install diff --git a/vars/main.yml b/vars/main.yml index 078ac76..049e976 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -4,6 +4,10 @@ ruby_apt_dependencies: - libssl-dev - libyaml-dev - zlib1g-dev + - libncurses-dev + - libffi-dev + - libgdbm3 + ruby_yum_dependencies: - readline-devel @@ -20,8 +24,9 @@ ruby_symlinks: - rdoc - ri - ruby - - testrb + #- testrb ruby_location: "/opt/{{ ruby_version }}" +ruby_source_location: /usr/local/src ruby_executable: "{{ ruby_location }}/bin/ruby" From a2e297ea3b3bb67573114cd6256304dc2053d8fc Mon Sep 17 00:00:00 2001 From: Oleg Vivtash Date: Sun, 5 Apr 2015 20:28:38 +0300 Subject: [PATCH 2/3] Symlinking updated --- tasks/main.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 7b48638..1c5bf2b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -56,15 +56,9 @@ command: "{{ ruby_location }}/bin/gem install bundler {{ ruby_bundler_flags }} creates={{ ruby_location }}/bin/bundle" - -- name: Delete old Ruby binaries/symlinks - file: path=/usr/local/bin/{{ item }} state=absent - with_items: ruby_symlinks - ignore_errors: yes - - - name: Make Ruby symlinks file: path=/usr/local/bin/{{ item }} src={{ ruby_location }}/bin/{{ item }} state=link + force=true with_items: ruby_symlinks From 9f285bb1910017585508bbe7c593e1c8de4aa3b4 Mon Sep 17 00:00:00 2001 From: Oleg Vivtash Date: Mon, 6 Apr 2015 20:00:12 +0300 Subject: [PATCH 3/3] Role version added (ref librariab-ansible) --- meta/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/main.yml b/meta/main.yml index 1fd1463..e647ab5 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,4 +1,5 @@ --- +version: 1.0.1 galaxy_info: author: "Joshua Lund" description: "Ansible role that compiles and installs Ruby (https://www.ruby-lang.org) and Bundler (http://bundler.io)."