Puppet Class: bolt

Defined in:
manifests/init.pp

Summary

installs bolt via yumrepo or release package

Overview

Examples:

install bolt via puppet-tools-release rpm

include bolt

install bolt via puppet-tools-release which is on a mirror

class { 'bolt':
  base_url => 'https://mirror.corp.internal',
}

manage the yumrepo directly

class { 'bolt':
  use_release_package => false,
}

manage the yumrepo with an internal mirror with odd directory layout

class { 'bolt':
  base_url         => 'https://internal.mirror.corp/keys/',
  yumrepo_base_url => 'https://internal.mirror.corp/puppet/puppet_tools/rhel8/',
}

Parameters:

  • version (String[1]) (defaults to: 'installed')

    desired version for bolt or ‘absent`

  • base_url (Stdlib::HTTPSUrl) (defaults to: $facts['os']['family'] ? { 'Debian' => 'https://apt.puppet.com/', 'RedHat' => 'https://yum.puppet.com/')

    HTTPS URL to the yumrepo base

  • release_package (String[1]) (defaults to: $facts['os']['family'] ? { 'Debian' => "puppet-release-${fact('os.distro.codename')}.deb", 'RedHat' => "puppet-tools-release-el-${facts['os']['release']['major']}.noarch.rpm")

    filename for the release package rpm

  • gpgkey (String[1]) (defaults to: $facts['os']['family'] ? { 'Debian' => 'DEB-GPG-KEY-puppet-20250406', 'RedHat' => 'RPM-GPG-KEY-puppet-20250406')

    name of the GPG key filename in the repo

  • use_release_package (Boolean) (defaults to: $facts['os']['family'] ? { 'Debian' => false, 'RedHat' => true)

    enable/disable the puppet-tools-release package installation. When disabled, we will configure the repo as yumrepo resource

  • yumrepo_base_url (Stdlib::HTTPSUrl) (defaults to: "${base_url}puppet-tools/el/${facts['os']['release']['major']}/\$basearch")

    configure the full repo URL, useful when you don’t exactly mirror yum.puppet.com

  • manage_repo (Boolean) (defaults to: true)

    when true, a repo will be added to install bolt. Useful when you manage repos externally. See also $use_release_package

Author:

  • Tim Meusel <tim@bastelfreak.de>



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

class bolt (
  String[1] $version = 'installed',
  Stdlib::HTTPSUrl $base_url = $facts['os']['family'] ? { 'Debian' => 'https://apt.puppet.com/', 'RedHat' => 'https://yum.puppet.com/', },
  String[1] $release_package = $facts['os']['family'] ? { 'Debian' => "puppet-release-${fact('os.distro.codename')}.deb", 'RedHat' => "puppet-tools-release-el-${facts['os']['release']['major']}.noarch.rpm", },
  String[1] $gpgkey = $facts['os']['family'] ? { 'Debian' => 'DEB-GPG-KEY-puppet-20250406', 'RedHat' => 'RPM-GPG-KEY-puppet-20250406', },
  Boolean $use_release_package = $facts['os']['family'] ? { 'Debian' => false, 'RedHat' => true, },
  Stdlib::HTTPSUrl $yumrepo_base_url = "${base_url}puppet-tools/el/${facts['os']['release']['major']}/\$basearch",
  Boolean $manage_repo = true,
) {
  unless $facts['os']['family'] in ['RedHat', 'Debian'] {
    fail("class bolt only works on ${facts['os']['family']} OS family")
  }

  $ensure = $version ? {
    'absent' => 'absent',
    default  => 'present',
  }
  if $manage_repo {
    if $use_release_package {
      package { 'puppet-tools-release':
        ensure => $ensure,
        source => "${base_url}${release_package}",
      }
      $require = Package['puppet-tools-release']
    } else {
      if $facts['os']['family'] == 'RedHat' {
        yumrepo { 'puppet-tools':
          ensure   => $ensure,
          baseurl  => $yumrepo_base_url,
          descr    => "Puppet Tools Repository el ${facts['os']['release']['major']} - \$basearch",
          enabled  => '1',
          gpgcheck => '1',
          gpgkey   => "${base_url}${gpgkey}",
        }
        $require = Yumrepo['puppet-tools']
      } else {
        apt::source { 'puppet-tools-release':
          location => $base_url,
          repos    => 'puppet-tools',
          before   => Package['puppet-bolt'],
        }
        # the update class, according to puppetlabs/apt, needs to be called before the package resource
        # https://github.com/puppetlabs/puppetlabs-apt?tab=readme-ov-file#adding-new-sources-or-ppas
        $require = [Class['apt::update'], Apt::Source['puppet-tools-release']]
      }
    }
  } else {
    $require = undef
  }

  package { 'puppet-bolt':
    ensure  => $version,
    require => $require,
  }
}