Puppet Class: profile::docker::engine

Defined in:
modules/profile/manifests/docker/engine.pp

Overview

Profile docker::engine

Installs docker, along with setting up the volume group needed for the devicemapper storage driver to work. to work

Parameters:

  • settings (Any) (defaults to: hiera_hash('profile::docker::engine::settings'))
  • version (Any) (defaults to: hiera('profile::docker::engine::version'))
  • packagename (Any) (defaults to: lookup('profile::docker::engine::packagename'))
  • declare_service (Any) (defaults to: hiera('profile::docker::engine::declare_service'))


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
# File 'modules/profile/manifests/docker/engine.pp', line 6

class profile::docker::engine(
    # We want to get settings across the hierarchy, some per host, some fleet
    # wide. So use hiera_hash to merge keys across the hierarchy
    $settings = hiera_hash('profile::docker::engine::settings'),
    # Version to install; the default is not to pick one.
    $version = hiera('profile::docker::engine::version'),
    $packagename = lookup('profile::docker::engine::packagename'),
    # Set to false if we don't want to declare the docker service here
    # We want this to be on if we want to use a different docker systemd service (with flannel support, for eg.)
    $declare_service = hiera('profile::docker::engine::declare_service')
) {

    # On Buster and later we use Docker from Debian
    if os_version('debian < buster') {
        apt::repository { 'thirdparty-k8s':
            uri        => 'http://apt.wikimedia.org/wikimedia',
            dist       => "${::lsbdistcodename}-wikimedia",
            components => 'thirdparty/k8s',
            before     => Class['docker'],
        }
    }

    # Docker config
    # Fetch the storage config from the related driver
    # I know this is horrible
    if defined(Class['::profile::docker::storage::thinpool']) {
        $docker_storage_options = $::profile::docker::storage::thinpool::options
    } elsif defined(Class['::profile::docker::storage::loopback']) {
        $docker_storage_options = $::profile::docker::storage::loopback::options

    } else {
        $docker_storage_options = $::profile::docker::storage::options
    }

    # We need to import one storage config
    class { '::docker::configuration':
        settings => merge($settings, $docker_storage_options),
    }

    # Install docker, we should remove the "version" parameter when everything
    # is using Buster/Docker as packaged by Debian
    class { '::docker':
        version      => $version,
        package_name => $packagename,
    }

    # Enable memory cgroup
    grub::bootparam { 'cgroup_enable':
        value => 'memory',
    }

    grub::bootparam { 'swapaccount':
        value => '1',
    }

    if $declare_service {
        # Service declaration
        service { 'docker':
            ensure => 'running',
        }
    }
}