diff --git a/cdist/conf/type/__rvm_ruby/gencode-remote b/cdist/conf/type/__rvm_ruby/gencode-remote index 0003cfe7..f1de3906 100755 --- a/cdist/conf/type/__rvm_ruby/gencode-remote +++ b/cdist/conf/type/__rvm_ruby/gencode-remote @@ -24,23 +24,24 @@ user="$(cat "$__object/parameter/user")" default="$(cat "$__object/parameter/default" 2>/dev/null || true)" state_should="$(cat "$__object/parameter/state")" -if [ "$state_is" != "$state_should" ]; then - case "$state_should" in - present) - echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\ - "rvm install $ruby\"" - case "$default" in - no) - ;; - *) - echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\ - "rvm use --default $ruby\"" - ;; - esac - ;; - absent) - echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\ - "rvm remove $ruby\"" - ;; - esac -fi +[ "$state_is" = "$state_should" ] && exit 0 + +case "$state_should" in + present) + echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\ + "rvm install $ruby\"" + if [ -f "$__object/parameter/default" ]; then + echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\ + "rvm use --default $ruby\"" + fi + ;; + absent) + echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\ + "rvm remove $ruby\"" + ;; + + *) + echo "Unknown state $state_should" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__rvm_ruby/man.text b/cdist/conf/type/__rvm_ruby/man.text index 90a7b654..dbbab85e 100644 --- a/cdist/conf/type/__rvm_ruby/man.text +++ b/cdist/conf/type/__rvm_ruby/man.text @@ -23,7 +23,7 @@ state:: BOOLEAN PARAMETERS ------------------ default: - If set to anything but "no" (the default), set the given version as default + Set the given version as default EXAMPLES -------- @@ -33,7 +33,7 @@ EXAMPLES __rvm_ruby ruby-1.9.3-p0 --user thelonious --state present # Install ruby 1.9.3 through rvm for user ornette and make it the default -__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default yes +__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default # Remove ruby 1.9.3 for user john __rvm_ruby ruby-1.9.3-p0 --user john --state absent diff --git a/cdist/conf/type/__rvm_ruby/parameter/optional b/cdist/conf/type/__rvm_ruby/parameter/boolean similarity index 100% rename from cdist/conf/type/__rvm_ruby/parameter/optional rename to cdist/conf/type/__rvm_ruby/parameter/boolean