diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 04da148..6d32a79 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,8 +53,10 @@ jobs: - "el7" - "el8" - "el9" + - "amazon2023" - "ubuntu-2004" - "ubuntu-2204" + - "debian-12" puppet: - "puppet7" - "puppet8" diff --git a/.sync.yml b/.sync.yml index 6bc8a92..a9b4c8b 100644 --- a/.sync.yml +++ b/.sync.yml @@ -10,8 +10,10 @@ Rakefile: - el7 - el8 - el9 + - amazon2023 - ubuntu-2004 - ubuntu-2204 + - debian-12 puppet: - puppet7 - puppet8 @@ -51,3 +53,9 @@ spec/acceptance/nodesets/ubuntu-2204.yml: default_module_install_opts: ignore-dependencies: ~ force: ~ +spec/acceptance/nodesets/debian-12.yml: + packages: + - cron + default_module_install_opts: + ignore-dependencies: ~ + force: ~ diff --git a/Gemfile b/Gemfile index 60f2000..300688d 100644 --- a/Gemfile +++ b/Gemfile @@ -29,8 +29,8 @@ group :system_tests do gem "beaker-pe", require: false gem "beaker-hostgenerator" gem "beaker-rspec" - gem "beaker-docker" - gem "beaker-puppet" + gem "beaker-docker", git: 'https://github.com/treydock/beaker-docker.git', branch: 'amazon-2023' + gem "beaker-puppet", git: 'https://github.com/puppetlabs/beaker-puppet.git', ref: '6063d22b6c4449df795731f5853c3c75241240c4' gem "beaker-puppet_install_helper", require: false gem "beaker-module_install_helper", require: false end diff --git a/README.md b/README.md index cf21c0e..e1c7210 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ Manage [Open OnDemand](http://openondemand.org/) installation and configuration. The following are the versions of this module and the supported versions of Open OnDemand: -* Module 3.x and 4.x supports Open OnDemand 3.x +* Module 5.x supports Open OnDemand 3.1 and 3.0 +* Module 3.x and 4.x supports Open OnDemand 3.0 * Module 2.x supports Open OnDemand 2.x * Module 1.x supports Open OnDemand 1.18.x * Module <= 0.12.0 supports Open OnDemand <= 1.7 @@ -55,8 +56,6 @@ If you already declare the apache class you may wish to only include apache in t ```yaml openondemand::declare_apache: false -apache::version::scl_httpd_version: '2.4' -apache::version::scl_php_version: '7.0' apache::default_vhost: false ``` @@ -358,7 +357,9 @@ openondemand::confs: This module has been tested on: * RedHat/CentOS 7 x86_64 -* RedHat/Rocky Linux/Alma Linux 8 x86_64 -* RedHat/Rocky Linux/Alma Linux 9 x86_64 -* Ubuntu 18.04 x86_64 -* Ubuntu 20.04 x86_64 +* RedHat/Rocky Linux/Alma Linux 8 +* RedHat/Rocky Linux/Alma Linux 9 +* Amazon Linux 2023 +* Ubuntu 20.04 +* Ubuntu 22.04 +* Debian 12 diff --git a/data/common.yaml b/data/common.yaml index f36cd40..fdf908f 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -2,11 +2,4 @@ openondemand::nginx_stage_app_root: dev: "/var/www/ood/apps/dev/%{literal('%')}{owner}/gateway/%{literal('%')}{name}" usr: "/var/www/ood/apps/usr/%{literal('%')}{owner}/gateway/%{literal('%')}{name}" sys: "/var/www/ood/apps/sys/%{literal('%')}{name}" -openondemand::basic_auth_users: - ood: - password: ood -openondemand::auth_configs: - - 'AuthName "Private"' - - 'AuthUserFile "/opt/rh/httpd24/root/etc/httpd/.htpasswd"' - - 'RequestHeader unset Authorization' - - 'Require valid-user' + diff --git a/data/os/Amazon.yaml b/data/os/Amazon.yaml new file mode 100644 index 0000000..528b718 --- /dev/null +++ b/data/os/Amazon.yaml @@ -0,0 +1,2 @@ +--- +openondemand::manage_epel: false diff --git a/data/os/RedHat/7.yaml b/data/os/RedHat/7.yaml index 9a903a0..f3e841f 100644 --- a/data/os/RedHat/7.yaml +++ b/data/os/RedHat/7.yaml @@ -1 +1,3 @@ +# OnDemand 3.1 does not support EL7 +openondemand::repo_release: '3.0' openondemand::repo_gpgkey: https://yum.osc.edu/ondemand/RPM-GPG-KEY-ondemand diff --git a/data/os/RedHat/8.yaml b/data/os/RedHat/8.yaml index 9a903a0..cc0cf77 100644 --- a/data/os/RedHat/8.yaml +++ b/data/os/RedHat/8.yaml @@ -1 +1,2 @@ openondemand::repo_gpgkey: https://yum.osc.edu/ondemand/RPM-GPG-KEY-ondemand +openondemand::repo_module_hotfixes: true diff --git a/hiera.yaml b/hiera.yaml index 0aba6ac..7f8ccd5 100644 --- a/hiera.yaml +++ b/hiera.yaml @@ -6,6 +6,8 @@ defaults: # Used for any hierarchy level that omits these keys. data_hash: yaml_data # Use the built-in YAML backend. hierarchy: + - name: 'os name' + path: "os/%{facts.os.name}.yaml" - name: 'os family - os major version' path: "os/%{facts.os.family}/%{facts.os.release.major}.yaml" - name: 'os family' diff --git a/manifests/init.pp b/manifests/init.pp index eec563d..03e0075 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,6 +10,8 @@ # The URL for proxy for OnDemand repo # @param repo_priority # The priority of the OnDemand repo +# @param repo_module_hotfixes +# The module_hotfixes of the OnDemand repo # @param repo_exclude # Exclusion for OnDemand repo # @param manage_dependency_repos @@ -46,6 +48,8 @@ # ood_porta.yml server_aliases # @param ssl # ood_portal.yml ssl +# @param disable_logs +# ood_portal.yml disable_logs # @param logroot # ood_portal.yml logroot # @param use_rewrites @@ -78,6 +82,10 @@ # ood_portal.yml auth_type # @param auth_configs # ood_portal.yml auth_configs +# @param custom_vhost_directives +# ood_portal.yml custom_vhost_directives +# @param custom_location_directives +# ood_portal.yml custom_location_directives # @param root_uri # ood_portal.yml root_uri # @param analytics @@ -234,13 +242,14 @@ # class openondemand ( # repos - String $repo_release = '3.0', + String $repo_release = '3.1', Variant[Stdlib::HTTPSUrl, Stdlib::HTTPUrl] $repo_baseurl_prefix = 'https://yum.osc.edu/ondemand', Variant[Stdlib::HTTPSUrl, Stdlib::HTTPUrl, Stdlib::Absolutepath] $repo_gpgkey = 'https://yum.osc.edu/ondemand/RPM-GPG-KEY-ondemand-SHA512', Optional[String[1]] $repo_proxy = undef, Integer[1,99] $repo_priority = 99, + Optional[Boolean] $repo_module_hotfixes = undef, String $repo_exclude = 'absent', Boolean $manage_dependency_repos = true, Boolean $manage_epel = true, @@ -264,6 +273,7 @@ Optional[String] $servername = undef, Optional[Array] $server_aliases = undef, Optional[Array] $ssl = undef, + Boolean $disable_logs = false, String $logroot = 'logs', Boolean $use_rewrites = true, Boolean $use_maintenance = true, @@ -280,6 +290,8 @@ Optional[String] $map_fail_uri = undef, Variant[Enum['CAS', 'openid-connect', 'shibboleth', 'dex'], String[1]] $auth_type = 'dex', Optional[Array] $auth_configs = undef, + Array $custom_vhost_directives = [], + Array $custom_location_directives = [], String $root_uri = '/pun/sys/dashboard', Optional[Struct[{ url => String, id => String }]] $analytics = undef, String $public_uri = '/public', @@ -381,27 +393,62 @@ $osname = $facts.dig('os', 'name') $osmajor = $facts.dig('os', 'release', 'major') - $supported = ['RedHat-7','RedHat-8','RedHat-9','Debian-20.04','Debian-22.04'] + $supported = ['RedHat-7','RedHat-8','RedHat-9','RedHat-2023','Debian-20.04','Debian-22.04','Debian-12'] $os = "${osfamily}-${osmajor}" if ! ($os in $supported) { fail("Unsupported OS: module ${module_name}. osfamily=${osfamily} osmajor=${osmajor} detected") } + # Handle unsupported distro and OnDemand combos + if $repo_release == '3.1' { + if "${osfamily}-${osmajor}" == 'RedHat-7' { + fail('EL7 is not supported with OnDemand 3.1') + } + } + if $repo_release == '3.0' { + if "${osname}-${osmajor}" == 'Amazon-2023' { + fail('Amazon 2023 is not supported with OnDemand 3.0') + } + if "${osname}-${osmajor}" == 'Debian-12' { + fail('Debian 12 is not supported with OnDemand 3.0') + } + } + if versioncmp($osmajor, '7') <= 0 { $scl_apache = true } else { $scl_apache = false } + # EL9 only has these two versions at this time + if $repo_release == '3.0' and "${osfamily}-${osmajor}" == 'RedHat-9' { + $nodejs = 'absent' + $ruby = 'absent' + } elsif $repo_release == '3.0' { + $nodejs = '14' + $ruby = '3.0' + } else { + $nodejs = '18' + $ruby = '3.1' + } + if $selinux { $selinux_package_ensure = $ondemand_package_ensure } else { $selinux_package_ensure = 'absent' } + if $facts['os']['name'] == 'Amazon' { + $dist = 'amzn' + } elsif $osfamily == 'RedHat' { + $dist = 'el' + } else { + $dist = undef + } + if $osfamily == 'RedHat' { - $repo_baseurl = "${repo_baseurl_prefix}/${repo_release}/web/el${osmajor}/\$basearch" - $repo_nightly_baseurl = "${repo_baseurl_prefix}/nightly/web/el${osmajor}/\$basearch" + $repo_baseurl = "${repo_baseurl_prefix}/${repo_release}/web/${dist}${osmajor}/\$basearch" + $repo_nightly_baseurl = "${repo_baseurl_prefix}/nightly/web/${dist}${osmajor}/\$basearch" } elsif $osfamily == 'Debian' { $repo_baseurl = "${repo_baseurl_prefix}/${repo_release}/web/apt" $repo_nightly_baseurl = "${repo_baseurl_prefix}/nightly/web/apt" @@ -477,6 +524,7 @@ 'server_aliases' => $server_aliases, 'port' => $port, 'ssl' => $ssl, + 'disable_logs' => $disable_logs, 'logroot' => $logroot, 'use_rewrites' => $use_rewrites, 'use_maintenance' => $use_maintenance, @@ -491,6 +539,8 @@ 'map_fail_uri' => $map_fail_uri, 'pun_stage_cmd' => $pun_stage_cmd, 'auth' => $auth, + 'custom_vhost_directives' => $custom_vhost_directives, + 'custom_location_directives' => $custom_location_directives, 'root_uri' => $root_uri, 'analytics' => $analytics, 'public_uri' => $public_uri, @@ -544,7 +594,8 @@ if $osfamily == 'RedHat' { contain openondemand::repo::rpm Class['openondemand::repo::rpm'] -> Class['openondemand::install'] - } elsif $osfamily == 'Debian' { + } + if $osfamily == 'Debian' { contain openondemand::repo::apt Class['openondemand::repo::apt'] -> Class['openondemand::install'] } diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp index 6c635b9..56305cb 100644 --- a/manifests/repo/apt.pp +++ b/manifests/repo/apt.pp @@ -25,14 +25,30 @@ }, } - apt::source { 'nodesource': - ensure => 'present', - location => 'https://deb.nodesource.com/node_14.x', - repos => 'main', - release => $facts['os']['distro']['codename'], - key => { - 'id' => '9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280', - 'source' => 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key', - }, + # Debian 12 has NodeJS 18 in OS repos + if String($openondemand::osmajor) != '12' and $openondemand::nodejs == '18' { + apt::source { 'nodesource': + ensure => 'present', + location => 'https://deb.nodesource.com/node_18.x', + repos => 'main', + release => 'nodistro', + key => { + 'id' => '6F71F525282841EEDAF851B42F59B5F99B1BE0B4', + 'source' => 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key', + }, + } + } + + if $openondemand::nodejs == '14' { + apt::source { 'nodesource': + ensure => 'present', + location => 'https://deb.nodesource.com/node_14.x', + repos => 'main', + release => $facts['os']['distro']['codename'], + key => { + 'id' => '9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280', + 'source' => 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key', + }, + } } } diff --git a/manifests/repo/rpm.pp b/manifests/repo/rpm.pp index 87d741e..e704024 100644 --- a/manifests/repo/rpm.pp +++ b/manifests/repo/rpm.pp @@ -23,6 +23,7 @@ priority => $openondemand::repo_priority, exclude => $openondemand::repo_exclude, proxy => $openondemand::repo_proxy, + module_hotfixes => $openondemand::repo_module_hotfixes, } yumrepo { 'ondemand-web-nightly': @@ -36,33 +37,24 @@ metadata_expire => '1', priority => $openondemand::repo_priority, proxy => $openondemand::repo_proxy, + module_hotfixes => $openondemand::repo_module_hotfixes, } - # Work around a bug where 'dnf module list' is not executed with -y - if versioncmp($openondemand::osmajor, '8') == 0 { + if versioncmp($openondemand::osmajor, '8') >= 0 { + # Work around a bug where 'dnf module list' is not executed with -y exec { 'dnf makecache ondemand-web': path => '/usr/bin:/bin:/usr/sbin:/sbin', command => "dnf -q makecache -y --disablerepo='*' --enablerepo='ondemand-web'", refreshonly => true, subscribe => Yumrepo['ondemand-web'], } - if $openondemand::manage_dependency_repos { - Exec['dnf makecache ondemand-web'] -> Package['nodejs'] - Exec['dnf makecache ondemand-web'] -> Package['ruby'] - } } if $openondemand::manage_epel { contain epel } - if versioncmp($openondemand::osmajor, '7') <= 0 and $openondemand::manage_dependency_repos { - if $facts['os']['name'] == 'CentOS' and versioncmp($openondemand::osmajor, '7') == 0 { - file { '/etc/yum.repos.d/ondemand-centos-scl.repo': - ensure => 'absent', - } - } - + if versioncmp($openondemand::osmajor, '7') == 0 and $openondemand::manage_dependency_repos { case $facts['os']['name'] { 'RedHat': { rh_repo { "rhel-server-rhscl-${openondemand::osmajor}-rpms": @@ -80,16 +72,18 @@ } } - if versioncmp($openondemand::osmajor, '8') == 0 and $openondemand::manage_dependency_repos { + if String($openondemand::osmajor) in ['8', '9'] and $openondemand::manage_dependency_repos { package { 'nodejs': - ensure => '14', + ensure => $openondemand::nodejs, enable_only => true, provider => 'dnfmodule', + require => Exec['dnf makecache ondemand-web'], } package { 'ruby': - ensure => '3.0', + ensure => $openondemand::ruby, enable_only => true, provider => 'dnfmodule', + require => Exec['dnf makecache ondemand-web'], } } } diff --git a/metadata.json b/metadata.json index 1264745..3a80b36 100644 --- a/metadata.json +++ b/metadata.json @@ -74,12 +74,24 @@ "9" ] }, + { + "operatingsystem": "Amazon", + "operatingsystemrelease": [ + "2023" + ] + }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "20.04", "22.04" ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "12" + ] } ], "requirements": [ @@ -95,5 +107,5 @@ ], "pdk-version": "2.7.1", "template-url": "https://github.com/treydock/pdk-templates.git#master", - "template-ref": "heads/master-0-g76f4dbb" + "template-ref": "heads/master-0-g5a59870" } diff --git a/spec/acceptance/nodesets/amazon2023.yml b/spec/acceptance/nodesets/amazon2023.yml new file mode 100644 index 0000000..2ea704c --- /dev/null +++ b/spec/acceptance/nodesets/amazon2023.yml @@ -0,0 +1,28 @@ +HOSTS: + amazon-2023: + roles: + - agent + platform: amazon-2023-x86_64 + hypervisor: docker + image: amazonlinux:2023 + docker_preserve_image: true + docker_cmd: + - '/usr/sbin/init' + docker_image_commands: + - 'dnf install -y dnf-utils' + - 'dnf install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks glibc-langpack-en cpio' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'openondemand-amazon2023' + default_module_install_opts: + ignore-dependencies: + force: +CONFIG: + log_level: debug + type: foss +ssh: + password: root + auth_methods: ["password"] + diff --git a/spec/acceptance/nodesets/debian-12.yml b/spec/acceptance/nodesets/debian-12.yml new file mode 100644 index 0000000..ad54880 --- /dev/null +++ b/spec/acceptance/nodesets/debian-12.yml @@ -0,0 +1,31 @@ +HOSTS: + debian12: + roles: + - agent + platform: debian-12-amd64 + hypervisor: docker + image: debian:12 + docker_preserve_image: true + docker_cmd: + - '/sbin/init' + docker_image_commands: + - 'apt-get install -y wget net-tools systemd-sysv locales apt-transport-https ca-certificates cron' + - 'echo "LC_ALL=en_US.UTF-8" >> /etc/environment' + - 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' + - 'echo "LANG=en_US.UTF-8" > /etc/locale.conf' + - 'locale-gen en_US.UTF-8' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'openondemand-debian12' + default_module_install_opts: + ignore-dependencies: + force: +CONFIG: + log_level: debug + type: foss +ssh: + password: root + auth_methods: ["password"] + diff --git a/spec/acceptance/openondemand_spec.rb b/spec/acceptance/openondemand_spec.rb index 7ea2495..66adf66 100644 --- a/spec/acceptance/openondemand_spec.rb +++ b/spec/acceptance/openondemand_spec.rb @@ -3,16 +3,19 @@ require 'spec_helper_acceptance' describe 'openondemand class:' do - context 'with default parameters' do - it 'runs successfully' do - pp = <<-PP - class { 'openondemand': - generator_insecure => true, - } - PP - - apply_manifest(pp, catch_failures: true) - apply_manifest(pp, catch_changes: true) + supported_releases.each do |release| + context "when repo_release => #{release}" do + it 'runs successfully' do + pp = <<-PP + class { 'openondemand': + repo_release => '#{release}', + generator_insecure => true, + } + PP + + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end end end @@ -20,8 +23,6 @@ class { 'openondemand': it 'runs successfully' do pp = <<-PP class { 'openondemand': - # TODO: Remove once repo_release uses 3.1 - repo_release => 'build/3.1', repo_nightly => true, ondemand_package_ensure => 'latest', generator_insecure => true, diff --git a/spec/shared_examples/repo_apt.rb b/spec/shared_examples/repo_apt.rb index 0a337db..c678efc 100644 --- a/spec/shared_examples/repo_apt.rb +++ b/spec/shared_examples/repo_apt.rb @@ -4,7 +4,7 @@ it do is_expected.to contain_apt__source('ondemand-web').with( ensure: 'present', - location: 'https://apt.osc.edu/ondemand/3.0/web/apt', + location: 'https://apt.osc.edu/ondemand/3.1/web/apt', repos: 'main', release: facts[:os]['distro']['codename'], key: { @@ -27,17 +27,38 @@ ) end - it do - is_expected.to contain_apt__source('nodesource').with( - ensure: 'present', - location: 'https://deb.nodesource.com/node_14.x', - repos: 'main', - release: facts[:os]['distro']['codename'], - key: { - 'id' => '9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280', - 'source' => 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key' - }, - ) + if facts[:os]['release']['major'].to_i != 12 + it do + is_expected.to contain_apt__source('nodesource').with( + ensure: 'present', + location: 'https://deb.nodesource.com/node_18.x', + repos: 'main', + release: 'nodistro', + key: { + 'id' => '6F71F525282841EEDAF851B42F59B5F99B1BE0B4', + 'source' => 'https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key' + }, + ) + end + else + it { is_expected.not_to contain_apt__source('nodesource') } + end + + context 'when repo_release => 3.0', if: facts[:os]['release']['major'].to_i != 12 do + let(:params) { { repo_release: '3.0' } } + + it do + is_expected.to contain_apt__source('nodesource').with( + ensure: 'present', + location: 'https://deb.nodesource.com/node_14.x', + repos: 'main', + release: facts[:os]['distro']['codename'], + key: { + 'id' => '9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280', + 'source' => 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key' + }, + ) + end end context 'when repo_nightly => true' do diff --git a/spec/shared_examples/repo_rpm.rb b/spec/shared_examples/repo_rpm.rb index 9d7e54a..5dfdc95 100644 --- a/spec/shared_examples/repo_rpm.rb +++ b/spec/shared_examples/repo_rpm.rb @@ -1,6 +1,20 @@ # frozen_string_literal: true shared_examples 'openondemand::repo::rpm' do |facts| + let(:repo_release) do + if facts[:os]['release']['major'].to_i == 7 + '3.0' + else + '3.1' + end + end + let(:dist) do + if facts[:os]['name'] == 'Amazon' + "amzn#{facts[:os]['release']['major']}" + else + "el#{facts[:os]['release']['major']}" + end + end let(:gpgkey) do if facts[:os]['release']['major'].to_i <= 8 'https://yum.osc.edu/ondemand/RPM-GPG-KEY-ondemand' @@ -8,11 +22,18 @@ 'https://yum.osc.edu/ondemand/RPM-GPG-KEY-ondemand-SHA512' end end + let(:module_hotfixes) do + if facts[:os]['release']['major'].to_i == 8 + 'true' + else + nil + end + end it do is_expected.to contain_yumrepo('ondemand-web').only_with( descr: 'Open OnDemand Web Repo', - baseurl: "https://yum.osc.edu/ondemand/3.0/web/el#{facts[:os]['release']['major']}/$basearch", + baseurl: "https://yum.osc.edu/ondemand/#{repo_release}/web/#{dist}/$basearch", enabled: '1', gpgcheck: '1', repo_gpgcheck: '1', @@ -20,6 +41,7 @@ metadata_expire: '1', priority: '99', exclude: 'absent', + module_hotfixes: module_hotfixes, ) end @@ -27,25 +49,31 @@ is_expected.to contain_yumrepo('ondemand-web-nightly').only_with( ensure: 'absent', descr: 'Open OnDemand Web Repo - Nightly', - baseurl: "https://yum.osc.edu/ondemand/nightly/web/el#{facts[:os]['release']['major']}/$basearch", + baseurl: "https://yum.osc.edu/ondemand/nightly/web/#{dist}/$basearch", enabled: '1', gpgcheck: '1', repo_gpgcheck: '1', gpgkey: gpgkey, metadata_expire: '1', priority: '99', + module_hotfixes: module_hotfixes, ) end - if facts[:os]['release']['major'].to_i == 7 - it { is_expected.not_to contain_exec('dnf makecache ondemand-web') } - - if facts[:os]['name'] == 'CentOS' - it { is_expected.to contain_file('/etc/yum.repos.d/ondemand-centos-scl.repo').with_ensure('absent') } - else - it { is_expected.not_to contain_file('/etc/yum.repos.d/ondemand-centos-scl.repo') } + if facts[:os]['release']['major'].to_i != 7 + it do + is_expected.to contain_exec('dnf makecache ondemand-web').with( + path: '/usr/bin:/bin:/usr/sbin:/sbin', + command: "dnf -q makecache -y --disablerepo='*' --enablerepo='ondemand-web'", + refreshonly: 'true', + subscribe: 'Yumrepo[ondemand-web]', + ) end + else + it { is_expected.not_to contain_exec('dnf makecache ondemand-web') } + end + if facts[:os]['release']['major'].to_i == 7 case facts[:os]['name'] when 'RedHat' it { is_expected.to contain_rh_repo("rhel-server-rhscl-#{facts[:os]['release']['major']}-rpms").with_ensure('present') } @@ -54,46 +82,61 @@ end it { is_expected.not_to contain_package('nodejs:14') } it { is_expected.not_to contain_package('ruby:3.0') } + it { is_expected.not_to contain_package('nodejs:18') } + it { is_expected.not_to contain_package('ruby:3.1') } end - if facts[:os]['release']['major'].to_i == 8 - it do - is_expected.to contain_exec('dnf makecache ondemand-web').with( - path: '/usr/bin:/bin:/usr/sbin:/sbin', - command: "dnf -q makecache -y --disablerepo='*' --enablerepo='ondemand-web'", - refreshonly: 'true', - subscribe: 'Yumrepo[ondemand-web]', - ) - end - - it do - is_expected.to contain_exec('dnf makecache ondemand-web').that_comes_before('Package[nodejs]') - is_expected.to contain_exec('dnf makecache ondemand-web').that_comes_before('Package[ruby]') - end - + if facts[:os]['release']['major'].to_s =~ %r{^(8|9)$} it do is_expected.to contain_package('nodejs').with( - ensure: '14', + ensure: '18', enable_only: 'true', provider: 'dnfmodule', + require: 'Exec[dnf makecache ondemand-web]', ) end it do is_expected.to contain_package('ruby').with( - ensure: '3.0', + ensure: '3.1', enable_only: 'true', provider: 'dnfmodule', + require: 'Exec[dnf makecache ondemand-web]', ) end + + context 'when repo_release => 3.0' do + let(:params) { { repo_release: '3.0' } } + + if facts[:os]['release']['major'].to_s == '9' + it { is_expected.to contain_package('nodejs').with_ensure('absent') } + it { is_expected.to contain_package('ruby').with_ensure('absent') } + else + it { is_expected.to contain_package('nodejs').with_ensure('14') } + it { is_expected.to contain_package('ruby').with_ensure('3.0') } + end + end + end + + if facts[:os]['name'] == 'Amazon' + it { is_expected.not_to contain_class('epel') } + else + it { is_expected.to contain_class('epel') } end context 'when manage_dependency_repos => false' do let(:params) { { manage_dependency_repos: false } } - it { is_expected.not_to contain_file('/etc/yum.repos.d/ondemand-centos-scl.repo') } - it { is_expected.not_to contain_rh_repo("rhel-server-rhscl-#{facts[:os]['release']['major']}-rpms") } - it { is_expected.not_to contain_package('centos-release-scl') } + it { is_expected.not_to contain_rh_repo("rhel-server-rhscl-#{facts[:os]['release']['major']}-rpms").with_ensure('present') } + it { is_expected.not_to contain_package('centos-release-scl').with_ensure('installed') } + it { is_expected.not_to contain_package('nodejs') } + it { is_expected.not_to contain_package('ruby') } + end + + context 'when manage_epel => false' do + let(:params) { { manage_epel: false } } + + it { is_expected.not_to contain_class('epel') } end context 'when repo_nightly => true' do diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d0d3a82..09cf9fa 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -9,7 +9,8 @@ Dir["#{dir}/acceptance/shared_examples/**/*.rb"].sort.each { |f| require f } require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) -run_puppet_install_helper +run_puppet_install_helper unless ENV['BEAKER_set'] == 'debian-12' +on hosts, 'apt install -y puppet-agent' if ENV['BEAKER_set'] == 'debian-12' install_module_on(hosts) install_module_dependencies_on(hosts) diff --git a/spec/spec_helper_acceptance_setup.rb b/spec/spec_helper_acceptance_setup.rb index e116497..8eed535 100644 --- a/spec/spec_helper_acceptance_setup.rb +++ b/spec/spec_helper_acceptance_setup.rb @@ -3,3 +3,56 @@ install_module_from_forge('puppetlabs-concat', '>= 9.0.0 < 10.0.0') install_module_from_forge('puppet-augeasproviders_core', '>= 3.0.0 < 4.0.0') on hosts, 'puppet config set strict warning' + +def supported_releases + osname = fact('os.name') + osfamily = fact('os.family') + osmajor = fact('os.release.major') + if ['Amazon-2023', 'Debian-12'].include?("#{osname}-#{osmajor}") + ['3.1'] + elsif "#{osfamily}-#{osmajor}" == 'RedHat-7' + ['3.0'] + else + ['3.0', '3.1'] + end +end + +RSpec.configure do |c| + c.before :suite do + hiera_yaml = <<-HIERA +--- +version: 5 +defaults: + datadir: data + data_hash: yaml_data +hierarchy: + - name: os + path: "%{facts.os.name}.yaml" + - name: "common" + path: "common.yaml" + HIERA + amazon_yaml = <<-HIERA +# The Apache service won't start during the Docker based tests +apache::service_ensure: stopped +openondemand::ssl: +- "SSLCertificateFile /etc/pki/tls/certs/localhost.crt" +- "SSLCertificateKeyFile /etc/pki/tls/private/localhost.key" + HIERA + on hosts, 'mkdir -p /etc/puppetlabs/puppet/data' + create_remote_file(hosts, '/etc/puppetlabs/puppet/hiera.yaml', hiera_yaml) + create_remote_file(hosts, '/etc/puppetlabs/puppet/data/Amazon.yaml', amazon_yaml) + # Need to bootstrap the localhost cert/key + if fact('os.name') == 'Amazon' + on hosts, 'dnf install -y sscg' + cert_bootstrap = [ + 'sscg -q', + '--cert-file /etc/pki/tls/certs/localhost.crt', + '--cert-key-file /etc/pki/tls/private/localhost.key', + '--ca-file /etc/pki/tls/certs/localhost.crt', + '--dhparams-file /tmp/dhparams.pem --lifetime 365', + '--hostname $(hostname) --email root@$(hostname)' + ] + on hosts, cert_bootstrap.join(' ') + end + end +end