Skip to content

Commit

Permalink
Add parameters to ensure OpenSCAP Ansible module state
Browse files Browse the repository at this point in the history
Ansible equivalent of fa6a515.
  • Loading branch information
ekohl committed Mar 21, 2023
1 parent e398f8c commit e8efb1e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/openscap.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include foreman_proxy
class { 'foreman_proxy::plugin::openscap':
puppet_module => true,
ansible_module => true,
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
#
# $ansible_module:: Ensure the Ansible module
#
# $puppet_module:: Ensure the Puppet module. This only makes sense if Puppetserver runs on the same machine.
#
# === Advanced parameters:
Expand All @@ -36,6 +38,8 @@
# $version:: plugin package version, it's passed to ensure parameter of package resource
# can be set to specific version number, 'latest', 'present' etc.
#
# $ansible_module_ensure:: The state of the Ansible module to ensure
#
# $puppet_module_ensure:: The state of the Puppet module to ensure
#
class foreman_proxy::plugin::openscap (
Expand All @@ -50,6 +54,8 @@
Stdlib::Absolutepath $corrupted_dir = '/var/lib/foreman-proxy/openscap/corrupted',
Optional[String] $proxy_name = undef,
Integer[0] $timeout = 60,
Boolean $ansible_module = false,
String[1] $ansible_module_ensure = 'present',
Boolean $puppet_module = false,
String[1] $puppet_module_ensure = 'present',
) {
Expand All @@ -60,6 +66,12 @@
enabled => $enabled,
}

if $ansible_module {
package { 'ansiblerole-foreman_scap_client':
ensure => $ansible_module_ensure,
}
}

if $puppet_module {
package { 'puppet-foreman_scap_client':
ensure => $puppet_module_ensure,
Expand Down
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 ansible_module' do
let :params do
{
ansible_module: true,
}
end

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

context 'with puppet_module' do
let :params do
{
Expand Down

0 comments on commit e8efb1e

Please sign in to comment.