From d06975e3115304fd665754e6307cd9b170b1ce4b Mon Sep 17 00:00:00 2001 From: Daniel Ochoa Date: Fri, 31 Jul 2020 02:46:02 -0500 Subject: [PATCH 1/2] Refactor rubies install and remove tasks --- CHANGELOG.md | 1 + tasks/rubies.yml | 30 ++++++++---------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79c46f33d..f7612bd5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Fixes regression forbidding installation of rubies (#209, fixed via #207) * Fix conditional logic for detecting and removing versions of Ruby (#212) * Report when Ruby is removed and don't ignore when version listing fails (#212) +* Refactor rubies install and remove tasks, allow rvm to handle idempotency around this (#216) ### 2.1.2 2018-12-28 · [Changes](https://github.com/rvm/rvm1-ansible/compare/v2.1.1...v2.1.2) diff --git a/tasks/rubies.yml b/tasks/rubies.yml index 96ba047e5..9573019f9 100644 --- a/tasks/rubies.yml +++ b/tasks/rubies.yml @@ -1,17 +1,11 @@ --- -- name: Detect if rubies are installed - command: '{{ rvm1_rvm }} {{ item }} do true' - changed_when: False - failed_when: False - register: detect_rubies - with_items: '{{ rvm1_rubies }}' - when: rvm1_rubies is defined and rvm1_rubies | length > 0 - - name: Install rubies - command: '{{ rvm1_rvm }} install {{ item.item }} {{ rvm1_ruby_install_flags }}' - when: rvm1_rubies is defined and rvm1_rubies | length > 0 and item.rc|default(0) != 0 - with_items: '{{ detect_rubies.results }}' + command: '{{ rvm1_rvm }} install {{ item }} {{ rvm1_ruby_install_flags }}' + when: rvm1_rubies is defined and rvm1_rubies | length > 0 + with_items: '{{ rvm1_rubies }}' + register: rvm_install_rubies + changed_when: "'#importing gemset' in rvm_install_rubies.stdout" - name: Detect default ruby version command: '{{ rvm1_rvm }} alias list default' @@ -62,16 +56,8 @@ when: not '--user-install' in rvm1_install_flags and rvm1_bundler_install with_items: '{{ rvm1_symlink_bundler_binaries }}' -- name: List installed versions of Ruby (for deletion) - command: '{{ rvm1_rvm }} list strings' - changed_when: False - register: rvm1_list_installed_rubies - when: rvm1_delete_ruby is defined and rvm1_delete_ruby != '' - - name: Delete ruby if relevant command: '{{ rvm1_rvm }} remove {{ rvm1_delete_ruby }}' - register: rvm_delete_command_result - changed_when: "'#removing' in rvm_delete_command_result.stdout" - when: - - rvm1_delete_ruby is defined and rvm1_delete_ruby != '' - - rvm1_delete_ruby in rvm1_list_installed_rubies.stdout.splitlines() + register: rvm_delete_command + changed_when: "'#removing' in rvm_delete_command.stdout" + when: rvm1_delete_ruby is defined and rvm1_delete_ruby From 6cad2527441e7a485c732a642f919366ac55e92c Mon Sep 17 00:00:00 2001 From: Daniel Ochoa Date: Fri, 31 Jul 2020 02:53:51 -0500 Subject: [PATCH 2/2] fix PR number in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7612bd5c..4a3e7df3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * Fixes regression forbidding installation of rubies (#209, fixed via #207) * Fix conditional logic for detecting and removing versions of Ruby (#212) * Report when Ruby is removed and don't ignore when version listing fails (#212) -* Refactor rubies install and remove tasks, allow rvm to handle idempotency around this (#216) +* Refactor rubies install and remove tasks, allow rvm to handle idempotency around this (#219) ### 2.1.2 2018-12-28 · [Changes](https://github.com/rvm/rvm1-ansible/compare/v2.1.1...v2.1.2)