Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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