Skip to content

Instantly share code, notes, and snippets.

@sycobuny
Last active December 16, 2015 01:59
Show Gist options
  • Save sycobuny/5358883 to your computer and use it in GitHub Desktop.
Save sycobuny/5358883 to your computer and use it in GitHub Desktop.
Debating formats for a custom type for RVM in puppet. I'm aware of an existing RVM type and provider, but it appears to install a global copy of RVM, and a group of which users must become a member to access. I'm looking to manage single-user installations of RVM.
# execute a command using an installed ruby/gemset
rvm::exec { 'start-myapp':
local => 'apache',
ruby_version => '1.9.3-p394',
gemset_name => 'myapp',
user => 'apache',
group => 'apache',
binary => 'thin',
arguments => ['start', '-p', '9292', '-P', '/var/run/myapp.pid'],
creates => '/var/run/myapp.pid',
require => Rvm::Bundle['apache:1.9.3-p394@myapp'],
}
# possible shorthand for specifying an rvm::exec resource?
rvm::exec { 'start-myapp':
gemset => 'apache:1.9.3-p394@myapp',
binary => 'thin',
arguments => ['start', '-p', '9292', '-P', '/var/run/myapp.pid'],
creates => '/var/run/myapp.pid',
require => Rvm::Bundle['apache:1.9.3-p394@myapp'],
}
# shorthand gets away with this (in theory) because:
# "version" arg can be a shorthand string: [local]:[ruby_version]
# "gemset" arg can be a shorthand string: [local]:[ruby_version]@[gemset_name]
# "user" and "group" can be inferred from the [local] you specify
# possible shorthand for setting up a bundle completely?
rvm::bundle { 'apache:1.9.3-p394@myapp':
gemfile => '/opt/www/myapp/Gemfile',
}
# uses the assumptions of how [local]:[ruby_version]@[gemset_name] is formatted
# pulls apart the $name if nothing else is provided and fills those values
# dynamically builds virtual resources for all the items it depends on
# install rvm for the apache user
rvm::local { 'apache':
ensure => 'installed',
root => '/opt/www/.rvm',
user => 'apache',
group => 'apache',
}
# manage rubies and gemsets seperately
rvm::ruby { 'apache:1.9.3-p394':
ensure => 'present',
local => 'apache',
ruby_version => '1.9.3-p394',
require => Rvm::Local['apache'],
}
rvm::gemset { 'apache:1.9.3-p394@myapp':
ensure => 'present',
local => 'apache',
ruby_version => '1.9.3-p394',
gemset_name => 'myapp',
require => Rvm::Ruby['apache:1.9.3-p394'],
}
# manage rubies and gemsets together
rvm::ruby { 'apache:1.9.3-p394':
ensure => 'present',
gemsets => ['myapp'],
require => Rvm::Local['apache'],
}
# manage a specific gem in a specific gemset
rvm::gem { 'apache:1.9.3-p394@myapp[sequel-3.34]':
ensure => 'present',
local => 'apache',
ruby_version => '1.9.3-p394',
gemset_name => 'myapp',
gem_name => 'sequel',
gem_version => '3.34',
}
# manage rubies, gemsets, and gems all together
rvm::ruby { 'apache:1.9.3-p394':
ensure => 'present',
local => 'apache',
ruby_version => '1.9.3-p394',
gemsets => ['myapp'],
gems => ['sequel', 'pg', 'sequel_pg'],
require => Rvm::Local['apache'],
}
# manage gems through bundler
rvm::bundle { 'apache:1.9.3-p394@myapp':
ensure => 'present',
local => 'apache',
ruby_version => '1.9.3-p394',
gemset_name => 'myapp',
gemfile => '/opt/www/myapp/Gemfile',
require => Rvm::Gemset['apache:1.9.3-p394@myapp'],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment