Puppet Class: docker::service

Defined in:
manifests/service.pp

Overview

Class: docker::service

Class to manage the docker service daemon

Parameters

tcp_bind

Which tcp port, if any, to bind the docker service to.

ip_forward

This flag interacts with the IP forwarding setting on your host system’s kernel

iptables

Enable Docker’s addition of iptables rules

ip_masq

Enable IP masquerading for bridge’s IP range.

socket_bind

Which local unix socket to bind the docker service to.

socket_group

Which local unix socket to bind the docker service to.

root_dir

Specify a non-standard root directory for docker.

extra_parameters

Plain additional parameters to pass to the docker daemon

shell_values

Array of shell values to pass into init script config files

manage_service

Specify whether the service should be managed. Valid values are ‘true’, ‘false’. Defaults to ‘true’.

Parameters:

  • service_name (Any) (defaults to: $docker::service_name)
  • daemon_command (Any) (defaults to: $docker::daemon_command)
  • tcp_bind (Any) (defaults to: $docker::tcp_bind)
  • ip_forward (Any) (defaults to: $docker::ip_forward)
  • iptables (Any) (defaults to: $docker::iptables)
  • ip_masq (Any) (defaults to: $docker::ip_masq)
  • icc (Any) (defaults to: $docker::icc)
  • bridge (Any) (defaults to: $docker::bridge)
  • fixed_cidr (Any) (defaults to: $docker::fixed_cidr)
  • default_gateway (Any) (defaults to: $docker::default_gateway)
  • socket_bind (Any) (defaults to: $docker::socket_bind)
  • log_level (Any) (defaults to: $docker::log_level)
  • log_driver (Any) (defaults to: $docker::log_driver)
  • log_opt (Any) (defaults to: $docker::log_opt)
  • selinux_enabled (Any) (defaults to: $docker::selinux_enabled)
  • socket_group (Any) (defaults to: $docker::socket_group)
  • labels (Any) (defaults to: $docker::labels)
  • dns (Any) (defaults to: $docker::dns)
  • dns_search (Any) (defaults to: $docker::dns_search)
  • service_state (Any) (defaults to: $docker::service_state)
  • service_enable (Any) (defaults to: $docker::service_enable)
  • manage_service (Any) (defaults to: $docker::manage_service)
  • root_dir (Any) (defaults to: $docker::root_dir)
  • extra_parameters (Any) (defaults to: $docker::extra_parameters)
  • shell_values (Any) (defaults to: $docker::shell_values)
  • proxy (Any) (defaults to: $docker::proxy)
  • no_proxy (Any) (defaults to: $docker::no_proxy)
  • execdriver (Any) (defaults to: $docker::execdriver)
  • bip (Any) (defaults to: $docker::bip)
  • mtu (Any) (defaults to: $docker::mtu)
  • storage_driver (Any) (defaults to: $docker::storage_driver)
  • dm_basesize (Any) (defaults to: $docker::dm_basesize)
  • dm_fs (Any) (defaults to: $docker::dm_fs)
  • dm_mkfsarg (Any) (defaults to: $docker::dm_mkfsarg)
  • dm_mountopt (Any) (defaults to: $docker::dm_mountopt)
  • dm_blocksize (Any) (defaults to: $docker::dm_blocksize)
  • dm_loopdatasize (Any) (defaults to: $docker::dm_loopdatasize)
  • dm_loopmetadatasize (Any) (defaults to: $docker::dm_loopmetadatasize)
  • dm_datadev (Any) (defaults to: $docker::dm_datadev)
  • dm_metadatadev (Any) (defaults to: $docker::dm_metadatadev)
  • tmp_dir (Any) (defaults to: $docker::tmp_dir)
  • nowarn_kernel (Any) (defaults to: $docker::nowarn_kernel)
  • dm_thinpooldev (Any) (defaults to: $docker::dm_thinpooldev)
  • dm_use_deferred_removal (Any) (defaults to: $docker::dm_use_deferred_removal)
  • dm_use_deferred_deletion (Any) (defaults to: $docker::dm_use_deferred_deletion)
  • dm_blkdiscard (Any) (defaults to: $docker::dm_blkdiscard)
  • dm_override_udev_sync_check (Any) (defaults to: $docker::dm_override_udev_sync_check)
  • storage_devs (Any) (defaults to: $docker::storage_devs)
  • storage_vg (Any) (defaults to: $docker::storage_vg)
  • storage_root_size (Any) (defaults to: $docker::storage_root_size)
  • storage_data_size (Any) (defaults to: $docker::storage_data_size)
  • storage_min_data_size (Any) (defaults to: $docker::storage_min_data_size)
  • storage_chunk_size (Any) (defaults to: $docker::storage_chunk_size)
  • storage_growpart (Any) (defaults to: $docker::storage_growpart)
  • storage_auto_extend_pool (Any) (defaults to: $docker::storage_auto_extend_pool)
  • storage_pool_autoextend_threshold (Any) (defaults to: $docker::storage_pool_autoextend_threshold)
  • storage_pool_autoextend_percent (Any) (defaults to: $docker::storage_pool_autoextend_percent)
  • storage_config (Any) (defaults to: $docker::storage_config)
  • storage_config_template (Any) (defaults to: $docker::storage_config_template)
  • storage_setup_file (Any) (defaults to: $docker::storage_setup_file)
  • service_provider (Any) (defaults to: $docker::service_provider)
  • service_config (Any) (defaults to: $docker::service_config)
  • service_config_template (Any) (defaults to: $docker::service_config_template)
  • service_overrides_template (Any) (defaults to: $docker::service_overrides_template)
  • service_hasstatus (Any) (defaults to: $docker::service_hasstatus)
  • service_hasrestart (Any) (defaults to: $docker::service_hasrestart)
  • daemon_environment_files (Any) (defaults to: $docker::daemon_environment_files)
  • tls_enable (Any) (defaults to: $docker::tls_enable)
  • tls_verify (Any) (defaults to: $docker::tls_verify)
  • tls_cacert (Any) (defaults to: $docker::tls_cacert)
  • tls_cert (Any) (defaults to: $docker::tls_cert)
  • tls_key (Any) (defaults to: $docker::tls_key)


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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'manifests/service.pp', line 39

class docker::service (
  $service_name                      = $docker::service_name,
  $daemon_command                    = $docker::daemon_command,
  $tcp_bind                          = $docker::tcp_bind,
  $ip_forward                        = $docker::ip_forward,
  $iptables                          = $docker::iptables,
  $ip_masq                           = $docker::ip_masq,
  $icc                               = $docker::icc,
  $bridge                            = $docker::bridge,
  $fixed_cidr                        = $docker::fixed_cidr,
  $default_gateway                   = $docker::default_gateway,
  $socket_bind                       = $docker::socket_bind,
  $log_level                         = $docker::log_level,
  $log_driver                        = $docker::log_driver,
  $log_opt                           = $docker::log_opt,
  $selinux_enabled                   = $docker::selinux_enabled,
  $socket_group                      = $docker::socket_group,
  $labels                            = $docker::labels,
  $dns                               = $docker::dns,
  $dns_search                        = $docker::dns_search,
  $service_state                     = $docker::service_state,
  $service_enable                    = $docker::service_enable,
  $manage_service                    = $docker::manage_service,
  $root_dir                          = $docker::root_dir,
  $extra_parameters                  = $docker::extra_parameters,
  $shell_values                      = $docker::shell_values,
  $proxy                             = $docker::proxy,
  $no_proxy                          = $docker::no_proxy,
  $execdriver                        = $docker::execdriver,
  $bip                               = $docker::bip,
  $mtu                               = $docker::mtu,
  $storage_driver                    = $docker::storage_driver,
  $dm_basesize                       = $docker::dm_basesize,
  $dm_fs                             = $docker::dm_fs,
  $dm_mkfsarg                        = $docker::dm_mkfsarg,
  $dm_mountopt                       = $docker::dm_mountopt,
  $dm_blocksize                      = $docker::dm_blocksize,
  $dm_loopdatasize                   = $docker::dm_loopdatasize,
  $dm_loopmetadatasize               = $docker::dm_loopmetadatasize,
  $dm_datadev                        = $docker::dm_datadev,
  $dm_metadatadev                    = $docker::dm_metadatadev,
  $tmp_dir                           = $docker::tmp_dir,
  $nowarn_kernel                     = $docker::nowarn_kernel,
  $dm_thinpooldev                    = $docker::dm_thinpooldev,
  $dm_use_deferred_removal           = $docker::dm_use_deferred_removal,
  $dm_use_deferred_deletion          = $docker::dm_use_deferred_deletion,
  $dm_blkdiscard                     = $docker::dm_blkdiscard,
  $dm_override_udev_sync_check       = $docker::dm_override_udev_sync_check,
  $storage_devs                      = $docker::storage_devs,
  $storage_vg                        = $docker::storage_vg,
  $storage_root_size                 = $docker::storage_root_size,
  $storage_data_size                 = $docker::storage_data_size,
  $storage_min_data_size             = $docker::storage_min_data_size,
  $storage_chunk_size                = $docker::storage_chunk_size,
  $storage_growpart                  = $docker::storage_growpart,
  $storage_auto_extend_pool          = $docker::storage_auto_extend_pool,
  $storage_pool_autoextend_threshold = $docker::storage_pool_autoextend_threshold,
  $storage_pool_autoextend_percent   = $docker::storage_pool_autoextend_percent,
  $storage_config                    = $docker::storage_config,
  $storage_config_template           = $docker::storage_config_template,
  $storage_setup_file                = $docker::storage_setup_file,
  $service_provider                  = $docker::service_provider,
  $service_config                    = $docker::service_config,
  $service_config_template           = $docker::service_config_template,
  $service_overrides_template        = $docker::service_overrides_template,
  $service_hasstatus                 = $docker::service_hasstatus,
  $service_hasrestart                = $docker::service_hasrestart,
  $daemon_environment_files          = $docker::daemon_environment_files,
  $tls_enable                        = $docker::tls_enable,
  $tls_verify                        = $docker::tls_verify,
  $tls_cacert                        = $docker::tls_cacert,
  $tls_cert                          = $docker::tls_cert,
  $tls_key                           = $docker::tls_key,
) {

  unless $::osfamily =~ /(Debian|RedHat|Archlinux|Gentoo)/ {
    fail('The docker::service class needs a Debian, RedHat, Archlinux or Gentoo based system.')
  }

  $dns_array = any2array($dns)
  $dns_search_array = any2array($dns_search)
  $extra_parameters_array = any2array($extra_parameters)
  $shell_values_array = any2array($shell_values)
  $tcp_bind_array = any2array($tcp_bind)

  if $service_config {
    $_service_config = $service_config
  } else {
    if $::osfamily == 'Debian' {
      $_service_config = "/etc/default/${service_name}"
    }
  }

  $_manage_service = $manage_service ? {
    true    => Service['docker'],
    default => [],
  }

  if $::osfamily == 'RedHat' {
    file { $storage_setup_file:
      ensure  => present,
      force   => true,
      content => template('docker/etc/sysconfig/docker-storage-setup.erb'),
      before  => $_manage_service,
      notify  => $_manage_service,
    }
  }

  case $service_provider {
    'systemd': {
      file { '/etc/systemd/system/docker.service.d':
        ensure => directory,
      }

      if $service_overrides_template {
        file { '/etc/systemd/system/docker.service.d/service-overrides.conf':
          ensure  => present,
          content => template($service_overrides_template),
          notify  => Exec['docker-systemd-reload-before-service'],
          before  => $_manage_service,
        }
        exec { 'docker-systemd-reload-before-service':
          path        => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'],
          command     => 'systemctl daemon-reload > /dev/null',
          before      => $_manage_service,
          refreshonly => true,
        }
      }
    }
    'upstart': {
      file { '/etc/init.d/docker':
        ensure => 'link',
        target => '/lib/init/upstart-job',
        force  => true,
        notify => $_manage_service,
      }
    }
    default: {}
  }

  if $storage_config {
    file { $storage_config:
      ensure  => present,
      force   => true,
      content => template($storage_config_template),
      notify  => $_manage_service,
    }
  }

  if $_service_config {
    file { $_service_config:
      ensure  => present,
      force   => true,
      content => template($service_config_template),
      notify  => $_manage_service,
    }
  }

  if $manage_service {
    service { 'docker':
      ensure     => $service_state,
      name       => $service_name,
      enable     => $service_enable,
      hasstatus  => $service_hasstatus,
      hasrestart => $service_hasrestart,
      provider   => $service_provider,
    }
  }
}