Skip to content

Commit

Permalink
Support AlmaLinux and Rocky Linux with Chef >= 7.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Slavek Kabrda committed Feb 11, 2022
1 parent 0070680 commit 56a463c
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ jobs:
RUBY_VERSION: '2.6.3'
PUPPET_VERSION: '7.9.0'

specs-ruby26-puppet714:
<<: *specs
environment:
STRICT_VARIABLES: 'yes'
RUBY_VERSION: '2.6.3'
PUPPET_VERSION: '7.14.0'

specs-ruby25-puppet65-windows: &windows-specs
executor:
name: win/default # Comes with ruby 2.6, which is not supported on Windows as of puppet 6.10.1
Expand Down Expand Up @@ -325,5 +332,6 @@ workflows:
- specs-ruby26-puppet60
- specs-ruby26-puppet65
- specs-ruby26-puppet79
- specs-ruby26-puppet714
- verify-gemfile-lock-dependencies
- kitchen-tests
19 changes: 19 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ platforms:
- gem install r10k -v 2.6.7
- cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules

- name: rocky-8-puppet-5
driver_config:
# we use a custom image that runs systemd
image: 'datadog/docker-library:chef_kitchen_systemd_rocky_8'
platform: rhel # kitchen-docker doesn't recognize rocky otherwise
run_command: /root/start.sh
driver:
provision_command:
- dnf install -y https://yum.puppetlabs.com/puppet7-release-el-8.noarch.rpm #installs the puppet-agent repo
- dnf install -y puppet-agent rubygems
- ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet

- mkdir /home/kitchen/puppet
- printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile

- gem install bundler -v '= 1.17.3'
- gem install r10k -v 2.6.7
- cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules

- name: ubuntu-1604-puppet-6
driver_config:
# we use the official image
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
skip_apt_key_trusting => $skip_apt_key_trusting,
}
}
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux' : {
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux','AlmaLinux','Rocky' : {
class { 'datadog_agent::redhat':
agent_major_version => $_agent_major_version,
agent_flavor => $agent_flavor,
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
$permissions_protected_file = '0600'
$agent_binary = '/opt/datadog-agent/bin/agent/agent'
}
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux', 'OpenSuSE', 'SLES' : {
'RedHat','CentOS','Fedora','Amazon','Scientific','OracleLinux', 'AlmaLinux', 'Rocky', 'OpenSuSE', 'SLES' : {
$rubydev_package = 'ruby-devel'
$legacy_conf_dir = '/etc/dd-agent/conf.d'
$conf_dir = '/etc/datadog-agent/conf.d'
Expand Down
12 changes: 12 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@
"7"
]
},
{
"operatingsystem": "AlmaLinux",
"operatingsystemrelease": [
"8"
]
},
{
"operatingsystem": "Rocky",
"operatingsystemrelease": [
"8"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
Expand Down
62 changes: 62 additions & 0 deletions spec/classes/datadog_agent_redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,66 @@
end
end
end

context 'almalinux 8', if: min_puppet_version('7.12.0') do
let(:facts) do
{
osfamily: 'redhat',
operatingsystem: 'AlmaLinux',
operatingsystemrelease: '8.5',
architecture: 'x86_64',
}
end

# it should install the repo
context 'with manage_repo => true' do
let(:params) do
{
manage_repo: true, agent_major_version: 7
}
end

it do
is_expected.to contain_yumrepo('datadog')
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public')\
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
.with_repo_gpgcheck(true)
end
end
end

context 'rocky 8', if: min_puppet_version('7.12.0') do
let(:facts) do
{
osfamily: 'redhat',
operatingsystem: 'Rocky',
operatingsystemrelease: '8.5',
architecture: 'x86_64',
}
end

# it should install the repo
context 'with manage_repo => true' do
let(:params) do
{
manage_repo: true, agent_major_version: 7
}
end

it do
is_expected.to contain_yumrepo('datadog')
.with_enabled(1)\
.with_gpgcheck(1)\
.with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public')\
.with_baseurl('https://yum.datadoghq.com/stable/7/x86_64/')\
.with_repo_gpgcheck(true)
end
end
end
end
6 changes: 5 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'puppetlabs_spec_helper/module_spec_helper'

DEBIAN_OS = ['Ubuntu', 'Debian'].freeze
REDHAT_OS = ['RedHat', 'CentOS', 'Fedora', 'Amazon', 'Scientific', 'OracleLinux'].freeze
REDHAT_OS = ['RedHat', 'CentOS', 'Fedora', 'Amazon', 'Scientific', 'OracleLinux', 'AlmaLinux', 'Rocky'].freeze
WINDOWS_OS = ['Windows'].freeze

if RSpec::Support::OS.windows?
Expand All @@ -26,6 +26,10 @@
PERMISSIONS_PROTECTED_FILE = '0600'.freeze
end

def min_puppet_version(version)
Gem.loaded_specs['puppet'].version > Gem::Version.new(version)
end

def getosfamily(operatingsystem)
if DEBIAN_OS.include?(operatingsystem)
'debian'
Expand Down

0 comments on commit 56a463c

Please sign in to comment.