From 558954bedf707dd206180de5e0bfd10edfe563fa Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 9 Jan 2014 14:35:17 -0500 Subject: [PATCH] Ensure apt::ppa fails on non-Ubuntu. --- Rakefile | 1 - manifests/ppa.pp | 4 ++++ spec/defines/ppa_spec.rb | 8 ++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index bb60173..cd3d379 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1 @@ require 'puppetlabs_spec_helper/rake_tasks' -require 'rspec-system/rake_task' diff --git a/manifests/ppa.pp b/manifests/ppa.pp index f929654..14fbbce 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -14,6 +14,10 @@ define apt::ppa( fail('lsbdistcodename fact not available: release parameter required') } + if $::operatingsystem != 'Ubuntu' { + fail("apt::ppa is currently supported on Ubuntu only.") + } + $filename_without_slashes = regsubst($name, '/', '-', 'G') $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G') $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index a05ca30..dc1173b 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -2,9 +2,11 @@ require 'spec_helper' describe 'apt::ppa', :type => :define do [ { :lsbdistrelease => '11.04', :lsbdistcodename => 'natty', + :operatingsystem => 'Ubuntu', :package => 'python-software-properties'}, { :lsbdistrelease => '12.10', :lsbdistcodename => 'quantal', + :operatingsystem => 'Ubuntu', :package => 'software-properties-common'}, ].each do |platform| context "on #{platform[:lsbdistcodename]}" do @@ -12,6 +14,7 @@ describe 'apt::ppa', :type => :define do { :lsbdistrelease => platform[:lsbdistrelease], :lsbdistcodename => platform[:lsbdistcodename], + :operatingsystem => platform[:operatingsystem], } end let :release do @@ -109,7 +112,7 @@ describe 'apt::ppa', :type => :define do end end - [ { :lsbdistcodename => 'natty', + [ { :lsbdistcodename => 'natty', :package => 'python-software-properties' }, { :lsbdistcodename => 'quantal', :package => 'software-properties-common'}, @@ -121,7 +124,8 @@ describe 'apt::ppa', :type => :define do 'package { "#{platform[:package]}": }->Apt::Ppa["ppa"]' end let :facts do - {:lsbdistcodename => '#{platform[:lsbdistcodename]}'} + {:lsbdistcodename => '#{platform[:lsbdistcodename]}', + :operatingsystem => 'Ubuntu'} end let(:title) { "ppa" } let(:release) { "#{platform[:lsbdistcodename]}" }