summaryrefslogtreecommitdiff
path: root/manifests/distribution_registry.pp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-06-11 02:26:17 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-06-11 02:44:18 +0200
commit04ef27409843d9cfc6d6a06a06632b937c547e8d (patch)
tree6abc503d489068063fefba1d66d3efcada44c130 /manifests/distribution_registry.pp
parentChange dhcpd domain. (diff)
downloadprofiles-04ef27409843d9cfc6d6a06a06632b937c547e8d.tar.gz
profiles-04ef27409843d9cfc6d6a06a06632b937c547e8d.tar.xz
Add distribution registry.
Diffstat (limited to '')
-rw-r--r--manifests/distribution_registry.pp79
1 files changed, 79 insertions, 0 deletions
diff --git a/manifests/distribution_registry.pp b/manifests/distribution_registry.pp
new file mode 100644
index 0000000..dc7920c
--- /dev/null
+++ b/manifests/distribution_registry.pp
@@ -0,0 +1,79 @@
+# @summary Manages the "distribution" container registry service
+#
+# https://github.com/distribution/distribution
+#
+# @param http_addr
+# Address to listen to
+# @param http_net
+# If http_addr refers to an IP-address/port, or a unix socket
+# @param registry_dir
+# Container storage.
+# @param htpasswd
+# Location of htpasswd file
+# TODO only have this if basic authentication is used.
+# @param conf_file
+# Path to configuration file.
+# Does *not* move the configuration file, but is where the
+# configuraion file is expected to be on the machine.
+# @param ensure
+# To allow decomissioning
+class profiles::distribution_registry (
+ String $http_addr,
+ Enum['tcp', 'unix'] $http_net = 'tcp',
+ String $registry_dir = '/var/lib/registry',
+ String $htpasswd = '/var/lib/distribution-registry/htpasswd',
+ String $conf_file = '/etc/distribution-registry/conf.yml',
+ Enum['present', 'absent'] $ensure = 'present',
+) {
+ ensure_packages([
+ 'distribution-registry',
+ ], {
+ 'ensure' => $ensure,
+ })
+
+ if $ensure == 'present' {
+ service { 'distribution-registry.service':
+ ensure => running,
+ }
+
+ file { $conf_file:
+ content => to_yaml({
+ 'version' => '0.1',
+ 'log' => {
+ 'fields' => {
+ 'service' => 'registry',
+ },
+ },
+ 'storage' => {
+ 'cache' => {
+ 'blobdescriptor' => 'inmemory',
+ },
+ 'filesystem' => {
+ 'rootdirectory' => $registry_dir,
+ },
+ },
+ 'http' => {
+ 'addr' => $http_addr,
+ 'net' => $http_net,
+ },
+ 'auth' => {
+ 'htpasswd' => {
+ 'realm' => 'basic-realm',
+ 'path' => $htpasswd,
+ },
+ },
+ 'health' => {
+ 'storagedriver' => {
+ 'enabled' => true,
+ 'interval' => '10s',
+ 'threshold' => 3,
+ },
+ },
+ })
+ }
+ } else {
+ file { $conf_file:
+ ensure => absent,
+ }
+ }
+}