Skip to content

Commit

Permalink
Handle smart proxy and plugins packaged for SCL
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Jan 15, 2020
1 parent 9c06de5 commit 32b61e3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 44 deletions.
12 changes: 6 additions & 6 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

case $::osfamily {
'RedHat': {
$plugin_prefix = 'rubygem-smart_proxy_'
if versioncmp($facts['os']['release']['major'], '7') <= 0 {
$plugin_prefix = 'tfm-rubygem-smart_proxy_'
} else {
$plugin_prefix = 'rubygem-smart_proxy_'
}

$dir = '/usr/share/foreman-proxy'
$etc = '/etc'
Expand Down Expand Up @@ -119,11 +123,7 @@
$plugin_version = 'installed'

# Enable listening on http
if $::osfamily == 'RedHat' and versioncmp($::operatingsystemmajrelease, '7') <= 0 and fact('ipaddress6') {
$bind_host = ['::']
} else {
$bind_host = ['*']
}
$bind_host = ['*']
$http = false
$http_port = 8000

Expand Down
7 changes: 0 additions & 7 deletions manifests/plugin/dynflow.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@

if $facts['osfamily'] == 'RedHat' {

if versioncmp($facts['operatingsystemmajrelease'], '8') >= 0 {
$scl_prefix = '' # lint:ignore:empty_string_assignment
} else {
$scl_prefix = 'tfm-'
}

foreman_proxy::plugin { 'dynflow_core':
package => "${scl_prefix}${::foreman_proxy::plugin_prefix}dynflow_core",
}
~> file { '/etc/smart_proxy_dynflow_core/settings.yml':
ensure => file,
Expand Down
30 changes: 0 additions & 30 deletions spec/classes/foreman_proxy__spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,36 +102,6 @@
should contain_file("#{etc_dir}/foreman-proxy/settings.d/puppet_proxy_puppetrun.yml").with_ensure('absent')
end

context 'with IPv6' do
let(:facts) { super().merge(ipaddress6: '2001:db8::1') }

it 'should generate correct settings.yml' do
if facts[:osfamily] == 'RedHat' and facts[:operatingsystemmajrelease].to_i <= 7
bind_host = '::'
else
bind_host = '*'
end

verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.yml", [
'---',
":settings_directory: #{etc_dir}/foreman-proxy/settings.d",
":ssl_ca_file: #{ssl_dir}/certs/ca.pem",
":ssl_certificate: #{ssl_dir}/certs/#{facts[:fqdn]}.pem",
":ssl_private_key: #{ssl_dir}/private_keys/#{facts[:fqdn]}.pem",
':trusted_hosts:',
" - #{facts[:fqdn]}",
":foreman_url: https://#{facts[:fqdn]}",
':daemon: true',
":bind_host: '#{bind_host}'",
':https_port: 8443',
':log_file: /var/log/foreman-proxy/proxy.log',
':log_level: INFO',
':log_buffer: 2000',
':log_buffer_errors: 1000',
])
end
end

context 'without IPv4' do
let(:facts) { super().reject { |fact| fact == :ipaddress } }

Expand Down
8 changes: 7 additions & 1 deletion spec/defines/foreman_proxy_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
end

context 'no parameters' do
package = facts[:osfamily] == 'Debian' ? 'ruby-smart-proxy-myplugin' : 'rubygem-smart_proxy_myplugin'
package = if facts[:osfamily] == 'Debian'
'ruby-smart-proxy-myplugin'
elsif facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '7'
'tfm-rubygem-smart_proxy_myplugin'
else
'rubygem-smart_proxy_myplugin'
end

it 'should install the correct package' do
should contain_package(package).with_ensure('installed')
Expand Down

0 comments on commit 32b61e3

Please sign in to comment.