Puppet Class: dockerinstall::repos

Defined in:
manifests/repos.pp

Summary

Docker repository managemennt

Overview

Docker repository managemennt

Examples:

include dockerinstall::repos

Parameters:

  • manage_package (Boolean) (defaults to: $dockerinstall::manage_package)
  • repo (Dockerinstall::Repo) (defaults to: $dockerinstall::repo)
  • location (String) (defaults to: $dockerinstall::repo_location)
  • os (Dockerinstall::RepoOS) (defaults to: $dockerinstall::repo_os)
  • gpgcheck (Boolean) (defaults to: $dockerinstall::repo_gpgcheck)
  • sslverify (Boolean) (defaults to: $dockerinstall::repo_sslverify)
  • basearch (String) (defaults to: $::architecture)
  • repo_ensure (Enum['present', 'absent']) (defaults to: 'present')


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
# File 'manifests/repos.pp', line 7

class dockerinstall::repos (
    Boolean $manage_package         = $dockerinstall::manage_package,
    Dockerinstall::Repo
            $repo                   = $dockerinstall::repo,
    String  $location               = $dockerinstall::repo_location,
    Dockerinstall::RepoOS
            $os                     = $dockerinstall::repo_os,
    Boolean $gpgcheck               = $dockerinstall::repo_gpgcheck,
    Boolean $sslverify              = $dockerinstall::repo_sslverify,
    String  $basearch               = $::architecture,
    Enum['present', 'absent']
            $repo_ensure            = 'present',
)
{
  # https://docs.docker.com/install/linux/docker-ce/fedora/#set-up-the-repository
  # https://docs.docker.com/install/linux/docker-ce/centos/#set-up-the-repository
  $distrourl = "${location}/${os}"
  $releasever = $facts['os']['release']['major']
  $rpmurl = "${distrourl}/${releasever}/${basearch}/${repo}"
  $gpgkey = "${distrourl}/gpg"

  if $manage_package {
    if $facts['os']['family'] == 'Debian' {
      # https://docs.docker.com/install/linux/docker-ce/ubuntu/
      apt::source { 'docker':
        architecture => $basearch,
        location     => $distrourl,
        repos        => $repo,
        key          => {
          id     => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
          source => $gpgkey,
        }
      }
    }
    else {
      $gpgcheck_param = $gpgcheck ? {
        true    => '1',
        default => '0',
      }
      $sslverify_param = $sslverify ? {
        true    => '1',
        default => '0',
      }
      yumrepo { 'docker':
        ensure    => $repo_ensure,
        descr     => 'Docker',
        baseurl   => $rpmurl,
        gpgkey    => $gpgkey,
        gpgcheck  => $gpgcheck_param,
        sslverify => $sslverify_param,
      }
      file { '/etc/yum.repos.d/docker.repo':
        ensure => $repo_ensure,
        mode   => '0644',
      }
    }
  }
}