Skip to content

Commit

Permalink
Add shellhooks plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Mar 4, 2021
1 parent 7d3da00 commit 03d7ae1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
30 changes: 30 additions & 0 deletions manifests/plugin/shellhooks.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# = Foreman Proxy Shelhooks plugin
#
# This class installs the Shellhooks plugin
#
# === Parameters:
#
# $directory:: Absolute path to directory with executables
#
# === Advanced parameters:
#
# $enabled:: enables/disables the shellhooks plugin
#
# $listen_on:: proxy feature listens on http, https, or both
#
# $version:: plugin package version, it's passed to ensure parameter of package resource
# can be set to specific version number, 'latest', 'present' etc.
#
class foreman_proxy::plugin::shellhooks (
Optional[String] $version = undef,
Boolean $enabled = true,
Stdlib::Absolutepath $directory = '/var/lib/foreman-proxy/shellhooks',
Foreman_proxy::ListenOn $listen_on = 'https',
) {
foreman_proxy::plugin::module { 'shellhooks':
enabled => $enabled,
feature => 'shellhooks',
listen_on => $listen_on,
version => $version,
}
}
35 changes: 35 additions & 0 deletions spec/classes/foreman_proxy__plugin__shellhooks_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper'

describe 'foreman_proxy::plugin::shellhooks' do
on_plugin_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
let(:pre_condition) { 'include foreman_proxy' }

describe 'with default settings' do
it { should contain_foreman_proxy__plugin__module('shellhooks') }
it 'shellhooks.yml should contain the correct configuration' do
verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/shellhooks.yml', [
'---',
':enabled: https',
':directory: /var/lib/foreman-proxy/shellhooks'
])
end
end

describe 'with overwritten parameters' do
let :params do
{ :directory => '/opt/custom_shellhooks' }
end

it 'shellhooks.yml should contain the correct configuration' do
verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/shellhooks.yml', [
'---',
':enabled: https',
':directory: /opt/custom_shellhooks',
])
end
end
end
end
end
5 changes: 5 additions & 0 deletions templates/plugin/shellhooks.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# always enable HTTPS only
:enabled: <%= @module_enabled %>
# directory with executables
:directory: <%= scope.lookupvar("foreman_proxy::plugin::shellhooks::directory") %>

0 comments on commit 03d7ae1

Please sign in to comment.