Skip to content

Commit

Permalink
Merge pull request #110 from srclab/master
Browse files Browse the repository at this point in the history
Allow rvm to mount a Ruby
  • Loading branch information
carlossg committed Apr 7, 2016
2 parents 1eddcf7 + c082d64 commit d9bac19
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ vendor/
.rvmrc*
.ruby-*

# IntelliJ/RubyMine
.idea/*

## rspec
spec/fixtures/manifests/
spec/fixtures/modules/
Expand Down
38 changes: 26 additions & 12 deletions lib/puppet/provider/rvm_system_ruby/rvm_system_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@
end

def create
unless resource[:proxy_url].nil?
ENV['http_proxy'] = resource[:proxy_url]
ENV['https_proxy'] = resource[:proxy_url]
unless resource[:no_proxy].nil?
ENV['no_proxy'] = resource[:no_proxy]
end
end
set_autolib_mode if resource.value(:autolib_mode)
options = Array(resource[:build_opts])
if resource[:proxy_url] and !resource[:proxy_url].empty?
rvmcmd "install", resource[:name], "--proxy", resource[:proxy_url], *options
if resource[:mount_from]
mount
else
rvmcmd "install", resource[:name], *options
install
end
set_default if resource.value(:default_use)
end
Expand Down Expand Up @@ -63,4 +54,27 @@ def set_autolib_mode
raise Puppet::Error, "Could not set autolib mode: #{detail}"
end
end

private

def install
unless resource[:proxy_url].nil?
ENV['http_proxy'] = resource[:proxy_url]
ENV['https_proxy'] = resource[:proxy_url]
unless resource[:no_proxy].nil?
ENV['no_proxy'] = resource[:no_proxy]
end
end
set_autolib_mode if resource.value(:autolib_mode)
options = Array(resource[:build_opts])
if resource[:proxy_url] and !resource[:proxy_url].empty?
rvmcmd "install", resource[:name], "--proxy", resource[:proxy_url], *options
else
rvmcmd "install", resource[:name], *options
end
end

def mount
rvmcmd "mount", resource[:mount_from]
end
end
4 changes: 4 additions & 0 deletions lib/puppet/type/rvm_system_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@
desc "Set RVM autolib mode"
end

newparam(:mount_from) do
desc 'If you wish to specify a Ruby archive to mount'
end

end
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Install RVM, create system user a install system level rubies
class rvm(
$version=undef,
$install_from=undef,
$install_rvm=true,
$install_dependencies=false,
$manage_rvmrc=$rvm::params::manage_rvmrc,
Expand Down Expand Up @@ -31,6 +32,7 @@
no_proxy => $no_proxy,
key_server => $key_server,
gnupg_key_id => $gnupg_key_id,
install_from => $install_from,
}
}

Expand Down
36 changes: 30 additions & 6 deletions manifests/system.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Install the RVM system
class rvm::system(
$version=undef,
$install_from=undef,
$proxy_url=undef,
$no_proxy=undef,
$key_server=undef,
Expand All @@ -20,7 +21,7 @@
ensure_packages(['curl'])
Package['curl'] -> Exec['system-rvm']
}
default: {}
default: { }
}
}

Expand All @@ -44,11 +45,34 @@
}
}

exec { 'system-rvm':
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
command => "curl -fsSL https://get.rvm.io | bash -s -- --version ${actual_version}",
creates => '/usr/local/rvm/bin/rvm',
environment => $environment,
if $install_from {

file { '/tmp/rvm':
ensure => directory,
}

exec { 'unpack-rvm':
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
command => "tar --strip-components=1 -xzf ${install_from}",
cwd => '/tmp/rvm',
}

exec { 'system-rvm':
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
command => './install --auto-dotfiles',
cwd => '/tmp/rvm',
creates => '/usr/local/rvm/bin/rvm',
environment => $environment,
}

}
else {
exec { 'system-rvm':
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
command => "curl -fsSL https://get.rvm.io | bash -s -- --version ${actual_version}",
creates => '/usr/local/rvm/bin/rvm',
environment => $environment,
}
}

# the fact won't work until rvm is installed before puppet starts
Expand Down

0 comments on commit d9bac19

Please sign in to comment.