use ruby manager

This commit is contained in:
Antonio J. Delgado 2023-11-27 19:19:40 +02:00
parent db3192e91d
commit eb11c0f218

View file

@ -12,11 +12,19 @@
# [*mastodon_home*] # [*mastodon_home*]
# String path to Mastodon user home directory. Default /opt/mastodon # String path to Mastodon user home directory. Default /opt/mastodon
# #
# [*db_password*]
# String with Database password.
#
# [*mastodon_version*]
# String with Mastodon version (code tag) to install. Default v4.2.1
#
class mastodon ( class mastodon (
String $ensure = 'present', String $ensure = 'present',
String $hostname = 'mastodon.example.org', String $hostname = 'mastodon.example.org',
String $smtp_server = 'mail.example.org', String $smtp_server = 'mail.example.org',
String $mastodon_home = '/opt/mastodon', String $mastodon_home = '/opt/mastodon',
String $db_password = '',
String $mastodon_version = 'v4.2.1',
) { ) {
case $ensure { case $ensure {
default: { default: {
@ -106,22 +114,108 @@ class mastodon (
system => true, system => true,
require => Group['mastodon'], require => Group['mastodon'],
} }
vcsrepo { 'rbenv': # vcsrepo { 'rbenv':
path => "${mastodon_home}/.rbenv", # path => "${mastodon_home}/.rbenv",
source => 'https://github.com/rbenv/rbenv.git', # source => 'https://github.com/rbenv/rbenv.git',
# provider => 'git',
# owner => 'mastodon',
# group => 'mastodon',
# require => User['mastodon'],
# }
# exec { 'configure_rbenv':
# command => "${mastodon_home}/.rbenv/src/configure",
# user => 'mastodon',
# cwd => "${mastodon_home}/.rbenv/",
# creates => "${mastodon_home}/.rbenv/src/Makefile",
# require => Vcsrepo['rbenv'],
# }
# exec { 'make_rbenv':
# command => '/usr/bin/make -C src',
# user => 'mastodon',
# cwd => "${mastodon_home}/.rbenv/",
# creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
# require => Exec['configure_rbenv'],
# }
# file_line { 'mastodon_path':
# path => "${mastodon_home}/.bashrc/",
# line => 'export PATH="$HOME/.rbenv/bin:$PATH"',
# match => '^export PATH="$HOME/.rbenv',
# require => Vcsrepo['rbenv'],
# }
# file_line { 'mastodon_rbenv_init':
# path => "${mastodon_home}/.bashrc/",
# line => 'eval "$(rbenv init -)"',
# match => '^eval "$(rbenv init -)"',
# require => Vcsrepo['rbenv'],
# }
# vcsrepo { 'ruby_build':
# path => "${mastodon_home}/.rbenv/plugins/ruby-build",
# source => 'https://github.com/rbenv/ruby-build.git',
# provider => 'git',
# owner => 'mastodon',
# group => 'mastodon',
# require => Vcsrepo['rbenv'],
# }
# exec { 'update_ruby':
# command => "${mastodon_home}/.rbenv/bin/rbenv global 3.2.2",
# environment => [
# 'RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.2.2',
# ],
# user => 'mastodon',
# cwd => "${mastodon_home}/.rbenv/",
# # creates => '',
# require => Vcsrepo['ruby_build'],
# }
# exec { '':}
rvm_system_ruby {
'ruby-3.2.2':
build_opts => ['--with-jemalloc'],
}
rvm_gemset {
'bundler':
name => 'bundler',
ruby_version => 'ruby-3.2.2',
require => Rvm_system_ruby['ruby-3.2.2'];
}
postgresql::server::db { 'mastodon':
user => 'mastodon',
password => postgresql::postgresql_password('mastodon', $db_password),
}
vcsrepo { 'mastodon_code':
path => "${mastodon_home}/live",
source => 'https://github.com/mastodon/mastodon.git',
revision => $mastodon_version,
provider => 'git', provider => 'git',
owner => 'mastodon',
group => 'mastodon',
require => User['mastodon'], require => User['mastodon'],
} }
exec { 'configure_rbenv': exec { 'config_deployment':
command => "${mastodon_home}/.rbenv/src/configure", command => 'bundle config deployment \'true\'',
cwd => "${mastodon_home}/.rbenv/", user => 'mastodon',
creates => "${mastodon_home}/.rbenv/src/Makefile", cwd => "${mastodon_home}/live",
require => Vcsrepo['rbenv'], # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
require => Rvm_gemset['bundler'],
} }
exec { 'make_rbenv': exec { 'config_without_devel_test':
command => '/usr/bin/make -C src', command => 'bundle config without \'development test\'',
cwd => "${mastodon_home}/.rbenv/", user => 'mastodon',
# creates => "${mastodon_home}/.rbenv/src/Makefile", cwd => "${mastodon_home}/live",
require => Exec['configure_rbenv'], # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
require => Exec['config_deployment'],
}
exec { 'bundle_install':
command => 'bundle install -j$(getconf _NPROCESSORS_ONLN)',
user => 'mastodon',
cwd => "${mastodon_home}/live",
# creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
require => Exec['config_without_devel_test'],
}
exec { 'yarn_install':
command => 'yarn install --pure-lockfile',
user => 'mastodon',
cwd => "${mastodon_home}/live",
# creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
require => Exec['bundle_install'],
} }
} }