Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shellhooks plugin #651

Merged
merged 3 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Shellhooks 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 @@
---
# Use https for production deployments. http and true only make sense in development
:enabled: <%= @module_enabled %>
# Directory with executables.
:directory: <%= scope.lookupvar("foreman_proxy::plugin::shellhooks::directory") %>