I developed an Ansible role that installs chruby and another one that installs ruby using ruby-install.
I would like to use chruby in my Ansible playbooks, but the chruby
command is not available to the command
and shell
modules, even if chruby works fine if I login via SSH with the same user I am running the playbook with.
This is what I tried:
Ensuring that chruby is available to all users by deploying the following script to
/etc/profile.d/chruby.sh
, as suggested in chruby's README:if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then source /usr/local/share/chruby/chruby.sh source /usr/local/share/chruby/auto.sh fi
Running a task with the
command
orshell
modules (using/bin/bash
as executable) to manually runsource /usr/local/share/chruby/chruby.sh
andsource /usr/local/share/chruby/auto.sh
before executing acommand
task forchruby
In both cases I got the following error: chruby: command not found
.
How can I run chruby within an Ansible play?