ansible-ruby/tasks/main.yml

83 lines
2.3 KiB
YAML
Raw Normal View History

2022-04-18 01:40:27 +02:00
---
- name: Install ruby-install dependencies
apt:
name:
- bash
- grep
- curl
- tar
- bzip2
- patch
- build-essential
- name: Check if ruby-install is installed
shell: which ruby-install && ruby-install --version
register: ruby_install_check
failed_when: false
changed_when: "ruby_install_check.stdout.find('ruby-install: ' + ruby_install_version) == -1"
- when: "ruby_install_check.stdout.find('ruby-install: ' + ruby_install_version) == -1"
block:
- name: Download ruby-install
get_url:
url: https://github.com/postmodern/ruby-install/archive/refs/tags/v{{ ruby_install_version }}.tar.gz
dest: /tmp/ruby-install-v{{ ruby_install_version }}.tar.gz
- name: Extract ruby-install
unarchive:
src: /tmp/ruby-install-v{{ ruby_install_version }}.tar.gz
dest: /tmp/
copy: no
- name: Install ruby-install
become: yes
command:
chdir: /tmp/ruby-install-{{ ruby_install_version }}
cmd: make install
- name: Check if chruby is installed
shell: which chruby-exec && chruby-exec --version
register: chruby_check
failed_when: false
changed_when: "chruby_check.stdout.find('chruby version ' + chruby_version) == -1"
- when: "chruby_check.stdout.find('chruby version ' + chruby_version) == -1"
block:
- name: Download chruby
get_url:
url: https://github.com/postmodern/chruby/archive/refs/tags/v{{ chruby_version }}.tar.gz
dest: /tmp/chruby-v{{ chruby_version }}.tar.gz
- name: Extract chruby
unarchive:
src: /tmp/chruby-v{{ chruby_version }}.tar.gz
dest: /tmp/
copy: no
- name: Install chruby
become: yes
command:
chdir: /tmp/chruby-{{ chruby_version }}
cmd: make install
- name: Setup chruby
become: yes
command:
chdir: /tmp/chruby-{{ chruby_version }}
cmd: ./scripts/setup.sh
- name: Check if ruby is installed
shell: test -x /opt/rubies/ruby-{{ ruby_version }}/bin/ruby && /opt/rubies/ruby-{{ ruby_version }}/bin/ruby --version
register: ruby_check
failed_when: false
changed_when: ruby_check.rc != 0
- name: Set fact for ruby installation
set_fact:
ruby_installed: "{{ ruby_check.rc != 0 }}"
- name: Install ruby
become: yes
command: ruby-install ruby {{ ruby_version }}
when: ruby_installed