Puppet Class: lldpd

Defined in:
manifests/init.pp

Summary

A module to manage lldpd and related facts

Overview

lldpd

Examples:

Basic usage

include lldpd

Parameters:

  • ensure (Enum['present', 'absent', 'latest']) (defaults to: 'present')

    Install or deinstall all related components

  • manage_service (Boolean) (defaults to: true)

    Enable or disable the service management

  • manage_repo (Boolean) (defaults to: false)

    Enable or disable the repository setup

  • repourl (Optional[String[1]]) (defaults to: undef)

    String that completes the url for the upstream repository

  • apt_key (Optional[String[1]]) (defaults to: undef)

    the public key used to sign the apt repository (default loaded from hiera)



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

class lldpd (
  Enum['present', 'absent', 'latest'] $ensure            = 'present',
  Boolean                             $manage_repo       = false,
  Boolean                             $manage_service    = true,
  Optional[String[1]]                 $repourl           = undef,
  Optional[String[1]]                 $apt_key           = undef,
) {
  if $manage_repo {
    case $facts['os']['family'] {
      'RedHat': {
        yumrepo { 'lldpd':
          ensure   => 'present',
          descr    => 'lldpd toolset',
          gpgkey   => "https://download.opensuse.org/repositories/home:/vbernat/${repourl}/repodata/repomd.xml.key",
          baseurl  => "https://download.opensuse.org/repositories/home:/vbernat/${repourl}/",
          gpgcheck => 1,
        }
        Yumrepo['lldpd'] -> Package['lldpd']
      }
      'Debian': {
        include apt # required so apt::key can access variables from init.pp

        # Get rid of all the different old keys
        file { [
            '/etc/apt/trusted.gpg.d/home_vbernat.gpg',
            '/etc/apt/trusted.gpg.d/home_vbernat.gpg~',
            '/usr/share/keyrings/lldpd.asc',
          ]:
            ensure => absent,
        }
        apt::key { 'EF795E4D26E48F1D7661267B431C37A97C3E114B':
          ensure => 'absent',
        }

        # Configure source and key
        apt::source { 'lldpd':
          location => "https://download.opensuse.org/repositories/home:/vbernat/${repourl}",
          release  => ' ',
          repos    => '/',
          key      => {
            name    => 'lldpd',
            content => $apt_key,
          },
          require  => File['/usr/share/keyrings/lldpd.asc'],
        }
        Apt::Source['lldpd'] -> Package['lldpd']
      }
      default: {
        warning("`\$manage_repo` not valid for: ${facts['os']['family']}")
      }
    }
  }

  package { 'lldpd':
    ensure => $ensure,
  }

  if $manage_service {
    service { 'lldpd':
      ensure  => 'running',
      enable  => true,
      require => Package['lldpd'],
    }
  }
}