Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow skipping installation of rubies #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 55 additions & 51 deletions tasks/rubies.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,66 @@
---

- name: Detect rubies
command: '{{ rvm1_rvm }} list strings'
register: rvm_list_strings
changed_when: False

- name: Install rubies
command: '{{ rvm1_rvm }} install {{ item }} {{ rvm1_ruby_install_flags }}'
loop: '{{ rvm1_rubies | difference(rvm_list_strings.stdout_lines) }}'
block:
- name: Detect rubies
command: '{{ rvm1_rvm }} list strings'
register: rvm_list_strings
changed_when: False

- name: Install rubies
command: '{{ rvm1_rvm }} install {{ item }} {{ rvm1_ruby_install_flags }}'
loop: '{{ rvm1_rubies | difference(rvm_list_strings.stdout_lines) }}'

- name: Detect default ruby version
command: '{{ rvm1_rvm }} alias list default'
changed_when: False
register: detect_default_ruby_version
- name: Detect default ruby version
command: '{{ rvm1_rvm }} alias list default'
changed_when: False
register: detect_default_ruby_version

- name: Select default ruby
command: '{{ rvm1_rvm }} alias create default {{ rvm1_default_ruby_version }}'
when: detect_default_ruby_version.stdout|default() == '' or
rvm1_default_ruby_version not in detect_default_ruby_version.stdout
- name: Select default ruby
command: '{{ rvm1_rvm }} alias create default {{ rvm1_default_ruby_version }}'
when:
- detect_default_ruby_version.stdout|default() == '' or
rvm1_default_ruby_version not in detect_default_ruby_version.stdout

- name: Detect installed ruby patch number
shell: >
{{ rvm1_rvm }} list strings | grep {{ item }} | tail -n 1
with_items: '{{ rvm1_rubies }}'
changed_when: False
register: ruby_patch
check_mode: no # Run in normal mode when in --check mode (http://docs.ansible.com/ansible/playbooks_checkmode.html)
- name: Detect installed ruby patch number
shell: >
{{ rvm1_rvm }} list strings | grep {{ item }} | tail -n 1
with_items: '{{ rvm1_rubies }}'
changed_when: False
register: ruby_patch
check_mode: no # Run in normal mode when in --check mode (http://docs.ansible.com/ansible/playbooks_checkmode.html)

- name: Install bundler if not installed
shell: >
ls {{ rvm1_install_path }}/wrappers/{{ item.stdout }}
| if ! grep "^bundler " ; then {{ rvm1_install_path }}/wrappers/{{ item.stdout }}/gem install bundler ; fi
args:
creates: '{{ rvm1_install_path }}/wrappers/{{ item.stdout }}/bundler'
with_items: '{{ ruby_patch.results }}'
when: rvm1_bundler_install
register: bundler_install
changed_when: '"Successfully installed bundler" in bundler_install.stdout'
- name: Install bundler if not installed
shell: >
ls {{ rvm1_install_path }}/wrappers/{{ item.stdout }}
| if ! grep "^bundler " ; then {{ rvm1_install_path }}/wrappers/{{ item.stdout }}/gem install bundler ; fi
args:
creates: '{{ rvm1_install_path }}/wrappers/{{ item.stdout }}/bundler'
with_items: '{{ ruby_patch.results }}'
when: rvm1_bundler_install
register: bundler_install
changed_when: '"Successfully installed bundler" in bundler_install.stdout'

- name: Symlink ruby related binaries on the system path
file:
state: 'link'
src: '{{ rvm1_install_path }}/wrappers/default/{{ item }}'
dest: '{{ rvm1_symlink_to }}/{{ item }}'
owner: '{{ root_user }}'
group: '{{ root_group }}'
when: not '--user-install' in rvm1_install_flags and rvm1_symlink
with_items: '{{ rvm1_symlink_binaries }}'
- name: Symlink ruby related binaries on the system path
file:
state: 'link'
src: '{{ rvm1_install_path }}/wrappers/default/{{ item }}'
dest: '{{ rvm1_symlink_to }}/{{ item }}'
owner: '{{ root_user }}'
group: '{{ root_group }}'
when: not '--user-install' in rvm1_install_flags and rvm1_symlink
with_items: '{{ rvm1_symlink_binaries }}'

- name: Symlink bundler binaries on the system path
file:
state: 'link'
src: '{{ rvm1_install_path }}/wrappers/default/{{ item }}'
dest: '{{ rvm1_symlink_to }}/{{ item }}'
owner: '{{ root_user }}'
group: '{{ root_group }}'
when: not '--user-install' in rvm1_install_flags and rvm1_bundler_install and rvm1_symlink
with_items: '{{ rvm1_symlink_bundler_binaries }}'
- name: Symlink bundler binaries on the system path
file:
state: 'link'
src: '{{ rvm1_install_path }}/wrappers/default/{{ item }}'
dest: '{{ rvm1_symlink_to }}/{{ item }}'
owner: '{{ root_user }}'
group: '{{ root_group }}'
when: not '--user-install' in rvm1_install_flags and rvm1_bundler_install and rvm1_symlink
with_items: '{{ rvm1_symlink_bundler_binaries }}'
when:
- rvm1_rubies|length > 0

- name: Delete ruby if relevant
command: '{{ rvm1_rvm }} remove {{ rvm1_delete_ruby }}'
Expand Down