Skip to content

Commit

Permalink
Fixes #35531 - Add Puppet module support
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl authored and ehelms committed Sep 22, 2022
1 parent 7f6601f commit fa6a515
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/openscap.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include foreman_proxy
class { 'foreman_proxy::plugin::openscap':
puppet_module => true,
}
12 changes: 12 additions & 0 deletions manifests/plugin/openscap.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#
# $timeout:: Timeout for sending ARF reports to foreman
#
# $puppet_module:: Ensure the Puppet module. This only makes sense if Puppetserver runs on the same machine.
#
# === Advanced parameters:
#
# $enabled:: enables/disables the openscap plugin
Expand All @@ -34,6 +36,8 @@
# $version:: plugin package version, it's passed to ensure parameter of package resource
# can be set to specific version number, 'latest', 'present' etc.
#
# $puppet_module_ensure:: The state of the Puppet module to ensure
#
class foreman_proxy::plugin::openscap (
Boolean $enabled = true,
Optional[String] $version = undef,
Expand All @@ -46,11 +50,19 @@
Stdlib::Absolutepath $corrupted_dir = '/var/lib/foreman-proxy/openscap/corrupted',
Optional[String] $proxy_name = undef,
Integer[0] $timeout = 60,
Boolean $puppet_module = false,
String[1] $puppet_module_ensure = 'present',
) {
$registered_proxy_name = pick($proxy_name, $foreman_proxy::registered_name)
foreman_proxy::plugin::module { 'openscap':
version => $version,
listen_on => $listen_on,
enabled => $enabled,
}

if $puppet_module {
package { 'puppet-foreman_scap_client':
ensure => $puppet_module_ensure,
}
}
}
13 changes: 13 additions & 0 deletions spec/acceptance/openscap_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'spec_helper_acceptance'

describe 'Scenario: install foreman-proxy with openscap plugin', if: ['redhat', 'centos'].include?(os[:family]) do
before(:context) { purge_foreman_proxy }

include_examples 'the example', 'openscap.pp'

it_behaves_like 'the default foreman proxy application'

describe package('puppet-foreman_scap_client') do
it { is_expected.to be_installed }
end
end
11 changes: 11 additions & 0 deletions spec/classes/foreman_proxy__plugin__openscap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@
end
end

context 'with puppet_module' do
let :params do
{
puppet_module: true,
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_package('puppet-foreman_scap_client').with_ensure('present') }
end

context 'openscap plugin is disabled' do
let :params do
{
Expand Down

0 comments on commit fa6a515

Please sign in to comment.