Puppet Class: k8s::repo

Defined in:
manifests/repo.pp

Summary

Handles repositories for the container runtime

Overview

Parameters:

  • manage_container_manager (Boolean) (defaults to: $k8s::manage_container_manager)

    whether to add cri-o repository or not

  • crio_version (String[1]) (defaults to: $k8s::version.split('\.')[0, 2].join('.'))

    version o cri-o

  • container_manager (K8s::Container_runtimes) (defaults to: $k8s::container_manager)

    The name of the container manager



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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'manifests/repo.pp', line 7

class k8s::repo (
  Boolean $manage_container_manager          = $k8s::manage_container_manager,
  K8s::Container_runtimes $container_manager = $k8s::container_manager,
  String[1] $crio_version                    = $k8s::version.split('\.')[0, 2].join('.'),
) {
  case fact('os.family') {
    'Debian': {
      case fact('os.name') {
        'Debian': {
          if versioncmp($crio_version, '1.19') >= 0 {
            $release_name = "Debian_${fact('os.release.major')}"
          } else {
            $release_name = 'Debian_Testing'
          }
        }
        'Ubuntu': {
          $release_name = "xUbuntu_${fact('os.release.full')}"
        }
        'Raspbian': {
          $release_name = "Raspbian_${fact('os.release.full')}"
        }
        default: {}
      }

      $libcontainers_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/${release_name}"
      $crio_url          = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${crio_version}/${release_name}"

      apt::source { 'libcontainers:stable':
        location => $libcontainers_url,
        repos    => '/',
        release  => '',
        key      => {
          id     => '2472D6D0D2F66AF87ABA8DA34D64390375060AA4',
          source => "${libcontainers_url}/Release.key",
        },
      }

      if $manage_container_manager and $container_manager == 'crio' {
        apt::source { 'libcontainers:stable:cri-o':
          location => $crio_url,
          repos    => '/',
          release  => '',
          key      => {
            id     => '2472D6D0D2F66AF87ABA8DA34D64390375060AA4',
            source => "${crio_url}/Release.key",
          },
        }
      }
    }
    'RedHat': {
      $libcontainers_url = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_${fact('os.release.major')}/"
      $crio_url          = "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/${crio_version}/CentOS_${fact('os.release.major')}/"

      yumrepo { 'libcontainers:stable':
        descr    => 'Stable releases of libcontainers',
        baseurl  => $libcontainers_url,
        gpgcheck => 1,
        gpgkey   => "${libcontainers_url}repodata/repomd.xml.key",
      }

      if $manage_container_manager {
        case $container_manager {
          'crio': {
            yumrepo { 'libcontainers:stable:cri-o':
              descr    => 'Stable releases of CRI-o',
              baseurl  => $crio_url,
              gpgcheck => 1,
              gpgkey   => "${crio_url}repodata/repomd.xml.key",
            }
          }
          'containerd': {
            yumrepo { 'docker-ce-stable':
              descr    => 'Docker CE Stable - $basearch',
              baseurl  => 'https://download.docker.com/linux/centos/$releasever/$basearch/stable',
              gpgcheck => 1,
              gpgkey   => 'https://download.docker.com/linux/centos/gpg',
            }
          }
          default: {}
        }
      }
    }
    default: {}
  }
}