```
I, [2022-01-06T14:57:13.783163 #204691] INFO -- : Catalogs compiled for worker01.softwareheritage.org
I, [2022-01-06T14:57:14.153481 #204691] INFO -- : Diffs computed for worker01.softwareheritage.org
diff origin/production/worker01.softwareheritage.org current/worker01.softwareheritage.org
*******************************************
- File[/etc/systemd/system/opam-manage-shared-state-coq.inria.fr.service]
*******************************************
File[/etc/systemd/system/opam-manage-shared-state-coq.inria.fr.timer] =>
parameters =>
ensure =>
- file
+ absent
*******************************************
- File[/etc/systemd/system/opam-manage-shared-state-ocamlbench-repo.service]
*******************************************
File[/etc/systemd/system/opam-manage-shared-state-ocamlbench-repo.timer] =>
parameters =>
ensure =>
- file
+ absent
*******************************************
- File[/etc/systemd/system/opam-manage-shared-state-opam.ocaml.org.service]
*******************************************
File[/etc/systemd/system/opam-manage-shared-state-opam.ocaml.org.timer] =>
parameters =>
ensure =>
- file
+ absent
*******************************************
+ File[/etc/systemd/system/opam-manage-shared-state.service] =>
parameters =>
"ensure": "file"
"group": "root"
"mode": "0444"
"notify": "Class[Systemd::Systemctl::Daemon_reload]"
"owner": "root"
"show_diff": true
"content": >>>
# 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
Requires=network.target
After=network.target
[Service]
User=swhworker
Group=swhworker
Type=simple
ExecStart=/usr/local/bin/opam-manage-shared-state.sh
[Install]
WantedBy=multi-user.target
<<<
*******************************************
+ File[/etc/systemd/system/opam-manage-shared-state.timer] =>
parameters =>
"ensure": "file"
"group": "root"
"mode": "0444"
"notify": ["Class[Systemd::Systemctl::Daemon_reload]", "Service[opam-manage-shared-state.timer]"]
"owner": "root"
"show_diff": true
"content": >>>
[Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
Persistent=true
# every ~4h
AccuracySec=4h
RandomizedDelaySec=1200
FixedRandomDelay=true
Unit=.service
[Unit]
Description=Software Heritage Manage OPAM shared state timer
<<<
*******************************************
File[/usr/local/bin/opam-manage-shared-state.sh] =>
parameters =>
content =>
@@ -4,19 +4,50 @@
# Changes will be overwritten
_
-CMD=/usr/bin/opam
+# This script is in charge of bootstraping the opam root folder with the default opam
+# repository.
+
+set -e
+
ROOT_DIR=/tmp/opam/
-DEFAULT_INSTANCE="opam.ocaml.org"
-INSTANCE=$1
-INSTANCE_URL=$2
-
-if [ $INSTANCE = $DEFAULT_INSTANCE ]; then
- # Opam instance is considered the main instance so we must initialize the repository
- # if not present, otherwise we update it
- ( $CMD repo --all --root $ROOT_DIR | grep $INSTANCE_URL && $CMD update --root $ROOT_DIR ) \
- || $CMD init --reinit --bare --no-setup --root $ROOT_DIR $INSTANCE $INSTANCE_URL
-else
- # Other instances, if present should be updated. If not present, they should be added
- # to the main root_dir as extra instances
- ( $CMD repo --all --root $ROOT_DIR | grep $INSTANCE_URL && $CMD update --root $ROOT_DIR ) \
- || $CMD repository add --root $ROOT_DIR $INSTANCE $INSTANCE_URL
-fi
+CMD=/usr/bin/opam
+
+function init_or_update_opam_root () {
+ "Ensure opam root directory exists and references the main opam repository as default
+ instance. If not, create it from scratch. If properly configured, update the opam
+ repository."
+
+ instance_name=$1
+ instance_url=$2
+
+ if $CMD repo --all --root $ROOT_DIR | grep -qx $instance_url; then
+ $CMD update --root $ROOT_DIR
+ else
+ $CMD init --reinit --bare --no-setup --root $ROOT_DIR $instance_name $instance_url
+ fi
+}
+
+function init_or_update_opam_instance () {
+ "Ensure opam root directory exists and references the main opam repository as default
+ instance. If not, create it from scratch. If properly configured, update the opam
+ repository.
+
+ This assumes that the function init_or_update_opam_root already got called prior to
+ calling this one."
+
+ instance_name=$1
+ instance_url=$2
+
+ if $CMD repo --all --root $ROOT_DIR | grep -qx $instance_url; then
+ $CMD update --root $ROOT_DIR
+ else
+ $CMD repository add --root $ROOT_DIR $instance_name $instance_url
+ fi
+}
+
+init_or_update_opam_root opam.ocaml.org https://opam.ocaml.org
+
+
+init_or_update_opam_instance coq.inria.fr https://coq.inria.fr/opam/released
+
+init_or_update_opam_instance ocamlbench-repo https://github.com/OCamlPro/ocamlbench-repo.git
+
*******************************************
Service[opam-manage-shared-state-coq.inria.fr.timer] =>
parameters =>
enable =>
- true
+ false
*******************************************
Service[opam-manage-shared-state-ocamlbench-repo.timer] =>
parameters =>
enable =>
- true
+ false
*******************************************
Service[opam-manage-shared-state-opam.ocaml.org.timer] =>
parameters =>
enable =>
- true
+ false
*******************************************
+ Service[opam-manage-shared-state.timer] =>
parameters =>
"enable": true
"provider": "systemd"
*******************************************
Systemd::Timer[opam-manage-shared-state-coq.inria.fr.timer] =>
parameters =>
enable =>
- true
+ false
ensure =>
- present
+ absent
service_content =>
- # 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 (coq.inria.fr)
Requires=network.target
After=network.target
[Service]
User=swhworker
Group=swhworker
Type=simple
ExecStart=/usr/local/bin/opam-manage-shared-state.sh coq.inria.fr https://coq.inria.fr/opam/released
[Install]
WantedBy=multi-user.target
timer_content =>
- [Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
AccuracySec=4h
Persistent=true
Unit=opam-manage-shared-state-coq.inria.fr.service
[Unit]
Description=Software Heritage Manage OPAM shared state (coq.inria.fr) timer
*******************************************
Systemd::Timer[opam-manage-shared-state-ocamlbench-repo.timer] =>
parameters =>
enable =>
- true
+ false
ensure =>
- present
+ absent
service_content =>
- # 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 (ocamlbench-repo)
Requires=network.target
After=network.target
[Service]
User=swhworker
Group=swhworker
Type=simple
ExecStart=/usr/local/bin/opam-manage-shared-state.sh ocamlbench-repo https://github.com/OCamlPro/ocamlbench-repo.git
[Install]
WantedBy=multi-user.target
timer_content =>
- [Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
AccuracySec=4h
Persistent=true
Unit=opam-manage-shared-state-ocamlbench-repo.service
[Unit]
Description=Software Heritage Manage OPAM shared state (ocamlbench-repo) timer
*******************************************
Systemd::Timer[opam-manage-shared-state-opam.ocaml.org.timer] =>
parameters =>
enable =>
- true
+ false
ensure =>
- present
+ absent
service_content =>
- # 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 (opam.ocaml.org)
Requires=network.target
After=network.target
[Service]
User=swhworker
Group=swhworker
Type=simple
ExecStart=/usr/local/bin/opam-manage-shared-state.sh opam.ocaml.org https://opam.ocaml.org
[Install]
WantedBy=multi-user.target
timer_content =>
- [Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
AccuracySec=4h
Persistent=true
Unit=opam-manage-shared-state-opam.ocaml.org.service
[Unit]
Description=Software Heritage Manage OPAM shared state (opam.ocaml.org) timer
*******************************************
+ Systemd::Timer[opam-manage-shared-state.timer] =>
parameters =>
"enable": true
"ensure": "present"
"group": "root"
"mode": "0444"
"owner": "root"
"path": "/etc/systemd/system"
"show_diff": true
"service_content": >>>
# 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
Requires=network.target
After=network.target
[Service]
User=swhworker
Group=swhworker
Type=simple
ExecStart=/usr/local/bin/opam-manage-shared-state.sh
[Install]
WantedBy=multi-user.target
<<<
"timer_content": >>>
[Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
Persistent=true
# every ~4h
AccuracySec=4h
RandomizedDelaySec=1200
FixedRandomDelay=true
Unit=.service
[Unit]
Description=Software Heritage Manage OPAM shared state timer
<<<
*******************************************
- Systemd::Unit_file[opam-manage-shared-state-coq.inria.fr.service]
*******************************************
Systemd::Unit_file[opam-manage-shared-state-coq.inria.fr.timer] =>
parameters =>
content =>
- [Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
AccuracySec=4h
Persistent=true
Unit=opam-manage-shared-state-coq.inria.fr.service
[Unit]
Description=Software Heritage Manage OPAM shared state (coq.inria.fr) timer
enable =>
- true
+ false
ensure =>
- present
+ absent
*******************************************
- Systemd::Unit_file[opam-manage-shared-state-ocamlbench-repo.service]
*******************************************
Systemd::Unit_file[opam-manage-shared-state-ocamlbench-repo.timer] =>
parameters =>
content =>
- [Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
AccuracySec=4h
Persistent=true
Unit=opam-manage-shared-state-ocamlbench-repo.service
[Unit]
Description=Software Heritage Manage OPAM shared state (ocamlbench-repo) timer
enable =>
- true
+ false
ensure =>
- present
+ absent
*******************************************
- Systemd::Unit_file[opam-manage-shared-state-opam.ocaml.org.service]
*******************************************
Systemd::Unit_file[opam-manage-shared-state-opam.ocaml.org.timer] =>
parameters =>
content =>
- [Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
AccuracySec=4h
Persistent=true
Unit=opam-manage-shared-state-opam.ocaml.org.service
[Unit]
Description=Software Heritage Manage OPAM shared state (opam.ocaml.org) timer
enable =>
- true
+ false
ensure =>
- present
+ absent
*******************************************
+ Systemd::Unit_file[opam-manage-shared-state.service] =>
parameters =>
"ensure": "present"
"group": "root"
"mode": "0444"
"owner": "root"
"path": "/etc/systemd/system"
"show_diff": true
"content": >>>
# 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
Requires=network.target
After=network.target
[Service]
User=swhworker
Group=swhworker
Type=simple
ExecStart=/usr/local/bin/opam-manage-shared-state.sh
[Install]
WantedBy=multi-user.target
<<<
*******************************************
+ Systemd::Unit_file[opam-manage-shared-state.timer] =>
parameters =>
"enable": true
"ensure": "present"
"group": "root"
"mode": "0444"
"owner": "root"
"path": "/etc/systemd/system"
"show_diff": true
"content": >>>
[Install]
WantedBy=timers.target
[Timer]
OnCalendar=daily
Persistent=true
# every ~4h
AccuracySec=4h
RandomizedDelaySec=1200
FixedRandomDelay=true
Unit=.service
[Unit]
Description=Software Heritage Manage OPAM shared state timer
<<<
*******************************************
*** End octocatalog-diff on worker01.softwareheritage.org
```
vagrant happily applies:
```
root@worker01:~# puppet agent --test
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for worker01.softwareheritage.org
Info: Applying configuration version '1641477373'
Notice: /Stage[main]/Profile::Swh::Deploy::Worker::Loader_opam/File[/usr/local/bin/opam-manage-shared-state.sh]/ensure: defined content as '{md5}83887117dc51304dccf9be4d2de6689e'
Notice: /Stage[main]/Profile::Systemd_journal::Journalbeat/Service[journalbeat]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Profile::Systemd_journal::Journalbeat/Service[journalbeat]: Unscheduling refresh on Service[journalbeat]
Notice: /Stage[main]/Profile::Swh::Deploy::Worker::Loader_opam/Systemd::Timer[opam-manage-shared-state.timer]/Systemd::Unit_file[opam-manage-shared-state.service]/File[/etc/systemd/system/opam-manage-shared-state.service]/ensure: defined content as '{md5}e8172aace3e66f8125e8dd130896ea04'
Info: /Stage[main]/Profile::Swh::Deploy::Worker::Loader_opam/Systemd::Timer[opam-manage-shared-state.timer]/Systemd::Unit_file[opam-manage-shared-state.service]/File[/etc/systemd/system/opam-manage-shared-state.service]: Scheduling refresh of Class[Systemd::Systemctl::Daemon_reload]
Notice: /Stage[main]/Profile::Swh::Deploy::Worker::Loader_opam/Systemd::Timer[opam-manage-shared-state.timer]/Systemd::Unit_file[opam-manage-shared-state.timer]/File[/etc/systemd/system/opam-manage-shared-state.timer]/ensure: defined content as '{md5}8ff16243ea844896f963343d7f0b0aa7'
Info: /Stage[main]/Profile::Swh::Deploy::Worker::Loader_opam/Systemd::Timer[opam-manage-shared-state.timer]/Systemd::Unit_file[opam-manage-shared-state.timer]/File[/etc/systemd/system/opam-manage-shared-state.timer]: Scheduling refresh of Service[opam-manage-shared-state.timer]
Info: /Stage[main]/Profile::Swh::Deploy::Worker::Loader_opam/Systemd::Timer[opam-manage-shared-state.timer]/Systemd::Unit_file[opam-manage-shared-state.timer]/File[/etc/systemd/system/opam-manage-shared-state.timer]: Scheduling refresh of Class[Systemd::Systemctl::Daemon_reload]
Info: Class[Systemd::Systemctl::Daemon_reload]: Scheduling refresh of Exec[systemctl-daemon-reload]
Notice: /Stage[main]/Systemd::Systemctl::Daemon_reload/Exec[systemctl-daemon-reload]: Triggered 'refresh' from 1 event
Notice: /Stage[main]/Profile::Swh::Deploy::Worker::Loader_opam/Systemd::Timer[opam-manage-shared-state.timer]/Systemd::Unit_file[opam-manage-shared-state.timer]/Service[opam-manage-shared-state.timer]/enable: enable changed 'false' to 'true'
Notice: /Stage[main]/Profile::Swh::Deploy::Worker::Loader_opam/Systemd::Timer[opam-manage-shared-state.timer]/Systemd::Unit_file[opam-manage-shared-state.timer]/Service[opam-manage-shared-state.timer]: Triggered 'refresh' from 1 event
Notice: Applied catalog in 2.68 seconds
```