Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9749612
D6305.id22986.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D6305.id22986.diff
View Options
diff --git a/data/common/common.yaml b/data/common/common.yaml
--- a/data/common/common.yaml
+++ b/data/common/common.yaml
@@ -2523,6 +2523,11 @@
- swh.loader.mercurial.tasks.LoadMercurial
- swh.loader.mercurial.tasks.LoadArchiveMercurial
+swh::deploy::worker::opam::root_directory: /tmp/opam/
+swh::deploy::worker::opam::instances:
+ opam: https://opam.ocaml.org
+ ocamlbench-repo: https://github.com/OCamlPro/ocamlbench-repo.git
+
swh::deploy::worker::loader_opam::config_file: "%{hiera('swh::conf_directory')}/loader_opam.yml"
swh::deploy::worker::loader_opam::concurrency: 1
swh::deploy::worker::loader_opam::private_tmp: true
diff --git a/site-modules/profile/manifests/swh/deploy/worker/loader_opam.pp b/site-modules/profile/manifests/swh/deploy/worker/loader_opam.pp
--- a/site-modules/profile/manifests/swh/deploy/worker/loader_opam.pp
+++ b/site-modules/profile/manifests/swh/deploy/worker/loader_opam.pp
@@ -17,4 +17,49 @@
Package[$packages],
],
}
+
+ $opam_instances = lookup('swh::deploy::worker::opam::instances')
+
+ $opam_root = lookup('swh::deploy::worker::opam::root_directory')
+ file {$opam_root:
+ ensure => 'directory',
+ owner => $user,
+ group => $group,
+ recurse => true,
+ mode => '0644',
+ }
+
+ $binary_cmd = "/usr/bin/opam"
+
+ each ( $opam_instances ) | $instance, $instance_url | {
+ $opam_manage_shared_state = "opam-manage-shared-state"
+ $opam_manage_service_name = "${$opam_manage_shared_state}-${instance}"
+ $opam_manage_shared_state_timer_name = "${opam_manage_service_name}.timer"
+
+ $command_suffix = "--root ${opam_root} ${instance} ${instance_url}"
+ if $instance == "opam" {
+ # Install the default rootdir for the main opam instance
+ $opam_command = "${binary_cmd} init --reinit --bare --no-setup ${command_suffix}"
+ } else {
+ # Other instances will just be added to the main opam root directory
+ $opam_command = "${binary_cmd} repository add ${command_suffix}"
+ }
+
+ # Template uses variables
+ # - $user
+ # - $group
+ # - $opam_root
+ # - $opam_manage_service_name
+ # - $command
+ ::systemd::timer { $opam_manage_shared_state_timer_name:
+ timer_content => template("profile/swh/deploy/loader_opam/${opam_manage_shared_state}.timer.erb"),
+ service_content => template("profile/swh/deploy/loader_opam/${opam_manage_shared_state}.service.erb"),
+ enable => true,
+ require => [
+ Package[$packages],
+ File[$opam_root],
+ ],
+ }
+ }
+
}
diff --git a/site-modules/profile/templates/swh/deploy/loader_opam/opam-manage-shared-state.service.erb b/site-modules/profile/templates/swh/deploy/loader_opam/opam-manage-shared-state.service.erb
new file mode 100644
--- /dev/null
+++ b/site-modules/profile/templates/swh/deploy/loader_opam/opam-manage-shared-state.service.erb
@@ -0,0 +1,17 @@
+# Opam manage shared state unit file
+# Managed by puppet class profile::swh::deploy::worker::loader_opam
+# Changes will be overwritten
+
+[Unit]
+Description=Software Heritage Manage OPAM shared state (<%= @instance %>)
+Requires=network.target
+After=network.target
+
+[Service]
+User=<%= @user %>
+Group=<%= @group %>
+Type=simple
+ExecStart=<%= @opam_command %> && /usr/bin/opam update
+
+[Install]
+WantedBy=multi-user.target
diff --git a/site-modules/profile/templates/swh/deploy/loader_opam/opam-manage-shared-state.timer.erb b/site-modules/profile/templates/swh/deploy/loader_opam/opam-manage-shared-state.timer.erb
new file mode 100644
--- /dev/null
+++ b/site-modules/profile/templates/swh/deploy/loader_opam/opam-manage-shared-state.timer.erb
@@ -0,0 +1,11 @@
+[Install]
+WantedBy=timers.target
+
+[Timer]
+OnCalendar=daily
+AccuracySec=4h
+Persistent=true
+Unit=<%= @opam_manage_service_name %>.service
+
+[Unit]
+Description=Software Heritage Manage OPAM shared state (<%= @instance %>) timer
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Aug 24, 6:02 PM (4 d, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3230510
Attached To
D6305: opam: Install and maintain up-to-date shared opam root directories
Event Timeline
Log In to Comment