From bc0598b7c69abd040389895f849a8c60e9991d66 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Tue, 28 Nov 2023 11:24:56 +0200 Subject: [PATCH] install from script --- manifests/init.pp | 62 ++++++------------- ...ll_ruby.sh.erb => install_mastodon.sh.erb} | 4 ++ 2 files changed, 22 insertions(+), 44 deletions(-) rename templates/{install_ruby.sh.erb => install_mastodon.sh.erb} (56%) diff --git a/manifests/init.pp b/manifests/init.pp index c4705db..9fb8c19 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -169,22 +169,6 @@ class mastodon ( group => $mastodon_group, require => Vcsrepo['rbenv'], } - file { '/usr/local/bin/install_ruby.sh': - ensure => $ensure, - content => template('mastodon/install_ruby.sh.erb'), - mode => '0750', - owner => $mastodon_user, - group => 'root', - require => Vcsrepo['ruby_build'], - } - exec { 'install_ruby': - command => '/usr/local/bin/install_ruby.sh', - # user => $mastodon_user, - # cwd => "${mastodon_home}/.rbenv/", - creates => "${mastodon_home}/.rbenv/versions/3.2.2/bin/bundler", - timeout => 0, - require => File['/usr/local/bin/install_ruby.sh'], - } postgresql::server::db { 'mastodon': user => 'mastodon', password => postgresql::postgresql_password('mastodon', $db_password), @@ -198,34 +182,24 @@ class mastodon ( group => $mastodon_group, require => User[$mastodon_user], } - exec { 'config_deployment': - command => "${mastodon_home}/live/bin/bundle config deployment 'true'", - user => $mastodon_user, - cwd => "${mastodon_home}/live", - # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib", - require => Exec['install_ruby'], + file { '/usr/local/bin/install_mastodon.sh': + ensure => $ensure, + content => template('mastodon/install_mastodon.sh.erb'), + mode => '0750', + owner => $mastodon_user, + group => 'root', + require => [ + Vcsrepo['mastodon_code'], + Postgresql::Server::Db['mastodon'], + Vcsrepo['ruby_build'], + ], } - exec { 'config_without_devel_test': - command => "${mastodon_home}/live/bin/bundle config without 'development test'", - user => $mastodon_user, - cwd => "${mastodon_home}/live", - # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib", - require => Exec['config_deployment'], - } - exec { 'bundle_install': - command => "${mastodon_home}/live/bin/bundle install -j$(getconf _NPROCESSORS_ONLN)", - path => '/usr/sbin:/usr/bin:/sbin:/bin', - user => $mastodon_user, - cwd => "${mastodon_home}/live", - # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib", - require => Exec['config_without_devel_test'], - } - exec { 'yarn_install': - command => "${mastodon_home}/live/bin/yarn install --pure-lockfile", - path => '/usr/sbin:/usr/bin:/sbin:/bin', - user => $mastodon_user, - cwd => "${mastodon_home}/live", - # creates => "${mastodon_home}/.rbenv/libexec/rbenv-realpath.dylib", - require => Exec['bundle_install'], + exec { 'install_mastodon': + command => '/usr/local/bin/install_mastodon.sh', + # user => $mastodon_user, + # cwd => "${mastodon_home}/.rbenv/", + creates => "${mastodon_home}/.rbenv/versions/3.2.2/bin/bundler", + timeout => 0, + require => File['/usr/local/bin/install_mastodon.sh'], } } diff --git a/templates/install_ruby.sh.erb b/templates/install_mastodon.sh.erb similarity index 56% rename from templates/install_ruby.sh.erb rename to templates/install_mastodon.sh.erb index ca5dc2c..dbb5601 100644 --- a/templates/install_ruby.sh.erb +++ b/templates/install_mastodon.sh.erb @@ -6,4 +6,8 @@ if [ ! -e '<%= @mastodon_home %>/.rbenv/versions/<%= @ruby_version %>/bin/ruby' sudo -u <%= @mastodon_user %> RUBY_CONFIGURE_OPTS=--with-jemalloc '<%= @mastodon_home %>/.rbenv/bin/rbenv' install '<%= @ruby_version %>' sudo -u <%= @mastodon_user %> '<%= @mastodon_home %>/.rbenv/bin/rbenv' global '<%= @ruby_version %>' sudo -u <%= @mastodon_user %> '<%= @mastodon_home %>/.rbenv/versions/<%= @ruby_version %>/bin/gem' install bundler --no-document + sudo -u <%= @mastodon_user %> '<%= @mastodon_home %>/live/bin/bundle' config deployment 'true' + sudo -u <%= @mastodon_user %> '<%= @mastodon_home %>/live/bin/bundle' config without 'development test' + sudo -u <%= @mastodon_user %> '<%= @mastodon_home %>/live/bin/bundle' install -j$(getconf _NPROCESSORS_ONLN) + sudo -u <%= @mastodon_user %> '<%= @mastodon_home %>/live/bin/yarn' install --pure-lockfile fi