#
class apt(
- $update = {},
- $purge = {},
- $proxy = {},
- $sources = undef,
+ $update = {},
+ $purge = {},
+ $proxy = {},
+ $sources = {},
+ $keys = {},
+ $ppas = {},
+ $settings = {},
) inherits ::apt::params {
-
$frequency_options = ['always','daily','weekly','reluctantly']
validate_hash($update)
if $update['frequency'] {
$_proxy = merge($apt::proxy_defaults, $proxy)
+ validate_hash($sources)
+ validate_hash($keys)
+ validate_hash($settings)
+ validate_hash($ppas)
+
if $proxy['host'] {
apt::setting { 'conf-proxy':
priority => '01',
}
# manage sources if present
- if $sources != undef {
- validate_hash($sources)
+ if $sources {
create_resources('apt::source', $sources)
}
+ # manage keys if present
+ if $keys {
+ create_resources('apt::key', $keys)
+ }
+ # manage ppas if present
+ if $ppas {
+ create_resources('apt::ppa', $ppas)
+ }
+ # manage settings if present
+ if $settings {
+ create_resources('apt::setting', $settings)
+ }
}
fail('lsbdistcodename fact not available: release parameter required')
}
- if $::operatingsystem != 'Ubuntu' {
- fail('apt::ppa is currently supported on Ubuntu only.')
+ if $::apt::distid != 'ubuntu' {
+ fail('apt::ppa is currently supported on Ubuntu and LinuxMint only.')
}
$filename_without_slashes = regsubst($name, '/', '-', 'G')
it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
end
+ context 'with keys defined on valid osfamily' do
+ let :facts do
+ { :osfamily => 'Debian',
+ :lsbdistcodename => 'precise',
+ :lsbdistid => 'Debian',
+ }
+ end
+ let(:params) { { :keys => {
+ '55BE302B' => {
+ 'key_server' => 'subkeys.pgp.net',
+ },
+ '4BD6EC30' => {
+ 'key_server' => 'pgp.mit.edu',
+ }
+ } } }
+
+ it { is_expected.to contain_apt__key('55BE302B').with({
+ :key_server => 'subkeys.pgp.net',
+ })}
+
+ it { is_expected.to contain_apt__key('4BD6EC30').with({
+ :key_server => 'pgp.mit.edu',
+ })}
+ end
+
+ context 'with ppas defined on valid osfamily' do
+ let :facts do
+ { :osfamily => 'Debian',
+ :lsbdistcodename => 'precise',
+ :lsbdistid => 'ubuntu',
+ }
+ end
+ let(:params) { { :ppas => {
+ 'ppa:drizzle-developers/ppa' => {},
+ 'ppa:nginx/stable' => {},
+ } } }
+
+ it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa')}
+ it { is_expected.to contain_apt__ppa('ppa:nginx/stable')}
+ end
+
+ context 'with settings defined on valid osfamily' do
+ let :facts do
+ { :osfamily => 'Debian',
+ :lsbdistcodename => 'precise',
+ :lsbdistid => 'Debian',
+ }
+ end
+ let(:params) { { :settings => {
+ 'conf-banana' => { 'content' => 'banana' },
+ 'pref-banana' => { 'content' => 'banana' },
+ } } }
+
+ it { is_expected.to contain_apt__setting('conf-banana')}
+ it { is_expected.to contain_apt__setting('pref-banana')}
+ end
+
describe 'failing tests' do
context "purge['sources.list']=>'banana'" do
let(:params) { { :purge => { 'sources.list' => 'banana' }, } }