From bfa326c03d862aca19e33ca515f17d80ed77699f Mon Sep 17 00:00:00 2001 From: Stephen Benjamin Date: Thu, 23 Jun 2016 20:00:56 -0400 Subject: [PATCH] refs #15217 - puppet 4 support (#132) --- .travis.yml | 21 ++- metadata.json | 2 +- spec/classes/katello_config_spec.rb | 163 +++++++++--------- spec/classes/katello_install_spec.rb | 60 ++++--- spec/classes/katello_spec.rb | 131 +++----------- templates/client.conf.erb | 4 +- .../conf.d/05-foreman-ssl.d/katello.conf.erb | 2 +- templates/katello.yaml.erb | 33 ++-- 8 files changed, 173 insertions(+), 243 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3ed90189..46424bf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,30 @@ # This file is managed centrally by modulesync # https://github.com/katello/foreman-installer-modulesync rvm: - - 1.8.7 - 1.9.3 - 2.0.0 - 2.1.5 env: - PUPPET_VERSION=3.5 + - PUPPET_VERSION=3.5 FUTURE_PARSER=yes + - PUPPET_VERSION=4.0 +matrix: + fast_finish: true + exclude: + # No support for Ruby 1.9.3 on Puppet 4.x + - rvm: 1.9.3 + env: PUPPET_VERSION=4.0 + include: + # Only platforms left to support ruby 1.8.7 + - rvm: 1.8.7 + env: PUPPET_VERSION=3.5 + - rvm: 1.8.7 + env: PUPPET_VERSION=3.5 FUTURE_PARSER=yes + # Only Puppet 4.x supports Ruby 2.2. Also limit the OS set we test Ruby 2.2 with. + - rvm: 2.2.3 + env: PUPPET_VERSION=4.0 + # Only Puppet >= 4.4 supports Ruby 2.3. Also limit the OS set we test Ruby 2.3 with. + - rvm: 2.3.0 + env: PUPPET_VERSION=4.4 bundler_args: --without development sudo: false diff --git a/metadata.json b/metadata.json index bdfb2cef..ef2b334f 100644 --- a/metadata.json +++ b/metadata.json @@ -56,7 +56,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 3.2.0 < 4.0.0" + "version_requirement": ">= 3.2.0 < 5.0.0" } ], "operatingsystem_support": [ diff --git a/spec/classes/katello_config_spec.rb b/spec/classes/katello_config_spec.rb index e93748a6..6ce10b35 100644 --- a/spec/classes/katello_config_spec.rb +++ b/spec/classes/katello_config_spec.rb @@ -1,96 +1,91 @@ require 'spec_helper' describe 'katello::config' do - let :facts do - { - :concat_basedir => '/tmp', - :interfaces => '', - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '6.5', - :fqdn => 'host.example.org', - } - end - - context 'default config settings' do - let(:pre_condition) do - [ - 'include foreman', - 'include certs', - 'class {"katello":' \ - 'post_sync_token => test_token,' \ - 'oauth_secret => secret' \ - '}' - ] + on_supported_os.each do |os, facts| + let :facts do + facts.merge(:concat_basedir => '/tmp', :mongodb_version => '2.4.14') end - it 'should NOT set the cdn-ssl-version' do - should_not contain_file('/etc/foreman/plugins/katello.yaml'). - with_content(/cdn_ssl_version/) - end + context 'default config settings' do + let(:pre_condition) do + [ + 'include foreman', + 'include certs', + 'class {"katello":' \ + 'post_sync_token => test_token,' \ + 'oauth_secret => secret' \ + '}' + ] + end - it 'should generate correct katello.yaml' do - should contain_file('/etc/foreman/plugins/katello.yaml') - content = catalogue.resource('file', '/etc/foreman/plugins/katello.yaml').send(:parameters)[:content] - content.split("\n").reject { |c| c =~ /(^#|^$)/ }.should == [ - ':katello:', - ' :rest_client_timeout: 3600', - ' :post_sync_url: https://host.example.org/katello/api/v2/repositories/sync_complete?token=test_token', - ' :candlepin:', - ' :url: https://host.example.org:8443/candlepin', - ' :oauth_key: katello', - ' :oauth_secret: secret', - ' :pulp:', - " :url: https://#{facts[:fqdn]}/pulp/api/v2/", - ' :oauth_key: katello', - ' :oauth_secret: secret', - ' :qpid:', - " :url: amqp:ssl:#{facts[:fqdn]}:5671", - ' :subscriptions_queue_address: katello_event_queue' - ] - end - end + it 'should NOT set the cdn-ssl-version' do + should_not contain_file('/etc/foreman/plugins/katello.yaml'). + with_content(/cdn_ssl_version/) + end - context 'when http proxy parameters are specified' do - let(:pre_condition) do - [ - 'include foreman', - 'include certs', - 'class {"katello":' \ - 'post_sync_token => "test_token",' \ - 'oauth_secret => "secret",' \ - 'proxy_url => "http://myproxy.org",' \ - 'proxy_port => 8888,' \ - 'proxy_username => "admin",' \ - 'proxy_password => "secret_password"' \ - '}' - ] + it 'should generate correct katello.yaml' do + should contain_file('/etc/foreman/plugins/katello.yaml') + content = catalogue.resource('file', '/etc/foreman/plugins/katello.yaml').send(:parameters)[:content] + content.split("\n").reject { |c| c =~ /(^#|^$)/ }.should == [ + ':katello:', + ' :rest_client_timeout: 3600', + ' :post_sync_url: https://foo.example.com/katello/api/v2/repositories/sync_complete?token=test_token', + ' :candlepin:', + ' :url: https://foo.example.com:8443/candlepin', + ' :oauth_key: katello', + ' :oauth_secret: secret', + ' :pulp:', + " :url: https://#{facts[:fqdn]}/pulp/api/v2/", + ' :oauth_key: katello', + ' :oauth_secret: secret', + ' :qpid:', + " :url: amqp:ssl:#{facts[:fqdn]}:5671", + ' :subscriptions_queue_address: katello_event_queue' + ] + end end - it 'should generate correct katello.yaml' do - should contain_file('/etc/foreman/plugins/katello.yaml') - content = catalogue.resource('file', '/etc/foreman/plugins/katello.yaml').send(:parameters)[:content] - content.split("\n").reject { |c| c =~ /(^#|^$)/ }.should == [ - ':katello:', - ' :rest_client_timeout: 3600', - ' :post_sync_url: https://host.example.org/katello/api/v2/repositories/sync_complete?token=test_token', - ' :candlepin:', - ' :url: https://host.example.org:8443/candlepin', - ' :oauth_key: katello', - ' :oauth_secret: secret', - ' :pulp:', - " :url: https://#{facts[:fqdn]}/pulp/api/v2/", - ' :oauth_key: katello', - ' :oauth_secret: secret', - ' :qpid:', - " :url: amqp:ssl:#{facts[:fqdn]}:5671", - ' :subscriptions_queue_address: katello_event_queue', - ' :cdn_proxy:', - ' :host: http://myproxy.org', - ' :port: 8888', - ' :user: admin', - ' :password: secret_password' - ] + context 'when http proxy parameters are specified' do + let(:pre_condition) do + [ + 'include foreman', + 'include certs', + 'class {"katello":' \ + 'post_sync_token => "test_token",' \ + 'oauth_secret => "secret",' \ + 'proxy_url => "http://myproxy.org",' \ + 'proxy_port => 8888,' \ + 'proxy_username => "admin",' \ + 'proxy_password => "secret_password"' \ + '}' + ] + end + + it 'should generate correct katello.yaml' do + should contain_file('/etc/foreman/plugins/katello.yaml') + content = catalogue.resource('file', '/etc/foreman/plugins/katello.yaml').send(:parameters)[:content] + content.split("\n").reject { |c| c =~ /(^#|^$)/ }.should == [ + ':katello:', + ' :rest_client_timeout: 3600', + ' :post_sync_url: https://foo.example.com/katello/api/v2/repositories/sync_complete?token=test_token', + ' :candlepin:', + ' :url: https://foo.example.com:8443/candlepin', + ' :oauth_key: katello', + ' :oauth_secret: secret', + ' :pulp:', + " :url: https://#{facts[:fqdn]}/pulp/api/v2/", + ' :oauth_key: katello', + ' :oauth_secret: secret', + ' :qpid:', + " :url: amqp:ssl:#{facts[:fqdn]}:5671", + ' :subscriptions_queue_address: katello_event_queue', + ' :cdn_proxy:', + ' :host: http://myproxy.org', + ' :port: 8888', + ' :user: admin', + ' :password: secret_password' + ] + end end end end diff --git a/spec/classes/katello_install_spec.rb b/spec/classes/katello_install_spec.rb index 1ff734e1..46c0c9aa 100644 --- a/spec/classes/katello_install_spec.rb +++ b/spec/classes/katello_install_spec.rb @@ -1,39 +1,37 @@ require 'spec_helper' describe 'katello::install' do - let :facts do - { - :concat_basedir => '/tmp', - :interfaces => '', - :osfamily => 'RedHat', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '6.5', - :fqdn => 'host.example.org', - } - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let :facts do + facts.merge(:concat_basedir => '/tmp', :mongodb_version => '2.4.14') + end - describe 'with enable_ostree == false' do - let(:pre_condition) do - ['include foreman', - 'include certs', - "class {'katello': - enable_ostree => false, - }" - ] - end - it { should_not contain_package("tfm-rubygem-katello_ostree")} - end + describe 'with enable_ostree == false' do + let(:pre_condition) do + ['include foreman', + 'include certs', + "class {'katello': + enable_ostree => false, + }" + ] + end + + it { should_not contain_package("tfm-rubygem-katello_ostree")} + end - describe 'with enable_ostree == true' do - let(:pre_condition) do - ['include foreman', - 'include certs', - "class {'katello': - enable_ostree => true, - }" - ] + describe 'with enable_ostree == true' do + let(:pre_condition) do + ['include foreman', + 'include certs', + "class {'katello': + enable_ostree => true, + }" + ] + end + it { should contain_package("tfm-rubygem-katello_ostree").with_ensure('installed'). + with_notify(["Service[foreman-tasks]", "Service[httpd]"]) } + end end - it { should contain_package("tfm-rubygem-katello_ostree").with_ensure('installed'). - with_notify(["Service[foreman-tasks]", "Service[httpd]"]) } end end diff --git a/spec/classes/katello_spec.rb b/spec/classes/katello_spec.rb index 4d9feb12..a4450c17 100644 --- a/spec/classes/katello_spec.rb +++ b/spec/classes/katello_spec.rb @@ -1,118 +1,38 @@ require 'spec_helper' describe 'katello' do - context 'on redhat' do - let :facts do - { - :concat_basedir => '/tmp', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.5', - :operatingsystemmajrelease => '6', - :osfamily => 'RedHat', - } - end - - let(:pre_condition) do - ['include foreman','include certs'] - end - - it { should contain_class('katello::install') } - it { should contain_class('katello::config') } - - it "should configure a qpid client" do - should contain_class('qpid::client'). - with(:ssl => true, - :ssl_cert_name => 'broker') - end - - context 'on setting cdn-ssl-version' do - let :params do - { - "cdn_ssl_version" => 'TLSv1' - } + on_supported_os.each do |os, facts| + context "on #{os}" do + let :facts do + facts.merge(:concat_basedir => '/tmp', :mongodb_version => '2.4.14') end - it 'should set up the cdn_ssl_version' do - should contain_file('/etc/foreman/plugins/katello.yaml'). - with_content(/^\s*:cdn_ssl_version:\s*TLSv1$/) + let(:pre_condition) do + ['include foreman', 'include certs'] end - end - end - context 'on centos' do - let :facts do - { - :concat_basedir => '/tmp', - :operatingsystem => 'CentOS', - :operatingsystemrelease => '6.5', - :operatingsystemmajrelease => '6', - :osfamily => 'RedHat', - } - end - - let(:pre_condition) do - ['include foreman','include certs'] - end + it { should contain_class('katello::install') } + it { should contain_class('katello::config') } - it { should contain_class('katello::install') } - it { should contain_class('katello::config') } - end - - context 'on oel' do - let :facts do - { - :concat_basedir => '/tmp', - :operatingsystem => 'OracleLinux', - :operatingsystemrelease => '6.5', - :operatingsystemmajrelease => '6', - :osfamily => 'RedHat', - } - end - - let(:pre_condition) do - ['include foreman','include certs'] - end - - it { should contain_class('katello::install') } - it { should contain_class('katello::config') } - end - - context 'on fedora' do - let :facts do - { - :concat_basedir => '/tmp', - :operatingsystem => 'Fedora', - :operatingsystemrelease => '20', - :operatingsystemmajrelease => '20', - :osfamily => 'RedHat', - } - end - - let(:pre_condition) do - ['include foreman','include certs'] - end - - it { should contain_class('katello::install') } - it { should contain_class('katello::config') } - end - - context 'on sl' do - let :facts do - { - :concat_basedir => '/tmp', - :operatingsystem => 'ScientificLinux', - :operatingsystemrelease => '6.5', - :operatingsystemmajrelease => '6', - :osfamily => 'RedHat', - } - end + it "should configure a qpid client" do + should contain_class('qpid::client'). + with(:ssl => true, + :ssl_cert_name => 'broker') + end - let(:pre_condition) do - ['include foreman','include certs'] + context 'on setting cdn-ssl-version' do + let :params do + { + "cdn_ssl_version" => 'TLSv1' + } + end + + it 'should set up the cdn_ssl_version' do + should contain_file('/etc/foreman/plugins/katello.yaml'). + with_content(/^\s*:cdn_ssl_version:\s*TLSv1$/) + end + end end - - it { should contain_class('katello::install') } - it { should contain_class('katello::config') } end context 'on unsupported osfamily' do @@ -129,5 +49,4 @@ it { expect { should contain_class('katello') }.to raise_error(Puppet::Error, /#{facts[:hostname]}: This module does not support osfamily #{facts[:osfamily]}/) } end - end diff --git a/templates/client.conf.erb b/templates/client.conf.erb index 59254b1e..5f735315 100644 --- a/templates/client.conf.erb +++ b/templates/client.conf.erb @@ -7,11 +7,11 @@ host = localhost.localdomain port = 443 scheme = https -path = <%= "/#{scope.lookupvar('katello::params::deployment_url')}" %> +path = <%= "/#{scope['katello::params::deployment_url']}" %> [interface] grep_friendly = false [shell] nohistory = false -prompt = <%= "#{scope.lookupvar('katello::params::deployment_url')}>" %> +prompt = <%= "#{scope['katello::params::deployment_url']}>" %> diff --git a/templates/etc/httpd/conf.d/05-foreman-ssl.d/katello.conf.erb b/templates/etc/httpd/conf.d/05-foreman-ssl.d/katello.conf.erb index 131fc2a8..a66ecee4 100644 --- a/templates/etc/httpd/conf.d/05-foreman-ssl.d/katello.conf.erb +++ b/templates/etc/httpd/conf.d/05-foreman-ssl.d/katello.conf.erb @@ -28,6 +28,6 @@ Alias /pub /var/www/html/pub KeepAlive On -<% unless [nil, :undefined, :undef, ''].include?(scope.lookupvar('katello::max_keep_alive')) -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['katello::max_keep_alive']) -%> MaxKeepAliveRequests <%= scope['::katello::max_keep_alive'] %> <% end -%> diff --git a/templates/katello.yaml.erb b/templates/katello.yaml.erb index 51c9c557..65c39f50 100644 --- a/templates/katello.yaml.erb +++ b/templates/katello.yaml.erb @@ -2,32 +2,31 @@ ## Module: puppet-katello :katello: - <%- if @cdn_ssl_version && !@cdn_ssl_version.strip.empty?-%> - :cdn_ssl_version: <%= @cdn_ssl_version %> + <%- unless [nil, :undefined, :undef].include?(scope['katello::cdn_ssl_version']) -%> + :cdn_ssl_version: <%= scope['katello::cdn_ssl_version']%> <%- end -%> - :rest_client_timeout: 3600 - :post_sync_url: https://<%= @fqdn %><%= @deployment_url %>/api/v2/repositories/sync_complete?token=<%= @post_sync_token %> + :post_sync_url: https://<%= scope['katello::fqdn'] %><%= scope['katello::deployment_url'] %>/api/v2/repositories/sync_complete?token=<%= scope['katello::post_sync_token'] %> :candlepin: - :url: <%= @candlepin_url %> - :oauth_key: <%= @oauth_key %> - :oauth_secret: <%= @oauth_secret %> + :url: <%= scope['katello::candlepin_url'] %> + :oauth_key: <%= scope['katello::oauth_key'] %> + :oauth_secret: <%= scope['katello::oauth_secret'] %> :pulp: - :url: <%= @pulp_url %> - :oauth_key: <%= @oauth_key %> - :oauth_secret: <%= @oauth_secret %> + :url: <%= scope['katello::pulp_url'] %> + :oauth_key: <%= scope['katello::oauth_key'] %> + :oauth_secret: <%= scope['katello::oauth_secret'] %> :qpid: - :url: <%= @qpid_url %> - :subscriptions_queue_address: <%= @candlepin_event_queue %> + :url: <%= scope['katello::qpid_url'] %> + :subscriptions_queue_address: <%= scope['katello::candlepin_event_queue'] %> -<%- if @proxy_url -%> +<%- unless [nil, :undefined, :undef].include?(scope['katello::proxy_url']) -%> :cdn_proxy: - :host: <%= @proxy_url %> - :port: <%= @proxy_port %> - :user: <%= @proxy_username %> - :password: <%= @proxy_password %> + :host: <%= scope['katello::proxy_url'] %> + :port: <%= scope['katello::proxy_port'] %> + :user: <%= scope['katello::proxy_username'] %> + :password: <%= scope['katello::proxy_password'] %> <%- end -%>