Skip to content

Commit

Permalink
Add support for external Dynflow core
Browse files Browse the repository at this point in the history
Co-Authored-By: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
  • Loading branch information
adamruzicka and ekohl committed Jul 18, 2019
1 parent d1954c7 commit 5bde9c7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions manifests/plugin/dynflow.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#
# $open_file_limit:: Limit number of open files - Only Red Hat Operating Systems with Software Collections.
#
# $external_core:: Forces usage of external/internal Dynflow core
class foreman_proxy::plugin::dynflow (
Boolean $enabled = $::foreman_proxy::plugin::dynflow::params::enabled,
Foreman_proxy::ListenOn $listen_on = $::foreman_proxy::plugin::dynflow::params::listen_on,
Expand All @@ -34,6 +35,7 @@
Optional[Array[String]] $ssl_disabled_ciphers = $::foreman_proxy::plugin::dynflow::params::ssl_disabled_ciphers,
Optional[Array[String]] $tls_disabled_versions = $::foreman_proxy::plugin::dynflow::params::tls_disabled_versions,
Integer[1] $open_file_limit = $::foreman_proxy::plugin::dynflow::params::open_file_limit,
Optional[Boolean] $external_core = $::foreman_proxy::plugin::dynflow::params::external_core,
) inherits foreman_proxy::plugin::dynflow::params {
if $::foreman_proxy::ssl {
$core_url = "https://${::fqdn}:${core_port}"
Expand Down
4 changes: 4 additions & 0 deletions manifests/plugin/dynflow/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
$ssl_disabled_ciphers = undef
$tls_disabled_versions = undef
$open_file_limit = 1000000
$external_core = $facts['osfamily'] ? {
'RedHat' => true,
default => undef
}
}
19 changes: 17 additions & 2 deletions spec/classes/foreman_proxy__plugin__dynflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
it { should contain_foreman_proxy__plugin('dynflow') }

it 'should generate correct dynflow.yml' do
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/dynflow.yml", [
lines = [
'---',
':enabled: https',
':database: ',
':core_url: https://foo.example.com:8008',
])
]
lines << ':external_core: true' if has_core
verify_exact_contents(catalogue,
"#{etc_dir}/foreman-proxy/settings.d/dynflow.yml",
lines)
end

if has_core
Expand Down Expand Up @@ -78,6 +82,7 @@
:ssl_disabled_ciphers => ['NULL-MD5', 'NULL-SHA'],
:tls_disabled_versions => ['1.1'],
:open_file_limit => 8000,
:external_core => false,
} end

it { should compile.with_all_deps }
Expand Down Expand Up @@ -110,6 +115,16 @@
':tls_disabled_versions: ["1.1"]',
])
end

it 'should generate correct dynflow.yml' do
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/dynflow.yml", [
'---',
':enabled: https',
':database: /var/lib/foreman-proxy/dynflow/dynflow.sqlite',
':core_url: https://foo.example.com:8008',
':external_core: false',
])
end
else
it { should_not contain_foreman_proxy__plugin('dynflow_core') }
it { should_not contain_file("#{etc_dir}/smart_proxy_dynflow_core/settings.d") }
Expand Down
10 changes: 10 additions & 0 deletions templates/plugin/dynflow.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
:enabled: <%= @module_enabled %>
:database: <%= scope.lookupvar('::foreman_proxy::plugin::dynflow::database_path') %>
:core_url: <%= scope.lookupvar('::foreman_proxy::plugin::dynflow::core_url') %>

# If true, external core will be used even if the core gem is available
# If false, the feature will be disabled if the core gem is unavailable
# If unset, the process will fallback to autodetection, using external core if the core gem is unavailable
<% external_core = scope.lookupvar('::foreman_proxy::plugin::dynflow::external_core') -%>
<% if [nil, :undefined, :undef].include?(external_core) -%>
# :external_core: true
<% else -%>
:external_core: <%= external_core %>
<% end -%>

0 comments on commit 5bde9c7

Please sign in to comment.