From 163f26c00c1c076821f3ed0c3bcc49fecf30680b 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 14:37:53 +0200 Subject: [PATCH] Updated the broker to use vcsrepo as well. --- files/broker/on_update.sh | 9 --------- manifests/aes_sw.pp | 13 ------------- manifests/auth.pp | 4 ++-- manifests/broker.pp | 31 ++++++++++++++++++++++--------- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/files/broker/on_update.sh b/files/broker/on_update.sh index 1e6a62c..f8a9579 100644 --- a/files/broker/on_update.sh +++ b/files/broker/on_update.sh @@ -1,6 +1,5 @@ #!/bin/bash -run_as_broker=$(cat <<'EOF' cd # To make sure we have a decent GCC in our path. source /opt/rh/devtoolset-7/enable @@ -17,12 +16,4 @@ cd mkdir -p bin/ rm -f bin/broker cp src/broker/broker bin/ -EOF -) - -# Compile as "broker". -sudo --user broker --group broker --set-home -- bash -c "$run_as_broker" - -# Then, we can restart the services. -systemctl restart aes_broker.service diff --git a/manifests/aes_sw.pp b/manifests/aes_sw.pp index f3b109a..54b18b2 100644 --- a/manifests/aes_sw.pp +++ b/manifests/aes_sw.pp @@ -138,13 +138,6 @@ class aes::aes_sw { enable => true, } - # exec { 'script-repo-updated': - # command => "/opt/utils/update_repo.sh ${examadm_home}/scripts https://oauth2:iAyewr9Jq5E-tnsVrmbj@gitlab.liu.se/examadm/scripts.git master", - # cwd => $examadm_home, - # user => $examadm_user, - # group => $examadm_group, - # } - # Test to replace exec for repo update //thojo16 vcsrepo { "${examadm_home}/scripts": ensure => latest, @@ -153,12 +146,6 @@ class aes::aes_sw { revision => 'master', owner => $examadm_user, group => $examadm_group, - notify => Exec['TriggeredByUpdates'], - } - exec { 'TriggeredByUpdates': - path => '/bin/:/usr/bin/', - command => "touch ${examadm_home}/foo-vcsrepo", - refreshonly => true, } schedule { 'everyday': diff --git a/manifests/auth.pp b/manifests/auth.pp index 5e4c432..6b581ce 100644 --- a/manifests/auth.pp +++ b/manifests/auth.pp @@ -141,10 +141,10 @@ class aes::auth ( group => $auth_group, cwd => $auth_home, path => '/bin:/usr/bin', - command => "${auth_home}/on_update.sh", environment => ["HOME=${auth_home}"], - refreshonly => true, + command => "${auth_home}/on_update.sh", require => File["${auth_home}/on_update.sh"], + refreshonly => true, notify => Service[$auth_service], } diff --git a/manifests/broker.pp b/manifests/broker.pp index 3a09333..ababc23 100644 --- a/manifests/broker.pp +++ b/manifests/broker.pp @@ -1,7 +1,8 @@ # @summary -# Describe what this class do! +# Message broker for the communication module. # -# Detailed summary info if suitable +# Sets up the message broker for the communication module in the +# new exam system. # # class aes::broker { @@ -93,14 +94,26 @@ class aes::broker { source => "puppet:///modules/${module_name}/broker/cert/${server_type}_password", } - exec { 'update-broker-repo' : - command => "/opt/utils/update_repo.sh ${broker_home}/src https://oauth2:F-agHaRXCdyFy38q4c-N@gitlab.liu.se/upp-aes/communication.git ${server_type}", - environment => ["REPO_USER=${broker_user}", "REPO_GROUP=${broker_group}", "REPO_ON_UPDATE=${broker_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 { "${broker_home}/src": + ensure => latest, + provider => git, + source => 'https://oauth2:F-agHaRXCdyFy38q4c-N@gitlab.liu.se/upp-aes/communication.git', + revision => $server_type, + owner => $broker_user, + group => $broker_group, + notify => 'compile-broker-repo', + } + + exec { 'compile-broker-repo': + user => $broker_user, + group => $broker_group, cwd => $broker_home, - require => File["${broker_home}/on_update.sh"], + path => '/bin:/usr/bin', + environment => ["HOME=${auth_home}"], + command => "${auth_home}/on_update.sh", + require => File["${auth_home}/on_update.sh"], + refreshonly => true, + notify => Service[$broker_service], } service { $broker_service : -- GitLab