Skip to content

Commit

Permalink
Specified custom dependencies for r10k installation
Browse files Browse the repository at this point in the history
  • Loading branch information
aursu committed Sep 18, 2024
1 parent 60196f0 commit 027bee9
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,14 @@ node on Puppet server.

**Known Issues**

## Release 0.19.11
## Release 0.19.12

**Features**

**Bugfixes**

* SSH access configuration compilation fix
* Puppet platform repository URL fix
* r10k installation for Puppet 7

**Known Issues**
49 changes: 49 additions & 0 deletions manifests/r10k/dependencies.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# @summary r10k dependencies
#
# r10k dependencies (GEM packages with specific requirements)
#
# @example
# include puppet::r10k::dependencies
class puppet::r10k::dependencies {
include puppet::agent::install

if versioncmp($facts['puppetversion'], '8.0.0') >= 0 {
$cri_ensure = 'installed'
}
elsif versioncmp($facts['puppetversion'], '7.0.0') >= 0 {
$cri_ensure = 'installed'

# https://www.puppet.com/docs/puppet/8/platform_lifecycle.html#about_agent-component-version-numbers
# Puppet 7 provides Ruby 2.7.8
# The following GEM packages already require Ruby 3, so we need to install specific versions compatible with Puppet 7

package { 'faraday-net_http':
ensure => '3.0.2',
provider => 'puppet_gem',
}

package { 'faraday':
ensure => '2.8.1',
provider => 'puppet_gem',
}

Class['puppet::agent::install'] -> Package['faraday']
Class['puppet::agent::install'] -> Package['faraday-net_http']
}
elsif versioncmp($facts['puppetversion'], '6.0.0') >= 0 {
# Puppet 6 comes with Ruby >= 2.5
$cri_ensure = 'installed'
}
else {
# Puppet 5
# cri-2.15.10 requires Ruby ~> 2.3
$cri_ensure = '2.15.10'
}

package { 'cri':
ensure => $cri_ensure,
provider => 'puppet_gem',
}

Class['puppet::agent::install'] -> Package['cri']
}
17 changes: 2 additions & 15 deletions manifests/r10k/gem_install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,7 @@
Stdlib::Absolutepath $r10k_cachedir = $puppet::params::r10k_cachedir,
) inherits puppet::params {
include puppet::agent::install

# Puppet 6 comes with Ruby >= 2.5
if versioncmp($facts['puppetversion'], '6.0.0') >= 0 {
$cri_ensure = 'installed'
}
else {
# cri-2.15.10 requires Ruby ~> 2.3
$cri_ensure = '2.15.10'
}

package { 'cri':
ensure => $cri_ensure,
provider => 'puppet_gem',
}
include puppet::r10k::dependencies

class { 'r10k':
provider => 'puppet_gem',
Expand All @@ -35,5 +22,5 @@
}

Class['puppet::agent::install'] -> Class['r10k']
Package['cri'] -> Class['r10k']
Class['puppet::r10k::dependencies'] -> Class['r10k']
}
12 changes: 7 additions & 5 deletions manifests/r10k/install.pp
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# puppet::install::r10k
#
# R10K installation on the server
# Installs R10K on the server using the `gem install` Exec resource to ensure it is actually installed.
#
# @summary R10K installation on the server
# @summary R10K installation on the server.
#
# @example
# include puppet::install::r10k
#
# @param r10k_package_name
# @param gem_path
# @param r10k_path
# @param r10k_package_name The name of the R10K gem package.
# @param gem_path The path to the Gem executable.
# @param r10k_path The path where R10K executable will be installed.
#
class puppet::r10k::install (
String $r10k_package_name = $puppet::params::r10k_package_name,
Stdlib::Absolutepath $gem_path = $puppet::params::gem_path,
Stdlib::Absolutepath $r10k_path = $puppet::params::r10k_path,
) inherits puppet::params {
include puppet::agent::install
include puppet::r10k::dependencies

exec { 'r10k-installation':
command => "${gem_path} install ${r10k_package_name}",
creates => $r10k_path,
}

Class['puppet::agent::install'] -> Exec['r10k-installation']
Class['puppet::r10k::dependencies'] -> Exec['r10k-installation']
}
1 change: 1 addition & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
cwd => '/tmp',
path => '/bin:/usr/bin',
creates => "/tmp/${package_filename}",
unless => "rpm --quiet -qip ${package_filename}",
}

package { 'puppet-release':
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aursu-puppet",
"version": "0.19.11",
"version": "0.19.12",
"author": "aursu",
"summary": "Puppet server installation and setup",
"license": "Apache-2.0",
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/r10k/dependencies_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'puppet::r10k::dependencies' do
let(:pre_condition) { 'include puppet' }

on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

it { is_expected.to compile.with_all_deps }
end
end
end

0 comments on commit 027bee9

Please sign in to comment.