Puppet Class: docker::registry

Defined in:
modules/docker/manifests/registry.pp

Overview

Parameters:

  • config (Any) (defaults to: {})
  • storage_backend (Any) (defaults to: 'filebackend')
  • datapath (Any) (defaults to: '/srv/registry')
  • swift_user (Any) (defaults to: undef)
  • swift_password (Any) (defaults to: undef)
  • swift_url (Any) (defaults to: undef)
  • swift_container (Any) (defaults to: undef)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
# File 'modules/docker/manifests/registry.pp', line 1

class docker::registry(
    $config={},
    $storage_backend='filebackend',
    $datapath='/srv/registry',
    $swift_user=undef,
    $swift_password=undef,
    $swift_url=undef,
    $swift_container=undef,
){

    require_package('docker-registry')

    case $storage_backend {
        'filebackend': {
            $storage_config = {
                'filesystem' => { 'rootdirectory' => $datapath },
                'cache'      => { 'blobdescriptor' => 'inmemory' },
            }
            file { $datapath:
                ensure => directory,
                mode   => '0775',
                owner  => 'docker-registry',
                group  => 'docker-registry',
            }
        }
        'swift': {
            $storage_config = {
                'swift'  => {
                    'username'  => $swift_user,
                    'password'  => $swift_password,
                    'authurl'   => $swift_url,
                    'container' => $swift_container,
                },
                'cache' => {
                    'blobdescriptor' => 'inmemory',
                },
            }
        }
        default: { fail("Unsupported storage backend ${storage_backend}") }
    }


    $base_config = {
        'version' => '0.1',
        'storage' => $storage_config,
        'http'     => {
            'addr' => '127.0.0.1:5000',
        },
    }

    # This is by default 0700 for some reason - nothing sensitive inside
    # that doesn't have additional protection
    file { '/etc/docker':
        ensure => directory,
        mode   => '0555',
    }


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

    service { 'docker-registry':
        ensure  => running,
        require => File[
            '/etc/docker',
            '/etc/docker/registry/config.yml'
        ],
    }
}