Defined Type: docker_registry::instance

Defined in:
modules/docker_registry/manifests/instance.pp

Overview

SPDX-License-Identifier: Apache-2.0 Puppet define allowing to set up a specific instance of the docker registry. Can be re-used to setup more than 1 running on a host https://distribution.github.io/distribution/about/configuration/#list-of-configuration-options prevent against tampering

Parameters:

  • backend_config. —

    Required. A hash having the configuration for the backend. Use the proper YAML straight from

  • redis_config. —

    Required. A hash with the following fields to configure a redis caching service. redis_host. String. The hostname to the Redis host redis_port. Integer. The port redis listen on redis_password. String. Password to connect to redis redis_db. Integer, the Redis database used

  • registry_shared_secret. —

    String. Only needed if >1 registry behind LB and all instances should have the same. Used to

  • port. —

    Integer. The port the registry listens on

  • debug_port. —

    Integer. Optional Debug is where the registry exposes Prometheus metrics. This is the port it listens on

  • redirect_backend. —

    Boolean. Optional. Allow content redirects from storage backends.

  • catalog_max_entries. —

    Integer. Optional. Max amout of entries returned by the catalog endpoint.

  • backend_config (Hash)
  • redis_config (Docker_registry::Redisconfig)
  • registry_shared_secret (String)
  • catalog_maxentries (Integer)
  • port (Integer) (defaults to: 5000)
  • debug_port (Integer) (defaults to: 5001)
  • redirect_backend (Boolean) (defaults to: false)
  • log_level (String) (defaults to: 'info')


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'modules/docker_registry/manifests/instance.pp', line 17

define docker_registry::instance (
    Hash $backend_config,
    Docker_registry::Redisconfig $redis_config,
    String  $registry_shared_secret,
    Integer $catalog_maxentries,
    Integer $port=5000,
    Integer $debug_port=5001,
    Boolean $redirect_backend=false,
    String  $log_level='info',
){
    $storage_config = {
        'storage' => {
            's3'       => $backend_config,
            'redirect' => {
                'disable' => !$redirect_backend,
            }
        }
    }

    # Read the basic configuration from a YAML file, merge in the parameters, spit it out as YAML file
    # Why? Cause carrying the configuration in a Puppet hash, while feasible is less readable. And messing with YAML in
    # ERB is most definitely not fun
    $module_path = get_module_path($module_name)
    $base_config = loadyaml("${module_path}/files/base-config.yaml")
    $overrides = {
        'log'     => {
            'level'  => $log_level,
        },
        'http'    => {
            'addr'   => ":${port}",
            'secret' => $registry_shared_secret,
            'debug'  => {
                'addr' => ":${debug_port}",
            }
        },
        'redis'   => $redis_config,
        'catalog' => {
            'maxentries' => $catalog_maxentries,
        },
        'health'  => {
            'tcp' => [{ 'addr' => $redis_config['addr']}],
        }
    }
    $config = deep_merge($base_config, $overrides, $storage_config)

    file { "/etc/docker/registry/config-${title}.yml":
        content => stdlib::to_yaml($config),
        owner   => 'docker-registry',
        group   => 'docker-registry',
        mode    => '0440',
        notify  => Service["docker-registry-${title}"],
    }

    systemd::service { "docker-registry-${title}":
        ensure         => 'present',
        content        =>  systemd_template('registry'),
        restart        => true,
        team           => 'ServiceOps',
        service_params => {
            enable  => true,
        },
    }
}