diff options
author | Micah <micah@riseup.net> | 2016-11-04 13:35:41 +0000 |
---|---|---|
committer | Micah <micah@riseup.net> | 2016-11-04 13:35:41 +0000 |
commit | 584b7aad338206026d62d846122e6bef532a2d2a (patch) | |
tree | e58bac6baf47d069f646bd78519550f4fb0d39a6 | |
parent | bd975e939717891b79fce1d7d91da4ce4528af12 (diff) | |
parent | c7581a1f0e2b64b186a2d7c37e7ba0a9fa2cc1df (diff) |
Merge branch 'puppet4' into 'master'
Puppet4
Fixes stuff for puppet 4
See merge request !54
-rw-r--r-- | manifests/apt_conf.pp | 6 | ||||
-rw-r--r-- | manifests/init.pp | 6 | ||||
-rw-r--r-- | manifests/preferences_snippet.pp | 10 | ||||
-rw-r--r-- | manifests/proxy_client.pp | 2 | ||||
-rw-r--r-- | manifests/sources_list.pp | 8 | ||||
-rw-r--r-- | manifests/unattended_upgrades.pp | 2 | ||||
-rw-r--r-- | spec/defines/preferences_snippet_spec.rb | 66 |
7 files changed, 83 insertions, 17 deletions
diff --git a/manifests/apt_conf.pp b/manifests/apt_conf.pp index 949f615..fa8cfa3 100644 --- a/manifests/apt_conf.pp +++ b/manifests/apt_conf.pp @@ -1,15 +1,15 @@ define apt::apt_conf( $ensure = 'present', - $source = '', + $source = undef, $content = undef, $refresh_apt = true ) { - if $source == '' and $content == undef { + if $source == undef and $content == undef { fail("One of \$source or \$content must be specified for apt_conf ${name}") } - if $source != '' and $content != undef { + if $source != undef and $content != undef { fail("Only one of \$source or \$content must specified for apt_conf ${name}") } diff --git a/manifests/init.pp b/manifests/init.pp index 4bf126c..3d93d22 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -40,14 +40,14 @@ class apt( mode => '0644'; } - apt_conf { '02show_upgraded': + ::apt::apt_conf { '02show_upgraded': source => [ "puppet:///modules/site_apt/${::fqdn}/02show_upgraded", 'puppet:///modules/site_apt/02show_upgraded', 'puppet:///modules/apt/02show_upgraded' ] } if ( $::virtual == 'vserver' ) { - apt_conf { '03clean_vserver': + ::apt::apt_conf { '03clean_vserver': source => [ "puppet:///modules/site_apt/${::fqdn}/03clean_vserver", 'puppet:///modules/site_apt/03clean_vserver', 'puppet:///modules/apt/03clean_vserver' ], @@ -55,7 +55,7 @@ class apt( } } else { - apt_conf { '03clean': + ::apt::apt_conf { '03clean': source => [ "puppet:///modules/site_apt/${::fqdn}/03clean", 'puppet:///modules/site_apt/03clean', 'puppet:///modules/apt/03clean' ] diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index b7dba0d..2b2fb74 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -2,9 +2,9 @@ define apt::preferences_snippet ( $priority = undef, $package = false, $ensure = 'present', - $source = '', - $release = '', - $pin = '' + $source = undef, + $release = undef, + $pin = undef ) { $real_package = $package ? { @@ -36,9 +36,9 @@ define apt::preferences_snippet ( } case $source { - '': { + undef: { case $release { - '': { + undef: { File["/etc/apt/preferences.d/${name}"]{ content => template('apt/preferences_snippet.erb') } diff --git a/manifests/proxy_client.pp b/manifests/proxy_client.pp index 9ba79f2..e7972f7 100644 --- a/manifests/proxy_client.pp +++ b/manifests/proxy_client.pp @@ -3,7 +3,7 @@ class apt::proxy_client( $port = '3142', ){ - apt_conf { '20proxy': + ::apt::apt_conf { '20proxy': content => template('apt/20proxy.erb'), } } diff --git a/manifests/sources_list.pp b/manifests/sources_list.pp index 7565bce..6ff4fc3 100644 --- a/manifests/sources_list.pp +++ b/manifests/sources_list.pp @@ -1,15 +1,15 @@ # Configure an apt source define apt::sources_list ( - $ensure = 'present', - $source = '', + $ensure = 'present', + $source = undef, $content = undef ) { if $ensure == 'present' { - if $source == '' and $content == undef { + if $source == undef and $content == undef { fail("One of \$source or \$content must be specified for apt_sources_snippet ${name}") } - if $source != '' and $content != undef { + if $source != undef and $content != undef { fail("Only one of \$source or \$content must specified for apt_sources_snippet ${name}") } } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index 52d7542..d604125 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -26,7 +26,7 @@ class apt::unattended_upgrades ( default => $config_content } - apt_conf { '50unattended-upgrades': + ::apt::apt_conf { '50unattended-upgrades': content => $file_content, require => Package['unattended-upgrades'], refresh_apt => false diff --git a/spec/defines/preferences_snippet_spec.rb b/spec/defines/preferences_snippet_spec.rb new file mode 100644 index 0000000..012a5f6 --- /dev/null +++ b/spec/defines/preferences_snippet_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' +describe 'apt::preferences_snippet', :type => :define do + let :pre_condition do + 'class { "apt": }' + end + let(:facts) { { + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :debian_release => 'jessie', + :debian_codename => 'jessie', + :lsbdistcodename => 'jessie', + :virtual => 'physical', + :puppetversion => Puppet.version, } } + let :title do + 'test' + end + + describe "when creating a preferences_snippet" do + let :default_params do + { + :ensure => 'present', + :release => "jessie-backports", + :priority => '999' + } + end + let :params do + default_params + end + let :filename do + "/etc/apt/preferences.d/test" + end + + it { is_expected.to contain_file(filename).with({ + 'ensure' => 'present', + 'content' => /Package: test\nPin: release a=jessie-backports\nPin-Priority: 999/, + 'owner' => 'root', + 'group' => '0', + 'mode' => '0644', + }) + } + + end + + describe "when using both pin and release parameters" do + let :default_params do + { + :ensure => 'present', + :priority => '999', + :release => "jessie-backports", + :pin => '1.0' + } + end + let :params do + default_params + end + let :filename do + "/etc/apt/preferences.d/test" + end + + it 'fails' do + expect { subject.call } .to raise_error(Puppet::Error, /apt::preferences_snippet requires either a 'pin' or 'release' argument, not both/) + end + end + +end |