diff --git a/files/opendsa/on_update.sh b/files/opendsa/on_update.sh
index a2912aae220747d95ecc6e82aec52d83e3c0d9fa..601494a2a79e503072beeea0d40df215a6b6c879 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 02092261dd54f71948c26bd09240488d7c97948f..89141745b7915cbb7814f4a847d68e61d528f6e7 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 0dc64cfe1ec99c8183509de9541203bcd914f898..a0b5afd8f58d5c2e314a44658f5d7fdc6af2dc7e 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":