Skip to content

Instantly share code, notes, and snippets.

@kayo-tozaki
Created April 25, 2016 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kayo-tozaki/128ca8fe6e1e699f0c78b768e91079f8 to your computer and use it in GitHub Desktop.
Save kayo-tozaki/128ca8fe6e1e699f0c78b768e91079f8 to your computer and use it in GitHub Desktop.
install ruby via rbenv
---
- hosts: ruby
name: install ruby require packages for actioning server
become: yes
vars:
RBENV_ROOT: /usr/local/rbenv
user: hogehoge
group: fugafuga
tasks:
- name: groupadd docker hogehoge
user: name={{ user }} groups={{ user }},{{ group }} append=yes
- name: install require packages for rbenv
yum: name={{ item }} state=present
with_items:
- git
- zlib
- zlib-devel
- openssl
- openssl-devel
- readline
- readline-devel
- sqlite-devel
- name: download rbenv repository
git: repo=https://github.com/sstephenson/rbenv.git dest={{ RBENV_ROOT }}
- hosts: ruby
name: install ruby via rbenv
vars:
RBENV_ROOT: /usr/local/rbenv
ruby_version: 2.0.0-p598
tasks:
- name: add rbenv path
lineinfile: >
dest=/home/hogehoge/.bashrc
line='RBENV_ROOT="/usr/local/rbenv"'
create=yes
- name: add ruby path
lineinfile: >
dest=/home/hogehoge/.bashrc
line='PATH="${RBENV_ROOT}/bin:/sbin/:${PATH}"'
create=yes
- name: set rbenv's path
lineinfile: >
dest=/home/hogehoge/.bashrc
line='eval "$(rbenv init -)"'
create=yes
- name: download ruby-build repository
git: repo=https://github.com/sstephenson/ruby-build.git dest=/home/hogehoge/.rbenv/plugins/ruby-build
- name: check ruby installed version
shell: bash -lc "rbenv versions"
register: ruby_installed_version
- name: install ruby via rbenv
shell: bash -lc "rbenv install 2.0.0-p598"
when: ruby_installed_version.stdout_lines.count("{{ ruby_version }}")
- name: set global rbenv
shell: bash -lc "rbenv global 2.0.0-p598"
when: ruby_installed_version.stdout_lines.count("{{ ruby_version }}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment