From 11be25116374e52ef734f6353f689c34010df37d Mon Sep 17 00:00:00 2001 From: Evax Software Date: Fri, 13 Jan 2012 08:28:13 +0100 Subject: [PATCH 1/7] add rvm types --- conf/type/__rvm/explorer/state | 26 +++++++++++ conf/type/__rvm/gencode-remote | 39 ++++++++++++++++ conf/type/__rvm/man.text | 45 +++++++++++++++++++ conf/type/__rvm/parameter/required | 1 + conf/type/__rvm_gem/explorer/state | 39 ++++++++++++++++ conf/type/__rvm_gem/gencode-remote | 43 ++++++++++++++++++ conf/type/__rvm_gem/man.text | 53 ++++++++++++++++++++++ conf/type/__rvm_gem/manifest | 38 ++++++++++++++++ conf/type/__rvm_gem/parameter/optional | 1 + conf/type/__rvm_gem/parameter/required | 3 ++ conf/type/__rvm_gemset/explorer/state | 37 +++++++++++++++ conf/type/__rvm_gemset/gencode-remote | 52 +++++++++++++++++++++ conf/type/__rvm_gemset/man.text | 55 +++++++++++++++++++++++ conf/type/__rvm_gemset/manifest | 35 +++++++++++++++ conf/type/__rvm_gemset/parameter/optional | 1 + conf/type/__rvm_gemset/parameter/required | 2 + conf/type/__rvm_ruby/explorer/state | 32 +++++++++++++ conf/type/__rvm_ruby/gencode-remote | 45 +++++++++++++++++++ conf/type/__rvm_ruby/man.text | 54 ++++++++++++++++++++++ conf/type/__rvm_ruby/manifest | 33 ++++++++++++++ conf/type/__rvm_ruby/parameter/optional | 1 + conf/type/__rvm_ruby/parameter/required | 2 + 22 files changed, 637 insertions(+) create mode 100755 conf/type/__rvm/explorer/state create mode 100755 conf/type/__rvm/gencode-remote create mode 100644 conf/type/__rvm/man.text create mode 100644 conf/type/__rvm/parameter/required create mode 100755 conf/type/__rvm_gem/explorer/state create mode 100755 conf/type/__rvm_gem/gencode-remote create mode 100644 conf/type/__rvm_gem/man.text create mode 100755 conf/type/__rvm_gem/manifest create mode 100644 conf/type/__rvm_gem/parameter/optional create mode 100644 conf/type/__rvm_gem/parameter/required create mode 100755 conf/type/__rvm_gemset/explorer/state create mode 100755 conf/type/__rvm_gemset/gencode-remote create mode 100644 conf/type/__rvm_gemset/man.text create mode 100755 conf/type/__rvm_gemset/manifest create mode 100644 conf/type/__rvm_gemset/parameter/optional create mode 100644 conf/type/__rvm_gemset/parameter/required create mode 100755 conf/type/__rvm_ruby/explorer/state create mode 100755 conf/type/__rvm_ruby/gencode-remote create mode 100644 conf/type/__rvm_ruby/man.text create mode 100755 conf/type/__rvm_ruby/manifest create mode 100644 conf/type/__rvm_ruby/parameter/optional create mode 100644 conf/type/__rvm_ruby/parameter/required diff --git a/conf/type/__rvm/explorer/state b/conf/type/__rvm/explorer/state new file mode 100755 index 00000000..92fa6e07 --- /dev/null +++ b/conf/type/__rvm/explorer/state @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +user="$__object_id" +if su - $user -c "[ -d \"\$HOME/.rvm\" ]" ; then + echo "installed" +else + echo "removed" +fi diff --git a/conf/type/__rvm/gencode-remote b/conf/type/__rvm/gencode-remote new file mode 100755 index 00000000..f306979a --- /dev/null +++ b/conf/type/__rvm/gencode-remote @@ -0,0 +1,39 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +user="$__object_id" +state_is="$(cat "$__object/explorer/state")" +state_should="$(cat "$__object/parameter/state")" +if [ "$state_is" != "$state_should" ]; then + case "$state_should" in + installed) + cat << DONE +su - $user -c "bash -s stable < <(curl -s \ +https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)" +DONE + ;; + removed) + cat << DONE +su - $user -c "rm -Rf \"\\\$HOME/.rvm\"; +sed -i '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\"" +DONE + ;; + esac +fi diff --git a/conf/type/__rvm/man.text b/conf/type/__rvm/man.text new file mode 100644 index 00000000..d54e2d1b --- /dev/null +++ b/conf/type/__rvm/man.text @@ -0,0 +1,45 @@ +cdist-type__rvm(7) +================== +Evax Software + + +NAME +---- +cdist-type__rvm - Install rvm for a given user + + +DESCRIPTION +----------- +RVM is the Ruby enVironment Manager for the Ruby programming language. + + +REQUIRED PARAMETERS +------------------- +state:: + Either "installed" or "removed". + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install rvm for user billie +__rvm billie --state installed + +# Remove rvm +__rvm billie --state removed +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__rvm_ruby(7) +- cdist-type__rvm_gemset(7) +- cdist-type__rvm_gem(7) + + +COPYING +------- +Copyright \(C) 2012 Evax Software. Free use of this software is granted under +the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__rvm/parameter/required b/conf/type/__rvm/parameter/required new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/conf/type/__rvm/parameter/required @@ -0,0 +1 @@ +state diff --git a/conf/type/__rvm_gem/explorer/state b/conf/type/__rvm_gem/explorer/state new file mode 100755 index 00000000..d4cca9cb --- /dev/null +++ b/conf/type/__rvm_gem/explorer/state @@ -0,0 +1,39 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +gem="$__object_id" +gemset="$(cat "$__object/parameter/gemset")" +ruby="$(echo "$gemset" | cut -d '@' -f 1)" +gemsetname="$(echo "$gemset" | cut -d '@' -f2)" +user="$(cat "$__object/parameter/user")" +if su - $user -c "[ ! -d \"\$HOME/.rvm\" ]" ; then + echo "removed" + exit 0 +fi +if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" +rvm list | grep $ruby"; then + if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" +rvm use $ruby; rvm gemset list | grep $gemsetname > /dev/null && +rvm use $gemset && gem list | grep $gem"; then + echo "installed" + exit 0 + fi +fi +echo "removed" diff --git a/conf/type/__rvm_gem/gencode-remote b/conf/type/__rvm_gem/gencode-remote new file mode 100755 index 00000000..8b784ac3 --- /dev/null +++ b/conf/type/__rvm_gem/gencode-remote @@ -0,0 +1,43 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +gem="$__object_id" +gemset="$(cat "$__object/parameter/gemset")" +ruby="$(echo "$gemset" | cut -d '@' -f 1)" +gemsetname="$(echo "$gemset" | cut -d '@' -f 2)" +state_is="$(cat "$__object/explorer/state")" +user="$(cat "$__object/parameter/user")" +state_should="$(cat "$__object/parameter/state")" +if [ "$state_is" != "$state_should" ]; then + case "$state_should" in + installed) + cat << DONE +su - $user -c "source \"\\\$HOME/.rvm/scripts/rvm\" +rvm use $gemset; gem install $gem" +DONE + ;; + removed) + cat << DONE +su - $user -c "source \"\\\$HOME/.rvm/scripts/rvm\" +rvm use $gemset; gem uninstall $gem" +DONE + ;; + esac +fi diff --git a/conf/type/__rvm_gem/man.text b/conf/type/__rvm_gem/man.text new file mode 100644 index 00000000..951884b8 --- /dev/null +++ b/conf/type/__rvm_gem/man.text @@ -0,0 +1,53 @@ +cdist-type__rvm_gemset(7) +========================== +Evax Software + + +NAME +---- +cdist-type__rvm_gem - Manage Ruby gems through rvm + + +DESCRIPTION +----------- +RVM is the Ruby enVironment Manager for the Ruby programming language. + + +REQUIRED PARAMETERS +------------------- +user:: + The remote user account to use +gemset:: + The gemset to use +state:: + Either "installed" or "removed". + +OPTIONAL PARAMETERS +------------------- +default:: + Make the selected gemset the default + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install the rails gem in gemset ruby-1.9.3-p0@myset for user bill +__rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill --state installed + +# Remove it +__rvm_ruby rails --gemset ruby-1.9.3-p0@myset --user bill --state removed +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__rvm(7) +- cdist-type__rvm_ruby(7) +- cdist-type__rvm_gemset(7) + + +COPYING +------- +Copyright \(C) 2012 Evax Software. Free use of this software is granted under +the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__rvm_gem/manifest b/conf/type/__rvm_gem/manifest new file mode 100755 index 00000000..737dbe75 --- /dev/null +++ b/conf/type/__rvm_gem/manifest @@ -0,0 +1,38 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +gem="$__object_id" +gemset="$(cat "$__object/parameter/gemset")" +ruby="$(echo "$gemset" | cut -d '@' -f 1)" +gemsetname="$(echo "$gemset" | cut -d '@' -f 2)" +user="$(cat "$__object/parameter/user")" +state="$(cat "$__object/explorer/state")" +if [ -f "$__object/parameter/default" ]; then + default="$(cat "$__object/parameter/default")" +else + default="no" + echo $default > "$__object/parameter/default" +fi + +__rvm $user --state installed +require="__rvm/$user" \ + __rvm_ruby $ruby --user $user --state installed --default $default +require="__rvm_ruby/$ruby" \ + __rvm_gemset $gemset --user $user --state installed --default $default diff --git a/conf/type/__rvm_gem/parameter/optional b/conf/type/__rvm_gem/parameter/optional new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/conf/type/__rvm_gem/parameter/optional @@ -0,0 +1 @@ +default diff --git a/conf/type/__rvm_gem/parameter/required b/conf/type/__rvm_gem/parameter/required new file mode 100644 index 00000000..75f60bb8 --- /dev/null +++ b/conf/type/__rvm_gem/parameter/required @@ -0,0 +1,3 @@ +state +gemset +user diff --git a/conf/type/__rvm_gemset/explorer/state b/conf/type/__rvm_gemset/explorer/state new file mode 100755 index 00000000..132c376d --- /dev/null +++ b/conf/type/__rvm_gemset/explorer/state @@ -0,0 +1,37 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +gemset="$__object_id" +ruby="$(echo "$gemset" | cut -d '@' -f 1)" +gemsetname="$(echo "$gemset" | cut -d '@' -f2)" +user="$(cat "$__object/parameter/user")" +if su - $user -c "[ ! -d \"\$HOME/.rvm\" ]" ; then + echo "removed" + exit 0 +fi +if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" +rvm list | grep $ruby"; then + if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" +rvm use $ruby; rvm gemset list | grep $gemsetname > /dev/null"; then + echo "installed" + exit 0 + fi +fi +echo "removed" diff --git a/conf/type/__rvm_gemset/gencode-remote b/conf/type/__rvm_gemset/gencode-remote new file mode 100755 index 00000000..5b934edb --- /dev/null +++ b/conf/type/__rvm_gemset/gencode-remote @@ -0,0 +1,52 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +gemset="$__object_id" +ruby="$(echo "$gemset" | cut -d '@' -f 1)" +gemsetname="$(echo "$gemset" | cut -d '@' -f 2)" +state_is="$(cat "$__object/explorer/state")" +user="$(cat "$__object/parameter/user")" +state_should="$(cat "$__object/parameter/state")" +if [ "$state_is" != "$state_should" ]; then + case "$state_should" in + installed) + cat << DONE +su - $user -c "source \"\\\$HOME/.rvm/scripts/rvm\" +rvm $gemset --create" +DONE + case "$default" in + no) + ;; + *) + cat << DONE +su - $user -c "source \"\\\$HOME/.rvm/scripts/rvm\" +rvm use --default $gemset" +DONE + ;; + esac + ;; + removed) + cat << DONE +su - $user -c "source \"\\\$HOME/.rvm/scripts/rvm\" +rvm use $ruby; rvm --force gemset delete $gemsetname" +DONE + ;; + esac +fi diff --git a/conf/type/__rvm_gemset/man.text b/conf/type/__rvm_gemset/man.text new file mode 100644 index 00000000..d7b4c04c --- /dev/null +++ b/conf/type/__rvm_gemset/man.text @@ -0,0 +1,55 @@ +cdist-type__rvm_gemset(7) +========================== +Evax Software + + +NAME +---- +cdist-type__rvm_gemset - Manage gemsets through rvm + + +DESCRIPTION +----------- +RVM is the Ruby enVironment Manager for the Ruby programming language. + + +REQUIRED PARAMETERS +------------------- +user:: + The remote user account to use +ruby:: + The ruby version to use +name:: + The gemset name (including +state:: + Either "installed" or "removed". + +OPTIONAL PARAMETERS +------------------- +default:: + If set to anything but "no" (the default), set the give gemset as default. + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install the gemset @myset for user charles on based on ruby-1.9.3-0 +__rvm_gemset ruby-1.9.3-p0@myset --user charles --state installed + +# Remove the gemset @myset for user john +__rvm_ruby ruby-1.9.3-p0@myset --user john --state removed +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__rvm(7) +- cdist-type__rvm_ruby(7) +- cdist-type__rvm_gem(7) + + +COPYING +------- +Copyright \(C) 2012 Evax Software. Free use of this software is granted under +the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__rvm_gemset/manifest b/conf/type/__rvm_gemset/manifest new file mode 100755 index 00000000..8e25251c --- /dev/null +++ b/conf/type/__rvm_gemset/manifest @@ -0,0 +1,35 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +gemset="$__object_id" +ruby="$(echo "$gemset" | cut -d '@' -f 1)" +gemsetname="$(echo "$gemset" | cut -d '@' -f 2)" +user="$(cat "$__object/parameter/user")" +state="$(cat "$__object/explorer/state")" +if [ -f "$__object/parameter/default" ]; then + default="$(cat "$__object/parameter/default")" +else + default="no" +fi + +__rvm $user --state installed +require="__rvm/$user" \ + __rvm_ruby $ruby --user $user --state installed --default $default + diff --git a/conf/type/__rvm_gemset/parameter/optional b/conf/type/__rvm_gemset/parameter/optional new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/conf/type/__rvm_gemset/parameter/optional @@ -0,0 +1 @@ +default diff --git a/conf/type/__rvm_gemset/parameter/required b/conf/type/__rvm_gemset/parameter/required new file mode 100644 index 00000000..5aea6f1e --- /dev/null +++ b/conf/type/__rvm_gemset/parameter/required @@ -0,0 +1,2 @@ +state +user diff --git a/conf/type/__rvm_ruby/explorer/state b/conf/type/__rvm_ruby/explorer/state new file mode 100755 index 00000000..3cf392f1 --- /dev/null +++ b/conf/type/__rvm_ruby/explorer/state @@ -0,0 +1,32 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +ruby="$__object_id" +user="$(cat "$__object/parameter/user")" +if su - $user -c "[ ! -d \"\$HOME/.rvm\" ]" ; then + echo "removed" + exit 0 +fi +if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" +rvm list | grep $ruby >/dev/null"; then + echo "installed" +else + echo "removed" +fi diff --git a/conf/type/__rvm_ruby/gencode-remote b/conf/type/__rvm_ruby/gencode-remote new file mode 100755 index 00000000..5dcb0e99 --- /dev/null +++ b/conf/type/__rvm_ruby/gencode-remote @@ -0,0 +1,45 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +ruby="$__object_id" +state_is="$(cat "$__object/explorer/state")" +user="$(cat "$__object/parameter/user")" +default="$(cat "$__object/parameter/default")" +state_should="$(cat "$__object/parameter/state")" +if [ "$state_is" != "$state_should" ]; then + case "$state_should" in + installed) + 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 + ;; + removed) + echo "su - $user -c \"source \\\$HOME/.rvm/scripts/rvm;"\ + "rvm remove $ruby\"" + ;; + esac +fi diff --git a/conf/type/__rvm_ruby/man.text b/conf/type/__rvm_ruby/man.text new file mode 100644 index 00000000..c3183a7b --- /dev/null +++ b/conf/type/__rvm_ruby/man.text @@ -0,0 +1,54 @@ +cdist-type__rvm_ruby(7) +======================= +Evax Software + + +NAME +---- +cdist-type__rvm_ruby - Manage ruby installations through rvm + + +DESCRIPTION +----------- +RVM is the Ruby enVironment Manager for the Ruby programming language. + + +REQUIRED PARAMETERS +------------------- +user:: + The remote user account to use +state:: + Either "installed" or "removed". + +OPTIONAL PARAMETERS +------------------- +default: + If set to anything but "no" (the default), set the given version as default + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install ruby 1.9.3 through rvm for user thelonious +__rvm_ruby ruby-1.9.3-p0 --user thelonious --state installed + +# 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 installed --default yes + +# Remove ruby 1.9.3 for user john +__rvm_ruby ruby-1.9.3-p0 --user john --state removed +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__rvm(7) +- cdist-type__rvm_gemset(7) +- cdist-type__rvm_gem(7) + + +COPYING +------- +Copyright \(C) 2012 Evax Software. Free use of this software is granted under +the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__rvm_ruby/manifest b/conf/type/__rvm_ruby/manifest new file mode 100755 index 00000000..4a4b2ac4 --- /dev/null +++ b/conf/type/__rvm_ruby/manifest @@ -0,0 +1,33 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +if [ -f "$__object/parameter/default" ]; then + default="$(cat "$__object/parameter/default")" +else + default="no" + echo "$default" > "$__object/parameter/default" +fi + +ruby="$__object_id" +user="$(cat "$__object/parameter/user")" +state="$(cat "$__object/explorer/state")" + +__rvm "$user" --state installed + diff --git a/conf/type/__rvm_ruby/parameter/optional b/conf/type/__rvm_ruby/parameter/optional new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/conf/type/__rvm_ruby/parameter/optional @@ -0,0 +1 @@ +default diff --git a/conf/type/__rvm_ruby/parameter/required b/conf/type/__rvm_ruby/parameter/required new file mode 100644 index 00000000..5aea6f1e --- /dev/null +++ b/conf/type/__rvm_ruby/parameter/required @@ -0,0 +1,2 @@ +state +user From 34fa123ed19856010582027c21d04d64cd2d52c0 Mon Sep 17 00:00:00 2001 From: Evax Software Date: Fri, 13 Jan 2012 15:19:29 +0100 Subject: [PATCH 2/7] prevent spurious output in __rvm_gem and __rvm_gemset explorers --- conf/type/__rvm_gem/explorer/state | 6 +++--- conf/type/__rvm_gemset/explorer/state | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/type/__rvm_gem/explorer/state b/conf/type/__rvm_gem/explorer/state index d4cca9cb..b80a2a9e 100755 --- a/conf/type/__rvm_gem/explorer/state +++ b/conf/type/__rvm_gem/explorer/state @@ -28,10 +28,10 @@ if su - $user -c "[ ! -d \"\$HOME/.rvm\" ]" ; then exit 0 fi if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm list | grep $ruby"; then +rvm list | grep $ruby > /dev/null"; then if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm use $ruby; rvm gemset list | grep $gemsetname > /dev/null && -rvm use $gemset && gem list | grep $gem"; then +rvm use $ruby > /dev/null; rvm gemset list | grep $gemsetname > /dev/null && +rvm use $gemset > /dev/null && gem list | grep $gem > /dev/null"; then echo "installed" exit 0 fi diff --git a/conf/type/__rvm_gemset/explorer/state b/conf/type/__rvm_gemset/explorer/state index 132c376d..04d5af2d 100755 --- a/conf/type/__rvm_gemset/explorer/state +++ b/conf/type/__rvm_gemset/explorer/state @@ -27,9 +27,9 @@ if su - $user -c "[ ! -d \"\$HOME/.rvm\" ]" ; then exit 0 fi if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm list | grep $ruby"; then +rvm list | grep $ruby > /dev/null"; then if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm use $ruby; rvm gemset list | grep $gemsetname > /dev/null"; then +rvm use $ruby > /dev/null; rvm gemset list | grep $gemsetname > /dev/null"; then echo "installed" exit 0 fi From eb83190efd72c1047771a31eb1fd039547700af7 Mon Sep 17 00:00:00 2001 From: Evax Software Date: Mon, 16 Jan 2012 12:29:51 +0100 Subject: [PATCH 3/7] use grep's -q option --- conf/type/__rvm_gem/explorer/state | 6 +++--- conf/type/__rvm_gemset/explorer/state | 4 ++-- conf/type/__rvm_ruby/explorer/state | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/type/__rvm_gem/explorer/state b/conf/type/__rvm_gem/explorer/state index b80a2a9e..e7f50247 100755 --- a/conf/type/__rvm_gem/explorer/state +++ b/conf/type/__rvm_gem/explorer/state @@ -28,10 +28,10 @@ if su - $user -c "[ ! -d \"\$HOME/.rvm\" ]" ; then exit 0 fi if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm list | grep $ruby > /dev/null"; then +rvm list | grep -q $ruby"; then if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm use $ruby > /dev/null; rvm gemset list | grep $gemsetname > /dev/null && -rvm use $gemset > /dev/null && gem list | grep $gem > /dev/null"; then +rvm use $ruby > /dev/null; rvm gemset list | grep -q $gemsetname && +rvm use $gemset > /dev/null && gem list | grep -q $gem"; then echo "installed" exit 0 fi diff --git a/conf/type/__rvm_gemset/explorer/state b/conf/type/__rvm_gemset/explorer/state index 04d5af2d..43667126 100755 --- a/conf/type/__rvm_gemset/explorer/state +++ b/conf/type/__rvm_gemset/explorer/state @@ -27,9 +27,9 @@ if su - $user -c "[ ! -d \"\$HOME/.rvm\" ]" ; then exit 0 fi if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm list | grep $ruby > /dev/null"; then +rvm list | grep -q $ruby"; then if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm use $ruby > /dev/null; rvm gemset list | grep $gemsetname > /dev/null"; then +rvm use $ruby > /dev/null; rvm gemset list | grep -q $gemsetname"; then echo "installed" exit 0 fi diff --git a/conf/type/__rvm_ruby/explorer/state b/conf/type/__rvm_ruby/explorer/state index 3cf392f1..1fc9e0a8 100755 --- a/conf/type/__rvm_ruby/explorer/state +++ b/conf/type/__rvm_ruby/explorer/state @@ -25,7 +25,7 @@ if su - $user -c "[ ! -d \"\$HOME/.rvm\" ]" ; then exit 0 fi if su - $user -c "source \"\$HOME/.rvm/scripts/rvm\" -rvm list | grep $ruby >/dev/null"; then +rvm list | grep -q $ruby"; then echo "installed" else echo "removed" From 8cc0d6f0e780b3bdf1ac9f5d801a69ddf4256f73 Mon Sep 17 00:00:00 2001 From: Evax Software Date: Mon, 16 Jan 2012 12:30:19 +0100 Subject: [PATCH 4/7] properly handle rvm and ruby dependencies --- conf/type/__rvm/manifest | 25 +++++++++++++++++ conf/type/__rvm_ruby/manifest | 52 ++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100755 conf/type/__rvm/manifest diff --git a/conf/type/__rvm/manifest b/conf/type/__rvm/manifest new file mode 100755 index 00000000..8e63a2c5 --- /dev/null +++ b/conf/type/__rvm/manifest @@ -0,0 +1,25 @@ +#!/bin/sh +# +# 2012 Evax Software +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +# rvm core dependencies +__package bash --state installed +__package curl --state installed +__package git-core --state installed +__package patch --state installed diff --git a/conf/type/__rvm_ruby/manifest b/conf/type/__rvm_ruby/manifest index 4a4b2ac4..c6e31244 100755 --- a/conf/type/__rvm_ruby/manifest +++ b/conf/type/__rvm_ruby/manifest @@ -29,5 +29,55 @@ ruby="$__object_id" user="$(cat "$__object/parameter/user")" state="$(cat "$__object/explorer/state")" -__rvm "$user" --state installed +apt_ruby="build-essential openssl libreadline6 libreadline6-dev curl git-core +zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 +libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison +subversion" +apt_jruby="curl g++ openjdk-6-jre-headless" +apt_jruby_head="ant openjdk-6-jdk" +apt_ironruby="curl mono-2.0-devel" +emerge_ruby="libiconv readline zlib openssl curl git libyaml sqlite libxslt +libtool gcc autoconf automake bison m4" +emerge_jruby="dev-java/sun-jdk dev-java/sun-jre-bin" +emerge_ironruby="dev-lang/mono" + +pacman_ruby="gcc patch curl zlib readline libxml2 libxslt git autoconf +diffutils make libtool bison subversion" +pacman_jruby="jdk jre curl" +pacman_ironruby="mono" + +yum_ruby="gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel +libffi-devel openssl-devel make bzip2 autoconf automake libtool bison +iconv-devel" +yum_jruby="java" + +os="$(cat "$__global/explorer/os")" +case "$os" in + archlinux) type="pacman" ;; + debian|ubuntu) type="apt" ;; + gentoo) type="emerge" ;; + fedora|redhat|centos) type="yum" ;; + *);; +esac +case "$ruby" in + ruby-head*) + deps_list="${type}_ruby_head" + ;; + ruby*) + deps_list="${type}_ruby" + ;; + jruby-head*) + deps_list="${type}_jruby_head" + ;; + jruby*) + deps_list="${type}_jruby" + ;; + ironruby*) + deps_list="${type}_ironruby" + ;; +esac +deps=$(eval echo \$$deps_list) +for p in $deps; do __package_${type} $p --state installed; done + +__rvm "$user" --state installed From 72dea3d930fbb8d02327af949990793b9cb76185 Mon Sep 17 00:00:00 2001 From: Evax Software Date: Wed, 18 Jan 2012 14:28:10 +0100 Subject: [PATCH 5/7] __rvm* types documentation cleanup --- conf/type/__rvm_gem/man.text | 4 ++++ conf/type/__rvm_gemset/man.text | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/conf/type/__rvm_gem/man.text b/conf/type/__rvm_gem/man.text index 951884b8..27b16053 100644 --- a/conf/type/__rvm_gem/man.text +++ b/conf/type/__rvm_gem/man.text @@ -34,6 +34,10 @@ EXAMPLES # Install the rails gem in gemset ruby-1.9.3-p0@myset for user bill __rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill --state installed +# Do the same and also make ruby-1.9.3-p0@myset the default gemset +__rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill \ + --state installed --default yes + # Remove it __rvm_ruby rails --gemset ruby-1.9.3-p0@myset --user bill --state removed -------------------------------------------------------------------------------- diff --git a/conf/type/__rvm_gemset/man.text b/conf/type/__rvm_gemset/man.text index d7b4c04c..f1e3f2bf 100644 --- a/conf/type/__rvm_gemset/man.text +++ b/conf/type/__rvm_gemset/man.text @@ -17,17 +17,13 @@ REQUIRED PARAMETERS ------------------- user:: The remote user account to use -ruby:: - The ruby version to use -name:: - The gemset name (including state:: Either "installed" or "removed". OPTIONAL PARAMETERS ------------------- default:: - If set to anything but "no" (the default), set the give gemset as default. + If set to anything but "no" (the default), set the given gemset as default. EXAMPLES -------- @@ -36,6 +32,9 @@ EXAMPLES # Install the gemset @myset for user charles on based on ruby-1.9.3-0 __rvm_gemset ruby-1.9.3-p0@myset --user charles --state installed +# Do the same and make ruby-1.9.3-p0@myset the default gemset +__rvm_gemset ruby-1.9.3-p0@myset --user charles --state installed --default yes + # Remove the gemset @myset for user john __rvm_ruby ruby-1.9.3-p0@myset --user john --state removed -------------------------------------------------------------------------------- From f5d07a941b5b74fa7349564feeccdcf2513ef097 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 18 Jan 2012 14:32:24 +0100 Subject: [PATCH 6/7] --todo Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 41d02861..ad859266 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,5 +1,3 @@ -- release 2.0.5 -- go through pull requests / check & include them - update/create docs - cdist-cache:: How to get use information about the hosts we have been working on [advanced] From 9551b2422f8d8185b659881bd13d875834a59292 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 18 Jan 2012 14:37:29 +0100 Subject: [PATCH 7/7] ++changes for 2.0.6 Signed-off-by: Nico Schottelius --- doc/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/changelog b/doc/changelog index 52af1f51..062db392 100644 --- a/doc/changelog +++ b/doc/changelog @@ -3,6 +3,10 @@ Also remove the [ppa-name].list file, if empty. (Tim Kersten) * Feature __package_apt: Initial support for virtual packages (Evax Software) + * New Type: __rvm (Evax Software) + * New Type: __rvm_gem (Evax Software) + * New Type: __rvm_gemset (Evax Software) + * New Type: __rvm_ruby (Evax Software) 2.0.5: 2012-01-18 * Bugfix __key_value: Use correct delimiters