Permalink
Browse files

Use run stages to install RVM first

This enables installing RVM and rubies in one puppet run.

References #29.
  • Loading branch information...
1 parent acea15e commit 0d44351a866d75f0d5ce6bc9735c4527ab997228 @blt04 blt04 committed Jan 21, 2012
Showing with 51 additions and 51 deletions.
  1. +47 −49 README.markdown
  2. +2 −2 manifests/classes/system.pp
  3. +2 −0 manifests/init.pp
View
@@ -6,11 +6,12 @@ as root) and using it to install rubies and gems. Support for installing and
configuring passenger is also included.
We are actively using this module. It works well, but does have some issues you
-should be aware of. Due to the way puppet works, puppet must run twice before all
-rubies and gems are installed. The first *pass* will install rvm. The second pass
-will install rubies and gems. If you are running manually, or running in
-standalone mode, make sure you run puppet twice to ensure everything is set up
-properly.
+should be aware of. Due to the way puppet works, certain resources
+(rvm\_sytem\_ruby, rvm\_gem and rvm\_gemset) may generate errors until RVM is
+installed. The puppet-rvm module uses run stages to install RVM before the rest
+of your configuration runs. However, if you run puppet using the `--noop`
+parameter, you may see _Could not find a default provider_ errors. See the
+Troubleshooting section for more information.
Please read the troubleshooting section below before opening an issue.
@@ -58,15 +59,13 @@ To use RVM without sudo, users need to be added to the `rvm` group. This can be
You can tell RVM to install one or more Ruby versions with:
- if $rvm_installed == "true" {
- rvm_system_ruby {
- 'ruby-1.9.2-p290':
- ensure => 'present',
- default_use => true;
- 'ruby-1.8.7-p357':
- ensure => 'present',
- default_use => false;
- }
+ rvm_system_ruby {
+ 'ruby-1.9.2-p290':
+ ensure => 'present',
+ default_use => true;
+ 'ruby-1.8.7-p357':
+ ensure => 'present',
+ default_use => false;
}
You should use the full version number. While the shorthand version may work (e.g. '1.9.2'), the provider will be unable to detect if the correct version is installed.
@@ -76,73 +75,73 @@ You should use the full version number. While the shorthand version may work (e
Create a gemset with:
- if $rvm_installed == "true" {
- rvm_gemset {
- "ruby-1.9.2-p290@myproject":
- ensure => present,
- require => Rvm_system_ruby['ruby-1.9.2-p290'];
- }
+ rvm_gemset {
+ "ruby-1.9.2-p290@myproject":
+ ensure => present,
+ require => Rvm_system_ruby['ruby-1.9.2-p290'];
}
## Installing Gems
Install a gem with:
- if $rvm_installed == "true" {
- rvm_gem {
- 'ruby-1.9.2-p290@myproject/bundler':
- ensure => '1.0.21',
- require => Rvm_gemset['ruby-1.9.2-p290@myproject'];
- }
+ rvm_gem {
+ 'ruby-1.9.2-p290@myproject/bundler':
+ ensure => '1.0.21',
+ require => Rvm_gemset['ruby-1.9.2-p290@myproject'];
}
The *name* of the gem should be `<ruby-version>[@<gemset>]/<gemname>`. For example, you can install bundler for ruby-1.9.2 using `ruby-1.9.2-p290/bundler`. You could install rails in your project's gemset with: `ruby-1.9.2-p290@myproject/rails`.
Alternatively, you can use this more verbose syntax:
- if $rvm_installed == "true" {
- rvm_gem {
- 'bundler':
- name => 'bundler',
- ruby_version => 'ruby-1.9.2-p290',
- ensure => latest,
- require => Rvm_system_ruby['ruby-1.9.2-p357'];
- }
+ rvm_gem {
+ 'bundler':
+ name => 'bundler',
+ ruby_version => 'ruby-1.9.2-p290',
+ ensure => latest,
+ require => Rvm_system_ruby['ruby-1.9.2-p357'];
}
## Installing Passenger
Install passenger with:
- if $rvm_installed == "true" {
- class {
- 'rvm::passenger::apache':
- version => '3.0.11',
- ruby_version => 'ruby-1.9.2-p290',
- mininstances => '3',
- maxinstancesperapp => '0',
- maxpoolsize => '30',
- spawnmethod => 'smart-lv2';
- }
+ class {
+ 'rvm::passenger::apache':
+ version => '3.0.11',
+ ruby_version => 'ruby-1.9.2-p290',
+ mininstances => '3',
+ maxinstancesperapp => '0',
+ maxpoolsize => '30',
+ spawnmethod => 'smart-lv2';
}
## Troubleshooting / FAQ
-### An error "Could not find a default provider for rvm\_system\_ruby" prevents puppet from running.
+### An error "Could not find a default provider for rvm\_system\_ruby" is displayed when running Puppet with --noop
-This means that puppet cannot find the `/usr/local/rvm/bin/rvm` command. Currently, Puppet does not support making a provider suitable using another resource (late-binding). You can avoid this error by surrounding your rvm configuration in an if block:
+This means that puppet cannot find the `/usr/local/rvm/bin/rvm` command
+(probably because RVM isn't installed yet). Currently, Puppet does not support
+making a provider suitable using another resource (late-binding). The
+puppet-rvm module uses run stages to install RVM before the rest of the
+configuration runs. When running in _noop_ mode, RVM is not actually installed
+causing rvm\_system\_ruby, rvm\_gem and rvm\_gemset resources to generate this
+error. You can avoid this error by surrounding your rvm configuration in an if
+block:
if $rvm_installed == "true" {
rvm_system_ruby ...
}
Do not surround `include rvm::system` in the if block, as this is used to install RVM.
-Note: When setting up a new box, the puppet agent will install RVM on it's first run and Ruby on its second run.
-
+NOTE: $rvm\_installed is evaluated at the beginning of each puppet run. If you
+use this in your manifests, you will need to run puppet twice to fully
+configure RVM.
### An error "Resource type rvm_gem does not support parameter false" prevents puppet from running.
@@ -179,4 +178,3 @@ I decided it was best to create a completely new set of types for RVM.
## TODO
* Allow upgrading the RVM version
-* Install RVM and Ruby in one pass
@@ -1,6 +1,6 @@
-class rvm::system($version='latest') {
+class rvm::system($version='latest', stage='rvm-install') {
- include rvm::dependencies
+ class {'rvm::dependencies': stage => 'rvm-install';}
exec { 'system-rvm':
path => '/usr/bin:/usr/sbin:/bin',
View
@@ -1,2 +1,4 @@
+stage { 'rvm-install': before => Stage['main'] }
+
import "classes/*.pp"
import "definitions/*.pp"

0 comments on commit 0d44351

Please sign in to comment.