From 374d9a1801354c855d89814cd63a01d2f5107523 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Thu, 4 Mar 2021 10:12:18 +0100 Subject: [PATCH 1/3] Add shellhooks plugin --- manifests/plugin/shellhooks.pp | 30 ++++++++++++++++ .../foreman_proxy__plugin__shellhooks_spec.rb | 35 +++++++++++++++++++ templates/plugin/shellhooks.yml.erb | 5 +++ 3 files changed, 70 insertions(+) create mode 100644 manifests/plugin/shellhooks.pp create mode 100644 spec/classes/foreman_proxy__plugin__shellhooks_spec.rb create mode 100644 templates/plugin/shellhooks.yml.erb diff --git a/manifests/plugin/shellhooks.pp b/manifests/plugin/shellhooks.pp new file mode 100644 index 00000000..91a77a16 --- /dev/null +++ b/manifests/plugin/shellhooks.pp @@ -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, + } +} diff --git a/spec/classes/foreman_proxy__plugin__shellhooks_spec.rb b/spec/classes/foreman_proxy__plugin__shellhooks_spec.rb new file mode 100644 index 00000000..7f1daeee --- /dev/null +++ b/spec/classes/foreman_proxy__plugin__shellhooks_spec.rb @@ -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 diff --git a/templates/plugin/shellhooks.yml.erb b/templates/plugin/shellhooks.yml.erb new file mode 100644 index 00000000..4cfa5842 --- /dev/null +++ b/templates/plugin/shellhooks.yml.erb @@ -0,0 +1,5 @@ +--- +# always enable HTTPS only +:enabled: <%= @module_enabled %> +# directory with executables +:directory: <%= scope.lookupvar("foreman_proxy::plugin::shellhooks::directory") %> From 650a9ecbe954a598469055a993d357d538c765ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20R=C5=AF=C5=BEi=C4=8Dka?= Date: Thu, 4 Mar 2021 14:18:06 +0100 Subject: [PATCH 2/3] Update manifests/plugin/shellhooks.pp Co-authored-by: Eric Helms --- manifests/plugin/shellhooks.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugin/shellhooks.pp b/manifests/plugin/shellhooks.pp index 91a77a16..da919a62 100644 --- a/manifests/plugin/shellhooks.pp +++ b/manifests/plugin/shellhooks.pp @@ -1,4 +1,4 @@ -# = Foreman Proxy Shelhooks plugin +# = Foreman Proxy Shellhooks plugin # # This class installs the Shellhooks plugin # From 4979a02a18e4060b98c9be6bf71f6d928c701fd6 Mon Sep 17 00:00:00 2001 From: Adam Ruzicka Date: Tue, 16 Mar 2021 13:57:51 +0100 Subject: [PATCH 3/3] Fix shellhooks template comment --- templates/plugin/shellhooks.yml.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/plugin/shellhooks.yml.erb b/templates/plugin/shellhooks.yml.erb index 4cfa5842..5ab0b796 100644 --- a/templates/plugin/shellhooks.yml.erb +++ b/templates/plugin/shellhooks.yml.erb @@ -1,5 +1,5 @@ --- -# always enable HTTPS only +# Use https for production deployments. http and true only make sense in development :enabled: <%= @module_enabled %> -# directory with executables +# Directory with executables. :directory: <%= scope.lookupvar("foreman_proxy::plugin::shellhooks::directory") %>