From 3aa9aa2f75dcbad252f6de9be52cceede7c1af0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Str=C3=B6mb=C3=A4ck?= <filip.stromback@liu.se> Date: Mon, 21 Aug 2023 15:23:12 +0200 Subject: [PATCH] Migrated OpenDSA to use vcsrepo. --- files/opendsa/on_update.sh | 11 ----------- manifests/latex.pp | 2 +- manifests/opendsa.pp | 32 ++++++++++++++++++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/files/opendsa/on_update.sh b/files/opendsa/on_update.sh index a2912aa..601494a 100644 --- a/files/opendsa/on_update.sh +++ b/files/opendsa/on_update.sh @@ -3,9 +3,6 @@ # This file is called whenever the OpenDSA repo was updated. This means we should re-check # the requirements.txt file and restart the service. -# Note: This file is executed as root, so we drop back to the opendsa user before starting pip. - -update_pip_fn=$(cat <<'EOF' cd python3 -m pip install --user -r OpenDSA/server/requirements.txt @@ -15,11 +12,3 @@ then cd OpenDSA/server/ ./main.py init_db fi -EOF -) - -# Run PIP as OpenDSA. -sudo --user opendsa --group opendsa --set-home -- bash -c "$update_pip_fn" - -# Then, we can restart the service. -systemctl service restart opendsa.service diff --git a/manifests/latex.pp b/manifests/latex.pp index 0209226..8914174 100644 --- a/manifests/latex.pp +++ b/manifests/latex.pp @@ -1,5 +1,5 @@ # @summary -# Describe what this class do! +# Install required LaTeX packages for PDF generation. # # Detailed summary info if suitable # diff --git a/manifests/opendsa.pp b/manifests/opendsa.pp index 0dc64cf..a0b5afd 100644 --- a/manifests/opendsa.pp +++ b/manifests/opendsa.pp @@ -1,5 +1,5 @@ # @summary -# Describe what this class do! +# OpenDSA server for exams. # # Detailed summary info if suitable # @@ -30,9 +30,9 @@ class aes::opendsa { # This file will be executed as root, which is why we don't let anyone but root examine it. file { "${opendsa_home}/on_update.sh": ensure => file, - owner => root, - group => root, - mode => '0700', + owner => $opendsa_user, + group => $opendsa_group, + mode => '0755', source => "puppet:///modules/${module_name}/opendsa/on_update.sh", } @@ -44,14 +44,26 @@ class aes::opendsa { source => "puppet:///modules/${module_name}/opendsa/opendsa.service", } - exec { 'update-repo': - command => "/opt/utils/update_repo.sh ${opendsa_home}/OpenDSA https://oauth2:taNPRZid9Hv6jJtdW_T8@gitlab.liu.se/opendsa/OpenDSA.git exam", - environment => ["REPO_USER=${opendsa_user}", "REPO_GROUP=${opendsa_group}", "REPO_ON_UPDATE=${opendsa_home}/on_update.sh"], - # This command will need to run "on_update" as root in order to restart the service. - user => root, - group => root, + vcsrepo { "${opendsa_home}/src": + ensure => latest, + provider => git, + source => 'https://oauth2:taNPRZid9Hv6jJtdW_T8@gitlab.liu.se/opendsa/OpenDSA.git', + revision => 'exam', + owner => $opendsa_user, + group => $opendsa_group, + notify => Exec['update-opendsa-repo'], + } + + exec { 'update-opendsa-repo': + user => $opendsa_user, + group => $opendsa_group, cwd => $opendsa_home, + path => '/bin:/usr/bin', + environment => ["HOME=${opendsa_home}"], + command => "${opendsa_home}/on_update.sh", require => File["${opendsa_home}/on_update.sh"], + notify => Service[$opendsa_service], + refreshonly => true } file { "${opendsa_home}/manage.sh": -- GitLab