Skip to content

Commit

Permalink
Remove the python-httplib2 dependency
Browse files Browse the repository at this point in the history
Rather than check the remote VERSION with the 'uri' Ansible module
I decided to just always run rvm update unless you specifically disable
that in the default options.

The benefits of this change is that the role no longer depends on any
packages and CentOS 7 does not have python-httplib2 anyways.

The cons of this change is that the update takes an additional 2-3
seconds to run when it was skipped previously unless needed. However, with the
elimination of quite a few tasks and logic the overall run speed of the
role is faster than before.
  • Loading branch information
nickjj committed Oct 16, 2014
1 parent 98a4eb8 commit a1faa54
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 36 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ rvm1_install_path: '/usr/local/lib/rvm'
# make sure you ADD the --user-install flag below
rvm1_install_flags: '--auto-dotfiles'
# Should rvm always be upgraded?
rvm1_rvm_force_upgrade_installer: False
# URLs for the latest installer and version
# URL for the latest installer script
rvm1_rvm_latest_installer: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer'
rvm1_rvm_stable_version_number: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/VERSION'
# Time in seconds before re-running apt-get update
# This is only used to download the httplib library so Ansible's URI module works
apt_cache_valid_time: 86400
# rvm version to use
rvm1_rvm_version: 'stable'
# Check and update rvm, disabling this will force rvm to never update
rvm1_rvm_check_for_updates: True
```

## Example playbook
Expand Down
14 changes: 6 additions & 8 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ rvm1_install_path: '/usr/local/lib/rvm'
# make sure you ADD the --user-install flag below
rvm1_install_flags: '--auto-dotfiles'

# Should rvm always be upgraded?
rvm1_rvm_force_upgrade_installer: False

# URLs for the latest installer and version
# URL for the latest installer script
rvm1_rvm_latest_installer: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer'
rvm1_rvm_stable_version_number: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/VERSION'

# Time in seconds before re-running apt-get update
# This is only used to download the httplib library so Ansible's URI module works
apt_cache_valid_time: 86400
# rvm version to use
rvm1_rvm_version: 'stable'

# Check and update rvm, disabling this will force rvm to never update
rvm1_rvm_check_for_updates: True
6 changes: 0 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
---

- include: 'debian.yml'
when: ansible_os_family == 'Debian'

- include: 'redhat.yml'
when: ansible_os_family == 'RedHat'

- include: 'rvm.yml'
- include: 'rubies.yml'
21 changes: 7 additions & 14 deletions tasks/rvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,28 @@
register: rvm_current_version
when: rvm_binary.stat.exists

- name: Detect stable rvm version
uri:
url: '{{ rvm1_rvm_stable_version_number }}'
return_content: True
register: rvm_stable_version_number
when: '"://" in rvm1_rvm_stable_version_number'

- name: Install rvm installer
get_url:
url: '{{ rvm1_rvm_latest_installer }}'
dest: '{{ rvm1_temp_download_path }}/rvm-installer.sh'
when: not rvm_installer.stat.exists or rvm1_rvm_force_upgrade_installer
when: not rvm_installer.stat.exists

- name: Configure rvm installer
file:
path: '{{ rvm1_temp_download_path }}/rvm-installer.sh'
mode: 0755
when: not rvm_binary.stat.exists or rvm1_rvm_force_upgrade_installer
when: not rvm_binary.stat.exists

- name: Install rvm stable
- name: Install rvm
command: >
{{ rvm1_temp_download_path }}/rvm-installer.sh stable
{{ rvm1_temp_download_path }}/rvm-installer.sh {{ rvm1_rvm_version }}
--path {{ rvm1_install_path }} {{ rvm1_install_flags }}
when: not rvm_binary.stat.exists

- name: Update rvm
shell: '{{ rvm1_rvm }} get stable && {{ rvm1_rvm }} reload'
when: rvm_binary.stat.exists and
rvm_stable_version_number.content | default(rvm1_rvm_stable_version_number) | replace('\n', '') > rvm_current_version.stdout.split()[1]
shell: '{{ rvm1_rvm }} get {{ rvm1_rvm_version }} && {{ rvm1_rvm }} reload'
changed_when: False
when: rvm_binary.stat.exists and rvm1_rvm_check_for_updates

- name: Configure rvm
command: '{{ rvm1_rvm }} autolibs 3'
Expand Down

0 comments on commit a1faa54

Please sign in to comment.