use variable for user, group and ruby version
This commit is contained in:
parent
a906ef2f57
commit
89c963a897
2 changed files with 40 additions and 27 deletions
|
@ -16,8 +16,18 @@
|
||||||
# String with Database password.
|
# String with Database password.
|
||||||
#
|
#
|
||||||
# [*mastodon_version*]
|
# [*mastodon_version*]
|
||||||
# String with Mastodon version (code tag) to install. Default v4.2.1
|
# String with Mastodon version (code tag) to install. Default: v4.2.1
|
||||||
#
|
#
|
||||||
|
# [*mastodon_user*]
|
||||||
|
# String with the system user name for mastodon. Default: mastodon
|
||||||
|
#
|
||||||
|
# [*mastodon_group*]
|
||||||
|
# String with the system group name for mastodon. Default: mastodon
|
||||||
|
#
|
||||||
|
# [*ruby_version*]
|
||||||
|
# String with the ruby version to use. Default: 3.2.2
|
||||||
|
#
|
||||||
|
|
||||||
class mastodon (
|
class mastodon (
|
||||||
String $ensure = 'present',
|
String $ensure = 'present',
|
||||||
String $hostname = 'mastodon.example.org',
|
String $hostname = 'mastodon.example.org',
|
||||||
|
@ -25,6 +35,9 @@ class mastodon (
|
||||||
String $mastodon_home = '/opt/mastodon',
|
String $mastodon_home = '/opt/mastodon',
|
||||||
String $db_password = '',
|
String $db_password = '',
|
||||||
String $mastodon_version = 'v4.2.1',
|
String $mastodon_version = 'v4.2.1',
|
||||||
|
String $ruby_version = '3.2.2',
|
||||||
|
String $mastodon_user = 'mastodon',
|
||||||
|
String $mastodon_group = 'mastodon',
|
||||||
) {
|
) {
|
||||||
case $ensure {
|
case $ensure {
|
||||||
default: {
|
default: {
|
||||||
|
@ -106,32 +119,32 @@ class mastodon (
|
||||||
creates => '/root/.yarnrc',
|
creates => '/root/.yarnrc',
|
||||||
require => Exec['enable_corepack'],
|
require => Exec['enable_corepack'],
|
||||||
}
|
}
|
||||||
group { 'mastodon': }
|
group { $mastodon_group: }
|
||||||
user { 'mastodon':
|
user { $mastodon_user:
|
||||||
gid => 'mastodon',
|
gid => $mastodon_group,
|
||||||
home => $mastodon_home,
|
home => $mastodon_home,
|
||||||
managehome => true,
|
managehome => true,
|
||||||
system => true,
|
system => true,
|
||||||
require => Group['mastodon'],
|
require => Group[$mastodon_group],
|
||||||
}
|
}
|
||||||
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',
|
provider => 'git',
|
||||||
owner => 'mastodon',
|
owner => $mastodon_user,
|
||||||
group => 'mastodon',
|
group => $mastodon_group,
|
||||||
require => User['mastodon'],
|
require => User[$mastodon_user],
|
||||||
}
|
}
|
||||||
exec { 'configure_rbenv':
|
exec { 'configure_rbenv':
|
||||||
command => "${mastodon_home}/.rbenv/src/configure",
|
command => "${mastodon_home}/.rbenv/src/configure",
|
||||||
user => 'mastodon',
|
user => $mastodon_user,
|
||||||
cwd => "${mastodon_home}/.rbenv/",
|
cwd => "${mastodon_home}/.rbenv/",
|
||||||
creates => "${mastodon_home}/.rbenv/src/Makefile",
|
creates => "${mastodon_home}/.rbenv/src/Makefile",
|
||||||
require => Vcsrepo['rbenv'],
|
require => Vcsrepo['rbenv'],
|
||||||
}
|
}
|
||||||
exec { 'make_rbenv':
|
exec { 'make_rbenv':
|
||||||
command => '/usr/bin/make -C src',
|
command => '/usr/bin/make -C src',
|
||||||
user => 'mastodon',
|
user => $mastodon_user,
|
||||||
cwd => "${mastodon_home}/.rbenv/",
|
cwd => "${mastodon_home}/.rbenv/",
|
||||||
creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
||||||
require => Exec['configure_rbenv'],
|
require => Exec['configure_rbenv'],
|
||||||
|
@ -152,35 +165,35 @@ class mastodon (
|
||||||
path => "${mastodon_home}/.rbenv/plugins/ruby-build",
|
path => "${mastodon_home}/.rbenv/plugins/ruby-build",
|
||||||
source => 'https://github.com/rbenv/ruby-build.git',
|
source => 'https://github.com/rbenv/ruby-build.git',
|
||||||
provider => 'git',
|
provider => 'git',
|
||||||
owner => 'mastodon',
|
owner => $mastodon_user,
|
||||||
group => 'mastodon',
|
group => $mastodon_group,
|
||||||
require => Vcsrepo['rbenv'],
|
require => Vcsrepo['rbenv'],
|
||||||
}
|
}
|
||||||
file { '/usr/local/bin/install_ruby.sh':
|
file { '/usr/local/bin/install_ruby.sh':
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
content => template('mastodon/install_ruby.sh.erb'),
|
content => template('mastodon/install_ruby.sh.erb'),
|
||||||
mode => '0750',
|
mode => '0750',
|
||||||
owner => 'mastodon',
|
owner => $mastodon_user,
|
||||||
group => 'root',
|
group => 'root',
|
||||||
require => Vcsrepo['ruby_build'],
|
require => Vcsrepo['ruby_build'],
|
||||||
}
|
}
|
||||||
exec { 'install_ruby':
|
exec { 'install_ruby':
|
||||||
command => '/usr/local/bin/install_ruby.sh',
|
command => '/usr/local/bin/install_ruby.sh',
|
||||||
user => 'mastodon',
|
user => $mastodon_user,
|
||||||
cwd => "${mastodon_home}/.rbenv/",
|
cwd => "${mastodon_home}/.rbenv/",
|
||||||
creates => "${mastodon_home}/.rbenv/versions/3.2.2/bin/ruby",
|
creates => "${mastodon_home}/.rbenv/versions/3.2.2/bin/ruby",
|
||||||
require => File['/usr/local/bin/install_ruby.sh'],
|
require => File['/usr/local/bin/install_ruby.sh'],
|
||||||
}
|
}
|
||||||
# exec { 'set_global_ruby_version':
|
# exec { 'set_global_ruby_version':
|
||||||
# command => "${mastodon_home}/.rbenv/libexec/rbenv global 3.2.2",
|
# command => "${mastodon_home}/.rbenv/libexec/rbenv global 3.2.2",
|
||||||
# user => 'mastodon',
|
# user => $mastodon_user,
|
||||||
# cwd => "${mastodon_home}/.rbenv/",
|
# cwd => "${mastodon_home}/.rbenv/",
|
||||||
# # creates => '',
|
# # creates => '',
|
||||||
# require => Exec['install_ruby'],
|
# require => Exec['install_ruby'],
|
||||||
# }
|
# }
|
||||||
# exec { 'install_bundler':
|
# exec { 'install_bundler':
|
||||||
# command => 'gem install bundler --no-document',
|
# command => 'gem install bundler --no-document',
|
||||||
# user => 'mastodon',
|
# user => $mastodon_user,
|
||||||
# cwd => "${mastodon_home}/.rbenv/",
|
# cwd => "${mastodon_home}/.rbenv/",
|
||||||
# # creates => '',
|
# # creates => '',
|
||||||
# require => Vcsrepo['ruby_build'],
|
# require => Vcsrepo['ruby_build'],
|
||||||
|
@ -194,20 +207,20 @@ class mastodon (
|
||||||
source => 'https://github.com/mastodon/mastodon.git',
|
source => 'https://github.com/mastodon/mastodon.git',
|
||||||
revision => $mastodon_version,
|
revision => $mastodon_version,
|
||||||
provider => 'git',
|
provider => 'git',
|
||||||
owner => 'mastodon',
|
owner => $mastodon_user,
|
||||||
group => 'mastodon',
|
group => $mastodon_group,
|
||||||
require => User['mastodon'],
|
require => User[$mastodon_user],
|
||||||
}
|
}
|
||||||
# exec { 'config_deployment':
|
# exec { 'config_deployment':
|
||||||
# command => 'bundle config deployment \'true\'',
|
# command => 'bundle config deployment \'true\'',
|
||||||
# user => 'mastodon',
|
# user => $mastodon_user,
|
||||||
# cwd => "${mastodon_home}/live",
|
# cwd => "${mastodon_home}/live",
|
||||||
# # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
# # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
||||||
# require => Rvm_gemset['bundler'],
|
# require => Rvm_gemset['bundler'],
|
||||||
# }
|
# }
|
||||||
# exec { 'config_without_devel_test':
|
# exec { 'config_without_devel_test':
|
||||||
# command => 'bundle config without \'development test\'',
|
# command => 'bundle config without \'development test\'',
|
||||||
# user => 'mastodon',
|
# user => $mastodon_user,
|
||||||
# cwd => "${mastodon_home}/live",
|
# cwd => "${mastodon_home}/live",
|
||||||
# # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
# # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
||||||
# require => Exec['config_deployment'],
|
# require => Exec['config_deployment'],
|
||||||
|
@ -215,7 +228,7 @@ class mastodon (
|
||||||
# exec { 'bundle_install':
|
# exec { 'bundle_install':
|
||||||
# command => 'bundle install -j$(getconf _NPROCESSORS_ONLN)',
|
# command => 'bundle install -j$(getconf _NPROCESSORS_ONLN)',
|
||||||
# path => '/usr/sbin:/usr/bin:/sbin:/bin',
|
# path => '/usr/sbin:/usr/bin:/sbin:/bin',
|
||||||
# user => 'mastodon',
|
# user => $mastodon_user',
|
||||||
# cwd => "${mastodon_home}/live",
|
# cwd => "${mastodon_home}/live",
|
||||||
# # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
# # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
||||||
# require => Exec['config_without_devel_test'],
|
# require => Exec['config_without_devel_test'],
|
||||||
|
@ -223,7 +236,7 @@ class mastodon (
|
||||||
# exec { 'yarn_install':
|
# exec { 'yarn_install':
|
||||||
# command => 'yarn install --pure-lockfile',
|
# command => 'yarn install --pure-lockfile',
|
||||||
# path => '/usr/sbin:/usr/bin:/sbin:/bin',
|
# path => '/usr/sbin:/usr/bin:/sbin:/bin',
|
||||||
# user => 'mastodon',
|
# user => $mastodon_user,
|
||||||
# cwd => "${mastodon_home}/live",
|
# cwd => "${mastodon_home}/live",
|
||||||
# # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
# # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib",
|
||||||
# require => Exec['bundle_install'],
|
# require => Exec['bundle_install'],
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
su mastodon
|
su '<%= @mastodon_user %>'
|
||||||
if [ ! -e "<%= @mastodon_home %>/.rbenv/versions/3.2.2/bin/ruby" ]; then
|
if [ ! -e '<%= @mastodon_home %>/.rbenv/versions/<%= @ruby_version %>/bin/ruby' ]; then
|
||||||
cd "<%= @mastodon_home %>"
|
cd '<%= @mastodon_home %>'
|
||||||
RUBY_CONFIGURE_OPTS=--with-jemalloc "<%= @mastodon_home %>/.rbenv/bin/rbenv" install 3.2.2
|
RUBY_CONFIGURE_OPTS=--with-jemalloc '<%= @mastodon_home %>/.rbenv/bin/rbenv' install '<%= @ruby_version %>'
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue