Skip to content

Small regression on Ansible 2.19 (Conditionals must have a boolean result) #240

@thbar

Description

@thbar

If you do not do anything specific and use the role, it defines rvm1_delete_ruby like this:

# Delete a specific version of ruby (ie. ruby-2.1.0)
rvm1_delete_ruby:

which then can optionally delete one version of Ruby, here:

- name: Delete ruby if relevant
command: '{{ rvm1_rvm }} remove {{ rvm1_delete_ruby }}'
register: rvm_delete_command
changed_when: "'#removing' in rvm_delete_command.stdout"
when: rvm1_delete_ruby is defined and rvm1_delete_ruby

While upgrading from 2.17 to 2.19, I got this error:

Details
TASK [rvm.ruby : Delete ruby if relevant] ***************************************************************************************************************************************************
[ERROR]: Task failed: Conditional result (False) was derived from value of type 'NoneType' at '<unknown>'. Conditionals must have a boolean result.

Task failed.
Origin: /Users/thbar/git/xyz/roles/rvm.ruby/tasks/rubies.yml:61:3

59   with_items: '{{ rvm1_symlink_bundler_binaries }}'
60
61 - name: Delete ruby if relevant
     ^ column 3

<<< caused by >>>

Conditional result (False) was derived from value of type 'NoneType' at '<unknown>'. Conditionals must have a boolean result.
Origin: /Users/thbar/git/xyz/roles/rvm.ruby/tasks/rubies.yml:65:9

63   register: rvm_delete_command
64   changed_when: "'#removing' in rvm_delete_command.stdout"
65   when: rvm1_delete_ruby is defined and rvm1_delete_ruby
           ^ column 9

Broken conditionals can be temporarily allowed with the `ALLOW_BROKEN_CONDITIONALS` configuration option.

fatal: [vagrant-worker-focal]: FAILED! => changed=false 
  msg: 'Task failed: Conditional result (False) was derived from value of type ''NoneType'' at ''<unknown>''. Conditionals must have a boolean result.'

Fix

The fix (without modifying the role) is quite easy:

rvm1_delete_ruby: false

I think doing the same in the role would be a good fix too, ensuring the default experience works.

Sidenote (if useful)

This is another solution to delete more versions of Ruby at once:

# The RVM ansible role does not support deleting more than one Ruby version
# https://github.com/rvm/rvm1-ansible?tab=readme-ov-file#upgrading-and-removing-old-versions-of-ruby
# So I added this custom task to delete a whole list during maintenance
- name: Delete obsolete ruby
  command: '{{ rvm1_rvm }} remove {{ item }}'
  become_user: '{{ rvm1_user }}'

and then:

- include_tasks: delete_obsolete_rubies.yml
  with_items: "{{ rubies_to_delete | default([]) }}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions