diff --git a/manifests/init.pp b/manifests/init.pp index faaecc7..a9d3540 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,10 +11,6 @@ class apt( $sources = undef, ) inherits ::apt::params { - if $::osfamily != 'Debian' { - fail('This module only works on Debian or derivatives like Ubuntu') - } - include apt::update $frequency_options = ['always','daily','weekly','reluctantly'] diff --git a/manifests/params.pp b/manifests/params.pp index 1c6cc99..b97a8a2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,6 +5,10 @@ class apt::params { $apt_conf_d = "${root}/apt.conf.d" $preferences_d = "${root}/preferences.d" + if $::osfamily != 'Debian' { + fail('This module only works on Debian or derivatives like Ubuntu') + } + case $::lsbdistid { 'ubuntu', 'debian': { $distid = $::lsbdistid diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index f65ed03..5095904 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -31,12 +31,6 @@ describe 'apt', :type => :class do 'recurse' => false, })} - it { should contain_file('01proxy').that_notifies('Exec[apt_update]').only_with({ - 'ensure' => 'absent', - 'path' => '/etc/apt/apt.conf.d/01proxy', - 'notify' => 'Exec[apt_update]', - })} - it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do should contain_file('/etc/apt/apt.conf.d/15update-stamp').with({ 'group' => 'root', @@ -45,12 +39,6 @@ describe 'apt', :type => :class do }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/) end - it { should contain_file('old-proxy-file').that_notifies('Exec[apt_update]').only_with({ - 'ensure' => 'absent', - 'path' => '/etc/apt/apt.conf.d/proxy', - 'notify' => 'Exec[apt_update]', - })} - it { should contain_exec('apt_update').with({ 'refreshonly' => 'true', })} @@ -60,16 +48,12 @@ describe 'apt', :type => :class do let :params do { :always_apt_update => true, - :disable_keys => true, - :proxy_host => 'foo', - :proxy_port => '9876', :purge_sources_list => true, :purge_sources_list_d => true, :purge_preferences => true, :purge_preferences_d => true, :update_timeout => '1', :update_tries => '3', - :fancy_progress => true, } end @@ -92,28 +76,6 @@ describe 'apt', :type => :class do 'recurse' => 'true', })} - it { should contain_file('99progressbar').only_with({ - 'ensure' => 'present', - 'content' => /Dpkg::Progress-Fancy "1";/, - 'path' => '/etc/apt/apt.conf.d/99progressbar', - })} - - it { should contain_file('99unauth').only_with({ - 'ensure' => 'present', - 'content' => /APT::Get::AllowUnauthenticated 1;/, - 'path' => '/etc/apt/apt.conf.d/99unauth', - })} - - it { should contain_file('01proxy').that_notifies('Exec[apt_update]').only_with({ - 'ensure' => 'present', - 'path' => '/etc/apt/apt.conf.d/01proxy', - 'content' => /Acquire::http::Proxy "http:\/\/foo:9876";/, - 'notify' => 'Exec[apt_update]', - 'mode' => '0644', - 'owner' => 'root', - 'group' => 'root' - })} - it { should contain_exec('apt_update').with({ 'refreshonly' => 'false', 'timeout' => '1', @@ -122,26 +84,6 @@ describe 'apt', :type => :class do end - context 'more non-default' do - let :params do - { - :fancy_progress => false, - :disable_keys => false, - } - end - - it { should contain_file('99progressbar').only_with({ - 'ensure' => 'absent', - 'path' => '/etc/apt/apt.conf.d/99progressbar', - })} - - it { should contain_file('99unauth').only_with({ - 'ensure' => 'absent', - 'path' => '/etc/apt/apt.conf.d/99unauth', - })} - - end - context 'with sources defined on valid osfamily' do let :facts do { :osfamily => 'Debian', diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index d85e849..9a75ade 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -14,7 +14,7 @@ describe 'apt::params', :type => :class do describe "With unknown lsbdistid" do - let(:facts) { { :lsbdistid => 'CentOS' } } + let(:facts) { { :lsbdistid => 'CentOS', :osfamily => 'Debian' } } let (:title) { 'my_package' } it do @@ -26,7 +26,7 @@ describe 'apt::params', :type => :class do end describe "With lsb-release not installed" do - let(:facts) { { :lsbdistid => '' } } + let(:facts) { { :lsbdistid => '', :osfamily => 'Debian' } } let (:title) { 'my_package' } it do diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb index f8c6512..e33a9be 100644 --- a/spec/classes/release_spec.rb +++ b/spec/classes/release_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::release', :type => :class do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let (:title) { 'my_package' } let :param_set do diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 3742bf1..e0a6ebf 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe 'apt::unattended_upgrades', :type => :class do let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' } let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' } - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } it { should contain_package("unattended-upgrades") } @@ -29,6 +29,7 @@ describe 'apt::unattended_upgrades', :type => :class do { 'lsbdistid' => 'debian', 'lsbdistcodename' => 'squeeze', + 'osfamily' => 'Debian', } end context 'bad auto_fix' do @@ -109,6 +110,7 @@ describe 'apt::unattended_upgrades', :type => :class do { 'lsbdistid' => 'debian', 'lsbdistcodename' => 'squeeze', + 'osfamily' => 'Debian', } end @@ -139,6 +141,7 @@ describe 'apt::unattended_upgrades', :type => :class do { 'lsbdistid' => 'debian', 'lsbdistcodename' => 'wheezy', + 'osfamily' => 'Debian', } end @@ -150,6 +153,7 @@ describe 'apt::unattended_upgrades', :type => :class do { 'lsbdistid' => 'debian', 'lsbdistcodename' => 'wheezy', + 'osfamily' => 'Debian', } end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 2c1752f..91b6d4e 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::conf', :type => :define do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let :title do 'norecommends' end diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index c32c438..5c48ec6 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::force', :type => :define do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let :pre_condition do 'include apt::params' end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 7ac1d28..d622ecb 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'apt::key', :type => :define do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' let :title do diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 23ebd59..206dbf1 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::pin', :type => :define do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let(:title) { 'my_pin' } context 'defaults' do diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 3a4c381..e10481e 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -67,41 +67,6 @@ describe 'apt::ppa', :type => :define do } end - describe 'apt included, proxy' do - let :pre_condition do - 'class { "apt": proxy_host => "example.com" }' - end - let :facts do - { - :lsbdistrelease => '14.04', - :lsbdistcodename => 'trusty', - :operatingsystem => 'Ubuntu', - :lsbdistid => 'Ubuntu', - :osfamily => 'Debian', - } - end - let :params do - { - 'release' => 'lucid', - } - end - let(:title) { 'ppa:foo' } - it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({ - 'environment' => ['http_proxy=http://example.com:8080', 'https_proxy=http://example.com:8080'], - 'command' => '/usr/bin/add-apt-repository -y ppa:foo', - 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-lucid.list', - 'user' => 'root', - 'logoutput' => 'on_failure', - }) - } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-lucid.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({ - 'ensure' => 'file', - }) - } - end - describe 'ensure absent' do let :facts do {