Puppet Class: wireguard::install

Defined in:
manifests/install.pp

Summary

Class installs wireguard packages and sets yum repository

Overview

Parameters:

  • package_name (Variant[Array, String])

    Name the package(s) that installs wireguard

  • repo_url (String)

    URL of wireguard repo

  • manage_repo (Boolean)

    Should class manage yum repo

  • manage_package (Boolean)

    Should class install package(s)

  • package_ensure (Variant[Boolean, Enum['installed','latest','present']])

    Set state of the package



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

class wireguard::install (
  Variant[Array, String] $package_name,
  String                 $repo_url,
  Boolean                $manage_repo,
  Boolean                $manage_package,
  Variant[Boolean, Enum['installed','latest','present']] $package_ensure,
) {

  if $manage_repo {
    case $facts['os']['name'] {
      'RedHat', 'CentOS': {
        exec {'download_wireguard_repo':
          command => "/usr/bin/curl -Lo /etc/yum.repos.d/wireguard.repo ${repo_url}",
          creates => '/etc/yum.repos.d/wireguard.repo',
        }
      }
      'Ubuntu': {
        include apt
        apt::ppa { $repo_url: }
      }
      'Debian': {
        include apt
        apt::pin { 'debian_unstable':
          release  => 'unstable',
          priority => 90,
        }
        apt::source { 'debian_unstable':
          location => $repo_url,
          release  => 'unstable',
        }
      }
      default: {
        warning("Unsupported OS family, couldn't configure package automatically")
      }
    }
  }

  case $facts['os']['name'] {
    'RedHat', 'CentOS': {
      $_require = $manage_repo ? {
        true    => Exec['download_wireguard_repo'],
        default => undef,
      }
    }
    'Ubuntu': {
      $_require = $manage_repo ? {
        true    => Apt::Ppa[$repo_url],
        default => undef,
      }
    }
    'Debian': {
      $_require = $manage_repo ? {
        true    => Apt::Source['debian_unstable'],
        default => undef,
      }
    }
    default: {
      if $manage_package {
        warning("Unsupported OS family, couldn't configure package automatically")
      }
    }
  }

  if $manage_package {
    package { $package_name:
      ensure  => $package_ensure,
      require => $_require,
    }
  }
}