Skip to content

Instantly share code, notes, and snippets.

@jschoolcraft
Forked from bobmaerten/files_gemrc
Created April 25, 2014 13:17
Show Gist options
  • Save jschoolcraft/11289227 to your computer and use it in GitHub Desktop.
Save jschoolcraft/11289227 to your computer and use it in GitHub Desktop.
---
:sources:
- http://gems.rubyforge.org
- http://gems.github.com
gem: --no-ri --no-rdoc
---
- hosts: apps-ruby-test
sudo: yes
vars:
- rbenv_root: /usr/local/rbenv
- ruby_version: 2.0.0-p353
tasks:
- name: rbenv | install build depends
apt: pkg={{ item }} state=latest install_recommends=no
with_items:
- build-essential
- git
- libcurl4-openssl-dev
- libmysqlclient-dev
- libsqlite3-dev
- libpq-dev
- libreadline6-dev
- libssl-dev
- libxml2-dev
- libxslt1-dev
- zlib1g-dev
- libc6-dev
- libyaml-dev
- name: rbenv | update rbenv repo
git: repo=git://github.com/sstephenson/rbenv.git dest={{ rbenv_root }} version=v0.4.0
- name: rbenv | add rbenv to path
file: path=/usr/local/bin/rbenv src={{ rbenv_root }}/bin/rbenv state=link
- name: rbenv | add rbenv initialization to profile
template: src=templates/rbenv.sh.j2 dest=/etc/profile.d/rbenv.sh owner=root group=root mode=0755
- name: rbenv | check ruby-build installed
command: test -x /usr/local/bin/ruby-build
register: rbuild_present
ignore_errors: yes
- name: rbenv | create temporary directory
command: mktemp -d
register: tempdir
when: rbuild_present|failed
- name: rbenv | clone ruby-build repo
git: repo=git://github.com/sstephenson/ruby-build.git dest={{tempdir.stdout}}/ruby-build
when: rbuild_present|failed
- name: rbenv | install ruby-build
command: ./install.sh chdir={{tempdir.stdout}}/ruby-build
when: rbuild_present|failed
- name: rbenv | remove temporary directory
file: path={{tempdir.stdout}} state=absent
when: rbuild_present|failed
- name: rbenv | check ruby ruby_version installed
shell: RBENV_ROOT={{rbenv_root}} rbenv versions | grep {{ruby_version}}
register: ruby_installed
ignore_errors: yes
- name: rbenv | install ruby ruby_version
shell: RBENV_ROOT={{rbenv_root}} rbenv install {{ruby_version}}
when: ruby_installed|failed
- name: rbenv | set global ruby {{ruby_version}}
shell: RBENV_ROOT={{rbenv_root}} rbenv global {{ruby_version}}
when: ruby_installed|failed
- name: rbenv | rehash
shell: RBENV_ROOT={{rbenv_root}} rbenv rehash
when: ruby_installed|failed
- name: rbenv | set gemrc
copy: src=files/gemrc dest=/root/.gemrc owner=root group=root mode=0644
export RBENV_ROOT="{{ rbenv_root }}"
eval "$(rbenv init -)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment