--- - name: check if proper ruby version is installed shell: RBENV_ROOT={{ rbenv_root }} rbenv versions | grep {{ ruby_version }} register: ruby_installed ignore_errors: yes - name: install proper ruby version shell: RBENV_ROOT={{ rbenv_root }} rbenv install {{ ruby_version }} when: ruby_installed|failed - name: set global ruby shell: RBENV_ROOT={{ rbenv_root }} rbenv global {{ ruby_version }} - name: rehash rbenv shell: RBENV_ROOT={{ rbenv_root }} rbenv rehash