From 4fa5222cdd7e436d18063db86d99ca219faff27c Mon Sep 17 00:00:00 2001 From: Geoff Williams Date: Wed, 9 Jul 2014 16:11:08 +1000 Subject: [PATCH 1/8] added missing line endings (-l) support for windows and solaris --- files/concatfragments.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) mode change 100755 => 100644 files/concatfragments.rb diff --git a/files/concatfragments.rb b/files/concatfragments.rb old mode 100755 new mode 100644 index cb66b03..904f824 --- a/files/concatfragments.rb +++ b/files/concatfragments.rb @@ -45,7 +45,8 @@ settings = { :test => false, :force => false, :warn => "", - :sortarg => "" + :sortarg => "", + :newline => false } OptionParser.new do |opts| @@ -77,6 +78,10 @@ OptionParser.new do |opts| opts.on("-n", "--sort", "Sort the output numerically rather than the default alpha sort") do settings[:sortarg] = "-n" end + + opts.on("-l", "--line", "Append a newline") do + settings[:newline] = true + end end.parse! # do we have -o? @@ -119,8 +124,15 @@ end # find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir open('fragments.concat', 'a') do |f| Dir.entries("fragments").sort.each{ |entry| + if File.file?(File.join("fragments", entry)) - f << File.read(File.join("fragments", entry)) + f << File.read(File.join("fragments", entry)) + + # append a newline if we were asked to (invoked with -l) + if settings[:newline] + f << "\n" + end + end } end From a8c563f1494199c796b515060852e4abe88d6322 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Mon, 22 Sep 2014 00:57:50 -0400 Subject: [PATCH 2/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f889866..54367be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ This is a bugfix release, and the first supported release of the 1.1.x series. - Make the `$order` parameter default to a string and be validated as an integer or a string - Use the ruby script on Solaris to not break Sol10 support -- Add quotes to the ryby script location for Windows +- Add quotes to the ruby script location for Windows - Fix typos in README.md - Make regex in concat::setup case-insensitive to make it work on Windows - Make sure concat fragments are always replaced From bc727a7a620b1885391d674d6ffbf96df7231a9e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 3 Oct 2014 15:01:20 -0400 Subject: [PATCH 3/8] Don't test mode and symlinks on windows --- spec/acceptance/concat_spec.rb | 22 ++++++++++---------- spec/acceptance/deprecation_warnings_spec.rb | 5 ++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 10f72d9..d9d835e 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -42,49 +42,49 @@ describe 'basic concat test' do describe file("#{vardir}/concat") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 755 } end describe file("#{vardir}/concat/bin") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 755 } end describe file("#{vardir}/concat/bin/#{scriptname}") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 755 } end describe file("#{vardir}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 750 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 750 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 640 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 640 } end @@ -125,7 +125,7 @@ describe 'basic concat test' do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 644 } it { should contain '1' } @@ -134,14 +134,14 @@ describe 'basic concat test' do describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 640 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 640 } end @@ -174,7 +174,7 @@ describe 'basic concat test' do describe file("#{basedir}/file") do it { should be_file } - it("should be mode", :unless => (fact('osfamily') == 'AIX')) { + it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { should be_mode 644 } it { should contain '1' } diff --git a/spec/acceptance/deprecation_warnings_spec.rb b/spec/acceptance/deprecation_warnings_spec.rb index 7b0f5c5..dc2f234 100644 --- a/spec/acceptance/deprecation_warnings_spec.rb +++ b/spec/acceptance/deprecation_warnings_spec.rb @@ -73,10 +73,9 @@ describe 'deprecation warnings' do end end - context 'concat::fragment ensure parameter' do + context 'concat::fragment ensure parameter', :unless => fact('osfamily') == 'windows' do context 'target file exists' do before(:all) do - shell("/bin/echo 'file1 contents' > #{basedir}/file1") pp = <<-EOS file { '#{basedir}': ensure => directory, @@ -126,7 +125,7 @@ describe 'deprecation warnings' do end end # target file exists - context 'target does not exist' do + context 'target does not exist', :unless => fact('osfamily') == 'windows' do pp = <<-EOS concat { '#{basedir}/file': } concat::fragment { 'foo': From 006eccc9bc1b3feaff19db82b10f0b694e7b3a55 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 3 Oct 2014 15:22:37 -0400 Subject: [PATCH 4/8] Typo fixes --- spec/acceptance/concat_spec.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index d9d835e..70b1a6d 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -42,49 +42,49 @@ describe 'basic concat test' do describe file("#{vardir}/concat") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 755 } end describe file("#{vardir}/concat/bin") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 755 } end describe file("#{vardir}/concat/bin/#{scriptname}") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 755 } end describe file("#{vardir}/concat/#{safe_basedir}_file") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 750 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do it { should be_directory } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 750 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 640 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 640 } end @@ -125,7 +125,7 @@ describe 'basic concat test' do it { should be_file } it { should be_owned_by username } it { should be_grouped_into groupname } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 644 } it { should contain '1' } @@ -134,14 +134,14 @@ describe 'basic concat test' do describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 640 } end describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do it { should be_file } it { should be_owned_by username } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 640 } end @@ -174,7 +174,7 @@ describe 'basic concat test' do describe file("#{basedir}/file") do it { should be_file } - it("should be mode", :unless => (fact('osfamily') == 'AIX') or fact('osfamily') == 'windows') { + it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 644 } it { should contain '1' } From 9ece566992cbd964d9532401bf50bc5a2b7cba82 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 7 Oct 2014 15:19:22 -0400 Subject: [PATCH 5/8] This *should* make tests pass on windows --- spec/acceptance/concat_spec.rb | 2 +- spec/acceptance/replace_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 70b1a6d..7cec1a5 100644 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -124,7 +124,7 @@ describe 'basic concat test' do describe file("#{basedir}/file") do it { should be_file } it { should be_owned_by username } - it { should be_grouped_into groupname } + it("should be group", :unless => (fact('osfamily') == 'windows')) { should be_grouped_into groupname } it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) { should be_mode 644 } diff --git a/spec/acceptance/replace_spec.rb b/spec/acceptance/replace_spec.rb index cc30d12..6882345 100644 --- a/spec/acceptance/replace_spec.rb +++ b/spec/acceptance/replace_spec.rb @@ -126,7 +126,7 @@ describe 'replacement of' do end # XXX specinfra doesn't support be_linked_to on AIX - describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX") do + describe file("#{basedir}/file"), :unless => (fact("osfamily") == "AIX" or fact("osfamily") == "windows") do it { should be_linked_to "#{basedir}/dangling" } end From ddab08f9d1dc860f6d29575d62bfaa4060324038 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 8 Oct 2014 13:59:14 -0400 Subject: [PATCH 6/8] Update sles metadata --- metadata.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 51f42f9..5a48a8f 100644 --- a/metadata.json +++ b/metadata.json @@ -43,7 +43,9 @@ { "operatingsystem": "SLES", "operatingsystemrelease": [ - "11 SP1" + "10 SP4", + "11 SP1", + "12" ] }, { From 0138787610dba57057e09e20916de3fce7d547f8 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 8 Oct 2014 18:06:15 -0400 Subject: [PATCH 7/8] Strict variables test updates --- spec/unit/classes/concat_setup_spec.rb | 23 +++++++++++----- spec/unit/defines/concat_fragment_spec.rb | 33 ++++++++++++++++++++--- spec/unit/defines/concat_spec.rb | 10 ++++++- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/spec/unit/classes/concat_setup_spec.rb b/spec/unit/classes/concat_setup_spec.rb index 3096e73..b25428e 100644 --- a/spec/unit/classes/concat_setup_spec.rb +++ b/spec/unit/classes/concat_setup_spec.rb @@ -5,7 +5,14 @@ describe 'concat::setup', :type => :class do shared_examples 'setup' do |concatdir| concatdir = '/foo' if concatdir.nil? - let(:facts) {{ :concat_basedir => concatdir }} + let(:facts) do + { + :concat_basedir => concatdir, + :caller_module_name => 'Test', + :osfamily => 'Debian', + :id => 'root', + } + end it do should contain_file("#{concatdir}/bin/concatfragments.sh").with({ @@ -44,9 +51,10 @@ describe 'concat::setup', :type => :class do concatdir = '/foo' let(:facts) do { - :concat_basedir => concatdir, - :osfamily => 'Solaris', - :id => 'root', + :concat_basedir => concatdir, + :caller_module_name => 'Test', + :osfamily => 'Solaris', + :id => 'root', } end @@ -65,9 +73,10 @@ describe 'concat::setup', :type => :class do concatdir = '/foo' let(:facts) do { - :concat_basedir => concatdir, - :osfamily => 'windows', - :id => 'batman', + :concat_basedir => concatdir, + :caller_module_name => 'Test', + :osfamily => 'windows', + :id => 'batman', } end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index 3c61aab..64ae7db 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -24,7 +24,14 @@ describe 'concat::fragment', :type => :define do end let(:title) { title } - let(:facts) {{ :concat_basedir => concatdir, :id => id }} + let(:facts) do + { + :concat_basedir => concatdir, + :id => id, + :osfamily => 'Debian', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end let(:params) { params } let(:pre_condition) do "concat{ '#{p[:target]}': }" @@ -162,7 +169,13 @@ describe 'concat::fragment', :type => :define do context 'ensure => target and source' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) do + { + :concat_basedir => '/tmp', + :osfamily => 'Debian', + :id => 'root', + } + end let(:params) do { :target => '/etc/motd', @@ -178,7 +191,13 @@ describe 'concat::fragment', :type => :define do context 'ensure => target and content' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) do + { + :concat_basedir => '/tmp', + :osfamily => 'Debian', + :id => 'root', + } + end let(:params) do { :target => '/etc/motd', @@ -194,7 +213,13 @@ describe 'concat::fragment', :type => :define do context 'source and content' do let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} + let(:facts) do + { + :concat_basedir => '/tmp', + :osfamily => 'Debian', + :id => 'root', + } + end let(:params) do { :target => '/etc/motd', diff --git a/spec/unit/defines/concat_spec.rb b/spec/unit/defines/concat_spec.rb index e7be4d5..7682cdf 100644 --- a/spec/unit/defines/concat_spec.rb +++ b/spec/unit/defines/concat_spec.rb @@ -33,7 +33,15 @@ describe 'concat', :type => :define do let(:title) { title } let(:params) { params } - let(:facts) {{ :concat_basedir => concatdir, :id => id }} + let(:facts) do + { + :concat_basedir => concatdir, + :id => id, + :osfamily => 'Debian', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :kernel => 'Linux', + } + end if p[:ensure] == 'present' it do From 624ae75baabff2a0e4749cfda095671505ac4698 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 24 Oct 2014 14:09:31 -0500 Subject: [PATCH 8/8] Install certs on windows This should allow the install of stdlib to succeed. --- spec/spec_helper_acceptance.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index b34a188..713466e 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -24,6 +24,10 @@ RSpec.configure do |c| c.before :suite do # Install module and dependencies hosts.each do |host| + if fact_on(host, 'osfamily') == 'windows' + on host, 'powershell.exe -command "(New-Object System.Net.Webclient).DownloadString(\'https://forge.puppetlabs.com\')"' + end + on host, "mkdir -p #{host['distmoduledir']}/concat" result = on host, "echo #{host['distmoduledir']}/concat" target = result.raw_output.chomp