Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround Puppets late binding issue for resources by Being Clever(TM) #39

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ 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, 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
should be aware of.
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.
Expand Down Expand Up @@ -121,8 +120,7 @@ Install passenger with:
### 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
(probably because RVM isn't installed yet). Currently, Puppet does not support
making a provider suitable using another resource (late-binding). The
(probably because RVM isn't installed yet). 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
Expand Down
12 changes: 10 additions & 2 deletions lib/puppet/provider/rvm_gem/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@
Puppet::Type.type(:rvm_gem).provide(:gem) do
desc "Ruby Gem support using RVM."

commands :rvmcmd => "/usr/local/rvm/bin/rvm"
#commands :rvmcmd => "/usr/local/rvm/bin/rvm"
commands :workaround => "true"

def get_rvm
"/usr/local/rvm/bin/rvm"
end

def rvmcmd(*args)
execute( [get_rvm] + args )
end

def ruby_version
resource[:ruby_version]
end

def gembinary
[command(:rvmcmd), ruby_version, "do", "gem"]
[get_rvm, ruby_version, "do", "gem"]
end


Expand Down
15 changes: 12 additions & 3 deletions lib/puppet/provider/rvm_gemset/gemset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
Puppet::Type.type(:rvm_gemset).provide(:gemset) do
desc "RVM gemset support."

commands :rvmcmd => "/usr/local/rvm/bin/rvm"
#commands :rvmcmd => "/usr/local/rvm/bin/rvm"
commands :workaround => "true"

def rvmcmd(*args)
execute( [get_rvm] + args )
end

def get_rvm
"/usr/local/rvm/bin/rvm"
end

def ruby_version
resource[:ruby_version]
Expand All @@ -13,11 +22,11 @@ def gemset_name
end

def gemsetcommand
[command(:rvmcmd), ruby_version, "exec", "rvm", "gemset"]
[get_rvm, ruby_version, "exec", "rvm", "gemset"]
end

def gemsetcommand_force
[command(:rvmcmd), ruby_version, "exec", "rvm", "--force", "gemset"]
[get_rvm, ruby_version, "exec", "rvm", "--force", "gemset"]
end

def gemset_list
Expand Down
8 changes: 7 additions & 1 deletion lib/puppet/provider/rvm_system_ruby/rvm_system_ruby.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Puppet::Type.type(:rvm_system_ruby).provide(:rvm) do
desc "Ruby RVM support."

commands :rvmcmd => "/usr/local/rvm/bin/rvm"
#commands :rvmcmd => "/usr/local/rvm/bin/rvm"
commands :workaround => "true"

def rvmcmd(*args)
execute( ["/usr/local/rvm/bin/rvm"] + args )
end


def create
rvmcmd "install", resource[:name]
Expand Down