Skip to content

Commit 6037cc8

Browse files
authored
[chore] Fix Puppet CI: Lint and Rake spec (#6120)
* Drop Puppet 6 - reached EOL * Get clarify on which command is failing * Move to ruby3 bookworm and use puppet8 * Fix formatting errors * Fix trailing comma warning * Disable checks with high number of hits * Update supported OSes * Remove usage of stdlib::merge * Lint fixes * Rake spec fixes * Explain win facts added for rake spec * Explain bundler version on image * Improve comment
1 parent 9962d06 commit 6037cc8

15 files changed

+49
-47
lines changed

.github/workflows/puppet-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
exit 1
7171
fi
7272
distro=$(for d in $dockerfiles; do echo -n "\"$d\","; done)
73-
puppet_release='"6","7","8"'
73+
puppet_release='"7","8"'
7474
with_instrumentation='"true","false"'
7575
matrix="{\"DISTRO\": [${distro%,}], \"PUPPET_RELEASE\": [${puppet_release}], \"WITH_INSTRUMENTATION\": [${with_instrumentation}]}"
7676
echo "$matrix" | jq
@@ -142,7 +142,7 @@ jobs:
142142
strategy:
143143
matrix:
144144
OS: [ "windows-2022" ]
145-
PUPPET_RELEASE: [ "6.0.2", "7.21.0", "8.1.0" ]
145+
PUPPET_RELEASE: [ "7.21.0", "8.1.0" ]
146146
TEST_CASE: [ "default", "custom_vars" ]
147147
WIN_COLLECTOR_VERSION: [ "0.86.0", "latest" ]
148148
fail-fast: false

deployments/puppet/Dockerfile

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
FROM ruby:2.6-buster
1+
FROM ruby:3.3.8-bookworm
22

33
ENV PATH=$PATH:/opt/puppetlabs/bin:/opt/puppetlabs/pdk/bin
44

55
WORKDIR /tmp
66

7-
RUN wget https://apt.puppetlabs.com/puppet6-release-buster.deb &&\
8-
dpkg -i puppet6-release-buster.deb &&\
9-
rm *.deb &&\
10-
apt update &&\
11-
apt install -y puppet-agent
7+
RUN wget https://apt.puppetlabs.com/puppet8-release-bookworm.deb
8+
RUN dpkg -i puppet8-release-bookworm.deb
9+
RUN rm *.deb
10+
RUN apt update
11+
RUN apt install -y puppet-agent
1212

13-
RUN wget https://apt.puppet.com/puppet-tools-release-buster.deb && \
14-
dpkg -i puppet-tools-release-buster.deb && \
15-
apt-get update && \
16-
apt-get install -y pdk && \
17-
rm -f *.deb
13+
RUN wget https://apt.puppet.com/puppet-tools-release-bookworm.deb
14+
RUN dpkg --force-overwrite -i puppet-tools-release-bookworm.deb
15+
RUN apt update
16+
RUN apt install -y pdk
17+
RUN rm -f *.deb
1818

1919
WORKDIR /etc/puppetlabs/code/modules/splunk_otel_collector
2020
COPY ./ ./
21-
RUN gem install bundler -v 2.4.22 && bundle install
21+
RUN pdk update
22+
# Bundler version matches the version used to generate the Gemfile.lock
23+
RUN gem install bundler -v 2.4.13 && bundle install
2224

2325
RUN mkdir -p /root/.config/puppet && \
2426
echo "---\n\

deployments/puppet/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ lint: dev-image
1818
docker run \
1919
--rm \
2020
splunk-otel-connector-puppet-dev \
21-
puppet-lint --fail-on-warnings .
21+
puppet-lint --fail-on-warnings \
22+
--no-parameter_documentation-check --no-parameter_types-check \
23+
--no-top_scope_facts-check --no-strict_indent-check \
24+
.
2225

2326
.PHONY: rake-spec
2427
rake-spec: dev-image

deployments/puppet/manifests/collector_debian_repo.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Installs the collector debian package repository config
22
class splunk_otel_collector::collector_debian_repo ($repo_url, $package_stage, $repo, $apt_gpg_key, $manage_repo) {
3-
43
if $manage_repo {
54
apt::source { 'splunk-otel-collector':
65
location => $repo_url,

deployments/puppet/manifests/collector_service_owner.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Sets the user/group for the splunk-otel-collector service.
22
# If the user or group does not exist, they will be created.
33
class splunk_otel_collector::collector_service_owner ($service_name, $service_user, $service_group) {
4-
54
if !defined(Group[$service_group]) {
65
if $service_group == 'splunk-otel-collector' or $service_group in split($::local_groups, ',') {
76
group { $service_group:

deployments/puppet/manifests/collector_win_config_options.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
{}
2828
}
2929

30-
$collector_env_vars = stdlib::merge($base_env_vars, $gomemlimit, $listen_interface)
31-
}
30+
$collector_env_vars = $base_env_vars + $gomemlimit + $listen_interface
31+
}

deployments/puppet/manifests/collector_win_install.pp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
contain 'splunk_otel_collector::collector_win_config_options'
44

55
$msi_name = "splunk-otel-collector-${version}-amd64.msi"
6-
$collector_path = "${::win_programfiles}\\Splunk\\OpenTelemetry Collector\\otelcol.exe"
6+
$collector_path = "${facts['win_programfiles']}\\Splunk\\OpenTelemetry Collector\\otelcol.exe"
77
$registry_key = 'HKLM\SYSTEM\CurrentControlSet\Services\splunk-otel-collector'
88

99
# Only download and install if not already installed or version does not match
10-
if $::win_collector_path != $collector_path or $::win_collector_version != $version {
11-
file { "${::win_temp}\\${msi_name}":
12-
source => "${repo_url}/${msi_name}"
10+
if $facts['win_collector_path'] != $collector_path or $facts['win_collector_version'] != $version {
11+
file { "${facts['win_temp']}\\${msi_name}":
12+
source => "${repo_url}/${msi_name}",
1313
}
1414

1515
-> package { $package_name:
16-
ensure => $version,
17-
source => "${::win_temp}\\${msi_name}",
16+
source => "${facts['win_temp']}\\${msi_name}",
1817
require => Class['splunk_otel_collector::collector_win_config_options'],
1918
# If the MSI is not configurable, the install_options below will be ignored during installation.
2019
install_options => $splunk_otel_collector::collector_win_config_options::collector_env_vars,

deployments/puppet/manifests/collector_win_registry.pp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"${var}=${value}"
88
}
99
+ if !empty($splunk_otel_collector::collector_additional_env_vars) or
10-
versioncmp($splunk_otel_collector::collector_version, '0.98.0') < 0
11-
{
10+
versioncmp($splunk_otel_collector::collector_version, '0.98.0') < 0 {
1211
$splunk_otel_collector::collector_win_config_options::collector_env_vars.map |$var, $value| {
1312
"${var}=${value}"
1413
}

deployments/puppet/manifests/collector_yum_repo.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Installs the collector yum package repostitory for the given stage
22
class splunk_otel_collector::collector_yum_repo ($repo_url, $yum_gpg_key, $manage_repo, $repo_path) {
3-
43
if $manage_repo {
54
file { "${repo_path}/splunk-otel-collector.repo":
65
content => @("EOH")

deployments/puppet/manifests/fluentd_win_install.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
class splunk_otel_collector::fluentd_win_install ($repo_base, $version, $package_name, $service_name) {
33
$msi_name = "td-agent-${version}-x64.msi"
44

5-
file { "${::win_temp}\\${msi_name}":
6-
source => "${repo_base}/4/windows/${msi_name}"
5+
file { "${facts['win_temp']}\\${msi_name}":
6+
source => "${repo_base}/4/windows/${msi_name}",
77
}
88

99
-> package { $package_name:
1010
ensure => $version,
11-
source => "${::win_temp}\\${msi_name}",
11+
source => "${facts['win_temp']}\\${msi_name}",
1212
}
1313
}

deployments/puppet/manifests/fluentd_yum_repo.pp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Installs the fluentd yum package repostitory
22
class splunk_otel_collector::fluentd_yum_repo ($repo_url, $gpg_key_url, $version, $manage_repo) {
3-
43
if $manage_repo {
54
$os_name = $facts['os']['name'] ? {
65
'Amazon' => 'amazon',

deployments/puppet/manifests/init.pp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
$auto_instrumentation_npm_path = 'npm', # linux only
5353
$collector_additional_env_vars = {}
5454
) inherits splunk_otel_collector::params {
55-
5655
if empty($splunk_access_token) {
5756
fail('The splunk_access_token parameter is required')
5857
}
@@ -336,8 +335,8 @@
336335
subscribe => File[$fluentd_config_dest, $fluentd_config_override],
337336
}
338337
} else {
339-
$collector_install_dir = "${::win_programfiles}\\Splunk\\OpenTelemetry Collector"
340-
$td_agent_config_dir = "${::win_systemdrive}\\opt\\td-agent\\etc\\td-agent"
338+
$collector_install_dir = "${facts['win_programfiles']}\\Splunk\\OpenTelemetry Collector"
339+
$td_agent_config_dir = "${facts['win_systemdrive']}\\opt\\td-agent\\etc\\td-agent"
341340
$td_agent_config_dest = "${td_agent_config_dir}\\td-agent.conf"
342341

343342
file { $td_agent_config_dest:

deployments/puppet/manifests/params.pp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
$fluentd_config_dest = $fluentd_config_source
2222
$auto_instrumentation_version = 'latest'
2323
$auto_instrumentation_java_agent_jar = '/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar'
24-
2524
} elsif $facts['os']['family'] == 'windows' {
26-
$collector_version = ''
27-
$collector_install_dir = "${::win_programfiles}\\Splunk\\OpenTelemetry Collector"
28-
$collector_config_dir = "${::win_programdata}\\Splunk\\OpenTelemetry Collector"
25+
$collector_version = 'latest'
26+
$collector_install_dir = "${facts['win_programfiles']}\\Splunk\\OpenTelemetry Collector"
27+
$collector_config_dir = "${facts['win_programdata']}\\Splunk\\OpenTelemetry Collector"
2928
$splunk_bundle_dir = "${collector_install_dir}\\agent-bundle"
3029
$splunk_collectd_dir = "${splunk_bundle_dir}\\run\\collectd"
3130
$collector_config_source = "${collector_install_dir}\\agent_config.yaml"

deployments/puppet/metadata.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
{
3737
"operatingsystem": "CentOS",
3838
"operatingsystemrelease": [
39-
"7",
4039
"8",
4140
"9"
4241
]
@@ -60,9 +59,8 @@
6059
{
6160
"operatingsystem": "Debian",
6261
"operatingsystemrelease": [
63-
"9",
64-
"10",
65-
"11"
62+
"11",
63+
"12"
6664
]
6765
},
6866
{
@@ -77,14 +75,13 @@
7775
{
7876
"operatingsystem": "SLES",
7977
"operatingsystemrelease": [
80-
"12",
81-
"15"
78+
"12.5",
79+
"15.3"
8280
]
8381
},
8482
{
8583
"operatingsystem": "Windows",
8684
"operatingsystemrelease": [
87-
"2012",
8885
"2016",
8986
"2019",
9087
"2022"

deployments/puppet/spec/classes/init_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@
99
end
1010

1111
on_supported_os.each do |os, facts|
12-
let(:facts) { facts }
12+
# When running 'rake spec' it checks for absolute paths and on Windows paths
13+
# are built from $facts. In order to pass the tests the required $facts are
14+
# being explicitly added.
15+
let(:facts) {{
16+
'win_temp' =>'C:\\Windows\\Temp',
17+
'win_programfiles' => 'C:\\Program Files',
18+
'win_programdata' => 'C:\\ProgramData',
19+
'win_systemdrive' => 'C:'}.merge( facts )
20+
}
1321
context "on #{os}" do
1422
let(:params) { { 'splunk_access_token' => "testing", 'splunk_realm' => 'test' } }
1523
it { is_expected.to compile.with_all_deps }

0 commit comments

Comments
 (0)