diff --git a/manifests/init.pp b/manifests/init.pp index f595742..bb078a0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -156,16 +156,20 @@ class mastodon ( group => 'mastodon', require => Vcsrepo['rbenv'], } + file { '/usr/local/bin/install_ruby.sh': + ensure => $ensure, + content => template('mastodon/install_ruby.sh.erb'), + mode => '0750', + owner => 'mastodon', + group => 'root', + require => Vcsrepo['ruby_build'], + } exec { 'install_ruby': - command => "${mastodon_home}/.rbenv/bin/rbenv install 3.2.2", - path => "${mastodon_home}/.rbenv/bin:/usr/sbin:/usr/bin:/sbin:/bin", - environment => [ - 'RUBY_CONFIGURE_OPTS=--with-jemalloc', - ], - user => 'mastodon', - cwd => "${mastodon_home}/.rbenv/", - creates => "${mastodon_home}/.rbenv/versions/3.2.2/bin/ruby", - require => Vcsrepo['ruby_build'], + command => '/usr/local/bin/install_ruby.sh', + user => 'mastodon', + cwd => "${mastodon_home}/.rbenv/", + creates => "${mastodon_home}/.rbenv/versions/3.2.2/bin/ruby", + require => File['/usr/local/bin/install_ruby.sh'], } # exec { 'set_global_ruby_version': # command => "${mastodon_home}/.rbenv/libexec/rbenv global 3.2.2", diff --git a/templates/install_ruby.sh.erb b/templates/install_ruby.sh.erb new file mode 100644 index 0000000..2502875 --- /dev/null +++ b/templates/install_ruby.sh.erb @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +su mastodon +if [ ! -e "<%= @mastodon_home %>/.rbenv/versions/3.2.2/bin/ruby" ]; then + cd "<%= @mastodon_home %>" + RUBY_CONFIGURE_OPTS=--with-jemalloc "<%= @mastodon_home %>/.rbenv/bin/rbenv" install 3.2.2 +fi