diff --git a/manifests/healthcheck.pp b/manifests/healthcheck.pp new file mode 100644 index 0000000..8cccbf8 --- /dev/null +++ b/manifests/healthcheck.pp @@ -0,0 +1,43 @@ +# == Define: oslo::healthcheck +# +# Configure oslo_middleware options in healthcheck section +# +# === Parameters: +# +# [*detailed*] +# (Optional) Show more detailed information as part of the response. +# Defaults to $::os_service_default +# +# [*backends*] +# (Optional) Additional backends that can perform health checks and report +# that information back as part of a request. +# Defaults to $::os_service_default +# +# [*disable_by_file_path*] +# (Optional) Check the presense of a file to determine if an application +# is running on a port. +# Defaults to $::os_service_default +# +# [*disable_by_file_paths*] +# (Optional) Check the presense of a file to determine if an application +# is running on a port. Expects a "port:path" list of strings. +# Defaults to $::os_service_default +# +define oslo::healthcheck( + $detailed = $::os_service_default, + $backends = $::os_service_default, + $disable_by_file_path = $::os_service_default, + $disable_by_file_paths = $::os_service_default, +) { + + $backends_real = join(any2array($backends), ',') + $disable_by_file_paths_real = join(any2array($disable_by_file_paths), ',') + + $healthcheck_options = { + 'healthcheck/detailed' => { value => $detailed }, + 'healthcheck/backends' => { value => $backends_real }, + 'healthcheck/disable_by_file_path' => { value => $disable_by_file_path }, + 'healthcheck/disable_by_file_paths' => { value => $disable_by_file_paths_real}, + } + create_resources($name, $healthcheck_options) +} diff --git a/releasenotes/notes/healthcheck-middleware-c254827e460e7443.yaml b/releasenotes/notes/healthcheck-middleware-c254827e460e7443.yaml new file mode 100644 index 0000000..7cdf57a --- /dev/null +++ b/releasenotes/notes/healthcheck-middleware-c254827e460e7443.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Support for options of healthcheck middleware has been added. diff --git a/spec/defines/oslo_healthcheck_spec.rb b/spec/defines/oslo_healthcheck_spec.rb new file mode 100644 index 0000000..9547067 --- /dev/null +++ b/spec/defines/oslo_healthcheck_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe 'oslo::healthcheck' do + + let (:title) { 'keystone_config' } + + shared_examples 'oslo::healthcheck' do + + context 'with default parameters' do + let :params do + {} + end + + it 'configure healthcheck default params' do + is_expected.to contain_keystone_config('healthcheck/detailed').with_value('') + is_expected.to contain_keystone_config('healthcheck/backends').with_value('') + is_expected.to contain_keystone_config('healthcheck/disable_by_file_path').with_value('') + is_expected.to contain_keystone_config('healthcheck/disable_by_file_paths').with_value('') + end + end + + context 'with parameters overridden' do + let :params do + { + :detailed => true, + :backends => ['disable_by_file', 'disable_by_files_ports'], + :disable_by_file_path => '/etc/keystone/healthcheck/disabled', + :disable_by_file_paths => [ + '5000:/etc/keystone/healthcheck/public-disabled', + '35357:/etc/keystone/healthcheck/admin-disabled' + ], + } + end + + it 'configure healthcheck params' do + is_expected.to contain_keystone_config('healthcheck/detailed').with_value('true') + is_expected.to contain_keystone_config('healthcheck/backends').with_value( + 'disable_by_file,disable_by_files_ports' + ) + is_expected.to contain_keystone_config('healthcheck/disable_by_file_path').with_value( + '/etc/keystone/healthcheck/disabled' + ) + is_expected.to contain_keystone_config('healthcheck/disable_by_file_paths').with_value( + '5000:/etc/keystone/healthcheck/public-disabled,35357:/etc/keystone/healthcheck/admin-disabled' + ) + end + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + include_examples 'oslo::healthcheck' + end + end +end