From 636ae8541dd99372f08177fca74a5d8e1ed3c607 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Sun, 29 May 2011 18:43:01 -0700 Subject: [PATCH 001/574] Added two params for apt class both of these params facilitate options that ease the management of apt repos in dev environments 1. disable_keys - allows repos without properly signed keys 2. always_apt_update - refreshes via apt update every time that puppet runs. --- manifests/init.pp | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 677523bcf2..c4df481dd3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,8 +1,30 @@ -# apt.pp +# Class: apt +# +# This module manages the initial configuration of apt. +# +# Parameters: +# Both of the parameters listed here are not required in general and were +# added for use cases related to development environments. +# disable_keys - disables the requirement for all packages to be signed +# always_apt_update - rather apt should be updated on every run (intended +# for development environments where package updates are frequent +# Actions: +# +# Requires: +# +# Sample Usage: +# class { 'apt': } +class apt( + $disable_keys = false, + $always_apt_update = false +) { -class apt { $root = '/etc/apt' $provider = '/usr/bin/apt-get' + $refresh_only_apt_update = $always_apt_update? { + true => false, + false => true + } package { "python-software-properties": } @@ -21,9 +43,15 @@ group => root, } - exec { "apt_update": - command => "${provider} update", - subscribe => [ File["sources.list"], File["sources.list.d"] ], - refreshonly => true, - } + exec { "apt_update": + command => "${apt::params::provider} update", + subscribe => [ File["sources.list"], File["sources.list.d"] ], + refreshonly => $refresh_only_apt_update, + } + if($disable_keys) { + exec { 'make-apt-insecure': + command => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth', + creates => '/etc/apt/apt.conf.d/99unauth' + } + } } From d8a1e4ee9d97a956c1823d644c715e98d9c5d27f Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 30 May 2011 10:18:13 -0700 Subject: [PATCH 002/574] Created a params class to hold global data. - Removes coupling between global data and resources from apt class. - Makes it easier to organize things into stages. --- manifests/init.pp | 8 ++++---- manifests/params.pp | 4 ++++ manifests/pin.pp | 5 ++--- manifests/release.pp | 5 +++-- manifests/source.pp | 9 ++++----- 5 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 manifests/params.pp diff --git a/manifests/init.pp b/manifests/init.pp index c4df481dd3..03ef116193 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -19,8 +19,8 @@ $always_apt_update = false ) { - $root = '/etc/apt' - $provider = '/usr/bin/apt-get' + include apt::params + $refresh_only_apt_update = $always_apt_update? { true => false, false => true @@ -29,19 +29,19 @@ package { "python-software-properties": } file { "sources.list": - name => "${root}/sources.list", ensure => present, owner => root, group => root, mode => 644, } + name => "${apt::params::root}/sources.list", file { "sources.list.d": - name => "${root}/sources.list.d", ensure => directory, owner => root, group => root, } + name => "${apt::params::root}/sources.list.d", exec { "apt_update": command => "${apt::params::provider} update", diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000000..3c39288039 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,4 @@ +class apt::params { + $root = '/etc/apt' + $provider = '/usr/bin/apt-get' +} diff --git a/manifests/pin.pp b/manifests/pin.pp index e8b251f7c8..d13193f315 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -6,15 +6,14 @@ $priority = 0 ) { - include apt - file { "${name}.pref": - name => "${apt::root}/preferences.d/${name}", ensure => file, owner => root, group => root, mode => 644, content => "# ${name}\nPackage: ${packages}\nPin: release a=${name}\nPin-Priority: ${priority}", } + include apt::params + name => "${apt::params::root}/preferences.d/${name}", } diff --git a/manifests/release.pp b/manifests/release.pp index cdd3da025d..7e00dba642 100644 --- a/manifests/release.pp +++ b/manifests/release.pp @@ -3,12 +3,13 @@ define apt::release ( ) { - include apt - file { "${apt::root}/apt.conf.d/01release": owner => root, group => root, mode => 644, content => "APT::Default-Release \"${name}\";" } + include apt::params + + file { "${apt::params::root}/apt.conf.d/01release": } diff --git a/manifests/source.pp b/manifests/source.pp index d6d93e4886..7dee0a985f 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -12,10 +12,7 @@ $pin = false ) { - include apt - file { "${name}.list": - name => "${apt::root}/sources.list.d/${name}.list", ensure => file, owner => root, group => root, @@ -28,13 +25,11 @@ } exec { "${name} apt update": - command => "${apt::provider} update", subscribe => File["${name}.list"], refreshonly => true, } if $required_packages != false { - exec { "${apt::provider} -y install ${required_packages}": subscribe => File["${name}.list"], refreshonly => true, } @@ -46,5 +41,9 @@ before => File["${name}.list"], } } + include apt::params + name => "${apt::params::root}/sources.list.d/${name}.list", + command => "${apt::params::provider} update", + exec { "${apt::params::provider} -y install ${required_packages}": } From 18f614b89be97040815f46ba95677b4d69ed305f Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 30 May 2011 10:22:04 -0700 Subject: [PATCH 003/574] reformatted apt::ppa according to recommended style. removed require apt in favor of marking a dependency. converted release define into a class since the resources are singletons. --- manifests/ppa.pp | 5 ++--- manifests/release.pp | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 9c277e9bd4..dd2143e246 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,9 +1,8 @@ # ppa.pp -define apt::ppa( +define apt::ppa() { -) { - require apt + Class['apt'] -> Apt::Ppa[$title] exec { "apt-update-${name}": command => "/usr/bin/aptitude update", diff --git a/manifests/release.pp b/manifests/release.pp index 7e00dba642..6df52a9991 100644 --- a/manifests/release.pp +++ b/manifests/release.pp @@ -1,15 +1,15 @@ # release.pp -define apt::release ( - +class apt::release ( + $release_id ) { owner => root, group => root, mode => 644, - content => "APT::Default-Release \"${name}\";" } include apt::params file { "${apt::params::root}/apt.conf.d/01release": + content => "APT::Default-Release \"${release_id}\";" } From 377d58a7affe169e0ac6a514ec4f727300e6f860 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 30 May 2011 10:23:18 -0700 Subject: [PATCH 004/574] added smoke tests for module. --- tests/debian/testing.pp | 2 ++ tests/debian/unstable.pp | 2 ++ tests/force.pp | 7 +++++++ tests/init.pp | 1 + tests/params.pp | 1 + tests/pin.pp | 5 +++++ tests/ppa.pp | 1 + tests/release.pp | 4 ++++ tests/source.pp | 11 +++++++++++ 9 files changed, 34 insertions(+) create mode 100644 tests/debian/testing.pp create mode 100644 tests/debian/unstable.pp create mode 100644 tests/force.pp create mode 100644 tests/init.pp create mode 100644 tests/params.pp create mode 100644 tests/pin.pp create mode 100644 tests/ppa.pp create mode 100644 tests/release.pp create mode 100644 tests/source.pp diff --git a/tests/debian/testing.pp b/tests/debian/testing.pp new file mode 100644 index 0000000000..8245b3a337 --- /dev/null +++ b/tests/debian/testing.pp @@ -0,0 +1,2 @@ +class { 'apt': } +class { 'apt::debian::testing': } diff --git a/tests/debian/unstable.pp b/tests/debian/unstable.pp new file mode 100644 index 0000000000..8605179295 --- /dev/null +++ b/tests/debian/unstable.pp @@ -0,0 +1,2 @@ +class { 'apt': } +class { 'apt::debian::unstable': } diff --git a/tests/force.pp b/tests/force.pp new file mode 100644 index 0000000000..f3313633d0 --- /dev/null +++ b/tests/force.pp @@ -0,0 +1,7 @@ +# force.pp +# force a package from a specific release + +apt::force { 'package': + release => 'testing', + version => false +} diff --git a/tests/init.pp b/tests/init.pp new file mode 100644 index 0000000000..abc75afa25 --- /dev/null +++ b/tests/init.pp @@ -0,0 +1 @@ +class { 'apt': } diff --git a/tests/params.pp b/tests/params.pp new file mode 100644 index 0000000000..5ddf3c6551 --- /dev/null +++ b/tests/params.pp @@ -0,0 +1 @@ +include apt::params diff --git a/tests/pin.pp b/tests/pin.pp new file mode 100644 index 0000000000..6a9024c234 --- /dev/null +++ b/tests/pin.pp @@ -0,0 +1,5 @@ +# pin a release in apt, useful for unstable repositories +apt::pin { 'foo': + packages => '*', + priority => 0, +} diff --git a/tests/ppa.pp b/tests/ppa.pp new file mode 100644 index 0000000000..24310ef667 --- /dev/null +++ b/tests/ppa.pp @@ -0,0 +1 @@ +apt::ppa{ 'foo': } diff --git a/tests/release.pp b/tests/release.pp new file mode 100644 index 0000000000..04be75985e --- /dev/null +++ b/tests/release.pp @@ -0,0 +1,4 @@ +class { 'apt': } +class { 'apt::release': + release_id => 'foo' +} diff --git a/tests/source.pp b/tests/source.pp new file mode 100644 index 0000000000..7d7321f74e --- /dev/null +++ b/tests/source.pp @@ -0,0 +1,11 @@ +class { 'apt': } +apt::source { 'foo': + location => '', + release => 'karmic', + repos => 'main', + include_src => true, + required_packages => false, + key => false, + key_server => 'keyserver.ubuntu.com', + pin => '600' +} From 27ebdfc57fee4ea65e61aa09784594ba69f4932b Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 30 May 2011 10:23:34 -0700 Subject: [PATCH 005/574] ignore swap files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..1377554ebe --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp From 77d2b0dd05c70aad99596dc314be065e06cfb4cf Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 30 May 2011 10:24:06 -0700 Subject: [PATCH 006/574] reformatted whitespace to match recommended style of 2 space indentation. --- manifests/debian/testing.pp | 30 +++++++-------- manifests/debian/unstable.pp | 30 +++++++-------- manifests/force.pp | 16 ++++---- manifests/init.pp | 22 +++++------ manifests/pin.pp | 18 ++++----- manifests/ppa.pp | 16 ++++---- manifests/release.pp | 8 ++-- manifests/source.pp | 75 ++++++++++++++++++------------------ 8 files changed, 108 insertions(+), 107 deletions(-) diff --git a/manifests/debian/testing.pp b/manifests/debian/testing.pp index 8f37bd567c..4eec1f8dbb 100644 --- a/manifests/debian/testing.pp +++ b/manifests/debian/testing.pp @@ -2,20 +2,20 @@ class apt::debian::testing { - # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free - # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free - # Key: 55BE302B Server: subkeys.pgp.net - # debian-keyring - # debian-archive-keyring - - apt::source { "debian_testing": - location => "http://debian.mirror.iweb.ca/debian/", - release => "testing", - repos => "main contrib non-free", - required_packages => "debian-keyring debian-archive-keyring", - key => "55BE302B", - key_server => "subkeys.pgp.net", - pin => "-10" - } + # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free + # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free + # Key: 55BE302B Server: subkeys.pgp.net + # debian-keyring + # debian-archive-keyring + + apt::source { "debian_testing": + location => "http://debian.mirror.iweb.ca/debian/", + release => "testing", + repos => "main contrib non-free", + required_packages => "debian-keyring debian-archive-keyring", + key => "55BE302B", + key_server => "subkeys.pgp.net", + pin => "-10" + } } diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp index d0dd1ce134..89e5d9a9fb 100644 --- a/manifests/debian/unstable.pp +++ b/manifests/debian/unstable.pp @@ -2,20 +2,20 @@ class apt::debian::unstable { - # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free - # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free - # Key: 55BE302B Server: subkeys.pgp.net - # debian-keyring - # debian-archive-keyring - - apt::source { "debian_unstable": - location => "http://debian.mirror.iweb.ca/debian/", - release => "unstable", - repos => "main contrib non-free", - required_packages => "debian-keyring debian-archive-keyring", - key => "55BE302B", - key_server => "subkeys.pgp.net", - pin => "-10" - } + # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free + # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free + # Key: 55BE302B Server: subkeys.pgp.net + # debian-keyring + # debian-archive-keyring + + apt::source { "debian_unstable": + location => "http://debian.mirror.iweb.ca/debian/", + release => "unstable", + repos => "main contrib non-free", + required_packages => "debian-keyring debian-archive-keyring", + key => "55BE302B", + key_server => "subkeys.pgp.net", + pin => "-10" + } } diff --git a/manifests/force.pp b/manifests/force.pp index 564ed75ff4..0a3007d0e5 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -2,15 +2,15 @@ # force a package from a specific release define apt::force( - $release = 'testing', - $version = false + $release = 'testing', + $version = false ) { - exec { "/usr/bin/aptitude -y -t ${release} install ${name}": - unless => $version ? { - false => "/usr/bin/dpkg -l | grep ${name}", - default => "/usr/bin/dpkg -l | grep ${name} | grep ${version}" - } - } + exec { "/usr/bin/aptitude -y -t ${release} install ${name}": + unless => $version ? { + false => "/usr/bin/dpkg -l | grep ${name}", + default => "/usr/bin/dpkg -l | grep ${name} | grep ${version}" + } + } } diff --git a/manifests/init.pp b/manifests/init.pp index 03ef116193..8042c8be19 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -28,20 +28,20 @@ package { "python-software-properties": } - file { "sources.list": - ensure => present, - owner => root, - group => root, - mode => 644, - } + file { "sources.list": name => "${apt::params::root}/sources.list", + ensure => present, + owner => root, + group => root, + mode => 644, + } - file { "sources.list.d": - ensure => directory, - owner => root, - group => root, - } + file { "sources.list.d": name => "${apt::params::root}/sources.list.d", + ensure => directory, + owner => root, + group => root, + } exec { "apt_update": command => "${apt::params::provider} update", diff --git a/manifests/pin.pp b/manifests/pin.pp index d13193f315..3485b2473d 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -2,18 +2,18 @@ # pin a release in apt, useful for unstable repositories define apt::pin( - $packages = '*', - $priority = 0 + $packages = '*', + $priority = 0 ) { - file { "${name}.pref": - ensure => file, - owner => root, - group => root, - mode => 644, - content => "# ${name}\nPackage: ${packages}\nPin: release a=${name}\nPin-Priority: ${priority}", - } include apt::params + file { "${name}.pref": name => "${apt::params::root}/preferences.d/${name}", + ensure => file, + owner => root, + group => root, + mode => 644, + content => "# ${name}\nPackage: ${packages}\nPin: release a=${name}\nPin-Priority: ${priority}", + } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index dd2143e246..8dcea856ed 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -4,14 +4,14 @@ Class['apt'] -> Apt::Ppa[$title] - exec { "apt-update-${name}": - command => "/usr/bin/aptitude update", - refreshonly => true, - } + exec { "apt-update-${name}": + command => "/usr/bin/aptitude update", + refreshonly => true, + } - exec { "add-apt-repository-${name}": - command => "/usr/bin/add-apt-repository ${name}", - notify => Exec["apt-update-${name}"], - } + exec { "add-apt-repository-${name}": + command => "/usr/bin/add-apt-repository ${name}", + notify => Exec["apt-update-${name}"], + } } diff --git a/manifests/release.pp b/manifests/release.pp index 6df52a9991..9fc0aa38dd 100644 --- a/manifests/release.pp +++ b/manifests/release.pp @@ -4,12 +4,12 @@ $release_id ) { - owner => root, - group => root, - mode => 644, - } include apt::params file { "${apt::params::root}/apt.conf.d/01release": + owner => root, + group => root, + mode => 644, content => "APT::Default-Release \"${release_id}\";" + } } diff --git a/manifests/source.pp b/manifests/source.pp index 7dee0a985f..b6e8476b4c 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -2,48 +2,49 @@ # add an apt source define apt::source( - $location = '', - $release = 'karmic', - $repos = 'main', - $include_src = true, - $required_packages = false, - $key = false, - $key_server = 'keyserver.ubuntu.com', - $pin = false + $location = '', + $release = 'karmic', + $repos = 'main', + $include_src = true, + $required_packages = false, + $key = false, + $key_server = 'keyserver.ubuntu.com', + $pin = false ) { - file { "${name}.list": - ensure => file, - owner => root, - group => root, - mode => 644, - content => template("apt/source.list.erb"), - } - - if $pin != false { - apt::pin { "${release}": priority => "${pin}" } - } - - exec { "${name} apt update": - subscribe => File["${name}.list"], - refreshonly => true, - } - - if $required_packages != false { - subscribe => File["${name}.list"], - refreshonly => true, - } - } - - if $key != false { - exec { "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}": - unless => "/usr/bin/apt-key list | grep ${key}", - before => File["${name}.list"], - } - } include apt::params + + file { "${name}.list": name => "${apt::params::root}/sources.list.d/${name}.list", + ensure => file, + owner => root, + group => root, + mode => 644, + content => template("apt/source.list.erb"), + } + + if $pin != false { + apt::pin { "${release}": priority => "${pin}" } + } + + exec { "${name} apt update": command => "${apt::params::provider} update", + subscribe => File["${name}.list"], + refreshonly => true, + } + + if $required_packages != false { exec { "${apt::params::provider} -y install ${required_packages}": + subscribe => File["${name}.list"], + refreshonly => true, + } + } + + if $key != false { + exec { "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}": + unless => "/usr/bin/apt-key list | grep ${key}", + before => File["${name}.list"], + } + } } From c42db0fa0f2d0ad3c6131461a7d1bd7dcaae5349 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 30 May 2011 10:43:15 -0700 Subject: [PATCH 007/574] Fixes ppa test. --- tests/ppa.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ppa.pp b/tests/ppa.pp index 24310ef667..495866c15b 100644 --- a/tests/ppa.pp +++ b/tests/ppa.pp @@ -1 +1,2 @@ +class { 'apt': } apt::ppa{ 'foo': } From a11af502cd839efbdab56da95aa1965e75d7ae1c Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Fri, 3 Jun 2011 00:20:00 -0700 Subject: [PATCH 008/574] added the ability to specify the content of a key Allows us to pass key_content when we specify a source. --- manifests/source.pp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index b6e8476b4c..56a80056ab 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -9,7 +9,8 @@ $required_packages = false, $key = false, $key_server = 'keyserver.ubuntu.com', - $pin = false + $pin = false, + $key_content = false ) { include apt::params @@ -42,9 +43,17 @@ } if $key != false { - exec { "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}": - unless => "/usr/bin/apt-key list | grep ${key}", - before => File["${name}.list"], + if $key_content { + exec { "Add key: ${key} from content": + command => "/bin/echo '${key_content}' | /usr/bin/apt-key add -", + unless => "/usr/bin/apt-key list | /bin/grep '${key}'", + before => File["${name}.list"], + } + } else { + exec { "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}": + unless => "/usr/bin/apt-key list | /bin/grep ${key}", + before => File["${name}.list"], + } } } } From 5c05fa0f913be3047e0787c7bc25f518cb050384 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sun, 24 Jul 2011 18:12:25 -0400 Subject: [PATCH 009/574] added builddep command. --- README.md | 6 ++++++ manifests/builddep.pp | 16 ++++++++++++++++ tests/builddep.pp | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 manifests/builddep.pp create mode 100644 tests/builddep.pp diff --git a/README.md b/README.md index 8beee7cf3b..a6eee80267 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ Provides helpful definitions for dealing with Apt. ## Usage +### apt:builddep +Install the build depends of a specified package. +
+apt::builddep { "glusterfs-server": }
+
+ ### apt::force Force a package to be installed from a specific release. Useful when using repositoires like Debian unstable in Ubuntu.
diff --git a/manifests/builddep.pp b/manifests/builddep.pp
new file mode 100644
index 0000000000..79b7e29e3c
--- /dev/null
+++ b/manifests/builddep.pp
@@ -0,0 +1,16 @@
+# builddep.pp
+
+define apt::builddep() {
+
+  Class['apt'] -> Apt::Ppa[$title]
+
+  exec { "apt-update-${name}":
+    command     => "/usr/bin/apt-get update",
+    refreshonly => true,
+  }
+
+  exec { "apt-builddep-${name}":
+    command     => "/usr/bin/apt-get -y --force-yes build-dep $name",
+    notify  => Exec["apt-update-${name}"],
+  }
+}
diff --git a/tests/builddep.pp b/tests/builddep.pp
new file mode 100644
index 0000000000..c5a7a20da1
--- /dev/null
+++ b/tests/builddep.pp
@@ -0,0 +1,2 @@
+class { 'apt': }
+apt::builddep{ 'foo': }

From 52ca73e964bc5200206efb0f0288acc1e4a6f88c Mon Sep 17 00:00:00 2001
From: Spencer Krum 
Date: Tue, 2 Aug 2011 15:08:39 -0700
Subject: [PATCH 010/574] (#8720) Replace Apt::Ppa with Apt::Builddep

Probably a copy & paste error

Reviewed-by: Matthaus Litteken 
Signed-off-by: Spencer Krum 
---
 manifests/builddep.pp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/manifests/builddep.pp b/manifests/builddep.pp
index 79b7e29e3c..8aebc679ae 100644
--- a/manifests/builddep.pp
+++ b/manifests/builddep.pp
@@ -2,7 +2,7 @@
 
 define apt::builddep() {
 
-  Class['apt'] -> Apt::Ppa[$title]
+  Class['apt'] -> Apt::Builddep[$name]
 
   exec { "apt-update-${name}":
     command     => "/usr/bin/apt-get update",
@@ -11,6 +11,6 @@
 
   exec { "apt-builddep-${name}":
     command     => "/usr/bin/apt-get -y --force-yes build-dep $name",
-    notify  => Exec["apt-update-${name}"],
+    notify      => Exec["apt-update-${name}"],
   }
 }

From 1af9a13c40c33e1ab8fb56f33cb9aa5e16cead0e Mon Sep 17 00:00:00 2001
From: Robert Navarro 
Date: Thu, 18 Aug 2011 02:37:54 -0300
Subject: [PATCH 011/574] Added some crazy bash madness to check if the ppa is
 installed already. Otherwise the manifest tries to add it on every run!

---
 manifests/ppa.pp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/manifests/ppa.pp b/manifests/ppa.pp
index 8dcea856ed..157692745f 100644
--- a/manifests/ppa.pp
+++ b/manifests/ppa.pp
@@ -4,6 +4,10 @@
 
   Class['apt'] -> Apt::Ppa[$title]
 
+  Exec {
+    onlyif => "/usr/bin/test ! $(/bin/ls /etc/apt/sources.list.d | /bin/grep -v $(echo \"${title}\" | /usr/bin/gawk 'match(\$0, /^ppa:(.*)\/(.*)$/, vals) {printf \"%s-%s\", vals[1], vals[2]}'))",
+  }
+
   exec { "apt-update-${name}":
     command     => "/usr/bin/aptitude update",
     refreshonly => true,

From 1de4e0a2944248897ad92adbdbe88fcd46ec30fb Mon Sep 17 00:00:00 2001
From: Robert Navarro 
Date: Wed, 24 Aug 2011 22:52:42 -0400
Subject: [PATCH 012/574] Refactored as per mlitteken

* https://github.com/rnavarro/puppet-apt/commit/1af9a13c40c33e1ab8fb56f33cb9aa5e16cead0e#commitcomment-539287
---
 manifests/ppa.pp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/manifests/ppa.pp b/manifests/ppa.pp
index 157692745f..af6eebff0a 100644
--- a/manifests/ppa.pp
+++ b/manifests/ppa.pp
@@ -5,7 +5,10 @@
   Class['apt'] -> Apt::Ppa[$title]
 
   Exec {
-    onlyif => "/usr/bin/test ! $(/bin/ls /etc/apt/sources.list.d | /bin/grep -v $(echo \"${title}\" | /usr/bin/gawk 'match(\$0, /^ppa:(.*)\/(.*)$/, vals) {printf \"%s-%s\", vals[1], vals[2]}'))",
+    unless => $name? {
+      /ppa:(.*)/ => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*ppa.*$1.*$'",
+      default    => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*${title}.*$'",
+    }
   }
 
   exec { "apt-update-${name}":

From 864302a0915bebd522a2bf68b37e210ea243af17 Mon Sep 17 00:00:00 2001
From: Matthias Pigulla 
Date: Wed, 2 Nov 2011 10:28:38 +0100
Subject: [PATCH 013/574] Set the pin priority before adding the source (Fix
 #10449)

---
 manifests/source.pp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/manifests/source.pp b/manifests/source.pp
index 56a80056ab..65afefdbe1 100644
--- a/manifests/source.pp
+++ b/manifests/source.pp
@@ -26,7 +26,7 @@
   }
 
   if $pin != false {
-    apt::pin { "${release}": priority => "${pin}" }
+    apt::pin { "${release}": priority => "${pin}" } -> File["${name}.list"]
   }
 
   exec { "${name} apt update":

From 1be745705cba4f98ab5796756631576a4db67a5f Mon Sep 17 00:00:00 2001
From: Matthias Pigulla 
Date: Wed, 2 Nov 2011 15:40:10 +0100
Subject: [PATCH 014/574] Fix (#10451) - apt::ppa fails to "apt-get update"
 when new PPA source is added

---
 manifests/ppa.pp | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/manifests/ppa.pp b/manifests/ppa.pp
index af6eebff0a..a41c814f29 100644
--- a/manifests/ppa.pp
+++ b/manifests/ppa.pp
@@ -4,13 +4,6 @@
 
   Class['apt'] -> Apt::Ppa[$title]
 
-  Exec {
-    unless => $name? {
-      /ppa:(.*)/ => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*ppa.*$1.*$'",
-      default    => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*${title}.*$'",
-    }
-  }
-
   exec { "apt-update-${name}":
     command     => "/usr/bin/aptitude update",
     refreshonly => true,
@@ -19,6 +12,10 @@
   exec { "add-apt-repository-${name}":
     command => "/usr/bin/add-apt-repository ${name}",
     notify  => Exec["apt-update-${name}"],
+    unless => $name? {
+      /ppa:(.*)/ => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*ppa.*$1.*$'",
+      default    => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*${title}.*$'",
+    }
   }
 }
 

From b662eb8644f74c7efa71c270ade545436d879aa6 Mon Sep 17 00:00:00 2001
From: "Christian G. Warden" 
Date: Tue, 20 Dec 2011 12:06:24 -0800
Subject: [PATCH 015/574] fix typos in "repositories"

---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index a6eee80267..f129a08481 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ apt::builddep { "glusterfs-server": }
 
### apt::force -Force a package to be installed from a specific release. Useful when using repositoires like Debian unstable in Ubuntu. +Force a package to be installed from a specific release. Useful when using repositories like Debian unstable in Ubuntu.
 apt::force { "glusterfs-server":
 	release => "unstable",
@@ -36,7 +36,7 @@ apt::ppa { "ppa:drizzle-developers/ppa": }
 
### apt::release -Set the default apt release. Useful when using repositoires like Debian unstable in Ubuntu. +Set the default apt release. Useful when using repositories like Debian unstable in Ubuntu.
 apt::release { "karmic": }
 
From 0dd697d7cf9a146b1cb5cf76c889c5354a23c233 Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Tue, 20 Dec 2011 13:45:43 -0800 Subject: [PATCH 016/574] include_src parameter in example; Whitespace cleanup In the apt::source example, include the include_src parameter. Clean-up whitespace in the example to be consistent with the style guide. --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a6eee80267..1276690cd3 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,13 @@ apt::release { "karmic": } Add an apt source to `/etc/apt/sources.list.d/`.
 apt::source { "debian_unstable":
-	location => "http://debian.mirror.iweb.ca/debian/",
-	release => "unstable",
-	repos => "main contrib non-free",
-	required_packages => "debian-keyring debian-archive-keyring",
-	key => "55BE302B",
-	key_server => "subkeys.pgp.net",
-	pin => "-10"
+  location          => "http://debian.mirror.iweb.ca/debian/",
+  release           => "unstable",
+  repos             => "main contrib non-free",
+  required_packages => "debian-keyring debian-archive-keyring",
+  key               => "55BE302B",
+  key_server        => "subkeys.pgp.net",
+  pin               => "-10",
+  include_src       => true
 }
 
From cf6caa1f15f279f306950ec44456c127649ca179 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Tue, 3 Jan 2012 17:03:24 -0800 Subject: [PATCH 017/574] (#10451) Add test coverage to apt::ppa This commit adds test coverage for apt::ppa. This test coverage is suficient to verify the code changes that resolve the issue with aptitude update not being called when ppas were added (#10451). --- Rakefile | 14 ++++++++++++++ spec/defines/ppa_spec.rb | 32 ++++++++++++++++++++++++++++++++ spec/spec.opts | 6 ++++++ spec/spec_helper.rb | 11 +++++++++++ 4 files changed, 63 insertions(+) create mode 100644 Rakefile create mode 100644 spec/defines/ppa_spec.rb create mode 100644 spec/spec.opts create mode 100644 spec/spec_helper.rb diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000000..6242a3704b --- /dev/null +++ b/Rakefile @@ -0,0 +1,14 @@ +require 'rake' + +task :default => [:spec] + +desc "Run all module spec tests (Requires rspec-puppet gem)" +task :spec do + system("rspec spec/**/*_spec.rb") +end + +desc "Build package" +task :build do + system("puppet-module build") +end + diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb new file mode 100644 index 0000000000..6532654559 --- /dev/null +++ b/spec/defines/ppa_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' +describe 'apt::ppa', :type => :define do + ['ppa:dans_ppa', 'dans_ppa'].each do |t| + describe "with title #{t}" do + let :pre_condition do + 'class { "apt": }' + end + let :title do + t + end + let :unless_statement do + if t =~ /ppa:(.*)/ + /^[^#].*ppa.*#{$1}.*$/ + else + /^[^#].*#{t}.*$/ + end + end + it { should contain_exec("add-apt-repository-#{t}").with( + 'command' => "/usr/bin/add-apt-repository #{t}", + 'notify' => "Exec[apt-update-#{t}]" + ) + } + it { should contain_exec("add-apt-repository-#{t}").with_unless(unless_statement) } + it { should contain_exec("apt-update-#{t}").with( + 'command' => '/usr/bin/aptitude update', + 'refreshonly' => true + ) + } + it { should contain_exec("apt-update-#{t}").without_unless } + end + end +end diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000000..91cd6427ed --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000000..d2648da2b2 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,11 @@ +require 'puppet' +require 'rubygems' +require 'rspec-puppet' + +def param_value(subject, type, title, param) + subject.resource(type, title).send(:parameters)[param.to_sym] +end + +RSpec.configure do |c| + c.module_path = File.join(File.dirname(__FILE__), '../../') +end From 2f5d317177976043dc3480ff715da5e1e56b8957 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 15 Dec 2011 15:52:21 +0100 Subject: [PATCH 018/574] (#11413) Update dpkg query used by apt::force This patch fixes the query used by apt::force to determine rather or not the package is installed. Previously, the expression was not specific enough and could not lead to false positives in cases where a package name is contained within another package name (puppet could be incorrectly determined as being installed if puppet-common is installed) This commit resolves that by improving the query expression. --- manifests/force.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index 0a3007d0e5..ece532acd0 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -8,8 +8,8 @@ exec { "/usr/bin/aptitude -y -t ${release} install ${name}": unless => $version ? { - false => "/usr/bin/dpkg -l | grep ${name}", - default => "/usr/bin/dpkg -l | grep ${name} | grep ${version}" + false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'", + default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" } } From f71db53130c28e9fc6fd7468df6800b15ad7676e Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Fri, 13 Jan 2012 11:02:42 -0800 Subject: [PATCH 019/574] (#11413) Add spec test for apt::force to verify changes to unless In the Previous commits, the query being done by the apt::force install command was not strict enough and could lead to false positives. These queries represented by the unless parameter have been resolved in another commit. This commit accompanies that commit and adds basic unit tests to correspond to the changes. --- spec/defines/force_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/defines/force_spec.rb diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb new file mode 100644 index 0000000000..d040dc9962 --- /dev/null +++ b/spec/defines/force_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' +describe 'apt::force', :type => :define do + + let :title do + 'my_package' + end + + [false, '1'].each do |version| + describe "with version: #{version}" do + let :params do + {:version => version, :release => 'testing'} + end + let :unless_query do + base_command = "/usr/bin/dpkg -s #{title} | grep -q " + base_command + (version ? "'Version: #{params[:version]}'" : "'Status: install'") + end + let :exec_title do + "/usr/bin/aptitude -y -t #{params[:release]} install #{title}" + end + it { should contain_exec(exec_title).with_unless(unless_query) } + end + end +end From f759bc039a6a132a262a196450aad2ca9fd5f735 Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Fri, 13 Jan 2012 15:29:47 -0800 Subject: [PATCH 020/574] (#11953) Apt::force passes $version to aptitude Previously, even if $version were passed to apt::force, aptitude would just install the default version of the package available. This updates the aptitude call to use the version string if it exists. If no version is passed, or if it is false, no version is added to the aptitude call. This also updates the rspec-puppet tests for the define, to reflect the changes to the exec. --- manifests/force.pp | 7 ++++++- spec/defines/force_spec.rb | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index ece532acd0..ec6f57e2cc 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -6,7 +6,12 @@ $version = false ) { - exec { "/usr/bin/aptitude -y -t ${release} install ${name}": + $version_string = $version ? { + false => undef, + default => "=${version}", + } + + exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}": unless => $version ? { false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'", default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index d040dc9962..8477a08560 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -15,7 +15,8 @@ base_command + (version ? "'Version: #{params[:version]}'" : "'Status: install'") end let :exec_title do - "/usr/bin/aptitude -y -t #{params[:release]} install #{title}" + base_exec = "/usr/bin/aptitude -y -t #{params[:release]} install #{title}" + base_exec + (version ? "=#{version}" : "") end it { should contain_exec(exec_title).with_unless(unless_query) } end From 0fb5f78379ef167d30770d14d6fee2b6787eeadd Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Mon, 23 Jan 2012 13:05:59 -0800 Subject: [PATCH 021/574] (#12094) Replace name with path in file resources When the name is used with a file resource, it becomes difficult to test the resource using rspec-puppet, as the name parameter gets aliased to path. So to maintain consistency between tests and manifests, this replaces all name parameters in file resources with the equivalent path parameter. --- manifests/init.pp | 4 ++-- manifests/pin.pp | 2 +- manifests/source.pp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 8042c8be19..59a56e3f32 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,7 +29,7 @@ package { "python-software-properties": } file { "sources.list": - name => "${apt::params::root}/sources.list", + path => "${apt::params::root}/sources.list", ensure => present, owner => root, group => root, @@ -37,7 +37,7 @@ } file { "sources.list.d": - name => "${apt::params::root}/sources.list.d", + path => "${apt::params::root}/sources.list.d", ensure => directory, owner => root, group => root, diff --git a/manifests/pin.pp b/manifests/pin.pp index 3485b2473d..40695af5fa 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -9,7 +9,7 @@ include apt::params file { "${name}.pref": - name => "${apt::params::root}/preferences.d/${name}", + path => "${apt::params::root}/preferences.d/${name}", ensure => file, owner => root, group => root, diff --git a/manifests/source.pp b/manifests/source.pp index 65afefdbe1..9f040b7734 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -17,7 +17,7 @@ file { "${name}.list": - name => "${apt::params::root}/sources.list.d/${name}.list", + path => "${apt::params::root}/sources.list.d/${name}.list", ensure => file, owner => root, group => root, From 2d688f4cdc121da434db873f818dd95977385a46 Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Mon, 23 Jan 2012 13:08:00 -0800 Subject: [PATCH 022/574] (#12094) Add rspec-puppet tests for apt This commit adds full coverage for the apt module as it currently exists. It adds rspec-puppet tests for the defines (apt::builddep, apt::force, apt::pin, apt::ppa, apt::source) and classes (apt, debian::testing, debian::unstable, apt::params, apt::release). --- spec/classes/apt_spec.rb | 74 ++++++++++++++++ spec/classes/debian_testing_spec.rb | 13 +++ spec/classes/debian_unstable_spec.rb | 13 +++ spec/classes/params_spec.rb | 13 +++ spec/classes/release_spec.rb | 21 +++++ spec/defines/builddep_spec.rb | 18 ++++ spec/defines/force_spec.rb | 31 +++++-- spec/defines/pin_spec.rb | 39 ++++++++ spec/defines/ppa_spec.rb | 5 ++ spec/defines/source_spec.rb | 128 +++++++++++++++++++++++++++ 10 files changed, 348 insertions(+), 7 deletions(-) create mode 100644 spec/classes/apt_spec.rb create mode 100644 spec/classes/debian_testing_spec.rb create mode 100644 spec/classes/debian_unstable_spec.rb create mode 100644 spec/classes/params_spec.rb create mode 100644 spec/classes/release_spec.rb create mode 100644 spec/defines/builddep_spec.rb create mode 100644 spec/defines/pin_spec.rb create mode 100644 spec/defines/source_spec.rb diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb new file mode 100644 index 0000000000..a858180455 --- /dev/null +++ b/spec/classes/apt_spec.rb @@ -0,0 +1,74 @@ +require 'spec_helper' +describe 'apt', :type => :class do + let :default_params do + { + :disable_keys => false, + :always_apt_update => false + } + end + + [{}, + { + :disable_keys => true, + :always_apt_update => true + } + ].each do |param_set| + describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do + let :param_hash do + param_set == {} ? default_params : params + end + + let :params do + param_set + end + + let :refresh_only_apt_update do + if param_hash[:always_apt_update] + false + else + true + end + end + + it { should include_class("apt::params") } + + it { should contain_package("python-software-properties") } + + it { + should create_file("sources.list")\ + .with_path("/etc/apt/sources.list")\ + .with_ensure("present")\ + .with_owner("root")\ + .with_group("root")\ + .with_mode(644) + } + + it { + should create_file("sources.list.d")\ + .with_path("/etc/apt/sources.list.d")\ + .with_ensure("directory")\ + .with_owner("root")\ + .with_group("root") + } + + it { + should create_exec("apt_update")\ + .with_command("/usr/bin/apt-get update")\ + .with_subscribe(["File[sources.list]", "File[sources.list.d]"])\ + .with_refreshonly(refresh_only_apt_update) + } + + it { + if param_hash[:disable_keys] + should create_exec("make-apt-insecure")\ + .with_command('/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth')\ + .with_creates('/etc/apt/apt.conf.d/99unauth') + else + should_not create_exec("make-apt-insecure")\ + .with_command('/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth')\ + .with_creates('/etc/apt/apt.conf.d/99unauth') + end + } + end + end +end diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb new file mode 100644 index 0000000000..0ee1b2efc3 --- /dev/null +++ b/spec/classes/debian_testing_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' +describe 'apt::debian::testing', :type => :class do + it { + should create_resource("Apt::source", "debian_testing")\ + .with_param("location", "http://debian.mirror.iweb.ca/debian/")\ + .with_param("release", "testing")\ + .with_param("repos", "main contrib non-free")\ + .with_param("required_packages", "debian-keyring debian-archive-keyring")\ + .with_param("key", "55BE302B")\ + .with_param("key_server", "subkeys.pgp.net")\ + .with_param("pin", "-10") + } +end diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb new file mode 100644 index 0000000000..5673b78161 --- /dev/null +++ b/spec/classes/debian_unstable_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' +describe 'apt::debian::unstable', :type => :class do + it { + should create_resource("Apt::source", "debian_unstable")\ + .with_param("location", "http://debian.mirror.iweb.ca/debian/")\ + .with_param("release", "unstable")\ + .with_param("repos", "main contrib non-free")\ + .with_param("required_packages", "debian-keyring debian-archive-keyring")\ + .with_param("key", "55BE302B")\ + .with_param("key_server", "subkeys.pgp.net")\ + .with_param("pin", "-10") + } +end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb new file mode 100644 index 0000000000..a0ec08ca4b --- /dev/null +++ b/spec/classes/params_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' +describe 'apt::params', :type => :class do + let (:title) { 'my_package' } + + it { should create_class("apt::params") } + + # There are 4 resources in this class currently + # there should not be any more resources because it is a params class + # The resources are class[apt::params], class[main], class[settings], stage[main] + it "Should not contain any resources" do + subject.resources.size.should == 4 + end +end diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb new file mode 100644 index 0000000000..a8b1448ac8 --- /dev/null +++ b/spec/classes/release_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' +describe 'apt::release', :type => :class do + let (:title) { 'my_package' } + + let :param_set do + { :release_id => 'precise' } + end + + let (:params) { param_set } + + it { should include_class("apt::params") } + + it { + should contain_file("/etc/apt/apt.conf.d/01release")\ + .with_owner("root")\ + .with_group("root")\ + .with_mode(644)\ + .with_content("APT::Default-Release \"#{param_set[:release_id]}\";") + } +end + diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb new file mode 100644 index 0000000000..d60a330e0c --- /dev/null +++ b/spec/defines/builddep_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' +describe 'apt::builddep', :type => :define do + + let(:title) { 'my_package' } + + describe "should succeed with a Class['apt']" do + let(:pre_condition) { 'class {"apt": } ' } + + it { should contain_exec("apt-update-#{title}").with_command("/usr/bin/apt-get update").with_refreshonly(true) } + end + + describe "should fail without Class['apt']" do + it { expect {should contain_exec("apt-update-#{title}").with_command("/usr/bin/apt-get update").with_refreshonly(true) }\ + .to raise_error(Puppet::Error) + } + end + +end diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index 8477a08560..11b82e3e52 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -1,22 +1,39 @@ require 'spec_helper' describe 'apt::force', :type => :define do - let :title do 'my_package' end - [false, '1'].each do |version| - describe "with version: #{version}" do + let :default_params do + { + :release => 'testing', + :version => false + } + end + + [{}, + { + :release => 'stable', + :version => '1' + } + ].each do |param_set| + describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do + let :param_hash do + param_set == {} ? default_params : params + end + let :params do - {:version => version, :release => 'testing'} + param_set end + let :unless_query do base_command = "/usr/bin/dpkg -s #{title} | grep -q " - base_command + (version ? "'Version: #{params[:version]}'" : "'Status: install'") + base_command + (params[:version] ? "'Version: #{params[:version]}'" : "'Status: install'") end + let :exec_title do - base_exec = "/usr/bin/aptitude -y -t #{params[:release]} install #{title}" - base_exec + (version ? "=#{version}" : "") + base_exec = "/usr/bin/aptitude -y -t #{param_hash[:release]} install #{title}" + base_exec + (params[:version] ? "=#{params[:version]}" : "") end it { should contain_exec(exec_title).with_unless(unless_query) } end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb new file mode 100644 index 0000000000..ac61864555 --- /dev/null +++ b/spec/defines/pin_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' +describe 'apt::pin', :type => :define do + let(:title) { 'my_pin' } + + let :default_params do + { + :packages => '*', + :priority => '0' + } + end + + [{}, + { + :packages => 'apache', + :priority => '1' + } + ].each do |param_set| + describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do + let :param_hash do + param_set == {} ? default_params : params + end + + let :params do + param_set + end + + it { should include_class("apt::params") } + + it { should create_file("#{title}.pref")\ + .with_path("/etc/apt/preferences.d/#{title}")\ + .with_ensure("file")\ + .with_owner("root")\ + .with_group("root")\ + .with_mode("644")\ + .with_content("# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}") + } + end + end +end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 6532654559..3d786e11ca 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -29,4 +29,9 @@ it { should contain_exec("apt-update-#{t}").without_unless } end end + + describe "without Class[apt] should raise a Puppet::Error" do + let(:title) { "ppa" } + it { expect { should create_resource("apt::ppa", title) }.to raise_error(Puppet::Error) } + end end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb new file mode 100644 index 0000000000..333d53460f --- /dev/null +++ b/spec/defines/source_spec.rb @@ -0,0 +1,128 @@ +require 'spec_helper' +describe 'apt::source', :type => :define do + let :title do + 'my_source' + end + + let :default_params do + { + :location => '', + :release => 'karmic', + :repos => 'main', + :include_src => true, + :required_packages => false, + :key => false, + :key_server => 'keyserver.ubuntu.com', + :pin => false, + :key_content => false + } + end + + [{}, + { + :location => 'somewhere', + :release => 'precise', + :repos => 'security', + :include_src => false, + :required_packages => 'apache', + :key => 'key_name', + :key_server => 'keyserver.debian.com', + :pin => '600', + :key_content => 'ABCD1234' + } + ].each do |param_set| + describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do + let :param_hash do + param_set == {} ? default_params : params + end + + let :params do + param_set + end + + let :filename do + "/etc/apt/sources.list.d/#{title}.list" + end + + let :content do + content = "# #{title}" + content << "\ndeb #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + if param_hash[:include_src] + content << "deb-src #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + end + content + end + + it { should contain_class("apt::params") } + + it { should contain_file("#{title}.list")\ + .with_path(filename)\ + .with_ensure("file")\ + .with_owner("root")\ + .with_group("root")\ + .with_mode(644)\ + .with_content(content) + } + + it { + if param_hash[:pin] + should create_resource("apt::pin", param_hash[:release]).with_param("priority", param_hash[:pin]).with_param("before", "File[#{title}.list]") + else + should_not create_resource("apt::pin", param_hash[:release]).with_param("priority", param_hash[:pin]).with_param("before", "File[#{title}.list]") + end + } + + it { + should contain_exec("#{title} apt update")\ + .with_command("/usr/bin/apt-get update")\ + .with_subscribe("File[#{title}.list]")\ + .with_refreshonly(true) + } + + it { + if param_hash[:required_packages] + should contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}")\ + .with_subscribe("File[#{title}.list]")\ + .with_refreshonly(true) + else + should_not contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}")\ + .with_subscribe("File[#{title}.list]")\ + .with_refreshonly(true) + end + } + + it { + if param_hash[:key] + if param_hash[:key_content] + should contain_exec("Add key: #{param_hash[:key]} from content")\ + .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\ + .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\ + .with_before("File[#{title}.list]") + should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}")\ + .with_unless("/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}")\ + .with_before("File[#{title}.list]") + + else + should contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}")\ + .with_unless("/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}")\ + .with_before("File[#{title}.list]") + should_not contain_exec("Add key: #{param_hash[:key]} from content")\ + .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\ + .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\ + .with_before("File[#{title}.list]") + end + else + should_not contain_exec("Add key: #{param_hash[:key]} from content")\ + .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\ + .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\ + .with_before("File[#{title}.list]") + should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}")\ + .with_unless("/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}")\ + .with_before("File[#{title}.list]") + + end + } + end + end +end + From 8cf1bd02891baf0184f8237367aa56f8640f1428 Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Mon, 23 Jan 2012 13:13:17 -0800 Subject: [PATCH 023/574] (#12094) Remove deprecated spec.opts file Rspec no longer uses the spec.opts file, and this particular file also uses options for rspec that are no longer honored or available, like loadby. So this commit removes the file. Users that want to customize rspec behavior should use a .rspec file in the repository root or in their home directory. --- spec/spec.opts | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 spec/spec.opts diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 91cd6427ed..0000000000 --- a/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace From d522877cdde21ffca44c5af7a0ba6a3312c4af8a Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Fri, 3 Feb 2012 17:24:09 -0800 Subject: [PATCH 024/574] (#12094) Replace chained .with_* with a hash The hash passing to the with method is cleaner and closer to puppet code, so all of the with_$param have been replaced with with($hash). This also includes two minor whitspace changes to unstable.pp and source.pp. This also replaces the ternary switch on param_set with a hash merge, which is cleaner and will support more use cases. --- manifests/debian/unstable.pp | 2 +- manifests/source.pp | 2 +- spec/classes/apt_spec.rb | 49 +++++++------ spec/classes/debian_testing_spec.rb | 17 ++--- spec/classes/debian_unstable_spec.rb | 17 ++--- spec/classes/params_spec.rb | 2 +- spec/classes/release_spec.rb | 11 +-- spec/defines/builddep_spec.rb | 13 +++- spec/defines/force_spec.rb | 2 +- spec/defines/pin_spec.rb | 17 ++--- spec/defines/ppa_spec.rb | 4 +- spec/defines/source_spec.rb | 100 ++++++++++++++++----------- 12 files changed, 134 insertions(+), 102 deletions(-) diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp index 89e5d9a9fb..782440fb30 100644 --- a/manifests/debian/unstable.pp +++ b/manifests/debian/unstable.pp @@ -7,7 +7,7 @@ # Key: 55BE302B Server: subkeys.pgp.net # debian-keyring # debian-archive-keyring - + apt::source { "debian_unstable": location => "http://debian.mirror.iweb.ca/debian/", release => "unstable", diff --git a/manifests/source.pp b/manifests/source.pp index 9f040b7734..ddf753adf1 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -48,7 +48,7 @@ command => "/bin/echo '${key_content}' | /usr/bin/apt-key add -", unless => "/usr/bin/apt-key list | /bin/grep '${key}'", before => File["${name}.list"], - } + } } else { exec { "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}": unless => "/usr/bin/apt-key list | /bin/grep ${key}", diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index a858180455..5ac64f2b2e 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -15,7 +15,7 @@ ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do let :param_hash do - param_set == {} ? default_params : params + default_params.merge(param_set) end let :params do @@ -35,38 +35,43 @@ it { should contain_package("python-software-properties") } it { - should create_file("sources.list")\ - .with_path("/etc/apt/sources.list")\ - .with_ensure("present")\ - .with_owner("root")\ - .with_group("root")\ - .with_mode(644) + should contain_file("sources.list").with({ + 'path' => "/etc/apt/sources.list", + 'ensure' => "present", + 'owner' => "root", + 'group' => "root", + 'mode' => 644 + }) } it { - should create_file("sources.list.d")\ - .with_path("/etc/apt/sources.list.d")\ - .with_ensure("directory")\ - .with_owner("root")\ - .with_group("root") + should create_file("sources.list.d").with({ + "path" => "/etc/apt/sources.list.d", + "ensure" => "directory", + "owner" => "root", + "group" => "root" + }) } it { - should create_exec("apt_update")\ - .with_command("/usr/bin/apt-get update")\ - .with_subscribe(["File[sources.list]", "File[sources.list.d]"])\ - .with_refreshonly(refresh_only_apt_update) + should contain_exec("apt_update").with({ + 'command' => "/usr/bin/apt-get update", + 'subscribe' => ["File[sources.list]", "File[sources.list.d]"], + 'refreshonly' => refresh_only_apt_update + }) } it { if param_hash[:disable_keys] - should create_exec("make-apt-insecure")\ - .with_command('/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth')\ - .with_creates('/etc/apt/apt.conf.d/99unauth') + should contain_exec("make-apt-insecure").with({ + 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth', + 'creates' => '/etc/apt/apt.conf.d/99unauth' + }) else - should_not create_exec("make-apt-insecure")\ - .with_command('/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth')\ - .with_creates('/etc/apt/apt.conf.d/99unauth') + should_not contain_exec("make-apt-insecure").with({ + 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth', + 'creates' => '/etc/apt/apt.conf.d/99unauth' + }) end } end diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb index 0ee1b2efc3..6006afb418 100644 --- a/spec/classes/debian_testing_spec.rb +++ b/spec/classes/debian_testing_spec.rb @@ -1,13 +1,14 @@ require 'spec_helper' describe 'apt::debian::testing', :type => :class do it { - should create_resource("Apt::source", "debian_testing")\ - .with_param("location", "http://debian.mirror.iweb.ca/debian/")\ - .with_param("release", "testing")\ - .with_param("repos", "main contrib non-free")\ - .with_param("required_packages", "debian-keyring debian-archive-keyring")\ - .with_param("key", "55BE302B")\ - .with_param("key_server", "subkeys.pgp.net")\ - .with_param("pin", "-10") + should contain_apt__source("debian_testing").with({ + "location" => "http://debian.mirror.iweb.ca/debian/", + "release" => "testing", + "repos" => "main contrib non-free", + "required_packages" => "debian-keyring debian-archive-keyring", + "key" => "55BE302B", + "key_server" => "subkeys.pgp.net", + "pin" => "-10" + }) } end diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb index 5673b78161..411182df11 100644 --- a/spec/classes/debian_unstable_spec.rb +++ b/spec/classes/debian_unstable_spec.rb @@ -1,13 +1,14 @@ require 'spec_helper' describe 'apt::debian::unstable', :type => :class do it { - should create_resource("Apt::source", "debian_unstable")\ - .with_param("location", "http://debian.mirror.iweb.ca/debian/")\ - .with_param("release", "unstable")\ - .with_param("repos", "main contrib non-free")\ - .with_param("required_packages", "debian-keyring debian-archive-keyring")\ - .with_param("key", "55BE302B")\ - .with_param("key_server", "subkeys.pgp.net")\ - .with_param("pin", "-10") + should contain_apt__source("debian_unstable").with({ + "location" => "http://debian.mirror.iweb.ca/debian/", + "release" => "unstable", + "repos" => "main contrib non-free", + "required_packages" => "debian-keyring debian-archive-keyring", + "key" => "55BE302B", + "key_server" => "subkeys.pgp.net", + "pin" => "-10" + }) } end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index a0ec08ca4b..f2790b0adb 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -2,7 +2,7 @@ describe 'apt::params', :type => :class do let (:title) { 'my_package' } - it { should create_class("apt::params") } + it { should contain_apt__params } # There are 4 resources in this class currently # there should not be any more resources because it is a params class diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb index a8b1448ac8..221df03683 100644 --- a/spec/classes/release_spec.rb +++ b/spec/classes/release_spec.rb @@ -11,11 +11,12 @@ it { should include_class("apt::params") } it { - should contain_file("/etc/apt/apt.conf.d/01release")\ - .with_owner("root")\ - .with_group("root")\ - .with_mode(644)\ - .with_content("APT::Default-Release \"#{param_set[:release_id]}\";") + should contain_file("/etc/apt/apt.conf.d/01release").with({ + "owner" => "root", + "group" => "root", + "mode" => 644, + "content" => "APT::Default-Release \"#{param_set[:release_id]}\";" + }) } end diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb index d60a330e0c..52a0704a3b 100644 --- a/spec/defines/builddep_spec.rb +++ b/spec/defines/builddep_spec.rb @@ -6,12 +6,19 @@ describe "should succeed with a Class['apt']" do let(:pre_condition) { 'class {"apt": } ' } - it { should contain_exec("apt-update-#{title}").with_command("/usr/bin/apt-get update").with_refreshonly(true) } + it { should contain_exec("apt-update-#{title}").with({ + 'command' => "/usr/bin/apt-get update", + 'refreshonly' => true + }) + } end describe "should fail without Class['apt']" do - it { expect {should contain_exec("apt-update-#{title}").with_command("/usr/bin/apt-get update").with_refreshonly(true) }\ - .to raise_error(Puppet::Error) + it { expect {should contain_exec("apt-update-#{title}").with({ + 'command' => "/usr/bin/apt-get update", + 'refreshonly' => true + }).to raise_error(Puppet::Error) + } } end diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index 11b82e3e52..eeea7ff094 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -19,7 +19,7 @@ ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do let :param_hash do - param_set == {} ? default_params : params + default_params.merge(param_set) end let :params do diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index ac61864555..52c6bfae19 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -17,7 +17,7 @@ ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do let :param_hash do - param_set == {} ? default_params : params + default_params.merge(param_set) end let :params do @@ -26,13 +26,14 @@ it { should include_class("apt::params") } - it { should create_file("#{title}.pref")\ - .with_path("/etc/apt/preferences.d/#{title}")\ - .with_ensure("file")\ - .with_owner("root")\ - .with_group("root")\ - .with_mode("644")\ - .with_content("# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}") + it { should contain_file("#{title}.pref").with({ + 'path' => "/etc/apt/preferences.d/#{title}", + 'ensure' => "file", + 'owner' => "root", + 'group' => "root", + 'mode' => "644", + 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}" + }) } end end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 3d786e11ca..c2ce26411c 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -20,7 +20,7 @@ 'notify' => "Exec[apt-update-#{t}]" ) } - it { should contain_exec("add-apt-repository-#{t}").with_unless(unless_statement) } + it { should contain_exec("add-apt-repository-#{t}").with({"unless" => unless_statement}) } it { should contain_exec("apt-update-#{t}").with( 'command' => '/usr/bin/aptitude update', 'refreshonly' => true @@ -32,6 +32,6 @@ describe "without Class[apt] should raise a Puppet::Error" do let(:title) { "ppa" } - it { expect { should create_resource("apt::ppa", title) }.to raise_error(Puppet::Error) } + it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) } end end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 333d53460f..01949b60ec 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -33,7 +33,7 @@ ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do let :param_hash do - param_set == {} ? default_params : params + default_params.merge(param_set) end let :params do @@ -53,72 +53,88 @@ content end - it { should contain_class("apt::params") } + it { should contain_apt__params } - it { should contain_file("#{title}.list")\ - .with_path(filename)\ - .with_ensure("file")\ - .with_owner("root")\ - .with_group("root")\ - .with_mode(644)\ - .with_content(content) + it { should contain_file("#{title}.list").with({ + 'path' => filename, + 'ensure' => "file", + 'owner' => "root", + 'group' => "root", + 'mode' => 644, + 'content' => content + }) } it { if param_hash[:pin] - should create_resource("apt::pin", param_hash[:release]).with_param("priority", param_hash[:pin]).with_param("before", "File[#{title}.list]") + should contain_apt__pin(param_hash[:release]).with({ + "priority" => param_hash[:pin], + "before" => "File[#{title}.list]" + }) else - should_not create_resource("apt::pin", param_hash[:release]).with_param("priority", param_hash[:pin]).with_param("before", "File[#{title}.list]") + should_not contain_apt__pin(param_hash[:release]).with({ + "priority" => param_hash[:pin], + "before" => "File[#{title}.list]" + }) end } it { - should contain_exec("#{title} apt update")\ - .with_command("/usr/bin/apt-get update")\ - .with_subscribe("File[#{title}.list]")\ - .with_refreshonly(true) + should contain_exec("#{title} apt update").with({ + "command" => "/usr/bin/apt-get update", + "subscribe" => "File[#{title}.list]", + "refreshonly" => true + }) } it { if param_hash[:required_packages] - should contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}")\ - .with_subscribe("File[#{title}.list]")\ - .with_refreshonly(true) + should contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}").with({ + "subscribe" => "File[#{title}.list]", + "refreshonly" => true + }) else - should_not contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}")\ - .with_subscribe("File[#{title}.list]")\ - .with_refreshonly(true) + should_not contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}").with({ + "subscribe" => "File[#{title}.list]", + "refreshonly" => true + }) end } it { if param_hash[:key] if param_hash[:key_content] - should contain_exec("Add key: #{param_hash[:key]} from content")\ - .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\ - .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\ - .with_before("File[#{title}.list]") - should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}")\ - .with_unless("/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}")\ - .with_before("File[#{title}.list]") + should contain_exec("Add key: #{param_hash[:key]} from content").with({ + "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", + "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", + "before" => "File[#{title}.list]" + }) + should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" + }) else - should contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}")\ - .with_unless("/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}")\ - .with_before("File[#{title}.list]") - should_not contain_exec("Add key: #{param_hash[:key]} from content")\ - .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\ - .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\ - .with_before("File[#{title}.list]") + should contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" + }) + should_not contain_exec("Add key: #{param_hash[:key]} from content").with({ + "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", + "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", + "before" => "File[#{title}.list]" + }) end else - should_not contain_exec("Add key: #{param_hash[:key]} from content")\ - .with_command("/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -")\ - .with_unless("/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'")\ - .with_before("File[#{title}.list]") - should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}")\ - .with_unless("/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}")\ - .with_before("File[#{title}.list]") + should_not contain_exec("Add key: #{param_hash[:key]} from content").with({ + "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", + "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", + "before" => "File[#{title}.list]" + }) + should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" + }) end } From 50f3cca0c67abad7168e852b58992afbdc8920bc Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Wed, 8 Feb 2012 09:40:43 -0800 Subject: [PATCH 025/574] (#12529) Add parameter to support setting a proxy for apt This commit adds two class parameter to apt that can be used to specify a proxy to use with apt. - proxy_host - proxy_port --- manifests/init.pp | 11 ++++++++++- manifests/source.pp | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 59a56e3f32..8d266b8b17 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,7 +16,9 @@ # class { 'apt': } class apt( $disable_keys = false, - $always_apt_update = false + $always_apt_update = false, + $proxy_host = false, + $proxy_port = '8080' ) { include apt::params @@ -54,4 +56,11 @@ creates => '/etc/apt/apt.conf.d/99unauth' } } + + if($proxy_host) { + file { 'configure-apt-proxy': + path => '/etc/apt/apt.conf.d/proxy', + content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", + } + } } diff --git a/manifests/source.pp b/manifests/source.pp index ddf753adf1..2bd2e42d5a 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -15,7 +15,6 @@ include apt::params - file { "${name}.list": path => "${apt::params::root}/sources.list.d/${name}.list", ensure => file, @@ -23,6 +22,7 @@ group => root, mode => 644, content => template("apt/source.list.erb"), + } if $pin != false { From 997c9fdc40919fb3a2949eaa3fd6c60ab7432baa Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 13 Feb 2012 09:58:30 -0800 Subject: [PATCH 026/574] (#12529) Add unit test for apt proxy settings This commit adds unit tests to validate that the apt proxy is configured as expected when the class parameter proxy_host is set as a class parameter for the apt class. --- spec/classes/apt_spec.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 5ac64f2b2e..1c7c18f4c2 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -10,7 +10,9 @@ [{}, { :disable_keys => true, - :always_apt_update => true + :always_apt_update => true, + :proxy_host => true, + :proxy_port => '3128' } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do @@ -74,6 +76,18 @@ }) end } + describe 'when setting a proxy' do + it { + if param_hash[:proxy_host] + should contain_file('configure-apt-proxy').with( + 'path' => '/etc/apt/apt.conf.d/proxy', + 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";" + ) + else + should_not contain_file('configure_apt_proxy') + end + } + end end end end From 8c279636f5e1bfd3bdda9abe912b8930bbc18a5b Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Wed, 8 Feb 2012 11:40:09 -0800 Subject: [PATCH 027/574] (#12522) Adding purge option to apt class Adds a purge option to the apt class to remove repositories that are not managed by apt::source --- manifests/init.pp | 13 ++++++++-- spec/classes/apt_spec.rb | 56 +++++++++++++++++++++++++++++----------- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 8d266b8b17..b0acdd0927 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -15,14 +15,17 @@ # Sample Usage: # class { 'apt': } class apt( - $disable_keys = false, $always_apt_update = false, + $disable_keys = false, $proxy_host = false, - $proxy_port = '8080' + $proxy_port = '8080', + $purge = false ) { include apt::params + validate_bool($purge) + $refresh_only_apt_update = $always_apt_update? { true => false, false => true @@ -36,6 +39,10 @@ owner => root, group => root, mode => 644, + content => $purge ? { + false => undef, + true => "# Repos managed by puppet.\n", + }, } file { "sources.list.d": @@ -43,6 +50,8 @@ ensure => directory, owner => root, group => root, + purge => $purge, + recurse => $purge, } exec { "apt_update": diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 1c7c18f4c2..294892f324 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -3,7 +3,8 @@ let :default_params do { :disable_keys => false, - :always_apt_update => false + :always_apt_update => false, + :purge => false } end @@ -12,7 +13,8 @@ :disable_keys => true, :always_apt_update => true, :proxy_host => true, - :proxy_port => '3128' + :proxy_port => '3128', + :purge => true } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do @@ -37,22 +39,46 @@ it { should contain_package("python-software-properties") } it { + if param_hash[:purge] should contain_file("sources.list").with({ - 'path' => "/etc/apt/sources.list", - 'ensure' => "present", - 'owner' => "root", - 'group' => "root", - 'mode' => 644 - }) + 'path' => "/etc/apt/sources.list", + 'ensure' => "present", + 'owner' => "root", + 'group' => "root", + 'mode' => 644, + "content" => "# Repos managed by puppet.\n" + }) + else + should contain_file("sources.list").with({ + 'path' => "/etc/apt/sources.list", + 'ensure' => "present", + 'owner' => "root", + 'group' => "root", + 'mode' => 644, + 'content' => nil + }) + end } - it { - should create_file("sources.list.d").with({ - "path" => "/etc/apt/sources.list.d", - "ensure" => "directory", - "owner" => "root", - "group" => "root" - }) + if param_hash[:purge] + should create_file("sources.list.d").with({ + 'path' => "/etc/apt/sources.list.d", + 'ensure' => "directory", + 'owner' => "root", + 'group' => "root", + 'purge' => true, + 'recurse' => true + }) + else + should create_file("sources.list.d").with({ + 'path' => "/etc/apt/sources.list.d", + 'ensure' => "directory", + 'owner' => "root", + 'group' => "root", + 'purge' => false, + 'recurse' => false + }) + end } it { From c65774204d7ab91f46f2aac243ec2650f2b39565 Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Tue, 14 Feb 2012 11:40:29 -0800 Subject: [PATCH 028/574] Allow the use of the same key in multiple sources Allow the use of the same key in multiple sources by including the name of the source in the declaration for the exec which adds the key. --- manifests/source.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 2bd2e42d5a..0512fa96c9 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -44,13 +44,14 @@ if $key != false { if $key_content { - exec { "Add key: ${key} from content": + exec { "Add key: ${key} from content for ${name}": command => "/bin/echo '${key_content}' | /usr/bin/apt-key add -", unless => "/usr/bin/apt-key list | /bin/grep '${key}'", before => File["${name}.list"], } } else { - exec { "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}": + exec { "Add key: ${key} from ${key_server} for ${name}": + command => "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}", unless => "/usr/bin/apt-key list | /bin/grep ${key}", before => File["${name}.list"], } From 2842d73b95ec5948cd5ce078b3ff8aabefa96c33 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Thu, 23 Feb 2012 14:01:31 -0800 Subject: [PATCH 029/574] Add Modulefile to puppet-apt Now that puppet-apt depends on puppetlabs-stdlib, an explicit dependency is required. Modulefile was entirely missing. This commit adds on. --- Modulefile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Modulefile diff --git a/Modulefile b/Modulefile new file mode 100644 index 0000000000..635f15755f --- /dev/null +++ b/Modulefile @@ -0,0 +1,11 @@ +name 'puppet-apt' +version '0.0.1' +source 'https://github.com/puppetlabs/puppet-apt' +author 'Evolving Web / Puppet Labs' +license 'Apache License 2.0' +summary 'Apt Module for Puppet' +description 'APT Module for Puppet' +project_page 'https://github.com/puppetlabs/puppet-apt' + +## Add dependencies, if any: +dependency 'puppetlabs/stdlib', '>= 2.2.1' From 1160bcd6d1c190e9afc3399b6b4895f9606b213f Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Thu, 9 Feb 2012 16:18:14 -0800 Subject: [PATCH 030/574] (#12526) Add ability to reverse apt { disable_keys => true } The setting `disable_keys => true` parameter in the apt module creates /etc/apt/apt.conf.d/99unauth with the contents "APT::Get::AllowUnauthenticated 1;". Changing `disable_keys` does not remove this file. This patch makes it so that `disable_keys => false` will remove /etc/apt/apt.conf.d/99unauth. --- manifests/init.pp | 22 +++++++++++++++++----- spec/classes/apt_spec.rb | 28 ++++++++++++++++++---------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b0acdd0927..472ed06d46 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,7 +16,7 @@ # class { 'apt': } class apt( $always_apt_update = false, - $disable_keys = false, + $disable_keys = undef, $proxy_host = false, $proxy_port = '8080', $purge = false @@ -59,11 +59,23 @@ subscribe => [ File["sources.list"], File["sources.list.d"] ], refreshonly => $refresh_only_apt_update, } - if($disable_keys) { - exec { 'make-apt-insecure': - command => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth', - creates => '/etc/apt/apt.conf.d/99unauth' + + case $disable_keys { + true: { + file { "99unauth": + content => "APT::Get::AllowUnauthenticated 1;\n", + ensure => present, + path => "/etc/apt/apt.conf.d/99unauth", + } + } + false: { + file { "99unauth": + ensure => absent, + path => "/etc/apt/apt.conf.d/99unauth", + } } + undef: { } # do nothing + default: { fail("Valid values for disable_keys are true or false") } } if($proxy_host) { diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 294892f324..e21c78ef9a 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -2,19 +2,22 @@ describe 'apt', :type => :class do let :default_params do { - :disable_keys => false, + :disable_keys => :undef, :always_apt_update => false, :purge => false } end [{}, - { + { :disable_keys => true, :always_apt_update => true, :proxy_host => true, :proxy_port => '3128', :purge => true + }, + { + :disable_keys => false } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do @@ -90,15 +93,20 @@ } it { - if param_hash[:disable_keys] - should contain_exec("make-apt-insecure").with({ - 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth', - 'creates' => '/etc/apt/apt.conf.d/99unauth' + if param_hash[:disable_keys] == true + should create_file("99unauth").with({ + 'content' => "APT::Get::AllowUnauthenticated 1;\n", + 'ensure' => "present", + 'path' => "/etc/apt/apt.conf.d/99unauth" }) - else - should_not contain_exec("make-apt-insecure").with({ - 'command' => '/bin/echo "APT::Get::AllowUnauthenticated 1;" >> /etc/apt/apt.conf.d/99unauth', - 'creates' => '/etc/apt/apt.conf.d/99unauth' + elsif param_hash[:disable_keys] == false + should create_file("99unauth").with({ + 'ensure' => "absent", + 'path' => "/etc/apt/apt.conf.d/99unauth" + }) + elsif param_hash[:disable_keys] != :undef + should_not create_file("99unauth").with({ + 'path' => "/etc/apt/apt.conf.d/99unauth" }) end } From 97ebb2d5d50aff93b0c86e61e9d8d56941227350 Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Thu, 23 Feb 2012 15:44:26 -0800 Subject: [PATCH 031/574] Test two sources with the same key --- tests/source.pp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/source.pp b/tests/source.pp index 7d7321f74e..4db740d417 100644 --- a/tests/source.pp +++ b/tests/source.pp @@ -9,3 +9,21 @@ key_server => 'keyserver.ubuntu.com', pin => '600' } + +# test two sources with the same key +apt::source { "debian_testing": + location => "http://debian.mirror.iweb.ca/debian/", + release => "testing", + repos => "main contrib non-free", + key => "55BE302B", + key_server => "subkeys.pgp.net", + pin => "-10" +} +apt::source { "debian_unstable": + location => "http://debian.mirror.iweb.ca/debian/", + release => "unstable", + repos => "main contrib non-free", + key => "55BE302B", + key_server => "subkeys.pgp.net", + pin => "-10" +} From 74c8371533dee0c07cc3165cde23665d3b80580f Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Thu, 23 Feb 2012 20:51:27 -0800 Subject: [PATCH 032/574] (#12430) Add tests for changes to apt module This update reflects the changes to the apt module to allow duplicate keys. It mostly involves tests for changes to the resource names to make them unique between defines. --- spec/defines/source_spec.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 01949b60ec..95c5a5496a 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -33,7 +33,7 @@ ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do let :param_hash do - default_params.merge(param_set) + param_set == {} ? default_params : params end let :params do @@ -104,34 +104,37 @@ it { if param_hash[:key] if param_hash[:key_content] - should contain_exec("Add key: #{param_hash[:key]} from content").with({ + should contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" }) - should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" + should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ + "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" }) else - should contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" - }) - should_not contain_exec("Add key: #{param_hash[:key]} from content").with({ + should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" - }) + }) + should contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ + "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" + }) end else - should_not contain_exec("Add key: #{param_hash[:key]} from content").with({ + should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" }) - should_not contain_exec("/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}").with({ + should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ + "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", "before" => "File[#{title}.list]" }) From f3735d2ba228fde8d2e119742e11bece4c2c78ac Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Thu, 23 Feb 2012 21:01:20 -0800 Subject: [PATCH 033/574] Allow duplicate $required_packages Previously, if more than one apt::source required the same packages to be installed it would fail with a duplicate exec resource. This adds the name of the source resource to the exec and gives the exec a name, moving it to a command parameter for the exec. --- manifests/source.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 0512fa96c9..9f31fe9130 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -36,8 +36,9 @@ } if $required_packages != false { - exec { "${apt::params::provider} -y install ${required_packages}": - subscribe => File["${name}.list"], + exec { "Required packages: '${required_packages}' for ${name}": + command => "${apt::params::provider} -y install ${required_packages}", + subscribe => File["${name}.list"], refreshonly => true, } } From 1dcbf3d3035b5eb50839bb2e182663b539cf2d6a Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Thu, 23 Feb 2012 21:04:57 -0800 Subject: [PATCH 034/574] Add tests for required_packages change This updates the tests for the apt::source defined type to use the new name for the exec resource and the new parameter for the same exec. --- spec/defines/source_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 95c5a5496a..b74a57d77e 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -89,12 +89,14 @@ it { if param_hash[:required_packages] - should contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}").with({ + should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({ + "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}", "subscribe" => "File[#{title}.list]", "refreshonly" => true }) else - should_not contain_exec("/usr/bin/apt-get -y install #{param_hash[:required_packages]}").with({ + should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({ + "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}", "subscribe" => "File[#{title}.list]", "refreshonly" => true }) From a4af11f7bc37211c690297c7893d99c12f7ef302 Mon Sep 17 00:00:00 2001 From: Peter Drake Date: Fri, 13 Jan 2012 10:40:41 -0500 Subject: [PATCH 035/574] Check if python-software-properties is defined before attempting to define it. --- manifests/init.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 472ed06d46..0f6bcef621 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -31,7 +31,9 @@ false => true } - package { "python-software-properties": } + if ! defined(Package["python-software-properties"]) { + package { "python-software-properties": } + } file { "sources.list": path => "${apt::params::root}/sources.list", From 8acb20268575002cd2b6e7d41eef71db7dd88452 Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Thu, 23 Feb 2012 21:40:42 -0800 Subject: [PATCH 036/574] Add test for python-software-properties package This test adds the precondition that the python-software-packages package be installed before the apt class is synced. If the defined function were not called around the package resource, this test would fail with a duplicate package resource error. --- spec/classes/apt_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index e21c78ef9a..812fa123c7 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -124,4 +124,9 @@ end end end + + describe "it should not error if package['python-software-properties'] is already defined" do + let(:pre_condition) { 'package { "python-software-properties": }->Class["Apt"]' } + it { should contain_package("python-software-properties") } + end end From 9059c4e2a8fc5d5d9ef6aa5d470037b827cd6f62 Mon Sep 17 00:00:00 2001 From: Matthaus Litteken Date: Thu, 23 Feb 2012 22:08:39 -0800 Subject: [PATCH 037/574] Fix source specs to test all key permutations Previously only one should in each block was being evaluated. This moves each should to its own block so that all values are tested. It also adds another set of params so that all useful permutations of key, key_server, and key_content are generated. It also replaces the previous ternary assignment for param_set with a hash merge. --- spec/defines/source_spec.rb | 44 +++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 95c5a5496a..cc06457ba9 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -29,11 +29,16 @@ :key_server => 'keyserver.debian.com', :pin => '600', :key_content => 'ABCD1234' + }, + { + :key => 'key_name', + :key_server => 'keyserver.debian.com', + :key_content => false, } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do let :param_hash do - param_set == {} ? default_params : params + default_params.merge(param_set) end let :params do @@ -56,9 +61,9 @@ it { should contain_apt__params } it { should contain_file("#{title}.list").with({ - 'path' => filename, - 'ensure' => "file", - 'owner' => "root", + 'path' => filename, + 'ensure' => "file", + 'owner' => "root", 'group' => "root", 'mode' => 644, 'content' => content @@ -109,23 +114,12 @@ "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" }) - should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ - "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" - }) - else should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" }) - should contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ - "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" - }) end else should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ @@ -133,12 +127,30 @@ "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", "before" => "File[#{title}.list]" }) + end + } + + it { + if param_hash[:key] + if param_hash[:key_content] + should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ + "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" + }) + else + should contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ + "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", + "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", + "before" => "File[#{title}.list]" + }) + end + else should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", "before" => "File[#{title}.list]" }) - end } end From 7dc60ae5ea1e345719fb5c11397b9ca98b97c5ae Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Fri, 24 Feb 2012 09:27:28 -0800 Subject: [PATCH 038/574] (#12522) Split purge option to spare sources.list Prior to this commit, when using the purge option, unmanaged entries in both /etc/apt/sources.list and sources.list.d would be purged. This commit splits purge into purge_sources_list and purge_sources_list_d which handle the purging of those items separately. Brief documentation on each added to class documentation. --- manifests/init.pp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 472ed06d46..ceb8d5ce0b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,11 +3,16 @@ # This module manages the initial configuration of apt. # # Parameters: -# Both of the parameters listed here are not required in general and were +# The parameters listed here are not required in general and were # added for use cases related to development environments. # disable_keys - disables the requirement for all packages to be signed # always_apt_update - rather apt should be updated on every run (intended # for development environments where package updates are frequent +# purge_sources_list - Accepts true or false. Defaults to false If set to +# true, Puppet will purge all unmanaged entries from sources.list" +# purge_sources_list_d - Accepts true or false. Defaults to false. If set +# to false, Puppet will purge all unmanaged entries from sources.list.d +# # Actions: # # Requires: @@ -19,12 +24,13 @@ $disable_keys = undef, $proxy_host = false, $proxy_port = '8080', - $purge = false + $purge_sources_list = false, + $purge_sources_list_d = false ) { include apt::params - validate_bool($purge) + validate_bool($purge_sources_list, $purge_sources_list_d) $refresh_only_apt_update = $always_apt_update? { true => false, @@ -39,7 +45,7 @@ owner => root, group => root, mode => 644, - content => $purge ? { + content => $purge_sources_list ? { false => undef, true => "# Repos managed by puppet.\n", }, @@ -50,8 +56,8 @@ ensure => directory, owner => root, group => root, - purge => $purge, - recurse => $purge, + purge => $purge_sources_list_d, + recurse => $purge_sources_list_d, } exec { "apt_update": From be2cc3ec1b7a56f1b6e558610960ca36edb60a85 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Fri, 24 Feb 2012 09:50:11 -0800 Subject: [PATCH 039/574] (#12522) Adjust spec test for splitting purge Now that the purge parameter is split into two, the spec test needs adjusted. This commit makes that adjustment. --- spec/classes/apt_spec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index e21c78ef9a..6ab1e9e6d6 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -4,7 +4,8 @@ { :disable_keys => :undef, :always_apt_update => false, - :purge => false + :purge_sources_list => false, + :purge_sources_list_d => false, } end @@ -14,7 +15,8 @@ :always_apt_update => true, :proxy_host => true, :proxy_port => '3128', - :purge => true + :purge_sources_list => true, + :purge_sources_list_d => true, }, { :disable_keys => false @@ -42,7 +44,7 @@ it { should contain_package("python-software-properties") } it { - if param_hash[:purge] + if param_hash[:purge_sources_list] should contain_file("sources.list").with({ 'path' => "/etc/apt/sources.list", 'ensure' => "present", @@ -63,7 +65,7 @@ end } it { - if param_hash[:purge] + if param_hash[:purge_sources_list_d] should create_file("sources.list.d").with({ 'path' => "/etc/apt/sources.list.d", 'ensure' => "directory", From 7c0d10b392cc6ef77817975e93bf8bedaf8f34f6 Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Fri, 24 Feb 2012 14:03:51 -0800 Subject: [PATCH 040/574] (#12809) $release should use $lsbdistcodename and fall back to manual input This commit changes $release to default to Facter's $lsbdistcodename and fall back to a Parse Error if $release is not set and $lsbdistcodename does not exist. Previously $release was hardcoded to karmic. This commit also modifies apt::ppa to use $release and sets the files to be ensured so that they are not purged when purge_sources_list_d is set to true. --- manifests/params.pp | 5 +++-- manifests/ppa.pp | 25 +++++++++++++++++----- manifests/source.pp | 6 +++++- spec/defines/ppa_spec.rb | 42 +++++++++++++++++++++++++------------ spec/defines/source_spec.rb | 7 +++++++ 5 files changed, 64 insertions(+), 21 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 3c39288039..ca5d65521d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,4 +1,5 @@ class apt::params { - $root = '/etc/apt' - $provider = '/usr/bin/apt-get' + $root = '/etc/apt' + $provider = '/usr/bin/apt-get' + $sources_list_d = "${root}/sources.list.d" } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index a41c814f29..712f425f49 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,21 +1,36 @@ # ppa.pp -define apt::ppa() { +define apt::ppa( + $release = $lsbdistcodename +) { Class['apt'] -> Apt::Ppa[$title] + include apt::params + + if ! $release { + fail("lsbdistcodename fact not available: release parameter required") + } + exec { "apt-update-${name}": command => "/usr/bin/aptitude update", refreshonly => true, } + $filename_without_slashes = regsubst($name,'/','-','G') + $filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G') + $sources_list_d_filename = "${filename_without_ppa}-${release}.list" + exec { "add-apt-repository-${name}": command => "/usr/bin/add-apt-repository ${name}", notify => Exec["apt-update-${name}"], - unless => $name? { - /ppa:(.*)/ => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*ppa.*$1.*$'", - default => "/bin/cat /etc/apt/sources.list /etc/apt/sources.list.d/* | /bin/egrep '^[^#].*${title}.*$'", - } + creates => "${apt::params::sources_list_d}/${sources_list_d_filename}", } + + file { "${apt::params::sources_list_d}/${sources_list_d_filename}": + ensure => file, + require => Exec["add-apt-repository-${name}"]; + } + } diff --git a/manifests/source.pp b/manifests/source.pp index 9f31fe9130..abc77e222b 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -3,7 +3,7 @@ define apt::source( $location = '', - $release = 'karmic', + $release = $lsbdistcodename, $repos = 'main', $include_src = true, $required_packages = false, @@ -15,6 +15,10 @@ include apt::params + if ! $release { + fail("lsbdistcodename fact not available: release parameter required") + } + file { "${name}.list": path => "${apt::params::root}/sources.list.d/${name}.list", ensure => file, diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index c2ce26411c..9d4750b737 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -1,37 +1,53 @@ require 'spec_helper' describe 'apt::ppa', :type => :define do - ['ppa:dans_ppa', 'dans_ppa'].each do |t| + ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t| describe "with title #{t}" do let :pre_condition do 'class { "apt": }' end + let :facts do + {:lsbdistcodename => 'natty'} + end let :title do t end - let :unless_statement do - if t =~ /ppa:(.*)/ - /^[^#].*ppa.*#{$1}.*$/ - else - /^[^#].*#{t}.*$/ - end + let :release do + "natty" + end + let :filename do + t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list" end + + it { should contain_exec("apt-update-#{t}").with( + 'command' => '/usr/bin/aptitude update', + 'refreshonly' => true + ) + } + it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{t}", - 'notify' => "Exec[apt-update-#{t}]" + 'notify' => "Exec[apt-update-#{t}]", + 'creates' => "/etc/apt/sources.list.d/#{filename}" ) } - it { should contain_exec("add-apt-repository-#{t}").with({"unless" => unless_statement}) } - it { should contain_exec("apt-update-#{t}").with( - 'command' => '/usr/bin/aptitude update', - 'refreshonly' => true + + it { should create_file("/etc/apt/sources.list.d/#{filename}").with( + 'ensure' => 'file', + 'require' => "Exec[add-apt-repository-#{t}]" ) } - it { should contain_exec("apt-update-#{t}").without_unless } end end describe "without Class[apt] should raise a Puppet::Error" do + let(:release) { "natty" } let(:title) { "ppa" } it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) } end + + describe "without release should raise a Puppet::Error" do + let(:title) { "ppa:" } + it { expect { should contain_apt__ppa(:release) }.to raise_error(Puppet::Error) } + end + end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 041175c1ce..3306ab1ee0 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -41,6 +41,10 @@ default_params.merge(param_set) end + let :facts do + {:lsbdistcodename => 'karmic'} + end + let :params do param_set end @@ -157,5 +161,8 @@ } end end + describe "without release should raise a Puppet::Error" do + it { expect { should contain_apt__source(:release) }.to raise_error(Puppet::Error) } + end end From 8cdaf855a1d0dd24fed02fc3ee9941e0a1e6849b Mon Sep 17 00:00:00 2001 From: Reid Vandewiele Date: Fri, 24 Feb 2012 10:10:03 -0800 Subject: [PATCH 041/574] (#12823) Add apt::key defined type and modify apt::source to use it Adding this defined type allows puppet to add keys to the apt keystore without needing to add a corresponding source; it also adds the "key_source" parameter for wget'ing keys from arbitrary URLs, and allows for keys to be explicity removed. apt::key allows a key to be ensured present multiple times to account for apt::source resources that all reference the same key. However, this means that it is possible for a given key to be defined multiple times with differing source parameters. e.g. apt::key { "Add key: 4BD6EC30 from Apt::Source bunny": key => "4BD6EC30", key_server => "pgp.mit.edu", } apt::key { "Add key: 4BD6EC30 from Apt::Source rabbit": key => "4BD6EC30", key_server => "keyserver.ubuntu.com", } The defined type will accept both definitions and will create multiple exec resources. This was deemed preferable to the alternative (creating only one exec resource) in that one broken definition won't hose an entire catalog. If one definition fails to install the key because of a bad "key_server", the next apt::key that uses the key will get it done. --- README.md | 19 ++++++ manifests/key.pp | 68 +++++++++++++++++++++ manifests/source.pp | 24 ++++---- spec/defines/key_spec.rb | 114 ++++++++++++++++++++++++++++++++++++ spec/defines/source_spec.rb | 59 ++++++------------- 5 files changed, 228 insertions(+), 56 deletions(-) create mode 100644 manifests/key.pp create mode 100644 spec/defines/key_spec.rb diff --git a/README.md b/README.md index 0c61866b0c..b60394f095 100644 --- a/README.md +++ b/README.md @@ -53,5 +53,24 @@ apt::source { "debian_unstable": key_server => "subkeys.pgp.net", pin => "-10", include_src => true + +### apt::key +Add a key to the list of keys used by apt to authenticate packages. +
+apt::key { "puppetlabs":
+  key        => "4BD6EC30",
+  key_server => "pgp.mit.edu",
+}
+
+ +
+apt::key { "jenkins":
+  key        => "D50582E6",
+  key_source => "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key",
+}
+
+ +Note that use of the "key_source" parameter requires wget to be installed and working. + } diff --git a/manifests/key.pp b/manifests/key.pp new file mode 100644 index 0000000000..24eef9e9cf --- /dev/null +++ b/manifests/key.pp @@ -0,0 +1,68 @@ +define apt::key ( + $key = $title, + $ensure = present, + $key_content = false, + $key_source = false, + $key_server = "keyserver.ubuntu.com" +) { + + include apt::params + + if $key_content { + $method = "content" + } elsif $key_source { + $method = "source" + } elsif $key_server { + $method = "server" + } + + # This is a hash of the parts of the key definition that we care about. + # It is used as a unique identifier for this instance of apt::key. It gets + # hashed to ensure that the resource name doesn't end up being pages and + # pages (e.g. in the situation where key_content is specified). + $digest = sha1("${key}/${key_content}/${key_source}/${key_server}/") + + # Allow multiple ensure => present for the same key to account for many + # apt::source resources that all reference the same key. + case $ensure { + present: { + if defined(Exec["apt::key $key absent"]) { + fail ("Cannot ensure Apt::Key[$key] present; $key already ensured absent") + } elsif !defined(Exec["apt::key $key present"]) { + # this is a marker to ensure we don't simultaneously define a key + # ensure => absent AND ensure => present + exec { "apt::key $key present": + path => "/", + onlyif => "/bin/false", + noop => true; + } + } + if !defined(Exec[$digest]) { + exec { $digest: + path => "/bin:/usr/bin", + unless => "/usr/bin/apt-key list | /bin/grep '${key}'", + command => $method ? { + "content" => "echo '${key_content}' | /usr/bin/apt-key add -", + "source" => "wget -q '${key_source}' -O- | apt-key add -", + "server" => "apt-key adv --keyserver '${key_server}' --recv-keys '${key}'", + }; + } + } + } + absent: { + if defined(Exec["apt::key $key present"]) { + fail ("Cannot ensure Apt::Key[$key] absent; $key already ensured present") + } + exec { "apt::key $key absent": + path => "/bin:/usr/bin", + onlyif => "apt-key list | grep '$key'", + command => "apt-key del '$key'", + user => "root", + group => "root", + } + } + default: { + fail "Invalid 'ensure' value '$ensure' for aptkey" + } + } +} diff --git a/manifests/source.pp b/manifests/source.pp index 9f31fe9130..475bee3bf0 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -9,8 +9,9 @@ $required_packages = false, $key = false, $key_server = 'keyserver.ubuntu.com', - $pin = false, - $key_content = false + $key_content = false, + $key_source = false, + $pin = false ) { include apt::params @@ -44,18 +45,13 @@ } if $key != false { - if $key_content { - exec { "Add key: ${key} from content for ${name}": - command => "/bin/echo '${key_content}' | /usr/bin/apt-key add -", - unless => "/usr/bin/apt-key list | /bin/grep '${key}'", - before => File["${name}.list"], - } - } else { - exec { "Add key: ${key} from ${key_server} for ${name}": - command => "/usr/bin/apt-key adv --keyserver ${key_server} --recv-keys ${key}", - unless => "/usr/bin/apt-key list | /bin/grep ${key}", - before => File["${name}.list"], - } + apt::key { "Add key: ${key} from Apt::Source ${title}": + key => $key, + ensure => present, + key_server => $key_server, + key_content => $key_content, + key_source => $key_source, + before => File["${name}.list"], } } } diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb new file mode 100644 index 0000000000..88038d2783 --- /dev/null +++ b/spec/defines/key_spec.rb @@ -0,0 +1,114 @@ +require 'spec_helper' +describe 'apt::key', :type => :define do + let :title do + '8347A27F' + end + + let :default_params do + { + :key => title, + :ensure => 'present', + :key_server => "keyserver.ubuntu.com", + :key_source => false, + :key_content => false + } + end + + [{}, + { + :ensure => 'absent' + }, + { + :ensure => 'random' + }, + { + :key_source => 'ftp://ftp.example.org/key', + }, + { + :key_content => 'deadbeef', + } + ].each do |param_set| + + let :param_hash do + default_params.merge(param_set) + end + + let :params do + param_set + end + + let :digest do + str = String.new + str << param_hash[:key].to_s << '/' + str << param_hash[:key_content].to_s << '/' + str << param_hash[:key_source].to_s << '/' + str << param_hash[:key_server].to_s << '/' + Digest::SHA1.hexdigest(str) + end + + describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do + + it { + if [:present, 'present', :absent, 'absent'].include? param_hash[:ensure] + should contain_apt__params + end + } + + it { + if [:present, 'present'].include? param_hash[:ensure] + should_not contain_exec("apt::key #{param_hash[:key]} absent") + should contain_exec("apt::key #{param_hash[:key]} present") + should contain_exec(digest).with({ + "path" => "/bin:/usr/bin", + "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'" + }) + elsif [:absent, 'absent'].include? param_hash[:ensure] + should_not contain_exec("apt::key #{param_hash[:key]} present") + should contain_exec("apt::key #{param_hash[:key]} absent").with({ + "path" => "/bin:/usr/bin", + "onlyif" => "apt-key list | grep '#{param_hash[:key]}'", + "command" => "apt-key del '#{param_hash[:key]}'" + }) + else + expect { should raise_error(Puppet::Error) } + end + } + + it { + if [:present, 'present'].include? param_hash[:ensure] + if param_hash[:key_content] + should contain_exec(digest).with({ + "command" => "echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -" + }) + elsif param_hash[:key_source] + should contain_exec(digest).with({ + "command" => "wget -q '#{param_hash[:key_source]}' -O- | apt-key add -" + }) + elsif param_hash[:key_server] + should contain_exec(digest).with({ + "command" => "apt-key adv --keyserver '#{param_hash[:key_server]}' --recv-keys '#{param_hash[:key]}'" + }) + end + end + } + + end + + describe "should correctly handle duplicate definitions" do + let :pre_condition do + "apt::key { 'duplicate': key => '#{params[:key]}'; }" + end + + it { + if [:present, 'present'].include? param_hash[:ensure] + should contain_exec("apt::key #{param_hash[:key]} present") + should contain_apt__key("duplicate") + should contain_apt__key(title) + elsif [:absent, 'absent'].include? params[:ensure] + expect { should raise_error(Puppet::Error) } + end + } + + end + end +end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 041175c1ce..3cafb5251b 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -13,8 +13,9 @@ :required_packages => false, :key => false, :key_server => 'keyserver.ubuntu.com', - :pin => false, - :key_content => false + :key_content => false, + :key_source => false, + :pin => false } end @@ -110,48 +111,22 @@ it { if param_hash[:key] - if param_hash[:key_content] - should contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ - "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", - "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", - "before" => "File[#{title}.list]" - }) - else - should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ - "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", - "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", - "before" => "File[#{title}.list]" - }) - end - else - should_not contain_exec("Add key: #{param_hash[:key]} from content for #{title}").with({ - "command" => "/bin/echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -", - "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'", - "before" => "File[#{title}.list]" + should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({ + "key" => param_hash[:key], + "ensure" => :present, + "key_server" => param_hash[:key_server], + "key_content" => param_hash[:key_content], + "key_source" => param_hash[:key_source], + "before" => "File[#{title}.list]" }) - end - } - - it { - if param_hash[:key] - if param_hash[:key_content] - should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ - "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" - }) - else - should contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ - "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" - }) - end else - should_not contain_exec("Add key: #{param_hash[:key]} from #{param_hash[:key_server]} for #{title}").with({ - "command" => "/usr/bin/apt-key adv --keyserver #{param_hash[:key_server]} --recv-keys #{param_hash[:key]}", - "unless" => "/usr/bin/apt-key list | /bin/grep #{param_hash[:key]}", - "before" => "File[#{title}.list]" + should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({ + "key" => param_hash[:key], + "ensure" => :present, + "key_server" => param_hash[:key_server], + "key_content" => param_hash[:key_content], + "key_source" => param_hash[:key_source], + "before" => "File[#{title}.list]" }) end } From 1132a07f3f451ecfc0e820344a45f645dc17c153 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Thu, 1 Mar 2012 15:01:01 -0800 Subject: [PATCH 042/574] (#12917) Add contributors to README Prior to this commit, this modules README had no list of contributors. This commit adds such a list and corrects a typo I overlooked on the last pull request. --- README.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b60394f095..952e331c1d 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ apt::source { "debian_unstable": key_server => "subkeys.pgp.net", pin => "-10", include_src => true - +} + ### apt::key Add a key to the list of keys used by apt to authenticate packages.
@@ -72,5 +73,22 @@ apt::key { "jenkins":
 
 Note that use of the "key_source" parameter requires wget to be installed and working.
 
-}
-
+ +## Contributors +A lot of great people have contributed to this module. A somewhat current list follows. +Ben Godfrey +Christian G. Warden +Dan Bode +Garrett Honeycutt +Jeff Wallace +Ken Barber +Matthaus Litteken +Matthias Pigulla +Monty Taylor +Peter Drake +Reid Vandewiele +Robert Navarro +Ryan Coleman +Scott McLeod +Spencer Krum +William Van Hevelingen From d4fec561f3eb7a61570dcdca1c3b10f309b3f4d5 Mon Sep 17 00:00:00 2001 From: Reid Vandewiele Date: Wed, 7 Mar 2012 10:10:46 -0800 Subject: [PATCH 043/574] Modify apt::source release parameter test This commit modifies the release parameter test in apt::source to work correctly within puppet-rspec for edge-case resource definitions. Previously, the test for the $release parameter was written as `if ! $release { fail() }` This commit updates the test to be written as `if $release == undef { fail() }` Additionally, the tests for correct behavior in the presence or absence of a $release parameter have been beefed up. The reason for making this change relates to examples such as the following resource definition: apt::source { "jenkins": location => "http://pkg.jenkins-ci.org/debian", release => "", repos => "binary/", key => "D50582E6", key_source => "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key", include_src => false, } Note that the $release parameter is given as the empty string. In practice, this is perfectly valid and everything will work great. However, it seems that the empty string gets interpreted by something in puppet-rspec as something equivalent to "False", and thus when testing, the above resource definition would fail with "Puppet::Error: lsbdistcodename fact not available: release parameter required" even though the $release parameter has been explicitely specified (as the empty string). See also: https://github.com/rtyler/puppet-jenkins/issues/9 --- manifests/source.pp | 3 +-- spec/defines/source_spec.rb | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 4c03412c5f..42a21e9e49 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -16,7 +16,7 @@ include apt::params - if ! $release { + if $release == undef { fail("lsbdistcodename fact not available: release parameter required") } @@ -27,7 +27,6 @@ group => root, mode => 644, content => template("apt/source.list.erb"), - } if $pin != false { diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 903468e5b6..e93137e8e4 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -136,8 +136,11 @@ } end end - describe "without release should raise a Puppet::Error" do - it { expect { should contain_apt__source(:release) }.to raise_error(Puppet::Error) } - end + describe "without release should raise a Puppet::Error" do + let(:default_params) { Hash.new } + let(:facts) { Hash.new } + it { expect { should raise_error(Puppet::Error) } } + let(:facts) { { :lsbdistcodename => 'lucid' } } + it { should contain_apt__source(title) } + end end - From b9607a440d39de5cb79f84ed39544284da5970f9 Mon Sep 17 00:00:00 2001 From: Reid Vandewiele Date: Wed, 7 Mar 2012 13:49:12 -0800 Subject: [PATCH 044/574] Convert apt::key to use anchors Previously, apt::key used a noop exec hack to do exactly what anchors were intended to be used for. This commit removes the exec hack and achieves the same end using Anchor resources from the puppetlabs/stdlib module. --- manifests/key.pp | 25 ++++++++++++++++--------- spec/defines/key_spec.rb | 21 ++++++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index 24eef9e9cf..68e0c76330 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -26,21 +26,22 @@ # apt::source resources that all reference the same key. case $ensure { present: { + + anchor { "apt::key/$title":; } + if defined(Exec["apt::key $key absent"]) { fail ("Cannot ensure Apt::Key[$key] present; $key already ensured absent") - } elsif !defined(Exec["apt::key $key present"]) { - # this is a marker to ensure we don't simultaneously define a key - # ensure => absent AND ensure => present - exec { "apt::key $key present": - path => "/", - onlyif => "/bin/false", - noop => true; - } } + + if !defined(Anchor["apt::key $key present"]) { + anchor { "apt::key $key present":; } + } + if !defined(Exec[$digest]) { exec { $digest: path => "/bin:/usr/bin", unless => "/usr/bin/apt-key list | /bin/grep '${key}'", + before => Anchor["apt::key $key present"], command => $method ? { "content" => "echo '${key_content}' | /usr/bin/apt-key add -", "source" => "wget -q '${key_source}' -O- | apt-key add -", @@ -48,11 +49,16 @@ }; } } + + Anchor["apt::key $key present"] -> Anchor["apt::key/$title"] + } absent: { - if defined(Exec["apt::key $key present"]) { + + if defined(Anchor["apt::key $key present"]) { fail ("Cannot ensure Apt::Key[$key] absent; $key already ensured present") } + exec { "apt::key $key absent": path => "/bin:/usr/bin", onlyif => "apt-key list | grep '$key'", @@ -61,6 +67,7 @@ group => "root", } } + default: { fail "Invalid 'ensure' value '$ensure' for aptkey" } diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 88038d2783..a15000765e 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -57,13 +57,13 @@ it { if [:present, 'present'].include? param_hash[:ensure] should_not contain_exec("apt::key #{param_hash[:key]} absent") - should contain_exec("apt::key #{param_hash[:key]} present") + should contain_anchor("apt::key #{param_hash[:key]} present") should contain_exec(digest).with({ "path" => "/bin:/usr/bin", "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'" }) elsif [:absent, 'absent'].include? param_hash[:ensure] - should_not contain_exec("apt::key #{param_hash[:key]} present") + should_not contain_anchor("apt::key #{param_hash[:key]} present") should contain_exec("apt::key #{param_hash[:key]} absent").with({ "path" => "/bin:/usr/bin", "onlyif" => "apt-key list | grep '#{param_hash[:key]}'", @@ -93,22 +93,29 @@ } end + end + [{ :ensure => 'present' }, { :ensure => 'absent' }].each do |param_set| describe "should correctly handle duplicate definitions" do + let :pre_condition do - "apt::key { 'duplicate': key => '#{params[:key]}'; }" + "apt::key { 'duplicate': key => '#{title}'; }" end + let(:params) { param_set } + it { - if [:present, 'present'].include? param_hash[:ensure] - should contain_exec("apt::key #{param_hash[:key]} present") - should contain_apt__key("duplicate") + if param_set[:ensure] == 'present' + should contain_anchor("apt::key #{title} present") should contain_apt__key(title) - elsif [:absent, 'absent'].include? params[:ensure] + should contain_apt__key("duplicate") + elsif param_set[:ensure] == 'absent' expect { should raise_error(Puppet::Error) } end } end end + end + From 909942bfd54650ac6741ebcc7b035a4bf0e81885 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Wed, 7 Mar 2012 21:22:50 -0500 Subject: [PATCH 045/574] (#13016) Add a CHANGELOG since first commit --- CHANGELOG | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 CHANGELOG diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000000..823e5e013e --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,53 @@ +2012-03-07 Puppet Labs - 0.0.1 +d4fec56 Modify apt::source release parameter test +1132a07 (#12917) Add contributors to README +8cdaf85 (#12823) Add apt::key defined type and modify apt::source to use it +7c0d10b (#12809) $release should use $lsbdistcodename and fall back to manual input +be2cc3e (#12522) Adjust spec test for splitting purge +7dc60ae (#12522) Split purge option to spare sources.list +9059c4e Fix source specs to test all key permutations +8acb202 Add test for python-software-properties package +a4af11f Check if python-software-properties is defined before attempting to define it. +1dcbf3d Add tests for required_packages change +f3735d2 Allow duplicate $required_packages +74c8371 (#12430) Add tests for changes to apt module +97ebb2d Test two sources with the same key +1160bcd (#12526) Add ability to reverse apt { disable_keys => true } +2842d73 Add Modulefile to puppet-apt +c657742 Allow the use of the same key in multiple sources +8c27963 (#12522) Adding purge option to apt class +997c9fd (#12529) Add unit test for apt proxy settings +50f3cca (#12529) Add parameter to support setting a proxy for apt +d522877 (#12094) Replace chained .with_* with a hash +8cf1bd0 (#12094) Remove deprecated spec.opts file +2d688f4 (#12094) Add rspec-puppet tests for apt +0fb5f78 (#12094) Replace name with path in file resources +f759bc0 (#11953) Apt::force passes $version to aptitude +f71db53 (#11413) Add spec test for apt::force to verify changes to unless +2f5d317 (#11413) Update dpkg query used by apt::force +cf6caa1 (#10451) Add test coverage to apt::ppa +0dd697d include_src parameter in example; Whitespace cleanup +b662eb8 fix typos in "repositories" +1be7457 Fix (#10451) - apt::ppa fails to "apt-get update" when new PPA source is added +864302a Set the pin priority before adding the source (Fix #10449) +1de4e0a Refactored as per mlitteken +1af9a13 Added some crazy bash madness to check if the ppa is installed already. Otherwise the manifest tries to add it on every run! +52ca73e (#8720) Replace Apt::Ppa with Apt::Builddep +5c05fa0 added builddep command. +a11af50 added the ability to specify the content of a key +c42db0f Fixes ppa test. +77d2b0d reformatted whitespace to match recommended style of 2 space indentation. +27ebdfc ignore swap files. +377d58a added smoke tests for module. +18f614b reformatted apt::ppa according to recommended style. +d8a1e4e Created a params class to hold global data. +636ae85 Added two params for apt class +148fc73 Update LICENSE. +ed2d19e Support ability to add more than one PPA +420d537 Add call to apt-update after add-apt-repository in apt::ppa +945be77 Add package definition for python-software-properties +71fc425 Abs paths for all commands +9d51cd1 Adding LICENSE +71796e3 Heading fix in README +87777d8 Typo in README +f848bac First commit From 5148cbf5a67b56f3e8fe33a082180c16f1e635f9 Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Wed, 14 Mar 2012 15:36:33 -0700 Subject: [PATCH 046/574] (#13125) Apt keys should be case insensitive Previously lowercase keys would be installed every puppet run because apt-key list returns an uppercase key. This commit makes the comparison case insensitive. --- manifests/key.pp | 30 ++++++++++++++++-------------- spec/defines/key_spec.rb | 4 +++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index 68e0c76330..c6e5f6e565 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -8,6 +8,8 @@ include apt::params + $upkey = upcase($key) + if $key_content { $method = "content" } elsif $key_source { @@ -20,7 +22,7 @@ # It is used as a unique identifier for this instance of apt::key. It gets # hashed to ensure that the resource name doesn't end up being pages and # pages (e.g. in the situation where key_content is specified). - $digest = sha1("${key}/${key_content}/${key_source}/${key_server}/") + $digest = sha1("${upkey}/${key_content}/${key_source}/${key_server}/") # Allow multiple ensure => present for the same key to account for many # apt::source resources that all reference the same key. @@ -29,40 +31,40 @@ anchor { "apt::key/$title":; } - if defined(Exec["apt::key $key absent"]) { - fail ("Cannot ensure Apt::Key[$key] present; $key already ensured absent") + if defined(Exec["apt::key $upkey absent"]) { + fail ("Cannot ensure Apt::Key[$upkey] present; $upkey already ensured absent") } - if !defined(Anchor["apt::key $key present"]) { - anchor { "apt::key $key present":; } + if !defined(Anchor["apt::key $upkey present"]) { + anchor { "apt::key $upkey present":; } } if !defined(Exec[$digest]) { exec { $digest: path => "/bin:/usr/bin", - unless => "/usr/bin/apt-key list | /bin/grep '${key}'", - before => Anchor["apt::key $key present"], + unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'", + before => Anchor["apt::key $upkey present"], command => $method ? { "content" => "echo '${key_content}' | /usr/bin/apt-key add -", "source" => "wget -q '${key_source}' -O- | apt-key add -", - "server" => "apt-key adv --keyserver '${key_server}' --recv-keys '${key}'", + "server" => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'", }; } } - Anchor["apt::key $key present"] -> Anchor["apt::key/$title"] + Anchor["apt::key $upkey present"] -> Anchor["apt::key/$title"] } absent: { - if defined(Anchor["apt::key $key present"]) { - fail ("Cannot ensure Apt::Key[$key] absent; $key already ensured present") + if defined(Anchor["apt::key $upkey present"]) { + fail ("Cannot ensure Apt::Key[$upkey] absent; $upkey already ensured present") } - exec { "apt::key $key absent": + exec { "apt::key $upkey absent": path => "/bin:/usr/bin", - onlyif => "apt-key list | grep '$key'", - command => "apt-key del '$key'", + onlyif => "apt-key list | grep '$upkey'", + command => "apt-key del '$upkey'", user => "root", group => "root", } diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index a15000765e..aea197a7b2 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -30,7 +30,9 @@ ].each do |param_set| let :param_hash do - default_params.merge(param_set) + param_hash = default_params.merge(param_set) + param_hash[:key].upcase! if param_hash[:key] + param_hash end let :params do From 99c3fd354d904e03f1d2ac21f25952b0932e2f69 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Wed, 21 Mar 2012 13:19:05 +0000 Subject: [PATCH 047/574] (#13289) Add puppet lint tests to Rakefile --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 6242a3704b..705d50de2f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ require 'rake' +require 'puppet-lint/tasks/puppet-lint' task :default => [:spec] From a758247f2632b3204167a8058fbb8903f0438841 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Wed, 21 Mar 2012 13:20:13 +0000 Subject: [PATCH 048/574] (#13289) Clean up style violations and fix corresponding tests --- manifests/builddep.pp | 2 +- manifests/debian/testing.pp | 16 ++++++------ manifests/debian/unstable.pp | 28 ++++++++++---------- manifests/force.pp | 11 ++++---- manifests/init.pp | 50 ++++++++++++++++++------------------ manifests/key.pp | 34 ++++++++++++------------ manifests/pin.pp | 11 ++++---- manifests/ppa.pp | 8 +++--- manifests/release.pp | 6 ++--- manifests/source.pp | 22 ++++++++-------- spec/classes/apt_spec.rb | 4 +-- spec/classes/release_spec.rb | 2 +- spec/defines/pin_spec.rb | 10 ++++---- spec/defines/source_spec.rb | 10 ++++---- tests/source.pp | 42 +++++++++++++++--------------- 15 files changed, 129 insertions(+), 127 deletions(-) diff --git a/manifests/builddep.pp b/manifests/builddep.pp index 8aebc679ae..8891bd903b 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -5,7 +5,7 @@ Class['apt'] -> Apt::Builddep[$name] exec { "apt-update-${name}": - command => "/usr/bin/apt-get update", + command => '/usr/bin/apt-get update', refreshonly => true, } diff --git a/manifests/debian/testing.pp b/manifests/debian/testing.pp index 4eec1f8dbb..cfdeb3cf73 100644 --- a/manifests/debian/testing.pp +++ b/manifests/debian/testing.pp @@ -8,14 +8,14 @@ # debian-keyring # debian-archive-keyring - apt::source { "debian_testing": - location => "http://debian.mirror.iweb.ca/debian/", - release => "testing", - repos => "main contrib non-free", - required_packages => "debian-keyring debian-archive-keyring", - key => "55BE302B", - key_server => "subkeys.pgp.net", - pin => "-10" + apt::source { 'debian_testing': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'testing', + repos => 'main contrib non-free', + required_packages => 'debian-keyring debian-archive-keyring', + key => '55BE302B', + key_server => 'subkeys.pgp.net', + pin => '-10', } } diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp index 782440fb30..3991023d17 100644 --- a/manifests/debian/unstable.pp +++ b/manifests/debian/unstable.pp @@ -2,20 +2,20 @@ class apt::debian::unstable { - # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free - # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free - # Key: 55BE302B Server: subkeys.pgp.net - # debian-keyring - # debian-archive-keyring + # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free + # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free + # Key: 55BE302B Server: subkeys.pgp.net + # debian-keyring + # debian-archive-keyring - apt::source { "debian_unstable": - location => "http://debian.mirror.iweb.ca/debian/", - release => "unstable", - repos => "main contrib non-free", - required_packages => "debian-keyring debian-archive-keyring", - key => "55BE302B", - key_server => "subkeys.pgp.net", - pin => "-10" - } + apt::source { 'debian_unstable': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + required_packages => 'debian-keyring debian-archive-keyring', + key => '55BE302B', + key_server => 'subkeys.pgp.net', + pin => '-10', + } } diff --git a/manifests/force.pp b/manifests/force.pp index ec6f57e2cc..45c5679292 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -7,15 +7,16 @@ ) { $version_string = $version ? { - false => undef, + false => undef, default => "=${version}", } + $install_check = $version ? { + false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'", + default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'", + } exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}": - unless => $version ? { - false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'", - default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" - } + unless => $install_check, } } diff --git a/manifests/init.pp b/manifests/init.pp index b41d359fbd..1a5c7e0c65 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -33,57 +33,57 @@ validate_bool($purge_sources_list, $purge_sources_list_d) $refresh_only_apt_update = $always_apt_update? { - true => false, - false => true + true => false, + false => true, } - if ! defined(Package["python-software-properties"]) { - package { "python-software-properties": } + if ! defined(Package['python-software-properties']) { + package { 'python-software-properties': } } - file { "sources.list": - path => "${apt::params::root}/sources.list", - ensure => present, - owner => root, - group => root, - mode => 644, + file { 'sources.list': + ensure => present, + path => "${apt::params::root}/sources.list", + owner => root, + group => root, + mode => '0644', content => $purge_sources_list ? { false => undef, true => "# Repos managed by puppet.\n", }, } - file { "sources.list.d": - path => "${apt::params::root}/sources.list.d", - ensure => directory, - owner => root, - group => root, - purge => $purge_sources_list_d, + file { 'sources.list.d': + ensure => directory, + path => "${apt::params::root}/sources.list.d", + owner => root, + group => root, + purge => $purge_sources_list_d, recurse => $purge_sources_list_d, } - exec { "apt_update": - command => "${apt::params::provider} update", - subscribe => [ File["sources.list"], File["sources.list.d"] ], + exec { 'apt_update': + command => "${apt::params::provider} update", + subscribe => [ File['sources.list'], File['sources.list.d'] ], refreshonly => $refresh_only_apt_update, } case $disable_keys { true: { - file { "99unauth": - content => "APT::Get::AllowUnauthenticated 1;\n", + file { '99unauth': ensure => present, - path => "/etc/apt/apt.conf.d/99unauth", + content => "APT::Get::AllowUnauthenticated 1;\n", + path => '/etc/apt/apt.conf.d/99unauth', } } false: { - file { "99unauth": + file { '99unauth': ensure => absent, - path => "/etc/apt/apt.conf.d/99unauth", + path => '/etc/apt/apt.conf.d/99unauth', } } undef: { } # do nothing - default: { fail("Valid values for disable_keys are true or false") } + default: { fail('Valid values for disable_keys are true or false') } } if($proxy_host) { diff --git a/manifests/key.pp b/manifests/key.pp index c6e5f6e565..63165f7546 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -3,7 +3,7 @@ $ensure = present, $key_content = false, $key_source = false, - $key_server = "keyserver.ubuntu.com" + $key_server = 'keyserver.ubuntu.com' ) { include apt::params @@ -11,11 +11,11 @@ $upkey = upcase($key) if $key_content { - $method = "content" + $method = 'content' } elsif $key_source { - $method = "source" + $method = 'source' } elsif $key_server { - $method = "server" + $method = 'server' } # This is a hash of the parts of the key definition that we care about. @@ -29,7 +29,7 @@ case $ensure { present: { - anchor { "apt::key/$title":; } + anchor { "apt::key/${title}":; } if defined(Exec["apt::key $upkey absent"]) { fail ("Cannot ensure Apt::Key[$upkey] present; $upkey already ensured absent") @@ -41,14 +41,14 @@ if !defined(Exec[$digest]) { exec { $digest: - path => "/bin:/usr/bin", + path => '/bin:/usr/bin', unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'", - before => Anchor["apt::key $upkey present"], + before => Anchor["apt::key ${upkey} present"], command => $method ? { - "content" => "echo '${key_content}' | /usr/bin/apt-key add -", - "source" => "wget -q '${key_source}' -O- | apt-key add -", - "server" => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'", - }; + 'content' => "echo '${key_content}' | /usr/bin/apt-key add -", + 'source' => "wget -q '${key_source}' -O- | apt-key add -", + 'server' => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'", + }, } } @@ -62,16 +62,16 @@ } exec { "apt::key $upkey absent": - path => "/bin:/usr/bin", - onlyif => "apt-key list | grep '$upkey'", - command => "apt-key del '$upkey'", - user => "root", - group => "root", + path => '/bin:/usr/bin', + onlyif => "apt-key list | grep '${upkey}'", + command => "apt-key del '${upkey}'", + user => 'root', + group => 'root', } } default: { - fail "Invalid 'ensure' value '$ensure' for aptkey" + fail "Invalid 'ensure' value '${ensure}' for aptkey" } } } diff --git a/manifests/pin.pp b/manifests/pin.pp index 40695af5fa..95d445c21c 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -8,12 +8,13 @@ include apt::params + $pcontent = "# ${name}\nPackage: ${packages}\nPin: release a=${name}\nPin-Priority: ${priority}" file { "${name}.pref": - path => "${apt::params::root}/preferences.d/${name}", - ensure => file, - owner => root, - group => root, - mode => 644, + ensure => file, + path => "${apt::params::root}/preferences.d/${name}", + owner => root, + group => root, + mode => '0644', content => "# ${name}\nPackage: ${packages}\nPin: release a=${name}\nPin-Priority: ${priority}", } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 712f425f49..095d8f17b2 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -9,17 +9,17 @@ include apt::params if ! $release { - fail("lsbdistcodename fact not available: release parameter required") + fail('lsbdistcodename fact not available: release parameter required') } exec { "apt-update-${name}": - command => "/usr/bin/aptitude update", + command => '/usr/bin/aptitude update', refreshonly => true, } $filename_without_slashes = regsubst($name,'/','-','G') - $filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G') - $sources_list_d_filename = "${filename_without_ppa}-${release}.list" + $filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G') + $sources_list_d_filename = "${filename_without_ppa}-${release}.list" exec { "add-apt-repository-${name}": command => "/usr/bin/add-apt-repository ${name}", diff --git a/manifests/release.pp b/manifests/release.pp index 9fc0aa38dd..ee94e139fa 100644 --- a/manifests/release.pp +++ b/manifests/release.pp @@ -7,9 +7,9 @@ include apt::params file { "${apt::params::root}/apt.conf.d/01release": - owner => root, - group => root, - mode => 644, + owner => root, + group => root, + mode => '0644', content => "APT::Default-Release \"${release_id}\";" } } diff --git a/manifests/source.pp b/manifests/source.pp index 42a21e9e49..95768dcfaa 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -17,25 +17,25 @@ include apt::params if $release == undef { - fail("lsbdistcodename fact not available: release parameter required") + fail('lsbdistcodename fact not available: release parameter required') } file { "${name}.list": - path => "${apt::params::root}/sources.list.d/${name}.list", - ensure => file, - owner => root, - group => root, - mode => 644, - content => template("apt/source.list.erb"), + ensure => file, + path => "${apt::params::root}/sources.list.d/${name}.list", + owner => root, + group => root, + mode => '0644', + content => template("${module_name}/source.list.erb"), } if $pin != false { - apt::pin { "${release}": priority => "${pin}" } -> File["${name}.list"] + apt::pin { $release: priority => $pin } -> File["${name}.list"] } exec { "${name} apt update": - command => "${apt::params::provider} update", - subscribe => File["${name}.list"], + command => "${apt::params::provider} update", + subscribe => File["${name}.list"], refreshonly => true, } @@ -49,8 +49,8 @@ if $key != false { apt::key { "Add key: ${key} from Apt::Source ${title}": - key => $key, ensure => present, + key => $key, key_server => $key_server, key_content => $key_content, key_source => $key_source, diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 71a438e062..000793d092 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -50,7 +50,7 @@ 'ensure' => "present", 'owner' => "root", 'group' => "root", - 'mode' => 644, + 'mode' => "0644", "content" => "# Repos managed by puppet.\n" }) else @@ -59,7 +59,7 @@ 'ensure' => "present", 'owner' => "root", 'group' => "root", - 'mode' => 644, + 'mode' => "0644", 'content' => nil }) end diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb index 221df03683..d131b22810 100644 --- a/spec/classes/release_spec.rb +++ b/spec/classes/release_spec.rb @@ -12,9 +12,9 @@ it { should contain_file("/etc/apt/apt.conf.d/01release").with({ + "mode" => "0644", "owner" => "root", "group" => "root", - "mode" => 644, "content" => "APT::Default-Release \"#{param_set[:release_id]}\";" }) } diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 52c6bfae19..dbc595c568 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -27,12 +27,12 @@ it { should include_class("apt::params") } it { should contain_file("#{title}.pref").with({ + 'ensure' => 'file', 'path' => "/etc/apt/preferences.d/#{title}", - 'ensure' => "file", - 'owner' => "root", - 'group' => "root", - 'mode' => "644", - 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}" + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}", }) } end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index e93137e8e4..284342940b 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -66,12 +66,12 @@ it { should contain_apt__params } it { should contain_file("#{title}.list").with({ + 'ensure' => 'file', 'path' => filename, - 'ensure' => "file", - 'owner' => "root", - 'group' => "root", - 'mode' => 644, - 'content' => content + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'content' => content, }) } diff --git a/tests/source.pp b/tests/source.pp index 4db740d417..a8702cf58a 100644 --- a/tests/source.pp +++ b/tests/source.pp @@ -1,29 +1,29 @@ class { 'apt': } apt::source { 'foo': - location => '', - release => 'karmic', - repos => 'main', - include_src => true, + location => '', + release => 'karmic', + repos => 'main', + include_src => true, required_packages => false, - key => false, - key_server => 'keyserver.ubuntu.com', - pin => '600' + key => false, + key_server => 'keyserver.ubuntu.com', + pin => '600', } # test two sources with the same key -apt::source { "debian_testing": - location => "http://debian.mirror.iweb.ca/debian/", - release => "testing", - repos => "main contrib non-free", - key => "55BE302B", - key_server => "subkeys.pgp.net", - pin => "-10" +apt::source { 'debian_testing': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'testing', + repos => 'main contrib non-free', + key => '55BE302B', + key_server => 'subkeys.pgp.net', + pin => '-10', } -apt::source { "debian_unstable": - location => "http://debian.mirror.iweb.ca/debian/", - release => "unstable", - repos => "main contrib non-free", - key => "55BE302B", - key_server => "subkeys.pgp.net", - pin => "-10" +apt::source { 'debian_unstable': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + key => '55BE302B', + key_server => 'subkeys.pgp.net', + pin => '-10', } From 0ea4ffa9a238d1f8fcbf6a73cba472ede78a4e18 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Wed, 21 Mar 2012 13:21:50 +0000 Subject: [PATCH 049/574] (#13289) Change test scaffolding to use a module & manifest dir fixture path This removes the need for depending on a global site.pp, and depending on the checked out apt module to be called 'apt' as well. It pulls in stdlib via sub-modules as I don't have a better way to deal with dependencies yet. It has pinned the revision for stdlib to 2.2.1 which is the minimum required version for apt to work. --- .gitmodules | 3 +++ spec/fixtures/manifests/site.pp | 0 spec/fixtures/modules/apt | 1 + spec/fixtures/modules/stdlib | 1 + spec/spec_helper.rb | 7 +++++-- 5 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 100644 spec/fixtures/manifests/site.pp create mode 120000 spec/fixtures/modules/apt create mode 160000 spec/fixtures/modules/stdlib diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..eb34d3b96b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "spec/fixtures/modules/stdlib"] + path = spec/fixtures/modules/stdlib + url = https://github.com/puppetlabs/puppetlabs-stdlib.git diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spec/fixtures/modules/apt b/spec/fixtures/modules/apt new file mode 120000 index 0000000000..1b20c9fb81 --- /dev/null +++ b/spec/fixtures/modules/apt @@ -0,0 +1 @@ +../../../ \ No newline at end of file diff --git a/spec/fixtures/modules/stdlib b/spec/fixtures/modules/stdlib new file mode 160000 index 0000000000..a70b09d5de --- /dev/null +++ b/spec/fixtures/modules/stdlib @@ -0,0 +1 @@ +Subproject commit a70b09d5de035de5254ebe6ad6e1519a6d7cf588 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d2648da2b2..46fe2371c9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,11 +1,14 @@ -require 'puppet' require 'rubygems' +require 'puppet' require 'rspec-puppet' def param_value(subject, type, title, param) subject.resource(type, title).send(:parameters)[param.to_sym] end +fixture_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) + RSpec.configure do |c| - c.module_path = File.join(File.dirname(__FILE__), '../../') + c.module_path = File.join(fixture_path, 'modules') + c.manifest_dir = File.join(fixture_path, 'manifests') end From 9c13872b5a4e08748695c9a7f99fc4ef844a8c29 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Wed, 21 Mar 2012 13:35:48 +0000 Subject: [PATCH 050/574] (#13289) Fix some more style violations --- manifests/init.pp | 9 +++++---- manifests/key.pp | 25 +++++++++++++------------ manifests/pin.pp | 1 - 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 1a5c7e0c65..29db697c14 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -41,16 +41,17 @@ package { 'python-software-properties': } } + $sources_list_content = $purge_sources_list ? { + false => undef, + true => "# Repos managed by puppet.\n", + } file { 'sources.list': ensure => present, path => "${apt::params::root}/sources.list", owner => root, group => root, mode => '0644', - content => $purge_sources_list ? { - false => undef, - true => "# Repos managed by puppet.\n", - }, + content => $sources_list_content, } file { 'sources.list.d': diff --git a/manifests/key.pp b/manifests/key.pp index 63165f7546..e87968d7fb 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -31,24 +31,25 @@ anchor { "apt::key/${title}":; } - if defined(Exec["apt::key $upkey absent"]) { - fail ("Cannot ensure Apt::Key[$upkey] present; $upkey already ensured absent") + if defined(Exec["apt::key ${upkey} absent"]) { + fail("Cannot ensure Apt::Key[${upkey}] present; ${upkey} already ensured absent") } - if !defined(Anchor["apt::key $upkey present"]) { - anchor { "apt::key $upkey present":; } + if !defined(Anchor["apt::key ${upkey} present"]) { + anchor { "apt::key ${upkey} present":; } } if !defined(Exec[$digest]) { + $digest_command = $method ? { + 'content' => "echo '${key_content}' | /usr/bin/apt-key add -", + 'source' => "wget -q '${key_source}' -O- | apt-key add -", + 'server' => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'", + } exec { $digest: path => '/bin:/usr/bin', unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'", before => Anchor["apt::key ${upkey} present"], - command => $method ? { - 'content' => "echo '${key_content}' | /usr/bin/apt-key add -", - 'source' => "wget -q '${key_source}' -O- | apt-key add -", - 'server' => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'", - }, + command => $digest_command, } } @@ -57,11 +58,11 @@ } absent: { - if defined(Anchor["apt::key $upkey present"]) { - fail ("Cannot ensure Apt::Key[$upkey] absent; $upkey already ensured present") + if defined(Anchor["apt::key ${upkey} present"]) { + fail("Cannot ensure Apt::Key[${upkey}] absent; ${upkey} already ensured present") } - exec { "apt::key $upkey absent": + exec { "apt::key ${upkey} absent": path => '/bin:/usr/bin', onlyif => "apt-key list | grep '${upkey}'", command => "apt-key del '${upkey}'", diff --git a/manifests/pin.pp b/manifests/pin.pp index 95d445c21c..46613667eb 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -8,7 +8,6 @@ include apt::params - $pcontent = "# ${name}\nPackage: ${packages}\nPin: release a=${name}\nPin-Priority: ${priority}" file { "${name}.pref": ensure => file, path => "${apt::params::root}/preferences.d/${name}", From 1ead0bf3abbc1e683c9095e486ecd992d76d4b57 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Tue, 20 Mar 2012 14:18:46 -0700 Subject: [PATCH 051/574] Ignore pkg directory. This commit modifies .gitingore to ignore changes to the pkg directory used when building Forge releases. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1377554ebe..444fe1a3a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +pkg/ From 7116c7a62494789ed377c45a4efe21b8a6a1264c Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Tue, 20 Mar 2012 14:52:43 -0700 Subject: [PATCH 052/574] (#13261) Replace foo source with puppetlabs source Prior to this commit, the source.pp test included an apt source named foo which broke the apt-get update exec when applied on a target system. This commit removes it in favor of the puppetlabs apt source which is valid on all target platforms. --- tests/source.pp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/source.pp b/tests/source.pp index a8702cf58a..9ebcd5209e 100644 --- a/tests/source.pp +++ b/tests/source.pp @@ -1,13 +1,12 @@ +# Declare the apt class to manage /etc/apt/sources.list and /etc/sources.list.d class { 'apt': } -apt::source { 'foo': - location => '', - release => 'karmic', - repos => 'main', - include_src => true, - required_packages => false, - key => false, - key_server => 'keyserver.ubuntu.com', - pin => '600', + +# Install the puppetlabs apt source +apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', } # test two sources with the same key From d159a78a8ff7cc51a2bac697bca07d424d062de7 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Tue, 20 Mar 2012 14:55:01 -0700 Subject: [PATCH 053/574] (#13261) Add key.pp smoke test This commit adds a smoke test for key.pp, adding a key declaration for the puppetlabs apt source. --- tests/key.pp | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/key.pp diff --git a/tests/key.pp b/tests/key.pp new file mode 100644 index 0000000000..5c62a4c0d8 --- /dev/null +++ b/tests/key.pp @@ -0,0 +1,5 @@ +# Declare Apt key for apt.puppetlabs.com source +apt::key { "puppetlabs": + key => "4BD6EC30", + key_server => "pgp.mit.edu", +} From 41cedbb7ba1fd5e5de4bf5ff3dc117e4f88327f8 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Tue, 20 Mar 2012 15:52:44 -0700 Subject: [PATCH 054/574] (#13261) Add real examples to smoke tests. This commit modifies some smoke tests with real-world usage examples instead of providing things like 'foo' that the module user must replace in order to conduct a smoke test or try out example functionality. --- tests/builddep.pp | 2 +- tests/ppa.pp | 4 +++- tests/release.pp | 2 +- tests/source.pp | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/builddep.pp b/tests/builddep.pp index c5a7a20da1..8b4f796408 100644 --- a/tests/builddep.pp +++ b/tests/builddep.pp @@ -1,2 +1,2 @@ class { 'apt': } -apt::builddep{ 'foo': } +apt::builddep{ 'glusterfs-server': } diff --git a/tests/ppa.pp b/tests/ppa.pp index 495866c15b..e728f6f10f 100644 --- a/tests/ppa.pp +++ b/tests/ppa.pp @@ -1,2 +1,4 @@ class { 'apt': } -apt::ppa{ 'foo': } + +# Example declaration of an Apt PPA +apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': } diff --git a/tests/release.pp b/tests/release.pp index 04be75985e..823f5861fa 100644 --- a/tests/release.pp +++ b/tests/release.pp @@ -1,4 +1,4 @@ class { 'apt': } class { 'apt::release': - release_id => 'foo' + release_id => 'karmic' } diff --git a/tests/source.pp b/tests/source.pp index 9ebcd5209e..d83cb9787a 100644 --- a/tests/source.pp +++ b/tests/source.pp @@ -2,6 +2,7 @@ class { 'apt': } # Install the puppetlabs apt source +# Release is automatically obtained from lsbdistcodename fact if available. apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', repos => 'main', From 1218d1103cd2f6f75257c830f8637eb11b92abc2 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Mon, 26 Mar 2012 17:01:54 -0700 Subject: [PATCH 055/574] Updated CHANGELOG and Modulefile for 0.0.2 This commit updates both the Modulefile and CHANGELOG for the 0.0.2 Puppet Forge release. --- CHANGELOG | 12 ++++++++++++ Modulefile | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 823e5e013e..dcd1f93efc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,15 @@ +2012-03-26 Puppet Labs - 0.0.2 +41cedbb (#13261) Add real examples to smoke tests. +d159a78 (#13261) Add key.pp smoke test +7116c7a (#13261) Replace foo source with puppetlabs source +1ead0bf Ignore pkg directory. +9c13872 (#13289) Fix some more style violations +0ea4ffa (#13289) Change test scaffolding to use a module & manifest dir fixture path +a758247 (#13289) Clean up style violations and fix corresponding tests +99c3fd3 (#13289) Add puppet lint tests to Rakefile +5148cbf (#13125) Apt keys should be case insensitive +b9607a4 Convert apt::key to use anchors + 2012-03-07 Puppet Labs - 0.0.1 d4fec56 Modify apt::source release parameter test 1132a07 (#12917) Add contributors to README diff --git a/Modulefile b/Modulefile index 635f15755f..60d8fd7344 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppet-apt' -version '0.0.1' +version '0.0.2' source 'https://github.com/puppetlabs/puppet-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From e656c65818f1140e396e83610ab7f06f0f07db79 Mon Sep 17 00:00:00 2001 From: Thomas Broyer Date: Fri, 30 Mar 2012 17:48:31 +0200 Subject: [PATCH 056/574] Make sure we configure the proxy before doing apt-get update. --- manifests/init.pp | 3 ++- spec/classes/apt_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 29db697c14..ba53fd2a23 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -87,10 +87,11 @@ default: { fail('Valid values for disable_keys are true or false') } } - if($proxy_host) { + if ($proxy_host) { file { 'configure-apt-proxy': path => '/etc/apt/apt.conf.d/proxy', content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", + notify => Exec['apt_update'], } } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 000793d092..079bd59c5b 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -117,7 +117,8 @@ if param_hash[:proxy_host] should contain_file('configure-apt-proxy').with( 'path' => '/etc/apt/apt.conf.d/proxy', - 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";" + 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";", + 'notify' => "Exec[apt_update]" ) else should_not contain_file('configure_apt_proxy') From e5f2dfe294a563f5ebcec3d31949a81e1815db6e Mon Sep 17 00:00:00 2001 From: Cody Herriges Date: Wed, 11 Apr 2012 14:54:13 -0700 Subject: [PATCH 057/574] Adds apt::{conf,backports} and variable style. With the addition of this patch two new defines will be added; one to manage APT configuration files (apt::conf) and one that abstracts out the requirements needed to turn on backport repositories (apt::backports). In addition, the patch takes the opportunity to clean up variable definitions so they follow a consistent pattern of setting local variables to the fully qualified value stored in the apt::params class. Previously all variable used within a class directly addressed the apt::params namespace when ever the variable was used. In the pattern they now adhere to we can more easily switch the namespace data lives in or externalize it even more using hiera. --- manifests/backports.pp | 45 ++++++++++++++++++++++++++++++++++++ manifests/conf.pp | 17 ++++++++++++++ manifests/debian/testing.pp | 2 +- manifests/debian/unstable.pp | 2 +- manifests/force.pp | 1 - manifests/init.pp | 18 ++++++++++----- manifests/params.pp | 18 +++++++++++++++ manifests/pin.pp | 4 +++- manifests/ppa.pp | 7 +++--- manifests/release.pp | 4 +++- manifests/source.pp | 9 +++++--- 11 files changed, 110 insertions(+), 17 deletions(-) create mode 100644 manifests/backports.pp create mode 100644 manifests/conf.pp diff --git a/manifests/backports.pp b/manifests/backports.pp new file mode 100644 index 0000000000..6734e05297 --- /dev/null +++ b/manifests/backports.pp @@ -0,0 +1,45 @@ +# This adds the necessary components to get backports for ubuntu and debian +# +# == Parameters +# +# [*release*] +# The ubuntu/debian release name. Defaults to $lsbdistcodename. Setting this +# manually can cause undefined behavior. (Read: universe exploding) +# +# == Examples +# +# include apt::backports +# +# class { 'apt::backports': +# release => 'natty', +# } +# +# == Authors +# +# Ben Hughes, I think. At least blame him if this goes wrong. I just added puppet doc. +# +# == Copyright +# +# Copyright 2011 Puppet Labs Inc, unless otherwise noted. +class apt::backports( + $release = $lsbdistcodename, + $location = $apt::params::backports_locations +) inherits apt::params { + + apt::source { 'backports.list': + location => $location, + release => "${release}-backports", + repos => $lsbdistid ? { + 'debian' => 'main contrib non-free', + 'ubuntu' => 'universe multiverse restricted', + }, + key => $lsbdistid ? { + 'debian' => '55BE302B', + 'ubuntu' => '437D05B5', + }, + key_server => 'pgp.mit.edu', + pin => '200', + notify => Exec["apt-get update"], + } +} + diff --git a/manifests/conf.pp b/manifests/conf.pp new file mode 100644 index 0000000000..6be1a67fac --- /dev/null +++ b/manifests/conf.pp @@ -0,0 +1,17 @@ +define apt::conf ( + $priority = '50', + $content + ) { + + include apt::params + + $root = "${apt::params::root}" + $apt_conf_d = "${apt::params::apt_conf_d}" + + file { "${apt_conf_d}/${priority}${name}": + content => $content, + owner => root, + group => root, + mode => 0644, + } +} diff --git a/manifests/debian/testing.pp b/manifests/debian/testing.pp index cfdeb3cf73..45133470fa 100644 --- a/manifests/debian/testing.pp +++ b/manifests/debian/testing.pp @@ -1,6 +1,7 @@ # testing.pp class apt::debian::testing { + include apt # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free @@ -17,5 +18,4 @@ key_server => 'subkeys.pgp.net', pin => '-10', } - } diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp index 3991023d17..401c9c5cda 100644 --- a/manifests/debian/unstable.pp +++ b/manifests/debian/unstable.pp @@ -1,6 +1,7 @@ # unstable.pp class apt::debian::unstable { + include apt # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free @@ -17,5 +18,4 @@ key_server => 'subkeys.pgp.net', pin => '-10', } - } diff --git a/manifests/force.pp b/manifests/force.pp index 45c5679292..0089bbd753 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -18,5 +18,4 @@ exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}": unless => $install_check, } - } diff --git a/manifests/init.pp b/manifests/init.pp index 29db697c14..5668d11005 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -45,9 +45,15 @@ false => undef, true => "# Repos managed by puppet.\n", } + + $root = $apt::params::root + $apt_conf_d = $apt::params::apt_conf_d + $sources_list_d = $apt::params::sources_list_d + $provider = $apt::params::provider + file { 'sources.list': ensure => present, - path => "${apt::params::root}/sources.list", + path => "${root}/sources.list", owner => root, group => root, mode => '0644', @@ -56,7 +62,7 @@ file { 'sources.list.d': ensure => directory, - path => "${apt::params::root}/sources.list.d", + path => $sources_list_d owner => root, group => root, purge => $purge_sources_list_d, @@ -64,7 +70,7 @@ } exec { 'apt_update': - command => "${apt::params::provider} update", + command => "${provider} update", subscribe => [ File['sources.list'], File['sources.list.d'] ], refreshonly => $refresh_only_apt_update, } @@ -74,13 +80,13 @@ file { '99unauth': ensure => present, content => "APT::Get::AllowUnauthenticated 1;\n", - path => '/etc/apt/apt.conf.d/99unauth', + path => "${apt_conf_d}/99unauth", } } false: { file { '99unauth': ensure => absent, - path => '/etc/apt/apt.conf.d/99unauth', + path => "${apt_conf_d}/99unauth", } } undef: { } # do nothing @@ -89,7 +95,7 @@ if($proxy_host) { file { 'configure-apt-proxy': - path => '/etc/apt/apt.conf.d/proxy', + path => "${apt_conf_d}/proxy", content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", } } diff --git a/manifests/params.pp b/manifests/params.pp index ca5d65521d..79989c08a4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -2,4 +2,22 @@ $root = '/etc/apt' $provider = '/usr/bin/apt-get' $sources_list_d = "${root}/sources.list.d" + $apt_conf_d = "${root}/apt.conf.d" + $preferences_d = "${root}/preferences.d" + + case $lsbdistid { + 'debian': { + $backports_location = 'http://backports.debian.org/debian-backports' + } + 'ubuntu': { + case $lsbdistcodename { + 'hardy','lucid','maverick','natty','oneiric','precise': { + $backports_location = http://us.archive.ubuntu.com/ubuntuk + } + default: { + $backports_location = 'http://old-releases.ubuntu.com/ubuntu', + } + } + } + } } diff --git a/manifests/pin.pp b/manifests/pin.pp index 46613667eb..2899fce77a 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -8,9 +8,11 @@ include apt::params + $preferences_d = $apt::params::preferences_d + file { "${name}.pref": ensure => file, - path => "${apt::params::root}/preferences.d/${name}", + path => "${preferences_d}/${name}", owner => root, group => root, mode => '0644', diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 095d8f17b2..2e4daa5d34 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -8,6 +8,8 @@ include apt::params + $sources_list_d = $apt::params::sources_list_d + if ! $release { fail('lsbdistcodename fact not available: release parameter required') } @@ -24,13 +26,12 @@ exec { "add-apt-repository-${name}": command => "/usr/bin/add-apt-repository ${name}", notify => Exec["apt-update-${name}"], - creates => "${apt::params::sources_list_d}/${sources_list_d_filename}", + creates => "${sources_list_d}/${sources_list_d_filename}", } - file { "${apt::params::sources_list_d}/${sources_list_d_filename}": + file { "${sources_list_d}/${sources_list_d_filename}": ensure => file, require => Exec["add-apt-repository-${name}"]; } - } diff --git a/manifests/release.pp b/manifests/release.pp index ee94e139fa..6e0a38f73f 100644 --- a/manifests/release.pp +++ b/manifests/release.pp @@ -6,7 +6,9 @@ include apt::params - file { "${apt::params::root}/apt.conf.d/01release": + $root = $apt::params::root + + file { "${root}/apt.conf.d/01release": owner => root, group => root, mode => '0644', diff --git a/manifests/source.pp b/manifests/source.pp index 95768dcfaa..3d4011e26d 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -16,13 +16,16 @@ include apt::params + $sources_list_d = $apt::params::sources_list_d + $provider = $apt::params::provider + if $release == undef { fail('lsbdistcodename fact not available: release parameter required') } file { "${name}.list": ensure => file, - path => "${apt::params::root}/sources.list.d/${name}.list", + path => "${apt::params::sources_list_d}/${name}.list", owner => root, group => root, mode => '0644', @@ -34,14 +37,14 @@ } exec { "${name} apt update": - command => "${apt::params::provider} update", + command => "${provider} update", subscribe => File["${name}.list"], refreshonly => true, } if $required_packages != false { exec { "Required packages: '${required_packages}' for ${name}": - command => "${apt::params::provider} -y install ${required_packages}", + command => "${provider} -y install ${required_packages}", subscribe => File["${name}.list"], refreshonly => true, } From 644ed232a0c402b1020b697a10c612db68a9ffa4 Mon Sep 17 00:00:00 2001 From: Cody Herriges Date: Wed, 11 Apr 2012 17:49:30 -0700 Subject: [PATCH 058/574] Tests to validate apt::{conf,backports} This patch adds the appropriate spec tests to validate the changes introduced by e5f2dfe. As a bonus it includes fixes to the manifests that were discovered while writing the tests. --- manifests/backports.pp | 9 +++-- manifests/conf.pp | 6 +-- manifests/init.pp | 2 +- manifests/params.pp | 4 +- manifests/source.pp | 2 +- spec/classes/backports_spec.rb | 74 ++++++++++++++++++++++++++++++++++ spec/defines/conf_spec.rb | 34 ++++++++++++++++ 7 files changed, 120 insertions(+), 11 deletions(-) create mode 100644 spec/classes/backports_spec.rb create mode 100644 spec/defines/conf_spec.rb diff --git a/manifests/backports.pp b/manifests/backports.pp index 6734e05297..152689055c 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -23,12 +23,14 @@ # Copyright 2011 Puppet Labs Inc, unless otherwise noted. class apt::backports( $release = $lsbdistcodename, - $location = $apt::params::backports_locations + $location = $apt::params::backports_location ) inherits apt::params { + $release_real = downcase($release) + apt::source { 'backports.list': location => $location, - release => "${release}-backports", + release => "${release_real}-backports", repos => $lsbdistid ? { 'debian' => 'main contrib non-free', 'ubuntu' => 'universe multiverse restricted', @@ -39,7 +41,6 @@ }, key_server => 'pgp.mit.edu', pin => '200', - notify => Exec["apt-get update"], + notify => Exec["apt_update"], } } - diff --git a/manifests/conf.pp b/manifests/conf.pp index 6be1a67fac..c1af710fd4 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -5,13 +5,13 @@ include apt::params - $root = "${apt::params::root}" - $apt_conf_d = "${apt::params::apt_conf_d}" + $apt_conf_d = $apt::params::apt_conf_d file { "${apt_conf_d}/${priority}${name}": + ensure => file, content => $content, owner => root, group => root, - mode => 0644, + mode => '0644', } } diff --git a/manifests/init.pp b/manifests/init.pp index 5668d11005..3ea92ab1bf 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -62,7 +62,7 @@ file { 'sources.list.d': ensure => directory, - path => $sources_list_d + path => $sources_list_d, owner => root, group => root, purge => $purge_sources_list_d, diff --git a/manifests/params.pp b/manifests/params.pp index 79989c08a4..8e4fa932b1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -12,10 +12,10 @@ 'ubuntu': { case $lsbdistcodename { 'hardy','lucid','maverick','natty','oneiric','precise': { - $backports_location = http://us.archive.ubuntu.com/ubuntuk + $backports_location = 'http://us.archive.ubuntu.com/ubuntu' } default: { - $backports_location = 'http://old-releases.ubuntu.com/ubuntu', + $backports_location = 'http://old-releases.ubuntu.com/ubuntu' } } } diff --git a/manifests/source.pp b/manifests/source.pp index 3d4011e26d..204639bdc5 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -25,7 +25,7 @@ file { "${name}.list": ensure => file, - path => "${apt::params::sources_list_d}/${name}.list", + path => "${sources_list_d}/${name}.list", owner => root, group => root, mode => '0644', diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb new file mode 100644 index 0000000000..feabef1a11 --- /dev/null +++ b/spec/classes/backports_spec.rb @@ -0,0 +1,74 @@ +require 'spec_helper' +describe 'apt::backports', :type => :class do + + describe 'when turning on backports for ubuntu karmic' do + + let :facts do + { + 'lsbdistcodename' => 'Karmic', + 'lsbdistid' => 'Ubuntu' + } + end + + it { should contain_apt__source('backports.list').with({ + 'location' => 'http://old-releases.ubuntu.com/ubuntu', + 'release' => 'karmic-backports', + 'repos' => 'universe multiverse restricted', + 'key' => '437D05B5', + 'key_server' => 'pgp.mit.edu', + 'pin' => '200', + 'notify' => 'Exec[apt_update]' + }) + } + end + + describe "when turning on backports for debian squeeze" do + + let :facts do + { + 'lsbdistcodename' => 'Squeeze', + 'lsbdistid' => 'Debian', + } + end + + it { should contain_apt__source('backports.list').with({ + 'location' => 'http://backports.debian.org/debian-backports', + 'release' => 'squeeze-backports', + 'repos' => 'main contrib non-free', + 'key' => '55BE302B', + 'key_server' => 'pgp.mit.edu', + 'pin' => '200', + 'notify' => 'Exec[apt_update]' + }) + } + end + + describe "when turning on backports for debian squeeze but using your own mirror" do + + let :facts do + { + 'lsbdistcodename' => 'Squeeze', + 'lsbdistid' => 'Debian' + } + end + + let :location do + 'http://mirrors.example.com/debian-backports' + end + + let :params do + { 'location' => location } + end + + it { should contain_apt__source('backports.list').with({ + 'location' => location, + 'release' => 'squeeze-backports', + 'repos' => 'main contrib non-free', + 'key' => '55BE302B', + 'key_server' => 'pgp.mit.edu', + 'pin' => '200', + 'notify' => 'Exec[apt_update]' + }) + } + end +end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb new file mode 100644 index 0000000000..7c04db1c12 --- /dev/null +++ b/spec/defines/conf_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' +describe 'apt::conf', :type => :define do + let :title do + 'norecommends' + end + + describe "when creating an apt preference" do + let :params do + { + :priority => '00', + :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" + } + end + + let :filename do + "/etc/apt/apt.conf.d/00norecommends" + end + + it { should contain_apt__conf('norecommends').with({ + 'priority' => '00', + 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" + }) + } + + it { should contain_file(filename).with({ + 'ensure' => 'file', + 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + }) + } + end +end From a5ba24695ff99ec86b8b8355cb22fbc926c903e6 Mon Sep 17 00:00:00 2001 From: Daniel Thornton Date: Mon, 23 Apr 2012 20:40:24 +0000 Subject: [PATCH 059/574] (#14138) Modify apt::ppa's update-apt exec to use the ${apt::params::provider} parameter rather than explicitly calling aptitude. Previously the update-apt exec would always use /usr/bin/aptitude, which is not necessarily present. This change makes it use ${apt::params::provider} which defaults to /usr/bin/apt-get. This also adds some consistency so that ${apt::params::provider} is used everywhere. --- manifests/ppa.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 095d8f17b2..94503669b7 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -13,7 +13,7 @@ } exec { "apt-update-${name}": - command => '/usr/bin/aptitude update', + command => "${apt::params::provider} update", refreshonly => true, } From d1e0e3ee37899edafa1485dde256d61267c484b9 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Wed, 2 May 2012 16:00:27 -0700 Subject: [PATCH 060/574] (#14287) Fix apt::pin resource for rspec-puppet. The shorthand syntax cause rspec-puppet failure for external modules depending on the puppet-apt module. This patch uses the require metaparameter to avoid this issue. --- manifests/source.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/source.pp b/manifests/source.pp index 95768dcfaa..999ff68bf9 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -30,7 +30,10 @@ } if $pin != false { - apt::pin { $release: priority => $pin } -> File["${name}.list"] + apt::pin { $release: + priority => $pin, + before => File["${name}.list"] + } } exec { "${name} apt update": From 67023aa43522fe6f191a101764e531c5138f3f5a Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Wed, 2 May 2012 21:35:13 -0700 Subject: [PATCH 061/574] (#14138) Fix spec test for aptitude changes. Fix spec test related to apttitude update -> apt-get update change, --- spec/defines/ppa_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 9d4750b737..95830169b7 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -19,7 +19,7 @@ end it { should contain_exec("apt-update-#{t}").with( - 'command' => '/usr/bin/aptitude update', + 'command' => '/usr/bin/apt-get update', 'refreshonly' => true ) } From 17b9ac3c7f0aaf7322eae634fb0f35eb27bf872c Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Thu, 3 May 2012 09:51:14 -0700 Subject: [PATCH 062/574] Cleanup apt-module puppet-lint related issues. --- manifests/backports.pp | 8 ++++---- manifests/builddep.pp | 4 ++-- manifests/conf.pp | 2 +- manifests/init.pp | 2 +- manifests/params.pp | 4 ++-- manifests/ppa.pp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index 152689055c..007a1ee3fa 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -22,7 +22,7 @@ # # Copyright 2011 Puppet Labs Inc, unless otherwise noted. class apt::backports( - $release = $lsbdistcodename, + $release = $::lsbdistcodename, $location = $apt::params::backports_location ) inherits apt::params { @@ -31,16 +31,16 @@ apt::source { 'backports.list': location => $location, release => "${release_real}-backports", - repos => $lsbdistid ? { + repos => $::lsbdistid ? { 'debian' => 'main contrib non-free', 'ubuntu' => 'universe multiverse restricted', }, - key => $lsbdistid ? { + key => $::lsbdistid ? { 'debian' => '55BE302B', 'ubuntu' => '437D05B5', }, key_server => 'pgp.mit.edu', pin => '200', - notify => Exec["apt_update"], + notify => Exec['apt_update'], } } diff --git a/manifests/builddep.pp b/manifests/builddep.pp index 8891bd903b..de6191c31b 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -10,7 +10,7 @@ } exec { "apt-builddep-${name}": - command => "/usr/bin/apt-get -y --force-yes build-dep $name", - notify => Exec["apt-update-${name}"], + command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", + notify => Exec["apt-update-${name}"], } } diff --git a/manifests/conf.pp b/manifests/conf.pp index c1af710fd4..fa7f97d435 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -1,7 +1,7 @@ define apt::conf ( $priority = '50', $content - ) { +) { include apt::params diff --git a/manifests/init.pp b/manifests/init.pp index 068fb497c4..7d243edd7b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,7 +42,7 @@ } $sources_list_content = $purge_sources_list ? { - false => undef, + false => undef, true => "# Repos managed by puppet.\n", } diff --git a/manifests/params.pp b/manifests/params.pp index 8e4fa932b1..ed698e72be 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,12 +5,12 @@ $apt_conf_d = "${root}/apt.conf.d" $preferences_d = "${root}/preferences.d" - case $lsbdistid { + case $::lsbdistid { 'debian': { $backports_location = 'http://backports.debian.org/debian-backports' } 'ubuntu': { - case $lsbdistcodename { + case $::lsbdistcodename { 'hardy','lucid','maverick','natty','oneiric','precise': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index bda392c946..d27aca4442 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,7 +1,7 @@ # ppa.pp define apt::ppa( - $release = $lsbdistcodename + $release = $::lsbdistcodename ) { Class['apt'] -> Apt::Ppa[$title] From 3f8a7846ab394c3a358a753ec89d72416bd729ad Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Thu, 3 May 2012 14:55:16 -0700 Subject: [PATCH 063/574] (#14299) Resolve Modulefile name mismatch. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The modulefile name is puppet-apt, but the module is released to forge under puppetlabs. This causes a dependency confusion for puppet module tool, which has been fixed by this patch. Previous: $ puppet module list ~/.puppet/modules ├── puppet-apt (v0.0.2) ├── puppetlabs-mongrodb (v0.0.1) └── puppetlabs-stdlib (v2.3.1) Now: $ puppet module list ~/.puppet/modules ├── puppetlabs-apt (v0.0.2) ├── puppetlabs-mongrodb (v0.0.1) └── puppetlabs-stdlib (v2.3.1) --- Modulefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modulefile b/Modulefile index 60d8fd7344..4ffe941716 100644 --- a/Modulefile +++ b/Modulefile @@ -1,9 +1,9 @@ -name 'puppet-apt' +name 'puppetlabs-apt' version '0.0.2' -source 'https://github.com/puppetlabs/puppet-apt' -author 'Evolving Web / Puppet Labs' +source 'https://github.com/puppetlabs/puppet-apt' +author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' -summary 'Apt Module for Puppet' +summary 'Puppet Labs Apt Module' description 'APT Module for Puppet' project_page 'https://github.com/puppetlabs/puppet-apt' From effb3f7ff35675afd512f87c24bb81d2a712b983 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Thu, 3 May 2012 16:59:13 -0700 Subject: [PATCH 064/574] (#14308) Add ensure=>absent for define resource. Several apt::* define resource type does not support ensurable. This update allows ensure=>absent to support the removal of these configuration files. * apt::conf * apt::pin * apt::source --- manifests/conf.pp | 3 ++- manifests/pin.pp | 3 ++- manifests/source.pp | 10 ++++++---- spec/defines/conf_spec.rb | 25 ++++++++++++++++++++++++- spec/defines/pin_spec.rb | 12 +++++++++--- spec/defines/source_spec.rb | 9 ++++++++- 6 files changed, 51 insertions(+), 11 deletions(-) diff --git a/manifests/conf.pp b/manifests/conf.pp index fa7f97d435..03aab8e002 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -1,4 +1,5 @@ define apt::conf ( + $ensure = present, $priority = '50', $content ) { @@ -8,7 +9,7 @@ $apt_conf_d = $apt::params::apt_conf_d file { "${apt_conf_d}/${priority}${name}": - ensure => file, + ensure => $ensure, content => $content, owner => root, group => root, diff --git a/manifests/pin.pp b/manifests/pin.pp index 2899fce77a..b69e230ea0 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -2,6 +2,7 @@ # pin a release in apt, useful for unstable repositories define apt::pin( + $ensure = present, $packages = '*', $priority = 0 ) { @@ -11,7 +12,7 @@ $preferences_d = $apt::params::preferences_d file { "${name}.pref": - ensure => file, + ensure => $ensure, path => "${preferences_d}/${name}", owner => root, group => root, diff --git a/manifests/source.pp b/manifests/source.pp index 17d2d8e5a2..c63fc2fb22 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -2,6 +2,7 @@ # add an apt source define apt::source( + $ensure = present, $location = '', $release = $lsbdistcodename, $repos = 'main', @@ -24,7 +25,7 @@ } file { "${name}.list": - ensure => file, + ensure => $ensure, path => "${sources_list_d}/${name}.list", owner => root, group => root, @@ -32,7 +33,7 @@ content => template("${module_name}/source.list.erb"), } - if $pin != false { + if ($pin != false) and ($ensure == 'present') { apt::pin { $release: priority => $pin, before => File["${name}.list"] @@ -45,7 +46,7 @@ refreshonly => true, } - if $required_packages != false { + if ($required_packages != false) and ($ensure == 'present') { exec { "Required packages: '${required_packages}' for ${name}": command => "${provider} -y install ${required_packages}", subscribe => File["${name}.list"], @@ -53,7 +54,8 @@ } } - if $key != false { + # We do not want to remove keys when the source is absent. + if ($key != false) and ($ensure == 'present') { apt::key { "Add key: ${key} from Apt::Source ${title}": ensure => present, key => $key, diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 7c04db1c12..5a81b5148c 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -23,7 +23,7 @@ } it { should contain_file(filename).with({ - 'ensure' => 'file', + 'ensure' => 'present', 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", 'owner' => 'root', 'group' => 'root', @@ -31,4 +31,27 @@ }) } end + + describe "when removing an apt preference" do + let :params do + { + :ensure => 'absent', + :priority => '00', + :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" + } + end + + let :filename do + "/etc/apt/apt.conf.d/00norecommends" + end + + it { should contain_file(filename).with({ + 'ensure' => 'absent', + 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + }) + } + end end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index dbc595c568..c5d3fd91af 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -4,13 +4,19 @@ let :default_params do { + :ensure => 'present', :packages => '*', :priority => '0' } end - [{}, - { + [ {}, + { + :packages => 'apache', + :priority => '1' + }, + { + :ensure => 'absent', :packages => 'apache', :priority => '1' } @@ -27,7 +33,7 @@ it { should include_class("apt::params") } it { should contain_file("#{title}.pref").with({ - 'ensure' => 'file', + 'ensure' => param_hash[:ensure], 'path' => "/etc/apt/preferences.d/#{title}", 'owner' => 'root', 'group' => 'root', diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 284342940b..02bc45fcbe 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -6,6 +6,7 @@ let :default_params do { + :ensure => 'present', :location => '', :release => 'karmic', :repos => 'main', @@ -35,6 +36,12 @@ :key => 'key_name', :key_server => 'keyserver.debian.com', :key_content => false, + }, + { + :ensure => 'absent', + :location => 'somewhere', + :release => 'precise', + :repos => 'security', } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do @@ -66,7 +73,7 @@ it { should contain_apt__params } it { should contain_file("#{title}.list").with({ - 'ensure' => 'file', + 'ensure' => param_hash[:ensure], 'path' => filename, 'owner' => 'root', 'group' => 'root', From 3684f88372959cb8dd6eb5bce99b6a07db43f058 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Fri, 4 May 2012 13:35:13 -0700 Subject: [PATCH 065/574] (#11966) Only invoke apt-get update once. Move apt-get update exec to a seperate class to minimize the number of apt-get updates invoked by configuration changes. * remove apt_update exec resource in apt class. * remove apt-get-${name} in defines. * apt::source notify Exec['apt update']. * Remove dependency to Exec['apt_update']. * fix rspec-puppet tests. Conflicts: manifests/source.pp --- manifests/backports.pp | 1 - manifests/builddep.pp | 8 ++------ manifests/init.pp | 24 +++++++++++------------- manifests/source.pp | 8 ++------ manifests/update.pp | 8 ++++++++ spec/classes/apt_spec.rb | 11 ++++++----- spec/classes/backports_spec.rb | 3 --- spec/defines/builddep_spec.rb | 2 +- spec/defines/source_spec.rb | 3 +-- 9 files changed, 31 insertions(+), 37 deletions(-) create mode 100644 manifests/update.pp diff --git a/manifests/backports.pp b/manifests/backports.pp index 007a1ee3fa..ecc75048e6 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -41,6 +41,5 @@ }, key_server => 'pgp.mit.edu', pin => '200', - notify => Exec['apt_update'], } } diff --git a/manifests/builddep.pp b/manifests/builddep.pp index de6191c31b..7a9dd332f5 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -1,16 +1,12 @@ # builddep.pp define apt::builddep() { + include apt::update Class['apt'] -> Apt::Builddep[$name] - exec { "apt-update-${name}": - command => '/usr/bin/apt-get update', - refreshonly => true, - } - exec { "apt-builddep-${name}": command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", - notify => Exec["apt-update-${name}"], + notify => Exec["apt update"], } } diff --git a/manifests/init.pp b/manifests/init.pp index 7d243edd7b..ce88c3bd83 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,14 +29,10 @@ ) { include apt::params + include apt::update validate_bool($purge_sources_list, $purge_sources_list_d) - $refresh_only_apt_update = $always_apt_update? { - true => false, - false => true, - } - if ! defined(Package['python-software-properties']) { package { 'python-software-properties': } } @@ -46,6 +42,12 @@ true => "# Repos managed by puppet.\n", } + if $always_apt_update == true { + Exec <| title=='apt update' |> { + refreshonly => false, + } + } + $root = $apt::params::root $apt_conf_d = $apt::params::apt_conf_d $sources_list_d = $apt::params::sources_list_d @@ -58,6 +60,7 @@ group => root, mode => '0644', content => $sources_list_content, + notify => Exec['apt update'], } file { 'sources.list.d': @@ -67,12 +70,7 @@ group => root, purge => $purge_sources_list_d, recurse => $purge_sources_list_d, - } - - exec { 'apt_update': - command => "${provider} update", - subscribe => [ File['sources.list'], File['sources.list.d'] ], - refreshonly => $refresh_only_apt_update, + notify => Exec['apt update'], } case $disable_keys { @@ -89,7 +87,7 @@ path => "${apt_conf_d}/99unauth", } } - undef: { } # do nothing + undef: { } # do nothing default: { fail('Valid values for disable_keys are true or false') } } @@ -97,7 +95,7 @@ file { 'configure-apt-proxy': path => "${apt_conf_d}/proxy", content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", - notify => Exec['apt_update'], + notify => Exec['apt update'], } } } diff --git a/manifests/source.pp b/manifests/source.pp index c63fc2fb22..e9eb654cb8 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -16,6 +16,7 @@ ) { include apt::params + include apt::update $sources_list_d = $apt::params::sources_list_d $provider = $apt::params::provider @@ -31,6 +32,7 @@ group => root, mode => '0644', content => template("${module_name}/source.list.erb"), + notify => Exec['apt update'], } if ($pin != false) and ($ensure == 'present') { @@ -40,12 +42,6 @@ } } - exec { "${name} apt update": - command => "${provider} update", - subscribe => File["${name}.list"], - refreshonly => true, - } - if ($required_packages != false) and ($ensure == 'present') { exec { "Required packages: '${required_packages}' for ${name}": command => "${provider} -y install ${required_packages}", diff --git a/manifests/update.pp b/manifests/update.pp new file mode 100644 index 0000000000..b079c1fcc3 --- /dev/null +++ b/manifests/update.pp @@ -0,0 +1,8 @@ +class apt::update { + include apt::params + + exec { 'apt update': + command => "${apt::params::provider} update", + refreshonly => true, + } +} diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 079bd59c5b..4d44bcc78c 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -72,7 +72,8 @@ 'owner' => "root", 'group' => "root", 'purge' => true, - 'recurse' => true + 'recurse' => true, + 'notify' => 'Exec[apt update]' }) else should create_file("sources.list.d").with({ @@ -81,15 +82,15 @@ 'owner' => "root", 'group' => "root", 'purge' => false, - 'recurse' => false + 'recurse' => false, + 'notify' => 'Exec[apt update]' }) end } it { - should contain_exec("apt_update").with({ + should contain_exec("apt update").with({ 'command' => "/usr/bin/apt-get update", - 'subscribe' => ["File[sources.list]", "File[sources.list.d]"], 'refreshonly' => refresh_only_apt_update }) } @@ -118,7 +119,7 @@ should contain_file('configure-apt-proxy').with( 'path' => '/etc/apt/apt.conf.d/proxy', 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";", - 'notify' => "Exec[apt_update]" + 'notify' => "Exec[apt update]" ) else should_not contain_file('configure_apt_proxy') diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb index feabef1a11..efac860755 100644 --- a/spec/classes/backports_spec.rb +++ b/spec/classes/backports_spec.rb @@ -17,7 +17,6 @@ 'key' => '437D05B5', 'key_server' => 'pgp.mit.edu', 'pin' => '200', - 'notify' => 'Exec[apt_update]' }) } end @@ -38,7 +37,6 @@ 'key' => '55BE302B', 'key_server' => 'pgp.mit.edu', 'pin' => '200', - 'notify' => 'Exec[apt_update]' }) } end @@ -67,7 +65,6 @@ 'key' => '55BE302B', 'key_server' => 'pgp.mit.edu', 'pin' => '200', - 'notify' => 'Exec[apt_update]' }) } end diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb index 52a0704a3b..39ee988b6a 100644 --- a/spec/defines/builddep_spec.rb +++ b/spec/defines/builddep_spec.rb @@ -6,7 +6,7 @@ describe "should succeed with a Class['apt']" do let(:pre_condition) { 'class {"apt": } ' } - it { should contain_exec("apt-update-#{title}").with({ + it { should contain_exec("apt update").with({ 'command' => "/usr/bin/apt-get update", 'refreshonly' => true }) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 02bc45fcbe..a6c5e5f3a0 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -97,9 +97,8 @@ } it { - should contain_exec("#{title} apt update").with({ + should contain_exec("apt update").with({ "command" => "/usr/bin/apt-get update", - "subscribe" => "File[#{title}.list]", "refreshonly" => true }) } From 82967a22fa2493773715f7da6e6cd9fa5df7f592 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Thu, 3 May 2012 10:22:49 -0700 Subject: [PATCH 066/574] (#11966) Update apt::ppa to use apt::update. Change apt::ppa define type to also use the apt::update class to invoke apt-get update once. --- manifests/builddep.pp | 2 +- manifests/ppa.pp | 7 ++----- spec/defines/ppa_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/manifests/builddep.pp b/manifests/builddep.pp index 7a9dd332f5..35d8d3074b 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -7,6 +7,6 @@ exec { "apt-builddep-${name}": command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", - notify => Exec["apt update"], + notify => Exec['apt update'], } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index d27aca4442..ca7f620956 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -7,6 +7,7 @@ Class['apt'] -> Apt::Ppa[$title] include apt::params + include apt::update $sources_list_d = $apt::params::sources_list_d @@ -14,10 +15,6 @@ fail('lsbdistcodename fact not available: release parameter required') } - exec { "apt-update-${name}": - command => "${apt::params::provider} update", - refreshonly => true, - } $filename_without_slashes = regsubst($name,'/','-','G') $filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G') @@ -25,8 +22,8 @@ exec { "add-apt-repository-${name}": command => "/usr/bin/add-apt-repository ${name}", - notify => Exec["apt-update-${name}"], creates => "${sources_list_d}/${sources_list_d_filename}", + notify => Exec['apt update'], } file { "${sources_list_d}/${sources_list_d_filename}": diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 95830169b7..e3534895aa 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -18,7 +18,7 @@ t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list" end - it { should contain_exec("apt-update-#{t}").with( + it { should contain_exec("apt update").with( 'command' => '/usr/bin/apt-get update', 'refreshonly' => true ) @@ -26,7 +26,7 @@ it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{t}", - 'notify' => "Exec[apt-update-#{t}]", + 'notify' => "Exec[apt update]", 'creates' => "/etc/apt/sources.list.d/#{filename}" ) } From f13f3cfac7c719aa4b7025fe7d427df638fc5cc2 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Thu, 3 May 2012 15:44:17 -0700 Subject: [PATCH 067/574] (#11966) Change apt update to apt_update. Based on code review change exec from apt update to apt_update. --- manifests/builddep.pp | 2 +- manifests/init.pp | 8 ++++---- manifests/ppa.pp | 2 +- manifests/source.pp | 2 +- manifests/update.pp | 2 +- spec/classes/apt_spec.rb | 8 ++++---- spec/defines/builddep_spec.rb | 2 +- spec/defines/ppa_spec.rb | 4 ++-- spec/defines/source_spec.rb | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/manifests/builddep.pp b/manifests/builddep.pp index 35d8d3074b..f7537fbb25 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -7,6 +7,6 @@ exec { "apt-builddep-${name}": command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", - notify => Exec['apt update'], + notify => Exec['apt_update'], } } diff --git a/manifests/init.pp b/manifests/init.pp index ce88c3bd83..53e25dca0e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -43,7 +43,7 @@ } if $always_apt_update == true { - Exec <| title=='apt update' |> { + Exec <| title=='apt_update' |> { refreshonly => false, } } @@ -60,7 +60,7 @@ group => root, mode => '0644', content => $sources_list_content, - notify => Exec['apt update'], + notify => Exec['apt_update'], } file { 'sources.list.d': @@ -70,7 +70,7 @@ group => root, purge => $purge_sources_list_d, recurse => $purge_sources_list_d, - notify => Exec['apt update'], + notify => Exec['apt_update'], } case $disable_keys { @@ -95,7 +95,7 @@ file { 'configure-apt-proxy': path => "${apt_conf_d}/proxy", content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", - notify => Exec['apt update'], + notify => Exec['apt_update'], } } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index ca7f620956..c0dfaa0f82 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -23,7 +23,7 @@ exec { "add-apt-repository-${name}": command => "/usr/bin/add-apt-repository ${name}", creates => "${sources_list_d}/${sources_list_d_filename}", - notify => Exec['apt update'], + notify => Exec['apt_update'], } file { "${sources_list_d}/${sources_list_d_filename}": diff --git a/manifests/source.pp b/manifests/source.pp index e9eb654cb8..cbf2fd4566 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -32,7 +32,7 @@ group => root, mode => '0644', content => template("${module_name}/source.list.erb"), - notify => Exec['apt update'], + notify => Exec['apt_update'], } if ($pin != false) and ($ensure == 'present') { diff --git a/manifests/update.pp b/manifests/update.pp index b079c1fcc3..016df7d6af 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -1,7 +1,7 @@ class apt::update { include apt::params - exec { 'apt update': + exec { 'apt_update': command => "${apt::params::provider} update", refreshonly => true, } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 4d44bcc78c..ac626d291e 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -73,7 +73,7 @@ 'group' => "root", 'purge' => true, 'recurse' => true, - 'notify' => 'Exec[apt update]' + 'notify' => 'Exec[apt_update]' }) else should create_file("sources.list.d").with({ @@ -83,13 +83,13 @@ 'group' => "root", 'purge' => false, 'recurse' => false, - 'notify' => 'Exec[apt update]' + 'notify' => 'Exec[apt_update]' }) end } it { - should contain_exec("apt update").with({ + should contain_exec("apt_update").with({ 'command' => "/usr/bin/apt-get update", 'refreshonly' => refresh_only_apt_update }) @@ -119,7 +119,7 @@ should contain_file('configure-apt-proxy').with( 'path' => '/etc/apt/apt.conf.d/proxy', 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";", - 'notify' => "Exec[apt update]" + 'notify' => "Exec[apt_update]" ) else should_not contain_file('configure_apt_proxy') diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb index 39ee988b6a..940c60c97b 100644 --- a/spec/defines/builddep_spec.rb +++ b/spec/defines/builddep_spec.rb @@ -6,7 +6,7 @@ describe "should succeed with a Class['apt']" do let(:pre_condition) { 'class {"apt": } ' } - it { should contain_exec("apt update").with({ + it { should contain_exec("apt_update").with({ 'command' => "/usr/bin/apt-get update", 'refreshonly' => true }) diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index e3534895aa..18c1a4f91e 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -18,7 +18,7 @@ t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list" end - it { should contain_exec("apt update").with( + it { should contain_exec("apt_update").with( 'command' => '/usr/bin/apt-get update', 'refreshonly' => true ) @@ -26,7 +26,7 @@ it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{t}", - 'notify' => "Exec[apt update]", + 'notify' => "Exec[apt_update]", 'creates' => "/etc/apt/sources.list.d/#{filename}" ) } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index a6c5e5f3a0..110e8c21b6 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -97,7 +97,7 @@ } it { - should contain_exec("apt update").with({ + should contain_exec("apt_update").with({ "command" => "/usr/bin/apt-get update", "refreshonly" => true }) From 0ffe484c7c5d64295f32eb34ce47c60eb823c66c Mon Sep 17 00:00:00 2001 From: Thomas Broyer Date: Mon, 2 Apr 2012 09:00:59 +0200 Subject: [PATCH 068/574] Move Package['python-software-properties'] to apt:ppa Also updates the apt-update in Apt::Ppa to use $apt::params::provider instead of aptitude. --- manifests/init.pp | 4 ---- manifests/ppa.pp | 5 +++++ spec/classes/apt_spec.rb | 7 ------- spec/defines/ppa_spec.rb | 21 ++++++++++++++++++--- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 53e25dca0e..e41cd3fdee 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -33,10 +33,6 @@ validate_bool($purge_sources_list, $purge_sources_list_d) - if ! defined(Package['python-software-properties']) { - package { 'python-software-properties': } - } - $sources_list_content = $purge_sources_list ? { false => undef, true => "# Repos managed by puppet.\n", diff --git a/manifests/ppa.pp b/manifests/ppa.pp index c0dfaa0f82..dd6ce19e8e 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -20,9 +20,14 @@ $filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G') $sources_list_d_filename = "${filename_without_ppa}-${release}.list" + if ! defined(Package['python-software-properties']) { + package { 'python-software-properties': } + } + exec { "add-apt-repository-${name}": command => "/usr/bin/add-apt-repository ${name}", creates => "${sources_list_d}/${sources_list_d_filename}", + require => Package['python-software-properties'], notify => Exec['apt_update'], } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index ac626d291e..d623a5bf78 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -41,8 +41,6 @@ it { should include_class("apt::params") } - it { should contain_package("python-software-properties") } - it { if param_hash[:purge_sources_list] should contain_file("sources.list").with({ @@ -128,9 +126,4 @@ end end end - - describe "it should not error if package['python-software-properties'] is already defined" do - let(:pre_condition) { 'package { "python-software-properties": }->Class["Apt"]' } - it { should contain_package("python-software-properties") } - end end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 18c1a4f91e..ab86b93b2e 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -18,6 +18,8 @@ t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list" end + it { should contain_package("python-software-properties") } + it { should contain_exec("apt_update").with( 'command' => '/usr/bin/apt-get update', 'refreshonly' => true @@ -26,8 +28,9 @@ it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{t}", - 'notify' => "Exec[apt_update]", - 'creates' => "/etc/apt/sources.list.d/#{filename}" + 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'require' => "Package[python-software-properties]", + 'notify' => "Exec[apt_update]" ) } @@ -39,6 +42,19 @@ end end + describe "it should not error if package['python-software-properties'] is already defined" do + let :pre_condition do + 'class {"apt": }' + + 'package { "python-software-properties": }->Apt::Ppa["ppa"]' + end + let :facts do + {:lsbdistcodename => 'natty'} + end + let(:title) { "ppa" } + let(:release) { "natty" } + it { should contain_package("python-software-properties") } + end + describe "without Class[apt] should raise a Puppet::Error" do let(:release) { "natty" } let(:title) { "ppa" } @@ -49,5 +65,4 @@ let(:title) { "ppa:" } it { expect { should contain_apt__ppa(:release) }.to raise_error(Puppet::Error) } end - end From feee023b24632b3bec03baa638dacde3ce1142f6 Mon Sep 17 00:00:00 2001 From: albac Date: Fri, 27 Apr 2012 21:23:48 -0300 Subject: [PATCH 069/574] Update manifests/pin.pp --- manifests/pin.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index b69e230ea0..7356a67497 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -4,7 +4,8 @@ define apt::pin( $ensure = present, $packages = '*', - $priority = 0 + $priority = 0, + $release = "${name}" ) { include apt::params @@ -17,6 +18,6 @@ owner => root, group => root, mode => '0644', - content => "# ${name}\nPackage: ${packages}\nPin: release a=${name}\nPin-Priority: ${priority}", + content => "# ${name}\nPackage: ${packages}\nPin: release a=${release}\nPin-Priority: ${priority}", } } From e8977deea10bfa3f9e707ad8b859372d7e087378 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Fri, 4 May 2012 13:56:35 -0700 Subject: [PATCH 070/574] (#14321) apt::pin resource support release. apt::pin release should default to title, but should be able to override. This update removes unnecessary "" around $name, and add spec tests. Conflicts: spec/defines/pin_spec.rb --- manifests/pin.pp | 2 +- spec/defines/pin_spec.rb | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 7356a67497..29fddfb85a 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -5,7 +5,7 @@ $ensure = present, $packages = '*', $priority = 0, - $release = "${name}" + $release = $name ) { include apt::params diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index c5d3fd91af..b5b10d702b 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -6,7 +6,8 @@ { :ensure => 'present', :packages => '*', - :priority => '0' + :priority => '0', + :release => nil } end @@ -19,6 +20,11 @@ :ensure => 'absent', :packages => 'apache', :priority => '1' + }, + { + :packages => 'apache', + :priority => '1', + :release => 'my_newpin' } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do @@ -38,7 +44,7 @@ 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}", + 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}", }) } end From 3b29220acda629ade0d91ec8f2ca3504caf4530d Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Thu, 3 May 2012 14:18:51 -0700 Subject: [PATCH 071/574] (#14221) update Modulefile for new release --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 4ffe941716..ac081cb862 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '0.0.2' +version '0.0.3' source 'https://github.com/puppetlabs/puppet-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From 3c43a97e6ae425be2c234f79cdd67dc038fff6fa Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Fri, 4 May 2012 14:05:57 -0700 Subject: [PATCH 072/574] (#14221) update CHANGELOG for release --- CHANGELOG | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index dcd1f93efc..1dc4b61cc9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,15 @@ +2012-05-04 Puppet Labs - 0.0.3 + * only invoke apt-get update once + * only install python-software-properties if a ppa is added + * support 'ensure => absent' for all defined types + * add apt::conf + * add apt::backports + * fixed Modulefile for module tool dependency resolution + * configure proxy before doing apt-get update + * use apt-get update instead of aptitude for apt::ppa + * add support to pin release + + 2012-03-26 Puppet Labs - 0.0.2 41cedbb (#13261) Add real examples to smoke tests. d159a78 (#13261) Add key.pp smoke test From 666a05dea1856ef358edbc9929152983106c8970 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Mon, 7 May 2012 15:27:53 -0700 Subject: [PATCH 073/574] (#11966) apt module containment for apt_update. The update to separate Exec["apt-get update ${name}"] to single exec in apt::update class resulted in apt-get update command to be dangled. Previously if user specified Package['package_a'] <- Apt::Resource['source_a'], the original refactor would no longer guarantee apt-get update is executed before the package is installed. This patch fixes the problem using the anchor resource and ensuring the old behaviour is maintained and user can depend on apt-get update command being invoked if they specify dependency on any apt::* define resource type as well as the apt class. --- manifests/builddep.pp | 5 +++++ manifests/init.pp | 5 +++++ manifests/ppa.pp | 5 +++++ manifests/source.pp | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/manifests/builddep.pp b/manifests/builddep.pp index f7537fbb25..ce9d8fd630 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -9,4 +9,9 @@ command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", notify => Exec['apt_update'], } + + # Need anchor to provide containment for dependencies. + anchor { "apt::builddep::${name}": + require => Class['apt::update'], + } } diff --git a/manifests/init.pp b/manifests/init.pp index e41cd3fdee..0002589368 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -94,4 +94,9 @@ notify => Exec['apt_update'], } } + + # Need anchor to provide containment for dependencies. + anchor { "apt::update": + require => Class['apt::update'], + } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index dd6ce19e8e..7800d3d388 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -35,5 +35,10 @@ ensure => file, require => Exec["add-apt-repository-${name}"]; } + + # Need anchor to provide containment for dependencies. + anchor { "apt::ppa::${name}": + require => Class['apt::update'], + } } diff --git a/manifests/source.pp b/manifests/source.pp index cbf2fd4566..e55cafdfd1 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -61,4 +61,9 @@ before => File["${name}.list"], } } + + # Need anchor to provide containment for dependencies. + anchor { "apt::source::${name}": + require => Class['apt::update'], + } } From 322f3b68e780d16ec676992233589c43b65b91db Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Tue, 8 May 2012 10:47:43 -0700 Subject: [PATCH 074/574] Fix style related issues in module. --- manifests/key.pp | 4 ++-- manifests/ppa.pp | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index e87968d7fb..037eec5288 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -29,14 +29,14 @@ case $ensure { present: { - anchor { "apt::key/${title}":; } + anchor { "apt::key/${title}": } if defined(Exec["apt::key ${upkey} absent"]) { fail("Cannot ensure Apt::Key[${upkey}] present; ${upkey} already ensured absent") } if !defined(Anchor["apt::key ${upkey} present"]) { - anchor { "apt::key ${upkey} present":; } + anchor { "apt::key ${upkey} present": } } if !defined(Exec[$digest]) { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 7800d3d388..578c81df71 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -15,10 +15,9 @@ fail('lsbdistcodename fact not available: release parameter required') } - $filename_without_slashes = regsubst($name,'/','-','G') - $filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G') - $sources_list_d_filename = "${filename_without_ppa}-${release}.list" + $filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G') + $sources_list_d_filename = "${filename_without_ppa}-${release}.list" if ! defined(Package['python-software-properties']) { package { 'python-software-properties': } @@ -33,7 +32,7 @@ file { "${sources_list_d}/${sources_list_d_filename}": ensure => file, - require => Exec["add-apt-repository-${name}"]; + require => Exec["add-apt-repository-${name}"], } # Need anchor to provide containment for dependencies. From 05fba437a37ad2212a720a9ba5caac339a6b35d4 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Tue, 8 May 2012 10:18:52 -0700 Subject: [PATCH 075/574] Add configuration for Travis CI --- .gitmodules | 3 --- .travis.yml | 16 ++++++++++++++++ Gemfile | 12 ++++++++++++ Rakefile | 24 +++++++++++++++++++----- spec/fixtures/modules/stdlib | 1 - 5 files changed, 47 insertions(+), 9 deletions(-) delete mode 100644 .gitmodules create mode 100644 .travis.yml create mode 100644 Gemfile delete mode 160000 spec/fixtures/modules/stdlib diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index eb34d3b96b..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "spec/fixtures/modules/stdlib"] - path = spec/fixtures/modules/stdlib - url = https://github.com/puppetlabs/puppetlabs-stdlib.git diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..a4ec2c12e1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: ruby +rvm: + - 1.8.7 +before_script: + - "git clone git://github.com/puppetlabs/puppetlabs-stdlib.git spec/fixtures/modules/stdlib" +after_script: +script: "rake spec" +branches: + only: + - master +env: + - PUPPET_VERSION=2.7.13 + - PUPPET_VERSION=2.7.6 + - PUPPET_VERSION=2.6.9 +notifications: + email: false diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..e4be4470c6 --- /dev/null +++ b/Gemfile @@ -0,0 +1,12 @@ +source :rubygems + +puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] + +gem 'puppet', puppetversion + +group :test do + gem 'rake', '>= 0.9.0' + gem 'rspec', '>= 2.8.0' + gem 'rspec-puppet', '>= 0.1.1' + gem 'mocha', '>= 0.11.0' +end diff --git a/Rakefile b/Rakefile index 705d50de2f..5cbef6b45c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,15 +1,29 @@ require 'rake' -require 'puppet-lint/tasks/puppet-lint' +require 'rspec/core/rake_task' task :default => [:spec] desc "Run all module spec tests (Requires rspec-puppet gem)" -task :spec do - system("rspec spec/**/*_spec.rb") +RSpec::Core::RakeTask.new(:spec) do |t| + t.rspec_opts = ['--color'] + t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb' end -desc "Build package" +desc "Build puppet module package" task :build do - system("puppet-module build") + # This will be deprecated once puppet-module is a face. + begin + Gem::Specification.find_by_name('puppet-module') + rescue Gem::LoadError, NoMethodError + require 'puppet/face' + pmod = Puppet::Face['module', :current] + pmod.build('./') + end end +desc "Check puppet manifests with puppet-lint" +task :lint do + # This requires pull request: https://github.com/rodjek/puppet-lint/pull/81 + system("puppet-lint manifests") + system("puppet-lint tests") +end diff --git a/spec/fixtures/modules/stdlib b/spec/fixtures/modules/stdlib deleted file mode 160000 index a70b09d5de..0000000000 --- a/spec/fixtures/modules/stdlib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a70b09d5de035de5254ebe6ad6e1519a6d7cf588 From e3784987fce98bf3c8c6cc40e73bb6c9582c0696 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Wed, 9 May 2012 11:50:43 -0700 Subject: [PATCH 076/574] Fix dependency issues introduced with anchor. apt::ppa and apt::builddep requires apt class. The anchor introduced for containment of apt-get update causes a dependency loop. apt::ppa appears to depend on apt class sources.d direcory. While apt::builddep have no clear reason for a dependency on apt class. This change refactor both define type, so they no longer cause a dependency loop. --- manifests/builddep.pp | 2 -- manifests/ppa.pp | 6 ++---- spec/defines/ppa_spec.rb | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/manifests/builddep.pp b/manifests/builddep.pp index ce9d8fd630..997a2064f8 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -3,8 +3,6 @@ define apt::builddep() { include apt::update - Class['apt'] -> Apt::Builddep[$name] - exec { "apt-builddep-${name}": command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", notify => Exec['apt_update'], diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 578c81df71..64c65bbd09 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -3,9 +3,6 @@ define apt::ppa( $release = $::lsbdistcodename ) { - - Class['apt'] -> Apt::Ppa[$title] - include apt::params include apt::update @@ -26,7 +23,8 @@ exec { "add-apt-repository-${name}": command => "/usr/bin/add-apt-repository ${name}", creates => "${sources_list_d}/${sources_list_d_filename}", - require => Package['python-software-properties'], + require => [ File[$sources_list_d], + Package['python-software-properties'] ], notify => Exec['apt_update'], } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index ab86b93b2e..d57c1fb854 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -29,7 +29,7 @@ it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{t}", 'creates' => "/etc/apt/sources.list.d/#{filename}", - 'require' => "Package[python-software-properties]", + 'require' => ["File[/etc/apt/sources.list.d]", "Package[python-software-properties]"], 'notify' => "Exec[apt_update]" ) } From 2ce47f065222ddf7adcd13aeb42f138130dac11c Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Wed, 9 May 2012 12:22:28 -0700 Subject: [PATCH 077/574] Fix apt::dep spec tests. Some of the existing tests were not verifying anything useful. This update replace them with more meaningful tests. --- spec/defines/builddep_spec.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb index 940c60c97b..4e2b698d93 100644 --- a/spec/defines/builddep_spec.rb +++ b/spec/defines/builddep_spec.rb @@ -3,22 +3,15 @@ let(:title) { 'my_package' } - describe "should succeed with a Class['apt']" do - let(:pre_condition) { 'class {"apt": } ' } - + describe "should require apt-get update" do it { should contain_exec("apt_update").with({ 'command' => "/usr/bin/apt-get update", 'refreshonly' => true }) } - end - - describe "should fail without Class['apt']" do - it { expect {should contain_exec("apt-update-#{title}").with({ - 'command' => "/usr/bin/apt-get update", - 'refreshonly' => true - }).to raise_error(Puppet::Error) - } + it { should contain_anchor("apt::builddep::my_package").with({ + 'require' => 'Class[Apt::Update]', + }) } end From 989b95a12d4a880b4be203291c4c94f6929e2373 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 14:17:37 -0700 Subject: [PATCH 078/574] Fixup name issue with apt::backports The '.list' is not needed since the apt::source type handles this. White space alignment. --- manifests/backports.pp | 2 +- manifests/source.pp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index ecc75048e6..147801e6e8 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -28,7 +28,7 @@ $release_real = downcase($release) - apt::source { 'backports.list': + apt::source { 'backports': location => $location, release => "${release_real}-backports", repos => $::lsbdistid ? { diff --git a/manifests/source.pp b/manifests/source.pp index e55cafdfd1..f3fc7b995a 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -2,17 +2,17 @@ # add an apt source define apt::source( - $ensure = present, - $location = '', - $release = $lsbdistcodename, - $repos = 'main', - $include_src = true, + $ensure = present, + $location = '', + $release = $lsbdistcodename, + $repos = 'main', + $include_src = true, $required_packages = false, - $key = false, - $key_server = 'keyserver.ubuntu.com', - $key_content = false, - $key_source = false, - $pin = false + $key = false, + $key_server = 'keyserver.ubuntu.com', + $key_content = false, + $key_source = false, + $pin = false ) { include apt::params From 2d19d8664e5e1b680deec7d487875c5d53b3ac39 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 14:19:18 -0700 Subject: [PATCH 079/574] Add functionality to support apt pinning to more than just the release. Write the pin preference filename as ${name} rather than ${release}, so that we can pin more than one thing. Change apt::source so that when pin is set, that it pins to the origin rather than the release. --- manifests/pin.pp | 13 +++++++++++-- manifests/source.pp | 10 ++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 29fddfb85a..2664c9ba6a 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -5,19 +5,28 @@ $ensure = present, $packages = '*', $priority = 0, - $release = $name + $release = '', + $origin = '' ) { include apt::params $preferences_d = $apt::params::preferences_d + if $release != '' { + $pin = "release a=${release}" + } elsif $origin != '' { + $pin = "origin \"${origin}\"" + } else { + err("Apt::Pin needs either $release or $origin") + } + file { "${name}.pref": ensure => $ensure, path => "${preferences_d}/${name}", owner => root, group => root, mode => '0644', - content => "# ${name}\nPackage: ${packages}\nPin: release a=${release}\nPin-Priority: ${priority}", + content => "# ${name}\nPackage: ${packages}\nPin: ${pin}\nPin-Priority: ${priority}", } } diff --git a/manifests/source.pp b/manifests/source.pp index f3fc7b995a..0040c14f4e 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -35,10 +35,16 @@ notify => Exec['apt_update'], } + if ($pin != false) and ($ensure == 'present') { - apt::pin { $release: + # Get the host portion out of the url so we can pin to origin + $url_split = split($location, '/') + $host = $url_split[2] + + apt::pin { $name: priority => $pin, - before => File["${name}.list"] + before => File["${name}.list"], + origin => $host, } } From d28de442663dbb6f982e8d8e28c2956171cf9810 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 14:49:30 -0700 Subject: [PATCH 080/574] move pin out to a template --- manifests/pin.pp | 2 +- templates/pin.pref.erb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 templates/pin.pref.erb diff --git a/manifests/pin.pp b/manifests/pin.pp index 2664c9ba6a..f19df00f23 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -27,6 +27,6 @@ owner => root, group => root, mode => '0644', - content => "# ${name}\nPackage: ${packages}\nPin: ${pin}\nPin-Priority: ${priority}", + content => template("apt/pin.pref.erb"), } } diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb new file mode 100644 index 0000000000..9a1e690ee6 --- /dev/null +++ b/templates/pin.pref.erb @@ -0,0 +1,4 @@ +# <%= name %> +Package: <%= packages %> +Pin: <%= pin %> +Pin-Priority: <%= priority %> From 5d94369f15145ed39df43b18858f818b17d56b8e Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 14:52:36 -0700 Subject: [PATCH 081/574] pass ensure through so that we can remove pin prefs too --- manifests/source.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/source.pp b/manifests/source.pp index 0040c14f4e..ce801bc76c 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -36,12 +36,13 @@ } - if ($pin != false) and ($ensure == 'present') { + if ($pin != false) { # Get the host portion out of the url so we can pin to origin $url_split = split($location, '/') $host = $url_split[2] apt::pin { $name: + ensure => $ensure, priority => $pin, before => File["${name}.list"], origin => $host, From 3ac02c5c4252ec93a34580309ad46e4d2e222fd1 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 15:03:30 -0700 Subject: [PATCH 082/574] Preserve backwards compatibility --- manifests/pin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index f19df00f23..73f5795f3c 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -18,7 +18,7 @@ } elsif $origin != '' { $pin = "origin \"${origin}\"" } else { - err("Apt::Pin needs either $release or $origin") + $pin = "release a=${name}" } file { "${name}.pref": From 6e9232a6279556920b88f3df70cf0a40435909ba Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 15:48:00 -0700 Subject: [PATCH 083/574] align = --- manifests/init.pp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 0002589368..7338907689 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,11 +20,11 @@ # Sample Usage: # class { 'apt': } class apt( - $always_apt_update = false, - $disable_keys = undef, - $proxy_host = false, - $proxy_port = '8080', - $purge_sources_list = false, + $always_apt_update = false, + $disable_keys = undef, + $proxy_host = false, + $proxy_port = '8080', + $purge_sources_list = false, $purge_sources_list_d = false ) { From cfb6a3560378bfc4380c80fa3b6ac66f80a9c3ab Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 15:51:33 -0700 Subject: [PATCH 084/574] allow for purging preferences --- manifests/init.pp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 7338907689..34756644a3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -25,7 +25,8 @@ $proxy_host = false, $proxy_port = '8080', $purge_sources_list = false, - $purge_sources_list_d = false + $purge_sources_list_d = false, + $purge_preferences_d = false ) { include apt::params @@ -69,6 +70,15 @@ notify => Exec['apt_update'], } + file { 'preferences.d': + ensure => directory, + path => $preferences_d, + owner => root, + group => root, + purge => $purge_preferences_d, + recurse => $purge_preferences_d, + } + case $disable_keys { true: { file { '99unauth': From f0d18b6ed78b6177e8a7bab721d340d811b10b9c Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 15:56:29 -0700 Subject: [PATCH 085/574] use variable from params and also validate the purge_preferences_d --- manifests/init.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 34756644a3..c42d9ac049 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -32,7 +32,7 @@ include apt::params include apt::update - validate_bool($purge_sources_list, $purge_sources_list_d) + validate_bool($purge_sources_list, $purge_sources_list_d, $purge_preferences_d) $sources_list_content = $purge_sources_list ? { false => undef, @@ -48,6 +48,7 @@ $root = $apt::params::root $apt_conf_d = $apt::params::apt_conf_d $sources_list_d = $apt::params::sources_list_d + $preferences_d = $apt::params::preferences_d $provider = $apt::params::provider file { 'sources.list': From 836f16e946b316d7eb3a38fb38c9e1a2d064f557 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Mon, 21 May 2012 17:06:10 -0700 Subject: [PATCH 086/574] add .pref extension, which according to apt_preferences(5) may or may not be present, and is helpful if you are going to have an extension at all --- manifests/pin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 73f5795f3c..58694d68f6 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -23,7 +23,7 @@ file { "${name}.pref": ensure => $ensure, - path => "${preferences_d}/${name}", + path => "${preferences_d}/${name}.pref", owner => root, group => root, mode => '0644', From fbe44e8b27d97c2946ed550ff2344c501aba7f32 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Tue, 22 May 2012 13:09:10 -0700 Subject: [PATCH 087/574] Remove recursive symlink from fixtures --- spec/fixtures/modules/apt | 1 - 1 file changed, 1 deletion(-) delete mode 120000 spec/fixtures/modules/apt diff --git a/spec/fixtures/modules/apt b/spec/fixtures/modules/apt deleted file mode 120000 index 1b20c9fb81..0000000000 --- a/spec/fixtures/modules/apt +++ /dev/null @@ -1 +0,0 @@ -../../../ \ No newline at end of file From a4e1ee750887456b0d396ad8fb2a76e71dd4c4d5 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Tue, 22 May 2012 13:10:05 -0700 Subject: [PATCH 088/574] fallback to the puppet modulepath if a module is missing from fixtures --- spec/spec_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 46fe2371c9..660e21823c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,9 +6,13 @@ def param_value(subject, type, title, param) subject.resource(type, title).send(:parameters)[param.to_sym] end +Puppet.parse_config +puppet_module_path = Puppet[:modulepath] + fixture_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) RSpec.configure do |c| - c.module_path = File.join(fixture_path, 'modules') + fixture_module_path = File.join(fixture_path, 'modules') + c.module_path = [fixture_module_path, puppet_module_path].join(":") c.manifest_dir = File.join(fixture_path, 'manifests') end From f420cb6314ad13e213c113cda08d7ea79b00b856 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Tue, 22 May 2012 13:10:30 -0700 Subject: [PATCH 089/574] add spec_prep, spec_clean, and spec_full rake tasks These targets automate the fixtures directory using a configuration stored in fixtures.yml. Because we can now handle the fixtures directory with a rake task, the clone commands have been removed from the Travis config. --- .travis.yml | 3 +-- Rakefile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ fixtures.yml | 5 +++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 fixtures.yml diff --git a/.travis.yml b/.travis.yml index a4ec2c12e1..8fa95c3875 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,8 @@ language: ruby rvm: - 1.8.7 before_script: - - "git clone git://github.com/puppetlabs/puppetlabs-stdlib.git spec/fixtures/modules/stdlib" after_script: -script: "rake spec" +script: "rake spec_full" branches: only: - master diff --git a/Rakefile b/Rakefile index 5cbef6b45c..481051942e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ require 'rake' require 'rspec/core/rake_task' +require 'yaml' task :default => [:spec] @@ -9,6 +10,61 @@ RSpec::Core::RakeTask.new(:spec) do |t| t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb' end +# This is a helper for the self-symlink entry of fixtures.yml +def source_dir + File.dirname(__FILE__) +end + +def fixtures(category) + begin + fixtures = YAML.load_file("fixtures.yml")["fixtures"] + rescue Errno::ENOENT + return {} + end + + if not fixtures + abort("malformed fixtures.yml") + end + + result = {} + if fixtures.include? category + fixtures[category].each do |fixture, source| + target = "spec/fixtures/modules/#{fixture}" + real_source = eval('"'+source+'"') + result[real_source] = target + end + end + return result +end + +desc "Create the fixtures directory" +task :spec_prep do + fixtures("repositories").each do |repo, target| + File::exists?(target) || system("git clone #{repo} #{target}") + end + + fixtures("symlinks").each do |source, target| + File::exists?(target) || FileUtils::ln_s(source, target) + end +end + +desc "Clean up the fixtures directory" +task :spec_clean do + fixtures("repositories").each do |repo, target| + FileUtils::rm_rf(target) + end + + fixtures("symlinks").each do |source, target| + FileUtils::rm(target) + end +end + +task :spec_full do + Rake::Task[:spec_prep].invoke + Rake::Task[:spec].invoke + Rake::Task[:spec_clean].invoke +end + desc "Build puppet module package" task :build do # This will be deprecated once puppet-module is a face. diff --git a/fixtures.yml b/fixtures.yml new file mode 100644 index 0000000000..dbd5621dea --- /dev/null +++ b/fixtures.yml @@ -0,0 +1,5 @@ +fixtures: + repositories: + "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" + symlinks: + "apt": "#{source_dir}" From 0f9793bda8e2f6e6e42121dfc9f7d098abb57249 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Tue, 22 May 2012 15:15:04 -0700 Subject: [PATCH 090/574] Make gemfile and fixtures.yml hidden files for the sake of module tool --- fixtures.yml => .fixtures.yml | 0 Gemfile => .gemfile | 0 .travis.yml | 1 + Rakefile | 2 +- 4 files changed, 2 insertions(+), 1 deletion(-) rename fixtures.yml => .fixtures.yml (100%) rename Gemfile => .gemfile (100%) diff --git a/fixtures.yml b/.fixtures.yml similarity index 100% rename from fixtures.yml rename to .fixtures.yml diff --git a/Gemfile b/.gemfile similarity index 100% rename from Gemfile rename to .gemfile diff --git a/.travis.yml b/.travis.yml index 8fa95c3875..0ec5a08732 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,4 @@ env: - PUPPET_VERSION=2.6.9 notifications: email: false +gemfile: .gemfile diff --git a/Rakefile b/Rakefile index 481051942e..20fc384a20 100644 --- a/Rakefile +++ b/Rakefile @@ -17,7 +17,7 @@ end def fixtures(category) begin - fixtures = YAML.load_file("fixtures.yml")["fixtures"] + fixtures = YAML.load_file(".fixtures.yml")["fixtures"] rescue Errno::ENOENT return {} end From 83e20806b2a80a1807cc7d4297d015afcb86a11c Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Tue, 22 May 2012 17:18:40 -0700 Subject: [PATCH 091/574] (#14657) Fix filename when there is a period in the PPA --- manifests/ppa.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 64c65bbd09..6b38e52d63 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -12,8 +12,9 @@ fail('lsbdistcodename fact not available: release parameter required') } - $filename_without_slashes = regsubst($name,'/','-','G') - $filename_without_ppa = regsubst($filename_without_slashes, '^ppa:','','G') + $filename_without_slashes = regsubst($name, '/', '-', G) + $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', G) + $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', G) $sources_list_d_filename = "${filename_without_ppa}-${release}.list" if ! defined(Package['python-software-properties']) { From 4ea122feac4ae80cefeebcde01746bd831d2e594 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Wed, 23 May 2012 10:18:48 -0700 Subject: [PATCH 092/574] contribute --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 952e331c1d..e8e5a9a305 100644 --- a/README.md +++ b/README.md @@ -92,3 +92,4 @@ Ryan Coleman Scott McLeod Spencer Krum William Van Hevelingen +Zach Leslie From f5b3c5bcdf72f88b3154ed46843c8ce212fac52f Mon Sep 17 00:00:00 2001 From: Roman Skvazh Date: Thu, 24 May 2012 13:46:00 +0400 Subject: [PATCH 093/574] Add functionality to pin source with originator "release o=..." If you need to pin certain Launchpad PPA (ppa:rskvazh/php), you may do: apt::pin { 'my-launchpad-repo': priority => 700, originator =>'LP-PPA-rskvazh-php', } --- manifests/pin.pp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 58694d68f6..8e2873a9c0 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -2,11 +2,12 @@ # pin a release in apt, useful for unstable repositories define apt::pin( - $ensure = present, - $packages = '*', - $priority = 0, - $release = '', - $origin = '' + $ensure = present, + $packages = '*', + $priority = 0, + $release = '', + $origin = '', + $originator = '', ) { include apt::params @@ -17,6 +18,8 @@ $pin = "release a=${release}" } elsif $origin != '' { $pin = "origin \"${origin}\"" + } elsif $originator != '' { + $pin = "release o=${originator}" } else { $pin = "release a=${name}" } From 4c77eed8ec78ebd7ee5ffa745dec010ac1d45983 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Fri, 25 May 2012 11:08:15 -0700 Subject: [PATCH 094/574] Update Rakefile to my latest template version * Add a 'clean' task * Fix an issue when there are no repository fixtures --- Rakefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Rakefile b/Rakefile index 20fc384a20..ab25667afa 100644 --- a/Rakefile +++ b/Rakefile @@ -43,6 +43,7 @@ task :spec_prep do File::exists?(target) || system("git clone #{repo} #{target}") end + FileUtils::mkdir_p("spec/fixtures/modules") fixtures("symlinks").each do |source, target| File::exists?(target) || FileUtils::ln_s(source, target) end @@ -77,6 +78,11 @@ task :build do end end +desc "Clean a built module package" +task :clean do + FileUtils.rm_rf("pkg/") +end + desc "Check puppet manifests with puppet-lint" task :lint do # This requires pull request: https://github.com/rodjek/puppet-lint/pull/81 From ebd05e5c5191d949f06efdd49fb2eef5ecd4e4a4 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Fri, 25 May 2012 11:20:46 -0700 Subject: [PATCH 095/574] Fix spec tests --- spec/classes/backports_spec.rb | 6 +++--- spec/defines/pin_spec.rb | 4 ++-- spec/defines/source_spec.rb | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb index efac860755..17e34a0e01 100644 --- a/spec/classes/backports_spec.rb +++ b/spec/classes/backports_spec.rb @@ -10,7 +10,7 @@ } end - it { should contain_apt__source('backports.list').with({ + it { should contain_apt__source('backports').with({ 'location' => 'http://old-releases.ubuntu.com/ubuntu', 'release' => 'karmic-backports', 'repos' => 'universe multiverse restricted', @@ -30,7 +30,7 @@ } end - it { should contain_apt__source('backports.list').with({ + it { should contain_apt__source('backports').with({ 'location' => 'http://backports.debian.org/debian-backports', 'release' => 'squeeze-backports', 'repos' => 'main contrib non-free', @@ -58,7 +58,7 @@ { 'location' => location } end - it { should contain_apt__source('backports.list').with({ + it { should contain_apt__source('backports').with({ 'location' => location, 'release' => 'squeeze-backports', 'repos' => 'main contrib non-free', diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index b5b10d702b..bfa0126030 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -40,11 +40,11 @@ it { should contain_file("#{title}.pref").with({ 'ensure' => param_hash[:ensure], - 'path' => "/etc/apt/preferences.d/#{title}", + 'path' => "/etc/apt/preferences.d/#{title}.pref", 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}", + 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}\n", }) } end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 110e8c21b6..ed9ce5292c 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -84,12 +84,12 @@ it { if param_hash[:pin] - should contain_apt__pin(param_hash[:release]).with({ + should contain_apt__pin(title).with({ "priority" => param_hash[:pin], "before" => "File[#{title}.list]" }) else - should_not contain_apt__pin(param_hash[:release]).with({ + should_not contain_apt__pin(title).with({ "priority" => param_hash[:pin], "before" => "File[#{title}.list]" }) From bf1bb279986234750138ea089fc8e9f6264f779e Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Fri, 25 May 2012 12:38:53 -0700 Subject: [PATCH 096/574] Remove a trailing comma to fix older puppets --- manifests/pin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 8e2873a9c0..14df14b5b3 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -7,7 +7,7 @@ $priority = 0, $release = '', $origin = '', - $originator = '', + $originator = '' ) { include apt::params From 16bb92da3601216bb322965fd3295e6219d3bf83 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Fri, 25 May 2012 11:42:17 -0700 Subject: [PATCH 097/574] Update Modulefile and CHANGELOG for 0.0.4 --- CHANGELOG | 6 ++++++ Modulefile | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 1dc4b61cc9..da4072f252 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +2012-05-25 Puppet Labs - 0.0.4 + * Fix ppa list filename when there is a period in the PPA name + * Add .pref extension to apt preferences files + * Allow preferences to be purged + * Extend pin support + 2012-05-04 Puppet Labs - 0.0.3 * only invoke apt-get update once * only install python-software-properties if a ppa is added diff --git a/Modulefile b/Modulefile index ac081cb862..9c988af97c 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '0.0.3' +version '0.0.4' source 'https://github.com/puppetlabs/puppet-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From 7450a5ffc0e89fbf87e2a02c4a52ff7b91258539 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Fri, 25 May 2012 15:32:49 -0700 Subject: [PATCH 098/574] Fix the spec test for apt::source the $location paramater is meant to be a deb location, so it should be formatted as a URI. --- spec/defines/source_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index ed9ce5292c..583c6190d4 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -22,7 +22,7 @@ [{}, { - :location => 'somewhere', + :location => 'http://example.com', :release => 'precise', :repos => 'security', :include_src => false, @@ -39,7 +39,7 @@ }, { :ensure => 'absent', - :location => 'somewhere', + :location => 'http://example.com', :release => 'precise', :repos => 'security', } From 918a3767ff7d8fb27a1db3c59a409fcfae83e2d2 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Tue, 29 May 2012 10:48:54 -0700 Subject: [PATCH 099/574] Switch to the new puppetlabs_spec_helper gem --- .gemfile | 9 +---- .travis.yml | 2 +- Rakefile | 92 +-------------------------------------------- spec/spec_helper.rb | 19 +--------- 4 files changed, 4 insertions(+), 118 deletions(-) diff --git a/.gemfile b/.gemfile index e4be4470c6..9aad840c0a 100644 --- a/.gemfile +++ b/.gemfile @@ -1,12 +1,5 @@ source :rubygems puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] - gem 'puppet', puppetversion - -group :test do - gem 'rake', '>= 0.9.0' - gem 'rspec', '>= 2.8.0' - gem 'rspec-puppet', '>= 0.1.1' - gem 'mocha', '>= 0.11.0' -end +gem 'puppetlabs_spec_helper', '>= 0.1.0' diff --git a/.travis.yml b/.travis.yml index 0ec5a08732..bf7829ef78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ rvm: - 1.8.7 before_script: after_script: -script: "rake spec_full" +script: "rake spec" branches: only: - master diff --git a/Rakefile b/Rakefile index ab25667afa..cd3d379958 100644 --- a/Rakefile +++ b/Rakefile @@ -1,91 +1 @@ -require 'rake' -require 'rspec/core/rake_task' -require 'yaml' - -task :default => [:spec] - -desc "Run all module spec tests (Requires rspec-puppet gem)" -RSpec::Core::RakeTask.new(:spec) do |t| - t.rspec_opts = ['--color'] - t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb' -end - -# This is a helper for the self-symlink entry of fixtures.yml -def source_dir - File.dirname(__FILE__) -end - -def fixtures(category) - begin - fixtures = YAML.load_file(".fixtures.yml")["fixtures"] - rescue Errno::ENOENT - return {} - end - - if not fixtures - abort("malformed fixtures.yml") - end - - result = {} - if fixtures.include? category - fixtures[category].each do |fixture, source| - target = "spec/fixtures/modules/#{fixture}" - real_source = eval('"'+source+'"') - result[real_source] = target - end - end - return result -end - -desc "Create the fixtures directory" -task :spec_prep do - fixtures("repositories").each do |repo, target| - File::exists?(target) || system("git clone #{repo} #{target}") - end - - FileUtils::mkdir_p("spec/fixtures/modules") - fixtures("symlinks").each do |source, target| - File::exists?(target) || FileUtils::ln_s(source, target) - end -end - -desc "Clean up the fixtures directory" -task :spec_clean do - fixtures("repositories").each do |repo, target| - FileUtils::rm_rf(target) - end - - fixtures("symlinks").each do |source, target| - FileUtils::rm(target) - end -end - -task :spec_full do - Rake::Task[:spec_prep].invoke - Rake::Task[:spec].invoke - Rake::Task[:spec_clean].invoke -end - -desc "Build puppet module package" -task :build do - # This will be deprecated once puppet-module is a face. - begin - Gem::Specification.find_by_name('puppet-module') - rescue Gem::LoadError, NoMethodError - require 'puppet/face' - pmod = Puppet::Face['module', :current] - pmod.build('./') - end -end - -desc "Clean a built module package" -task :clean do - FileUtils.rm_rf("pkg/") -end - -desc "Check puppet manifests with puppet-lint" -task :lint do - # This requires pull request: https://github.com/rodjek/puppet-lint/pull/81 - system("puppet-lint manifests") - system("puppet-lint tests") -end +require 'puppetlabs_spec_helper/rake_tasks' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 660e21823c..2c6f56649a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,18 +1 @@ -require 'rubygems' -require 'puppet' -require 'rspec-puppet' - -def param_value(subject, type, title, param) - subject.resource(type, title).send(:parameters)[param.to_sym] -end - -Puppet.parse_config -puppet_module_path = Puppet[:modulepath] - -fixture_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures')) - -RSpec.configure do |c| - fixture_module_path = File.join(fixture_path, 'modules') - c.module_path = [fixture_module_path, puppet_module_path].join(":") - c.manifest_dir = File.join(fixture_path, 'manifests') -end +require 'puppetlabs_spec_helper/module_spec_helper' From f9218530f83cbcb5d7aa8dbef182cb5954a74721 Mon Sep 17 00:00:00 2001 From: Branan Purvine-Riley Date: Tue, 5 Jun 2012 09:50:41 -0700 Subject: [PATCH 100/574] Fix Modulefile for puppet-apt to puppetlabs-apt rename --- Modulefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modulefile b/Modulefile index 9c988af97c..5dfa9e6614 100644 --- a/Modulefile +++ b/Modulefile @@ -1,11 +1,11 @@ name 'puppetlabs-apt' version '0.0.4' -source 'https://github.com/puppetlabs/puppet-apt' +source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' summary 'Puppet Labs Apt Module' description 'APT Module for Puppet' -project_page 'https://github.com/puppetlabs/puppet-apt' +project_page 'https://github.com/puppetlabs/puppetlabs-apt' ## Add dependencies, if any: dependency 'puppetlabs/stdlib', '>= 2.2.1' From 2dcec036ca9d7e99dd9f50c4031dafeb86d6b6c2 Mon Sep 17 00:00:00 2001 From: Nan Liu Date: Thu, 7 Jun 2012 14:53:41 -0700 Subject: [PATCH 101/574] Add logoutput on_failure for all exec resources. We need more information to debug issues on exec failure. This change enables logouput => on_failure. --- manifests/builddep.pp | 5 +++-- manifests/force.pp | 3 ++- manifests/key.pp | 20 +++++++++++--------- manifests/ppa.pp | 11 ++++++----- manifests/source.pp | 3 ++- manifests/update.pp | 1 + 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/manifests/builddep.pp b/manifests/builddep.pp index 997a2064f8..3294f71339 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -4,8 +4,9 @@ include apt::update exec { "apt-builddep-${name}": - command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", - notify => Exec['apt_update'], + command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", + logoutput => 'on_failure', + notify => Exec['apt_update'], } # Need anchor to provide containment for dependencies. diff --git a/manifests/force.pp b/manifests/force.pp index 0089bbd753..d3d5962d08 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -16,6 +16,7 @@ default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'", } exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}": - unless => $install_check, + unless => $install_check, + logoutput => 'on_failure', } } diff --git a/manifests/key.pp b/manifests/key.pp index 037eec5288..dbbed2bef0 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -46,10 +46,11 @@ 'server' => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'", } exec { $digest: - path => '/bin:/usr/bin', - unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'", - before => Anchor["apt::key ${upkey} present"], - command => $digest_command, + command => $digest_command, + path => '/bin:/usr/bin', + unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'", + logoutput => 'on_failure', + before => Anchor["apt::key ${upkey} present"], } } @@ -63,11 +64,12 @@ } exec { "apt::key ${upkey} absent": - path => '/bin:/usr/bin', - onlyif => "apt-key list | grep '${upkey}'", - command => "apt-key del '${upkey}'", - user => 'root', - group => 'root', + command => "apt-key del '${upkey}'", + path => '/bin:/usr/bin', + onlyif => "apt-key list | grep '${upkey}'", + user => 'root', + group => 'root', + logoutput => 'on_failure', } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 6b38e52d63..9527e0d624 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -22,11 +22,12 @@ } exec { "add-apt-repository-${name}": - command => "/usr/bin/add-apt-repository ${name}", - creates => "${sources_list_d}/${sources_list_d_filename}", - require => [ File[$sources_list_d], - Package['python-software-properties'] ], - notify => Exec['apt_update'], + command => "/usr/bin/add-apt-repository ${name}", + creates => "${sources_list_d}/${sources_list_d_filename}", + logoutput => 'on_failure', + require => [ File[$sources_list_d], + Package['python-software-properties'] ], + notify => Exec['apt_update'], } file { "${sources_list_d}/${sources_list_d_filename}": diff --git a/manifests/source.pp b/manifests/source.pp index ce801bc76c..106b16000c 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -52,8 +52,9 @@ if ($required_packages != false) and ($ensure == 'present') { exec { "Required packages: '${required_packages}' for ${name}": command => "${provider} -y install ${required_packages}", - subscribe => File["${name}.list"], + logoutput => 'on_failure', refreshonly => true, + subscribe => File["${name}.list"], } } diff --git a/manifests/update.pp b/manifests/update.pp index 016df7d6af..e9b9ea9554 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -3,6 +3,7 @@ exec { 'apt_update': command => "${apt::params::provider} update", + logoutput => 'on_failure', refreshonly => true, } } From 74959d8f8e22d52103954ee4127d15cc812cb94d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Lindstr=C3=B6m?= Date: Tue, 12 Jun 2012 09:56:19 +0200 Subject: [PATCH 102/574] fix scoping of $lsbdistcodename in source.pp Current unscoped variable yields deprecation warning: warning: Dynamic lookup of $lsbdistcodename at [..]/apt/manifests/source.pp:7 is deprecated. --- manifests/source.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/source.pp b/manifests/source.pp index 106b16000c..2c26227ec4 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -4,7 +4,7 @@ define apt::source( $ensure = present, $location = '', - $release = $lsbdistcodename, + $release = $::lsbdistcodename, $repos = 'main', $include_src = true, $required_packages = false, From 3adb53c4a6bf99efa79f59468561657208dae2b8 Mon Sep 17 00:00:00 2001 From: ytjohn Date: Wed, 13 Jun 2012 18:48:58 -0300 Subject: [PATCH 103/574] Without puppetlabs/stdlib, you will get "err: Could not retrieve catalog from remote server: Error 400 on SERVER: Unknown function validate_bool" --- manifests/init.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index c42d9ac049..3587d21b5b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,9 +16,10 @@ # Actions: # # Requires: -# +# puppetlabs/stdlib # Sample Usage: # class { 'apt': } + class apt( $always_apt_update = false, $disable_keys = undef, From 145a2853d4e5eaf857fdcf487e50ed62cb29ed95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Ara=C3=B1a=20Cruz?= Date: Fri, 29 Jun 2012 13:15:13 +0200 Subject: [PATCH 104/574] =?UTF-8?q?Add=20=C2=ABmain=C2=BB=20to=20Ubuntu=20?= =?UTF-8?q?backports=20repos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifests/backports.pp | 2 +- spec/classes/backports_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index 147801e6e8..aafdf96578 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -33,7 +33,7 @@ release => "${release_real}-backports", repos => $::lsbdistid ? { 'debian' => 'main contrib non-free', - 'ubuntu' => 'universe multiverse restricted', + 'ubuntu' => 'main universe multiverse restricted', }, key => $::lsbdistid ? { 'debian' => '55BE302B', diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb index 17e34a0e01..27c6708f25 100644 --- a/spec/classes/backports_spec.rb +++ b/spec/classes/backports_spec.rb @@ -13,7 +13,7 @@ it { should contain_apt__source('backports').with({ 'location' => 'http://old-releases.ubuntu.com/ubuntu', 'release' => 'karmic-backports', - 'repos' => 'universe multiverse restricted', + 'repos' => 'main universe multiverse restricted', 'key' => '437D05B5', 'key_server' => 'pgp.mit.edu', 'pin' => '200', From fcb90f7b6c716ce0f491fd8b19fb84a3ca253ba8 Mon Sep 17 00:00:00 2001 From: sathlan Date: Mon, 9 Jul 2012 05:24:49 +0300 Subject: [PATCH 105/574] Add a way to specify a timeout for the apt::force define. --- manifests/force.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/force.pp b/manifests/force.pp index d3d5962d08..75634b476d 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -3,7 +3,8 @@ define apt::force( $release = 'testing', - $version = false + $version = false, + $timeout = 300 ) { $version_string = $version ? { @@ -18,5 +19,6 @@ exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}": unless => $install_check, logoutput => 'on_failure', + timeout => $timeout, } } From d49dbb49ae2d450e434133640a71107c61d8d56d Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Tue, 3 Jul 2012 23:49:01 +0200 Subject: [PATCH 106/574] fix check of release parameter --- manifests/source.pp | 12 +++++++++--- spec/defines/source_spec.rb | 6 ++++++ templates/source.list.erb | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 2c26227ec4..a859174a1a 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -4,7 +4,7 @@ define apt::source( $ensure = present, $location = '', - $release = $::lsbdistcodename, + $release = 'UNDEF', $repos = 'main', $include_src = true, $required_packages = false, @@ -21,8 +21,14 @@ $sources_list_d = $apt::params::sources_list_d $provider = $apt::params::provider - if $release == undef { - fail('lsbdistcodename fact not available: release parameter required') + if $release == 'UNDEF' { + if $::lsbdistcodename == undef { + fail('lsbdistcodename fact not available: release parameter required') + } else { + $release_real = $::lsbdistcodename + } + } else { + $release_real = $release } file { "${name}.list": diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 583c6190d4..0f37f6367b 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -42,6 +42,12 @@ :location => 'http://example.com', :release => 'precise', :repos => 'security', + }, + { + :release => '', + }, + { + :release => 'custom', } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do diff --git a/templates/source.list.erb b/templates/source.list.erb index 345269162b..faa7e286ec 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,5 +1,5 @@ # <%= name %> -deb <%= location %> <%= release %> <%= repos %> +deb <%= location %> <%= release_real %> <%= repos %> <%- if include_src then -%> -deb-src <%= location %> <%= release %> <%= repos %> +deb-src <%= location %> <%= release_real %> <%= repos %> <%- end -%> From a3d782c3b5cf128b3ef8e910ef42297a38a96a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Dal=C3=A9n?= Date: Tue, 21 Aug 2012 22:55:24 +0200 Subject: [PATCH 107/574] Fix style errors --- manifests/backports.pp | 21 ++++++++++++--------- manifests/conf.pp | 4 ++-- manifests/init.pp | 2 +- manifests/key.pp | 2 +- manifests/pin.pp | 2 +- manifests/ppa.pp | 6 ++++-- tests/key.pp | 6 +++--- 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index aafdf96578..e9180c48c2 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -16,7 +16,8 @@ # # == Authors # -# Ben Hughes, I think. At least blame him if this goes wrong. I just added puppet doc. +# Ben Hughes, I think. At least blame him if this goes wrong. +# I just added puppet doc. # # == Copyright # @@ -27,18 +28,20 @@ ) inherits apt::params { $release_real = downcase($release) + $key = $::lsbdistid ? { + 'debian' => '55BE302B', + 'ubuntu' => '437D05B5', + } + $repos = $::lsbdistid ? { + 'debian' => 'main contrib non-free', + 'ubuntu' => 'main universe multiverse restricted', + } apt::source { 'backports': location => $location, release => "${release_real}-backports", - repos => $::lsbdistid ? { - 'debian' => 'main contrib non-free', - 'ubuntu' => 'main universe multiverse restricted', - }, - key => $::lsbdistid ? { - 'debian' => '55BE302B', - 'ubuntu' => '437D05B5', - }, + repos => $repos, + key => $key, key_server => 'pgp.mit.edu', pin => '200', } diff --git a/manifests/conf.pp b/manifests/conf.pp index 03aab8e002..3c4cb1975c 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -1,7 +1,7 @@ define apt::conf ( + $content, $ensure = present, - $priority = '50', - $content + $priority = '50' ) { include apt::params diff --git a/manifests/init.pp b/manifests/init.pp index 3587d21b5b..442e04c587 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -108,7 +108,7 @@ } # Need anchor to provide containment for dependencies. - anchor { "apt::update": + anchor { 'apt::update': require => Class['apt::update'], } } diff --git a/manifests/key.pp b/manifests/key.pp index dbbed2bef0..98a0f3a32c 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -54,7 +54,7 @@ } } - Anchor["apt::key $upkey present"] -> Anchor["apt::key/$title"] + Anchor["apt::key ${upkey} present"] -> Anchor["apt::key/${title}"] } absent: { diff --git a/manifests/pin.pp b/manifests/pin.pp index 14df14b5b3..4ef8953aa8 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -30,6 +30,6 @@ owner => root, group => root, mode => '0644', - content => template("apt/pin.pref.erb"), + content => template('apt/pin.pref.erb'), } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 9527e0d624..0458589849 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -25,8 +25,10 @@ command => "/usr/bin/add-apt-repository ${name}", creates => "${sources_list_d}/${sources_list_d_filename}", logoutput => 'on_failure', - require => [ File[$sources_list_d], - Package['python-software-properties'] ], + require => [ + File[$sources_list_d], + Package['python-software-properties'], + ], notify => Exec['apt_update'], } diff --git a/tests/key.pp b/tests/key.pp index 5c62a4c0d8..92679cf6be 100644 --- a/tests/key.pp +++ b/tests/key.pp @@ -1,5 +1,5 @@ # Declare Apt key for apt.puppetlabs.com source -apt::key { "puppetlabs": - key => "4BD6EC30", - key_server => "pgp.mit.edu", +apt::key { 'puppetlabs': + key => '4BD6EC30', + key_server => 'pgp.mit.edu', } From 14b2eb1ca0ce3886478fcc0b23794237cd387de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Dal=C3=A9n?= Date: Wed, 22 Aug 2012 10:11:48 +0200 Subject: [PATCH 108/574] (#16075) Allow pinning on version numbers This is needed to be able to produce the following pinning from apt_preferences(5): Package: perl Pin: version 5.8* Pin-Priority: 1001 --- manifests/pin.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 14df14b5b3..a69df2a695 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -7,7 +7,8 @@ $priority = 0, $release = '', $origin = '', - $originator = '' + $originator = '', + $version = '' ) { include apt::params @@ -20,6 +21,8 @@ $pin = "origin \"${origin}\"" } elsif $originator != '' { $pin = "release o=${originator}" + } elsif $version != '' { + $pin = "version ${version}" } else { $pin = "release a=${name}" } From 40f875521715759eddab7315f6d51e6519f016d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Dal=C3=A9n?= Date: Tue, 21 Aug 2012 23:14:54 +0200 Subject: [PATCH 109/574] (#16070) Allow optional order parameter to apt::pin As the apt pinnings are parsed in ascending alphabetical order with first match wins within a given scope it is useful to be able to specify a ordering parameter. Then the name parameter can be kept to something meaningful. --- manifests/pin.pp | 11 ++++++++++- spec/defines/pin_spec.rb | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 14df14b5b3..96a3d70643 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -3,6 +3,7 @@ define apt::pin( $ensure = present, + $order = '', $packages = '*', $priority = 0, $release = '', @@ -14,6 +15,10 @@ $preferences_d = $apt::params::preferences_d + if $order != '' and !is_integer($order) { + fail('Only integers are allowed in the apt::pin order param') + } + if $release != '' { $pin = "release a=${release}" } elsif $origin != '' { @@ -24,9 +29,13 @@ $pin = "release a=${name}" } + $path = $order ? { + '' => "${preferences_d}/${name}.pref", + default => "${preferences_d}/${order}-${name}.pref", + } file { "${name}.pref": ensure => $ensure, - path => "${preferences_d}/${name}.pref", + path => $path, owner => root, group => root, mode => '0644', diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index bfa0126030..cd269d3b8b 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -5,6 +5,7 @@ let :default_params do { :ensure => 'present', + :order => '', :packages => '*', :priority => '0', :release => nil @@ -16,6 +17,11 @@ :packages => 'apache', :priority => '1' }, + { + :order => 50, + :packages => 'apache', + :priority => '1' + }, { :ensure => 'absent', :packages => 'apache', @@ -40,7 +46,7 @@ it { should contain_file("#{title}.pref").with({ 'ensure' => param_hash[:ensure], - 'path' => "/etc/apt/preferences.d/#{title}.pref", + 'path' => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref", 'owner' => 'root', 'group' => 'root', 'mode' => '0644', From bf7992daa188df52283384716ad4aa03fc062931 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Tue, 2 Oct 2012 10:55:35 -0700 Subject: [PATCH 110/574] Add PL Repo source to README Prior to this commit, the only information about the Puppet Labs repository source was in the tests folder. This commit adds example usage for apt::source to the README for the Puppet Labs APT repository. --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index e8e5a9a305..705cb33de5 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,17 @@ apt::source { "debian_unstable": include_src => true } + +This source will configure your system for the Puppet Labs APT repository. +
+apt::source { 'puppetlabs':
+  location   => 'http://apt.puppetlabs.com',
+  repos      => 'main',
+  key        => '4BD6EC30',
+  key_server => 'pgp.mit.edu',
+}
+
+ ### apt::key Add a key to the list of keys used by apt to authenticate packages.

From 00155ccf1b2486e1a17e3b9f579c6e715fc06ccd Mon Sep 17 00:00:00 2001
From: Markelov Anton 
Date: Thu, 11 Oct 2012 17:37:15 +1100
Subject: [PATCH 111/574] Add a $key_options parameter, which need to work
 apt-key via proxy.

---
 manifests/key.pp | 12 ++++++++++--
 tests/key.pp     |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/manifests/key.pp b/manifests/key.pp
index 98a0f3a32c..a6ebf7bd37 100644
--- a/manifests/key.pp
+++ b/manifests/key.pp
@@ -3,7 +3,8 @@
   $ensure = present,
   $key_content = false,
   $key_source = false,
-  $key_server = 'keyserver.ubuntu.com'
+  $key_server = 'keyserver.ubuntu.com',
+  $key_options = false
 ) {
 
   include apt::params
@@ -39,11 +40,18 @@
         anchor { "apt::key ${upkey} present": }
       }
 
+      if $key_options{
+        $options_string = "--keyserver-options ${key_options}"
+      }
+      else{
+        $options_string = ''
+      }
+
       if !defined(Exec[$digest]) {
         $digest_command = $method ? {
           'content' => "echo '${key_content}' | /usr/bin/apt-key add -",
           'source'  => "wget -q '${key_source}' -O- | apt-key add -",
-          'server'  => "apt-key adv --keyserver '${key_server}' --recv-keys '${upkey}'",
+          'server'  => "apt-key adv --keyserver '${key_server}' ${options_string} --recv-keys '${upkey}'",
         }
         exec { $digest:
           command   => $digest_command,
diff --git a/tests/key.pp b/tests/key.pp
index 92679cf6be..cc90f909c0 100644
--- a/tests/key.pp
+++ b/tests/key.pp
@@ -2,4 +2,5 @@
 apt::key { 'puppetlabs':
   key        => '4BD6EC30',
   key_server => 'pgp.mit.edu',
+  key_options => "http-proxy=\"http://proxyuser:proxypass@example.org:3128\"",
 }

From 2aafe6cbb2545528d19515b8ed91b8f0a9f97bd2 Mon Sep 17 00:00:00 2001
From: Branan Purvine-Riley 
Date: Thu, 18 Oct 2012 18:28:05 -0700
Subject: [PATCH 112/574] Improve documentation of the core apt class usage

---
 README.md | 135 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 74 insertions(+), 61 deletions(-)

diff --git a/README.md b/README.md
index 705cb33de5..e5e86d8f77 100644
--- a/README.md
+++ b/README.md
@@ -5,89 +5,102 @@ Provides helpful definitions for dealing with Apt.
 
 ## Usage
 
-### apt:builddep
+### apt
+The apt class provides a number of common resources and options which
+are shared by the various defined types in this module. This class
+should always be included in your manifests if you are using the `apt`
+module.
+
+    class { 'apt':
+      $always_apt_update    = false,
+      $disable_keys         = undef,
+      $proxy_host           = false,
+      $proxy_port           = '8080',
+      $purge_sources_list   = false,
+      $purge_sources_list_d = false,
+      $purge_preferences_d  = false
+    }
+
+### apt::builddep
 Install the build depends of a specified package.
-
-apt::builddep { "glusterfs-server": }
-
+ + apt::builddep { "glusterfs-server": } ### apt::force -Force a package to be installed from a specific release. Useful when using repositories like Debian unstable in Ubuntu. -
-apt::force { "glusterfs-server":
-	release => "unstable",
-	version => '3.0.3',
-	require => Apt::Source["debian_unstable"],
-}
-
+Force a package to be installed from a specific release. Useful when +using repositories like Debian unstable in Ubuntu. + + apt::force { "glusterfs-server": + release => "unstable", + version => '3.0.3', + require => Apt::Source["debian_unstable"], + } ### apt::pin Add an apt pin for a certain release. -
-apt::pin { "karmic": priority => 700 }
-apt::pin { "karmic-updates": priority => 700 }
-apt::pin { "karmic-security": priority => 700 }
-
+ + apt::pin { "karmic": priority => 700 } + apt::pin { "karmic-updates": priority => 700 } + apt::pin { "karmic-security": priority => 700 } ### apt::ppa Add a ppa repository using `add-apt-repository`. Somewhat experimental. -
-apt::ppa { "ppa:drizzle-developers/ppa": }
-
+ + apt::ppa { "ppa:drizzle-developers/ppa": } ### apt::release -Set the default apt release. Useful when using repositories like Debian unstable in Ubuntu. -
-apt::release { "karmic": }
-
+Set the default apt release. Useful when using repositories like +Debian unstable in Ubuntu. + + apt::release { "karmic": } ### apt::source Add an apt source to `/etc/apt/sources.list.d/`. -
-apt::source { "debian_unstable":
-  location          => "http://debian.mirror.iweb.ca/debian/",
-  release           => "unstable",
-  repos             => "main contrib non-free",
-  required_packages => "debian-keyring debian-archive-keyring",
-  key               => "55BE302B",
-  key_server        => "subkeys.pgp.net",
-  pin               => "-10",
-  include_src       => true
-}
-
- -This source will configure your system for the Puppet Labs APT repository. -
-apt::source { 'puppetlabs':
-  location   => 'http://apt.puppetlabs.com',
-  repos      => 'main',
-  key        => '4BD6EC30',
-  key_server => 'pgp.mit.edu',
-}
-
+ + apt::source { "debian_unstable": + location => "http://debian.mirror.iweb.ca/debian/", + release => "unstable", + repos => "main contrib non-free", + required_packages => "debian-keyring debian-archive-keyring", + key => "55BE302B", + key_server => "subkeys.pgp.net", + pin => "-10", + include_src => true + } + +This source will configure your system for the Puppet Labs APT +repository. + + apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } ### apt::key Add a key to the list of keys used by apt to authenticate packages. -
-apt::key { "puppetlabs":
-  key        => "4BD6EC30",
-  key_server => "pgp.mit.edu",
-}
-
-
-apt::key { "jenkins":
-  key        => "D50582E6",
-  key_source => "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key",
-}
-
+ apt::key { "puppetlabs": + key => "4BD6EC30", + key_server => "pgp.mit.edu", + } + + apt::key { "jenkins": + key => "D50582E6", + key_source => "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key", + } -Note that use of the "key_source" parameter requires wget to be installed and working. +Note that use of the "key_source" parameter requires wget to be +installed and working. ## Contributors -A lot of great people have contributed to this module. A somewhat current list follows. -Ben Godfrey +A lot of great people have contributed to this module. A somewhat +current list follows. + +Ben Godfrey +Branan Purvine-Riley Christian G. Warden Dan Bode Garrett Honeycutt From 5e268fe72b81812f2c11a84c30221c88b6aa89cd Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Sun, 21 Oct 2012 00:18:19 +0300 Subject: [PATCH 113/574] Update readme.md - Syntax of apt class We have to use => and no dollar sign --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e5e86d8f77..72a130c5e7 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ should always be included in your manifests if you are using the `apt` module. class { 'apt': - $always_apt_update = false, - $disable_keys = undef, - $proxy_host = false, - $proxy_port = '8080', - $purge_sources_list = false, - $purge_sources_list_d = false, - $purge_preferences_d = false + always_apt_update => false, + disable_keys => undef, + proxy_host => false, + proxy_port => '8080', + purge_sources_list => false, + purge_sources_list_d => false, + purge_preferences_d => false } ### apt::builddep From 9264120d2e289e30d44ffa394853755de9b9b7a8 Mon Sep 17 00:00:00 2001 From: Markelov Anton Date: Tue, 23 Oct 2012 11:13:58 +1100 Subject: [PATCH 114/574] add new puppet version to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bf7829ef78..6db520f6b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ branches: only: - master env: + - PUPPET_VERSION=3.0.1 - PUPPET_VERSION=2.7.13 - PUPPET_VERSION=2.7.6 - PUPPET_VERSION=2.6.9 From 1378cd5a441ee6dc41a8b85fe8d604deff7d97d6 Mon Sep 17 00:00:00 2001 From: Markelov Anton Date: Tue, 23 Oct 2012 12:35:53 +1100 Subject: [PATCH 115/574] Fix stdlib version dependency --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 5dfa9e6614..24dd985288 100644 --- a/Modulefile +++ b/Modulefile @@ -8,4 +8,4 @@ description 'APT Module for Puppet' project_page 'https://github.com/puppetlabs/puppetlabs-apt' ## Add dependencies, if any: -dependency 'puppetlabs/stdlib', '>= 2.2.1' +dependency 'puppetlabs/stdlib', '>= 3.0.1' From 75092fdbf1b87dbff22ae5b728b390c778db6d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Dal=C3=A9n?= Date: Wed, 22 Aug 2012 10:22:21 +0200 Subject: [PATCH 116/574] (#16076) Ability to fill in pin explanation Adds the ability to fill it in and sets a reasonable default. --- manifests/pin.pp | 1 + spec/defines/pin_spec.rb | 2 +- templates/pin.pref.erb | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index cebc6e7b0d..21cc3ffdef 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -3,6 +3,7 @@ define apt::pin( $ensure = present, + $explanation = "${::caller_module_name}: ${name}", $order = '', $packages = '*', $priority = 0, diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index cd269d3b8b..3aaf49cef4 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -50,7 +50,7 @@ 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - 'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}\n", + 'content' => "# #{title}\nExplanation: : #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}\n", }) } end diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb index 9a1e690ee6..74b92659b8 100644 --- a/templates/pin.pref.erb +++ b/templates/pin.pref.erb @@ -1,4 +1,5 @@ # <%= name %> +Explanation: <%= explanation %> Package: <%= packages %> Pin: <%= pin %> Pin-Priority: <%= priority %> From 949981ff5c0aca3efb73d35c844d97990802edd4 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Mon, 29 Oct 2012 20:24:35 -0700 Subject: [PATCH 117/574] Update Modulefile for 1.0.0 release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit increments the version number to 1.0.0 for a new Puppet Forge release. Version 1.0.0 is a backwards incompatible release of puppetlabs-apt. The major change is to the apt::backports class which had its repos property modified on Ubuntu systems to include the main repository in addition to universe, multiverse & restricted. Additionally, the following bug fixes or minor enhancements were introduced: * Cleanup of style, variable scope and bug fixes. * Exec resources now set the `logoutput` parameter to on_failure. * Adds a timeout parameter to the apt::force defined resource type * Allow pinning on version numbers in apt::pin * Allow optional order parameter to apt::pin * Allow ability to fill in pin explanation Contributions were provided by the following fine folk: Nan Liu Anton Lindström ytjohn Steffen Zieger Erik Dalén Jonathan Araña Cruz sathlan Branan Purvine-Riley Alexander Menk --- Modulefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modulefile b/Modulefile index 5dfa9e6614..64a896f933 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '0.0.4' +version '1.0.0' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' @@ -8,4 +8,4 @@ description 'APT Module for Puppet' project_page 'https://github.com/puppetlabs/puppetlabs-apt' ## Add dependencies, if any: -dependency 'puppetlabs/stdlib', '>= 2.2.1' +dependency 'puppetlabs/stdlib', '2.x' From d190d916787c8140eda2852ca99819a9bd76c2ff Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Mon, 29 Oct 2012 22:31:25 -0700 Subject: [PATCH 118/574] Reset Modulefile to greater than dep expression This commit changes the 2.x expression in the Modulefile which while supported in the PMT, is not supported in librarian-puppet. --- Modulefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 64a896f933..2811677e34 100644 --- a/Modulefile +++ b/Modulefile @@ -8,4 +8,7 @@ description 'APT Module for Puppet' project_page 'https://github.com/puppetlabs/puppetlabs-apt' ## Add dependencies, if any: -dependency 'puppetlabs/stdlib', '2.x' +#dependency 'puppetlabs/stdlib', '2.x' +# The dependency should be written as above but librarian-puppet +# does not support the expression as the PMT does. +dependency 'puppetlabs/stdlib', '>= 2.2.1' From 99eb33612c86926691684fc0a2e617393b9a43d6 Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Mon, 29 Oct 2012 22:33:44 -0700 Subject: [PATCH 119/574] Increment for 1.0.1 release. --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 2811677e34..91d5befcd6 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.0.0' +version '1.0.1' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From ac86fab4598f5ddd3c74ba20e46720714cc468a5 Mon Sep 17 00:00:00 2001 From: Jarl Nicolson Date: Mon, 5 Nov 2012 19:33:38 +1000 Subject: [PATCH 120/574] Changed PPA manifest and tests for new package which started in Quantal --- manifests/ppa.pp | 14 ++++-- spec/defines/ppa_spec.rb | 104 ++++++++++++++++++++++++--------------- 2 files changed, 73 insertions(+), 45 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 0458589849..9ac4d03cee 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -16,9 +16,14 @@ $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', G) $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', G) $sources_list_d_filename = "${filename_without_ppa}-${release}.list" - - if ! defined(Package['python-software-properties']) { - package { 'python-software-properties': } + + $package = $::lsbdistrelease ? { + /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties', + default => 'software-properties-common', + } + + if ! defined(Package[$package]) { + package { $package: } } exec { "add-apt-repository-${name}": @@ -27,7 +32,7 @@ logoutput => 'on_failure', require => [ File[$sources_list_d], - Package['python-software-properties'], + Package["${package}"], ], notify => Exec['apt_update'], } @@ -42,4 +47,3 @@ require => Class['apt::update'], } } - diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index d57c1fb854..6be9ab9142 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -1,58 +1,82 @@ require 'spec_helper' describe 'apt::ppa', :type => :define do - ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t| - describe "with title #{t}" do - let :pre_condition do - 'class { "apt": }' - end + [ { :lsbdistrelease => '11.04', + :lsbdistcodename => 'natty', + :package => 'python-software-properties'}, + { :lsbdistrelease => '12.10', + :lsbdistcodename => 'quantal', + :package => 'software-properties-common'}, + ].each do |platform| + context "on #{platform[:lsbdistcodename]}" do let :facts do - {:lsbdistcodename => 'natty'} - end - let :title do - t + { + :lsbdistrelease => platform[:lsbdistrelease], + :lsbdistcodename => platform[:lsbdistcodename], + } end let :release do - "natty" + "#{platform[:lsbdistcodename]}" end - let :filename do - t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list" + let :package do + "#{platform[:package]}" end + ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t| + describe "with title #{t}" do + let :pre_condition do + 'class { "apt": }' + end + let :title do + t + end + let :filename do + t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list" + end - it { should contain_package("python-software-properties") } + it { should contain_package("#{package}") } - it { should contain_exec("apt_update").with( - 'command' => '/usr/bin/apt-get update', - 'refreshonly' => true - ) - } + it { should contain_exec("apt_update").with( + 'command' => '/usr/bin/apt-get update', + 'refreshonly' => true + ) + } - it { should contain_exec("add-apt-repository-#{t}").with( - 'command' => "/usr/bin/add-apt-repository #{t}", - 'creates' => "/etc/apt/sources.list.d/#{filename}", - 'require' => ["File[/etc/apt/sources.list.d]", "Package[python-software-properties]"], - 'notify' => "Exec[apt_update]" - ) - } + it { should contain_exec("add-apt-repository-#{t}").with( + 'command' => "/usr/bin/add-apt-repository #{t}", + 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], + 'notify' => "Exec[apt_update]" + ) + } - it { should create_file("/etc/apt/sources.list.d/#{filename}").with( - 'ensure' => 'file', - 'require' => "Exec[add-apt-repository-#{t}]" - ) - } + it { should create_file("/etc/apt/sources.list.d/#{filename}").with( + 'ensure' => 'file', + 'require' => "Exec[add-apt-repository-#{t}]" + ) + } + end + end end end - describe "it should not error if package['python-software-properties'] is already defined" do - let :pre_condition do - 'class {"apt": }' + - 'package { "python-software-properties": }->Apt::Ppa["ppa"]' - end - let :facts do - {:lsbdistcodename => 'natty'} + [ { :lsbdistcodename => 'natty', + :package => 'python-software-properties' }, + { :lsbdistcodename => 'quantal', + :package => 'software-properties-common'}, + ].each do |platform| + context "on #{platform[:lsbdistcodename]}" do + describe "it should not error if package['#{platform[:package]}'] is already defined" do + let :pre_condition do + 'class {"apt": }' + + 'package { "#{platform[:package]}": }->Apt::Ppa["ppa"]' + end + let :facts do + {:lsbdistcodename => '#{platform[:lsbdistcodename]}'} + end + let(:title) { "ppa" } + let(:release) { "#{platform[:lsbdistcodename]}" } + it { should contain_package('#{platform[:package]}') } + end end - let(:title) { "ppa" } - let(:release) { "natty" } - it { should contain_package("python-software-properties") } end describe "without Class[apt] should raise a Puppet::Error" do From f6c4c385abb9e1ab35f16b042606aac996d99cfd Mon Sep 17 00:00:00 2001 From: Ryan Coleman Date: Sun, 2 Dec 2012 16:02:05 -0800 Subject: [PATCH 121/574] Release 1.1.0 (Ubuntu 12.10 support) Prior to this release, Ubuntu 12.10 (Quantal) was not supported. This commit marks the Forge release of 1.1.0 which includes this support, thanks to Jarl Nicolson. --- Modulefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modulefile b/Modulefile index 91d5befcd6..d351142464 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.0.1' +version '1.1.0' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From 5cdf186c45ca05d5ccecd74aa00172b7eff93d35 Mon Sep 17 00:00:00 2001 From: Chris Rutter Date: Mon, 31 Dec 2012 00:16:29 +0000 Subject: [PATCH 122/574] fix minor comment typo --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 442e04c587..02579fb4de 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,7 +11,7 @@ # purge_sources_list - Accepts true or false. Defaults to false If set to # true, Puppet will purge all unmanaged entries from sources.list" # purge_sources_list_d - Accepts true or false. Defaults to false. If set -# to false, Puppet will purge all unmanaged entries from sources.list.d +# to true, Puppet will purge all unmanaged entries from sources.list.d # # Actions: # From c58d19f29ac8fed6e3325ca6a5600ded891a8a95 Mon Sep 17 00:00:00 2001 From: Chris Rutter Date: Mon, 31 Dec 2012 00:22:45 +0000 Subject: [PATCH 123/574] minor punctuation and quotation corrections in comments --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 02579fb4de..b8e356c53a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -7,9 +7,9 @@ # added for use cases related to development environments. # disable_keys - disables the requirement for all packages to be signed # always_apt_update - rather apt should be updated on every run (intended -# for development environments where package updates are frequent +# for development environments where package updates are frequent) # purge_sources_list - Accepts true or false. Defaults to false If set to -# true, Puppet will purge all unmanaged entries from sources.list" +# true, Puppet will purge all unmanaged entries from sources.list # purge_sources_list_d - Accepts true or false. Defaults to false. If set # to true, Puppet will purge all unmanaged entries from sources.list.d # From eee5ff8e38b0661a32376aabb2f4b76a914ba67a Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Sat, 12 Jan 2013 00:21:39 +0100 Subject: [PATCH 124/574] whitespace fixes --- manifests/ppa.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 9ac4d03cee..725170d2dc 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -16,12 +16,12 @@ $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', G) $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', G) $sources_list_d_filename = "${filename_without_ppa}-${release}.list" - + $package = $::lsbdistrelease ? { - /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties', - default => 'software-properties-common', + /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties', + default => 'software-properties-common', } - + if ! defined(Package[$package]) { package { $package: } } From abf1be8f22913c34aea1ef11c227e59bce9df2f6 Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Sat, 2 Feb 2013 01:19:21 -0800 Subject: [PATCH 125/574] Update travis config file This commit adds ruby 1.9.3, puppet 3.0.2 support and a build status image to the README. --- .travis.yml | 15 ++++++++++++++- README.md | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf7829ef78..03b1729d71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: ruby rvm: - 1.8.7 + - 1.9.3 before_script: after_script: script: "rake spec" @@ -8,9 +9,21 @@ branches: only: - master env: - - PUPPET_VERSION=2.7.13 + - PUPPET_VERSION=3.0.2 + - PUPPET_VERSION=2.7.20 - PUPPET_VERSION=2.7.6 - PUPPET_VERSION=2.6.9 +matrix: + exclude: + - rvm: 1.9.3 + gemfile: .gemfile + env: PUPPET_VERSION=2.6.9 + - rvm: 1.9.3 + gemfile: .gemfile + env: PUPPET_VERSION=2.7.6 + - rvm: 1.9.3 + gemfile: .gemfile + env: PUPPET_VERSION=2.7.20 notifications: email: false gemfile: .gemfile diff --git a/README.md b/README.md index 72a130c5e7..24d2e8182e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Apt module for Puppet +[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-apt.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-apt) + ## Description Provides helpful definitions for dealing with Apt. From c46bc7fe4a0a89d25152c6d0dd5b5edeafee6f0a Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Sat, 2 Feb 2013 16:11:50 -0800 Subject: [PATCH 126/574] Build all branches on travis We should build all branches for travis, otherwise users won't be able to test their own feature branches. --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 03b1729d71..a7f6b9c3f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ rvm: before_script: after_script: script: "rake spec" -branches: - only: - - master env: - PUPPET_VERSION=3.0.2 - PUPPET_VERSION=2.7.20 From 122cafe62a27d9e698ba2eddcc5b8a30ee98edc5 Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Sat, 2 Feb 2013 16:55:21 -0800 Subject: [PATCH 127/574] Standardize travis.yml on pattern introduced in stdlib --- .gemfile | 5 ----- .gitignore | 1 + .travis.yml | 35 +++++++++++++++++------------------ Gemfile | 13 +++++++++++++ 4 files changed, 31 insertions(+), 23 deletions(-) delete mode 100644 .gemfile create mode 100644 Gemfile diff --git a/.gemfile b/.gemfile deleted file mode 100644 index 9aad840c0a..0000000000 --- a/.gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source :rubygems - -puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] -gem 'puppet', puppetversion -gem 'puppetlabs_spec_helper', '>= 0.1.0' diff --git a/.gitignore b/.gitignore index 444fe1a3a5..d0aec6d793 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp pkg/ +Gemfile.lock diff --git a/.travis.yml b/.travis.yml index a7f6b9c3f0..dd3394d8d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,25 @@ language: ruby +bundler_args: --without development +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" rvm: - 1.8.7 - 1.9.3 -before_script: -after_script: -script: "rake spec" + - ruby-head env: - - PUPPET_VERSION=3.0.2 - - PUPPET_VERSION=2.7.20 - - PUPPET_VERSION=2.7.6 - - PUPPET_VERSION=2.6.9 + - PUPPET_GEM_VERSION="~> 2.6" + - PUPPET_GEM_VERSION="~> 2.7" + - PUPPET_GEM_VERSION="~> 3.0" matrix: - exclude: - - rvm: 1.9.3 - gemfile: .gemfile - env: PUPPET_VERSION=2.6.9 - - rvm: 1.9.3 - gemfile: .gemfile - env: PUPPET_VERSION=2.7.6 - - rvm: 1.9.3 - gemfile: .gemfile - env: PUPPET_VERSION=2.7.20 + allow_failures: + - rvm: ruby-head + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7" + - rvm: ruby-head + env: PUPPET_GEM_VERSION="~> 2.7" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.6" + - rvm: ruby-head + env: PUPPET_GEM_VERSION="~> 2.6" notifications: email: false -gemfile: .gemfile diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..8e5e04d744 --- /dev/null +++ b/Gemfile @@ -0,0 +1,13 @@ +source :rubygems + +group :development, :test do + gem 'puppetlabs_spec_helper', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby From 6d8a013bbea8f71919d2df8e64c24e05b2ca840c Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Fri, 15 Feb 2013 17:51:44 -0800 Subject: [PATCH 128/574] Updated content to conform to README best practices template *Note: I thought this was small enough to forgo a TOC. Please let me know if one is desired and I can add it in.* Before alterations, this content was the module author- determined description of and instructions for use of the module. As part of a joint Forge/Docs team effort to standardize formatting and encourage quality module documentation, a best practices README template was created via internal and external user testing. That template was then applied to this module. I pulled in content from the original README on GitHub. Standard headings were added (Overview, Module Description, Setup, Usage, Implementation, etc.) to organize content, existent content was moved under its appropriate heading and edited for tone/flow/clarity, and basic formatting was done to adhere to template standards. --- README.md | 250 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 173 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 72a130c5e7..4ab857fb11 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,46 @@ -# Apt module for Puppet +apt +=== -## Description -Provides helpful definitions for dealing with Apt. +Overview +-------- -## Usage +The APT module provides a simple interface for managing APT source, key, and definitions with Puppet. -### apt -The apt class provides a number of common resources and options which -are shared by the various defined types in this module. This class -should always be included in your manifests if you are using the `apt` -module. +Module Description +------------------ + +APT automates obtaining and installing software packages on *nix systems. + +Setup +----- + +**What APT affects:** + +* package/service/configuration files for APT +* your system's `sources.list` file and `sources.list.d` directory + * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'. +* system repositories +* authentication keys +* wget (optional) + +###Beginning with APT + +To begin using the APT module with default parameters, declare the class + + class { 'apt': } + +Puppet code that uses anything from the APT module requires that the core apt class be declared. + +Usage +----- + +Using the APT module consists predominantly in declaring classes that provide desired functionality and features. + +###apt + +`apt` provides a number of common resources and options that are shared by the various defined types in this module, so you MUST always include this class in your manifests. + +The parameters for `apt` are not required in general and are predominantly for development environment use-cases. class { 'apt': always_apt_update => false, @@ -21,55 +52,78 @@ module. purge_preferences_d => false } -### apt::builddep -Install the build depends of a specified package. +Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. + +If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. + +###apt::builddep + +Installs the build depends of a specified package. - apt::builddep { "glusterfs-server": } + apt::builddep { 'glusterfs-server': } -### apt::force -Force a package to be installed from a specific release. Useful when -using repositories like Debian unstable in Ubuntu. +###apt::force - apt::force { "glusterfs-server": - release => "unstable", +Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. + + apt::force { 'glusterfs-server': + release => 'unstable', version => '3.0.3', - require => Apt::Source["debian_unstable"], + require => Apt::Source['debian_unstable'], + } + +###apt::key + +Adds a key to the list of keys used by APT to authenticate packages. + + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_server => 'pgp.mit.edu', } -### apt::pin -Add an apt pin for a certain release. + apt::key { 'jenkins': + key => 'D50582E6', + key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', + } + +Note that use of `key_source` requires wget to be installed and working. + +###apt::pin + +Adds an apt pin for a certain release. + + apt::pin { 'karmic': priority => 700 } + apt::pin { 'karmic-updates': priority => 700 } + apt::pin { 'karmic-security': priority => 700 } + +###apt::ppa + +Adds a ppa repository using `add-apt-repository`. - apt::pin { "karmic": priority => 700 } - apt::pin { "karmic-updates": priority => 700 } - apt::pin { "karmic-security": priority => 700 } + apt::ppa { 'ppa:drizzle-developers/ppa': } -### apt::ppa -Add a ppa repository using `add-apt-repository`. Somewhat experimental. +###apt::release - apt::ppa { "ppa:drizzle-developers/ppa": } +Sets the default apt release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. -### apt::release -Set the default apt release. Useful when using repositories like -Debian unstable in Ubuntu. + apt::release { 'karmic': } - apt::release { "karmic": } +###apt::source -### apt::source -Add an apt source to `/etc/apt/sources.list.d/`. +Adds an apt source to `/etc/apt/sources.list.d/`. - apt::source { "debian_unstable": - location => "http://debian.mirror.iweb.ca/debian/", - release => "unstable", - repos => "main contrib non-free", - required_packages => "debian-keyring debian-archive-keyring", - key => "55BE302B", - key_server => "subkeys.pgp.net", - pin => "-10", + apt::source { 'debian_unstable': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + required_packages => 'debian-keyring debian-archive-keyring', + key => '55BE302B', + key_server => 'subkeys.pgp.net', + pin => '-10', include_src => true } -This source will configure your system for the Puppet Labs APT -repository. +If you would like to configure your system so the source is the Puppet Labs APT repository apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', @@ -78,42 +132,84 @@ repository. key_server => 'pgp.mit.edu', } -### apt::key -Add a key to the list of keys used by apt to authenticate packages. +###Testing - apt::key { "puppetlabs": - key => "4BD6EC30", - key_server => "pgp.mit.edu", - } +The APT module is mostly a collection of defined resource types, which provide reusable logic that can be leveraged to manage APT. It does provide smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. + +####Example Test - apt::key { "jenkins": - key => "D50582E6", - key_source => "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key", +This test will set up a Puppet Labs apt repository. Start by creating a new smoke test in the apt module's test folder. Call it puppetlabs-apt.pp. Inside, declare a single resource representing the Puppet Labs APT source and gpg key + + apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', } + +This resource creates an apt source named puppetlabs and gives Puppet information about the repository's location and key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set it directly by adding the release type. + +Check your smoke test for syntax errors + + $ puppet parser validate tests/puppetlabs-apt.pp + +If you receive no output from that command, it means nothing is wrong. Then apply the code + + $ puppet apply --verbose tests/puppetlabs-apt.pp + notice: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]/ensure: defined content as '{md5}3be1da4923fb910f1102a233b77e982e' + info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update] + notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events> + +The above example used a smoke test to easily lay out a resource declaration and apply it on your system. In production, you may want to declare your APT sources inside the classes where they’re needed. + +Implementation +-------------- + +###apt::backports + +Adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined behavior (read: universe exploding). + +Limitations +----------- + +This module should work across all versions of Debian/Ubuntu and support all major APT repository management features. + +Development +------------ + +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) + +Contributors +------------ + +A lot of great people have contributed to this module. A somewhat current list follows: + +* Ben Godfrey +* Branan Purvine-Riley +* Christian G. Warden +* Dan Bode +* Garrett Honeycutt +* Jeff Wallace +* Ken Barber +* Matthaus Litteken +* Matthias Pigulla +* Monty Taylor +* Peter Drake +* Reid Vandewiele +* Robert Navarro +* Ryan Coleman +* Scott McLeod +* Spencer Krum +* William Van Hevelingen +* Zach Leslie + +Release Notes +------------- + +**1.1.0** -Note that use of the "key_source" parameter requires wget to be -installed and working. - - -## Contributors -A lot of great people have contributed to this module. A somewhat -current list follows. - -Ben Godfrey -Branan Purvine-Riley -Christian G. Warden -Dan Bode -Garrett Honeycutt -Jeff Wallace -Ken Barber -Matthaus Litteken -Matthias Pigulla -Monty Taylor -Peter Drake -Reid Vandewiele -Robert Navarro -Ryan Coleman -Scott McLeod -Spencer Krum -William Van Hevelingen -Zach Leslie +This release includes Ubuntu 12.10 (Quantal) support for PPAs. \ No newline at end of file From 06a964c500723ceec06268e170ca7e4a92e5b982 Mon Sep 17 00:00:00 2001 From: Richard Clamp Date: Mon, 25 Feb 2013 19:56:03 +0000 Subject: [PATCH 129/574] Restrict the versions and add 3.1 --- .travis.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd3394d8d2..8f713e06b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,20 +6,21 @@ rvm: - 1.9.3 - ruby-head env: - - PUPPET_GEM_VERSION="~> 2.6" - - PUPPET_GEM_VERSION="~> 2.7" - - PUPPET_GEM_VERSION="~> 3.0" + - PUPPET_GEM_VERSION="~> 2.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.0.0" + - PUPPET_GEM_VERSION="~> 3.1.0" matrix: allow_failures: - rvm: ruby-head exclude: - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7" + env: PUPPET_GEM_VERSION="~> 2.7.0" - rvm: ruby-head - env: PUPPET_GEM_VERSION="~> 2.7" + env: PUPPET_GEM_VERSION="~> 2.7.0" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.6" + env: PUPPET_GEM_VERSION="~> 2.6.0" - rvm: ruby-head - env: PUPPET_GEM_VERSION="~> 2.6" + env: PUPPET_GEM_VERSION="~> 2.6.0" notifications: email: false From 7b5d30ed18ada02e46dd65c01c66a8dbd5bfed77 Mon Sep 17 00:00:00 2001 From: Thomas Spalinger Date: Tue, 26 Feb 2013 21:35:49 +0100 Subject: [PATCH 130/574] replace aptitude with apt in apt::force --- manifests/force.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/force.pp b/manifests/force.pp index 75634b476d..2d33e942dc 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -16,7 +16,7 @@ false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'", default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'", } - exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}": + exec { "/usr/bin/apt-get -y -t ${release} install ${name}${version_string}": unless => $install_check, logoutput => 'on_failure', timeout => $timeout, From 256c90e0fd3e9034477b81a7a3454393f1ed576c Mon Sep 17 00:00:00 2001 From: johnnyrun Date: Tue, 7 May 2013 14:13:59 +0200 Subject: [PATCH 131/574] Location changed: http://backports.debian.org/news/Backports_integrated_into_the_main_archive/ --- manifests/params.pp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index ed698e72be..aa0f80d60c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -7,7 +7,14 @@ case $::lsbdistid { 'debian': { - $backports_location = 'http://backports.debian.org/debian-backports' + case $::lsbdistcodename { + 'squeeze': { + $backports_location = 'http://backports.debian.org/debian-backports' + } + default: { + $backports_location = 'http://ftp.debian.org/debian/' + } + } } 'ubuntu': { case $::lsbdistcodename { From 976d81a3b599ac48f037c27310b21944b5ec6d13 Mon Sep 17 00:00:00 2001 From: Brian Galey Date: Wed, 29 May 2013 14:46:32 -0700 Subject: [PATCH 132/574] Fix apt::release example in readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c6d39151cc..5082e34337 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,9 @@ Adds a ppa repository using `add-apt-repository`. Sets the default apt release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. - apt::release { 'karmic': } + class { 'apt::release': + release_id => 'precise', + } ###apt::source From 597bc3d82dc579aef8514f2e2d1288a53e5d66c7 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Thu, 30 May 2013 18:28:57 +0800 Subject: [PATCH 133/574] add @ to variables in template --- templates/source.list.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/source.list.erb b/templates/source.list.erb index faa7e286ec..65764b2612 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,5 +1,5 @@ -# <%= name %> -deb <%= location %> <%= release_real %> <%= repos %> -<%- if include_src then -%> -deb-src <%= location %> <%= release_real %> <%= repos %> +# <%= @name %> +deb <%= @location %> <%= @release_real %> <%= @repos %> +<%- if @include_src then -%> +deb-src <%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> From a7e604810328568f7ded97765570816e323c8238 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Sun, 2 Jun 2013 18:24:33 +0100 Subject: [PATCH 134/574] Remove deprecation warnings for pin.pref.erb as well Signed-off-by: Ken Barber --- .gitignore | 1 + spec/fixtures/manifests/site.pp | 0 templates/pin.pref.erb | 10 +++++----- 3 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 spec/fixtures/manifests/site.pp diff --git a/.gitignore b/.gitignore index d0aec6d793..b77434bea0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.swp pkg/ Gemfile.lock +spec/fixtures/manifests diff --git a/spec/fixtures/manifests/site.pp b/spec/fixtures/manifests/site.pp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb index 74b92659b8..74df8b79c4 100644 --- a/templates/pin.pref.erb +++ b/templates/pin.pref.erb @@ -1,5 +1,5 @@ -# <%= name %> -Explanation: <%= explanation %> -Package: <%= packages %> -Pin: <%= pin %> -Pin-Priority: <%= priority %> +# <%= @name %> +Explanation: <%= @explanation %> +Package: <%= @packages %> +Pin: <%= @pin %> +Pin-Priority: <%= @priority %> From 54d6dcad82a663a0d39d9ea54e0ebd498c4ab73a Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Sun, 2 Jun 2013 18:27:15 +0100 Subject: [PATCH 135/574] Update travis.yml to latest versions of puppet Signed-off-by: Ken Barber --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8f713e06b8..a19074d0b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,13 @@ env: - PUPPET_GEM_VERSION="~> 2.7.0" - PUPPET_GEM_VERSION="~> 3.0.0" - PUPPET_GEM_VERSION="~> 3.1.0" + - PUPPET_GEM_VERSION="~> 3.2.0" matrix: - allow_failures: - - rvm: ruby-head exclude: + - rvm: ruby-head + env: PUPPET_GEM_VERSION="~> 3.0.0" + - rvm: ruby-head + env: PUPPET_GEM_VERSION="~> 3.1.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 2.7.0" - rvm: ruby-head From 1b07921c0c59dcf77987ac29c21d9909dfdb38f5 Mon Sep 17 00:00:00 2001 From: Scott Barber Date: Thu, 1 Nov 2012 14:08:28 -0600 Subject: [PATCH 136/574] Update manifests/init.pp If a proxy is set and then later unset we need to remove the proxy file. As it currently sits it'll just sit there hanging out. --- manifests/init.pp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index b8e356c53a..21f36bd9ed 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -105,6 +105,12 @@ content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", notify => Exec['apt_update'], } + } else { + file { 'configure-apt-proxy': + path => "${apt_conf_d}/proxy", + ensure => absent + notify => Exec['apt_update'], + } } # Need anchor to provide containment for dependencies. From f985752a1abadf6e5f5440906182ae16fc35d560 Mon Sep 17 00:00:00 2001 From: Scott Barber Date: Thu, 1 Nov 2012 14:17:16 -0600 Subject: [PATCH 137/574] Update manifests/init.pp --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 21f36bd9ed..ad1b4466d0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -108,7 +108,7 @@ } else { file { 'configure-apt-proxy': path => "${apt_conf_d}/proxy", - ensure => absent + ensure => absent, notify => Exec['apt_update'], } } From 041548bcbe664fc228d11f4b8b54b8f75a1442e0 Mon Sep 17 00:00:00 2001 From: Scott Barber Date: Thu, 1 Nov 2012 14:33:31 -0600 Subject: [PATCH 138/574] Update manifests/init.pp --- manifests/init.pp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index ad1b4466d0..2319771950 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -99,18 +99,16 @@ default: { fail('Valid values for disable_keys are true or false') } } - if ($proxy_host) { - file { 'configure-apt-proxy': - path => "${apt_conf_d}/proxy", - content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", - notify => Exec['apt_update'], - } - } else { - file { 'configure-apt-proxy': - path => "${apt_conf_d}/proxy", - ensure => absent, - notify => Exec['apt_update'], - } + $proxy_set = $proxy_host ? { + false => absent, + default => present + } + + file { 'configure-apt-proxy': + path => "${apt_conf_d}/proxy", + content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", + notify => Exec['apt_update'], + ensure => $proxy_set, } # Need anchor to provide containment for dependencies. From d8e2cf24a52af0470abd2f9f00892ddd4d206cff Mon Sep 17 00:00:00 2001 From: Dean Reilly Date: Fri, 12 Apr 2013 17:26:26 +0100 Subject: [PATCH 139/574] Add spec test for removing proxy configuration. --- spec/classes/apt_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index d623a5bf78..a66feac788 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -120,7 +120,11 @@ 'notify' => "Exec[apt_update]" ) else - should_not contain_file('configure_apt_proxy') + should contain_file('configure-apt-proxy').with( + 'path' => '/etc/apt/apt.conf.d/proxy', + 'notify' => 'Exec[apt_update]', + 'ensure' => 'absent' + ) end } end From 4dbd2c7948c81d8c0b4fa651a74837d654c08296 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Sun, 2 Jun 2013 19:54:32 +0100 Subject: [PATCH 140/574] Release 1.1.1 CHANGELOG & Modulefile updated. Signed-off-by: Ken Barber --- CHANGELOG | 43 +++++++++++++++++++++++++++++++++++++++++++ Modulefile | 2 +- README.md | 7 ------- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index da4072f252..88cfa2d540 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,46 @@ +## puppetlabs-apt changelog + +Release notes for the puppetlabs-apt module. + +1.1.1 +===== + +This is a bug fix release that resolves a number of issues: + +* By changing template variable usage, we remove the deprecation warnings + for Puppet 3.2.x +* Fixed proxy file removal, when proxy absent + +Some documentation, style and whitespaces changes were also merged. This +release also introduced proper rspec-puppet unit testing on Travis-CI to help +reduce regression. + +Thanks to all the community contributors below that made this patch possible. + +#### Detail Changes + +* fix minor comment type (Chris Rutter) +* whitespace fixes (Michael Moll) +* Update travis config file (William Van Hevelingen) +* Build all branches on travis (William Van Hevelingen) +* Standardize travis.yml on pattern introduced in stdlib (William Van Hevelingen) +* Updated content to conform to README best practices template (Lauren Rother) +* Fix apt::release example in readme (Brian Galey) +* add @ to variables in template (Peter Hoeg) +* Remove deprecation warnings for pin.pref.erb as well (Ken Barber) +* Update travis.yml to latest versions of puppet (Ken Barber) +* Fix proxy file removal (Scott Barber) +* Add spec test for removing proxy configuration (Dean Reilly) + +--------------------------------------- + +1.1.0 +===== + +This release includes Ubuntu 12.10 (Quantal) support for PPAs. + +--------------------------------------- + 2012-05-25 Puppet Labs - 0.0.4 * Fix ppa list filename when there is a period in the PPA name * Add .pref extension to apt preferences files diff --git a/Modulefile b/Modulefile index d351142464..2b1b21c3f8 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.1.0' +version '1.1.1' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' diff --git a/README.md b/README.md index 5082e34337..f9f7ee8321 100644 --- a/README.md +++ b/README.md @@ -213,10 +213,3 @@ A lot of great people have contributed to this module. A somewhat current list f * Spencer Krum * William Van Hevelingen * Zach Leslie - -Release Notes -------------- - -**1.1.0** - -This release includes Ubuntu 12.10 (Quantal) support for PPAs. From b3d67c8937644c1b40e29f68a35e1450f7e443bb Mon Sep 17 00:00:00 2001 From: Joe O'Pecko Date: Wed, 29 May 2013 15:52:32 -0700 Subject: [PATCH 141/574] Add optional architecture qualifier to apt-sources --- manifests/source.pp | 3 ++- spec/defines/source_spec.rb | 11 +++++++++-- templates/source.list.erb | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index a859174a1a..64461ee57a 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -12,7 +12,8 @@ $key_server = 'keyserver.ubuntu.com', $key_content = false, $key_source = false, - $pin = false + $pin = false, + $architecture = undef ) { include apt::params diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 0f37f6367b..884194e9f1 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -48,6 +48,9 @@ }, { :release => 'custom', + }, + { + :architecture => 'amd64', } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do @@ -69,9 +72,13 @@ let :content do content = "# #{title}" - content << "\ndeb #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + if param_hash[:architecture] + arch = "[arch=#{param_hash[:architecture]}]" + end + content << "\ndeb #{arch} #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + if param_hash[:include_src] - content << "deb-src #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + content << "deb-src #{arch} #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" end content end diff --git a/templates/source.list.erb b/templates/source.list.erb index 65764b2612..845b8ae161 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,5 +1,5 @@ # <%= @name %> -deb <%= @location %> <%= @release_real %> <%= @repos %> +deb <% if @architecture %>[arch=<%= @architecture %>]<% end %> <%= @location %> <%= @release_real %> <%= @repos %> <%- if @include_src then -%> -deb-src <%= @location %> <%= @release_real %> <%= @repos %> +deb-src <% if @architecture %>[arch=<%= @architecture %>]<% end %> <%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> From 0ba3af7de89dcc8e08de2f85b099063493c60ce8 Mon Sep 17 00:00:00 2001 From: Markelov Anton Date: Mon, 3 Jun 2013 10:53:17 +1100 Subject: [PATCH 142/574] fix conflicts --- .travis.yml | 7 ------- Modulefile | 8 +------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index c825f5e4ed..a19074d0b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,12 +6,6 @@ rvm: - 1.9.3 - ruby-head env: -<<<<<<< HEAD - - PUPPET_VERSION=3.0.1 - - PUPPET_VERSION=2.7.13 - - PUPPET_VERSION=2.7.6 - - PUPPET_VERSION=2.6.9 -======= - PUPPET_GEM_VERSION="~> 2.6.0" - PUPPET_GEM_VERSION="~> 2.7.0" - PUPPET_GEM_VERSION="~> 3.0.0" @@ -31,6 +25,5 @@ matrix: env: PUPPET_GEM_VERSION="~> 2.6.0" - rvm: ruby-head env: PUPPET_GEM_VERSION="~> 2.6.0" ->>>>>>> 18ee4cc6c9eb8d16becfec68254d8955eb10c7d5 notifications: email: false diff --git a/Modulefile b/Modulefile index dbf3f2e209..374368073e 100644 --- a/Modulefile +++ b/Modulefile @@ -8,11 +8,5 @@ description 'APT Module for Puppet' project_page 'https://github.com/puppetlabs/puppetlabs-apt' ## Add dependencies, if any: -<<<<<<< HEAD dependency 'puppetlabs/stdlib', '>= 3.0.1' -======= -#dependency 'puppetlabs/stdlib', '2.x' -# The dependency should be written as above but librarian-puppet -# does not support the expression as the PMT does. -dependency 'puppetlabs/stdlib', '>= 2.2.1' ->>>>>>> 18ee4cc6c9eb8d16becfec68254d8955eb10c7d5 + From 409ed73140d2a92d23fa7049e156c30df26266eb Mon Sep 17 00:00:00 2001 From: Anton Markelov Date: Mon, 3 Jun 2013 12:04:37 +1200 Subject: [PATCH 143/574] fix 'puppetlabs/stdlib' dependency --- Modulefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Modulefile b/Modulefile index 374368073e..d351142464 100644 --- a/Modulefile +++ b/Modulefile @@ -8,5 +8,7 @@ description 'APT Module for Puppet' project_page 'https://github.com/puppetlabs/puppetlabs-apt' ## Add dependencies, if any: -dependency 'puppetlabs/stdlib', '>= 3.0.1' - +#dependency 'puppetlabs/stdlib', '2.x' +# The dependency should be written as above but librarian-puppet +# does not support the expression as the PMT does. +dependency 'puppetlabs/stdlib', '>= 2.2.1' From 37a0dcd0b63ab5420420ffe988cce49eb5e01c73 Mon Sep 17 00:00:00 2001 From: Francois Deppierraz Date: Mon, 3 Jun 2013 09:57:58 +0000 Subject: [PATCH 144/574] Install required_packages before 'apt-get update' This is necessary when required_packages contains GPG keys that are used for authenticating other packages. Tested with package ubuntu-cloud-keyring which is included in Ubuntu main and used by the Ubuntu Cloud Archive. I think the same problem applies to other *-keyring packages as well. --- manifests/source.pp | 1 + spec/defines/source_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/source.pp b/manifests/source.pp index a859174a1a..9a358fe29c 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -61,6 +61,7 @@ logoutput => 'on_failure', refreshonly => true, subscribe => File["${name}.list"], + before => Exec['apt_update'], } } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 0f37f6367b..32aa6c8dcb 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -114,7 +114,8 @@ should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({ "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}", "subscribe" => "File[#{title}.list]", - "refreshonly" => true + "refreshonly" => true, + "before" => 'Exec[apt_update]', }) else should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({ From 9033eb687eb0fa12bd187db5409e1f13cddc147c Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 14 Jan 2013 16:05:44 +0100 Subject: [PATCH 145/574] Add geppetto project definition --- .project | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 0000000000..6523c6dafa --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + apt + + + + + + org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.cloudsmith.geppetto.pp.dsl.ui.puppetNature + org.eclipse.xtext.ui.shared.xtextNature + + From ffb89f6d5d806a27ad43129f5e74fdd7033bd2f3 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 14 Jan 2013 16:18:09 +0100 Subject: [PATCH 146/574] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b77434bea0..0485a727cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ pkg/ Gemfile.lock spec/fixtures/manifests +metadata.json From 414c57926c21e53222807b42ea9281296988bf6c Mon Sep 17 00:00:00 2001 From: Mathieu Bornoz Date: Tue, 18 Jun 2013 11:31:38 +0200 Subject: [PATCH 147/574] apt::pin: handling all apt preferences properties The two forms of APT preferences records (general & specific) can now be completely and not partially defined. All distribution properties can be passed as resource parameters. This change is totally backward-compatible. --- manifests/pin.pp | 62 +++++++++++++++++++++++---------- spec/defines/pin_spec.rb | 75 +++++++++++++++++++++++++++++++--------- templates/pin.pref.erb | 17 +++++++++ 3 files changed, 119 insertions(+), 35 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 21cc3ffdef..e6e293e452 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -2,15 +2,19 @@ # pin a release in apt, useful for unstable repositories define apt::pin( - $ensure = present, - $explanation = "${::caller_module_name}: ${name}", - $order = '', - $packages = '*', - $priority = 0, - $release = '', - $origin = '', - $originator = '', - $version = '' + $ensure = present, + $explanation = "${::caller_module_name}: ${name}", + $order = '', + $packages = '*', + $priority = 0, + $release = '', # a= + $origin = '', + $version = '', + $codename = '', # n= + $release_version = '', # v= + $component = '', # c= + $originator = '', # o= + $label = '', # l= ) { include apt::params @@ -21,16 +25,36 @@ fail('Only integers are allowed in the apt::pin order param') } - if $release != '' { - $pin = "release a=${release}" - } elsif $origin != '' { - $pin = "origin \"${origin}\"" - } elsif $originator != '' { - $pin = "release o=${originator}" - } elsif $version != '' { - $pin = "version ${version}" - } else { - $pin = "release a=${name}" + $pin_release = join([ + $release, + $codename, + $release_version, + $component, + $originator, + $label], '') + + # Read the manpage 'apt_preferences(5)', especially the chapter + # 'Thea Effect of APT Preferences' to understand the following logic + # and the difference between specific and general form + if $packages != '*' { # specific form + + if ( $pin_release != '' and ( $origin != '' or $version != '' )) or + ( $origin != '' and ( $pin_release != '' or $version != '' )) or + ( $version != '' and ( $pin_release != '' or $origin != '' )) { + fail('parameters release, origin, and version are mutually exclusive') + } + + } else { # general form + + if $version != '' { + fail('parameter version cannot be used in general form') + } + + if ( $pin_release != '' and $origin != '' ) or + ( $origin != '' and $pin_release != '' ) { + fail('parmeters release and origin are mutually exclusive') + } + } $path = $order ? { diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 3aaf49cef4..a4cb1e26e3 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -12,34 +12,77 @@ } end - [ {}, + [ + { :params => {}, + :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n" + }, { - :packages => 'apache', - :priority => '1' + :params => { + :packages => 'apache', + :priority => '1' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" }, { - :order => 50, - :packages => 'apache', - :priority => '1' + :params => { + :order => 50, + :packages => 'apache', + :priority => '1' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" }, { - :ensure => 'absent', - :packages => 'apache', - :priority => '1' + :params => { + :ensure => 'absent', + :packages => 'apache', + :priority => '1' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" }, { - :packages => 'apache', - :priority => '1', - :release => 'my_newpin' - } + :params => { + :packages => 'apache', + :priority => '1', + :release => 'my_newpin' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n" + }, + { + :params => { + :packages => 'apache', + :priority => '1', + :version => '2.2.16*' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n" + }, + { + :params => { + :priority => '1', + :origin => 'ftp.de.debian.org' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin \"ftp.de.debian.org\"\nPin-Priority: 1\n" + }, + { + :params => { + :packages => 'apache', + :priority => '1', + :release => 'stable', + :codename => 'wheezy', + :release_version => '3.0', + :component => 'main', + :originator => 'Debian', + :label => 'Debian' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n" + }, ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do let :param_hash do - default_params.merge(param_set) + default_params.merge(param_set[:params]) end let :params do - param_set + param_set[:params] end it { should include_class("apt::params") } @@ -50,7 +93,7 @@ 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - 'content' => "# #{title}\nExplanation: : #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}\n", + 'content' => param_set[:content], }) } end diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb index 74df8b79c4..62c44c7241 100644 --- a/templates/pin.pref.erb +++ b/templates/pin.pref.erb @@ -1,3 +1,20 @@ +<%- +@pin = "release a=#{@name}" # default value +if @pin_release.length > 0 + options = [] + options.push("a=#{@release}") if @release.length > 0 + options.push("n=#{@codename}") if @codename.length > 0 + options.push("v=#{@release_version}") if @release_version.length > 0 + options.push("c=#{@component}") if @component.length > 0 + options.push("o=#{@originator}") if @originator.length > 0 + options.push("l=#{@label}") if @label.length > 0 + @pin = "release #{options.join(', ')}" +elsif @version.length > 0 + @pin = "version #{@version}" +elsif @origin.length > 0 + @pin = "origin \"#{@origin}\"" +end +-%> # <%= @name %> Explanation: <%= @explanation %> Package: <%= @packages %> From e8f11eac018df9c6a1912f07ad9b9dd1c1eea30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 18 Jun 2013 15:14:00 +0200 Subject: [PATCH 148/574] Fix apt::pin for Puppet 2.6 --- manifests/pin.pp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index e6e293e452..39de3d8f1f 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -14,7 +14,7 @@ $release_version = '', # v= $component = '', # c= $originator = '', # o= - $label = '', # l= + $label = '' # l= ) { include apt::params @@ -25,13 +25,14 @@ fail('Only integers are allowed in the apt::pin order param') } - $pin_release = join([ + $pin_release_array = [ $release, $codename, $release_version, $component, $originator, - $label], '') + $label] + $pin_release = join($pin_release_array, '') # Read the manpage 'apt_preferences(5)', especially the chapter # 'Thea Effect of APT Preferences' to understand the following logic From 62ba61fc3c0accf4cc0789684574b5f326c5d1f1 Mon Sep 17 00:00:00 2001 From: Mathieu Bornoz Date: Wed, 19 Jun 2013 09:13:08 +0200 Subject: [PATCH 149/574] Improve apt::pin example --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 5082e34337..a6a0013e3f 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,16 @@ Adds an apt pin for a certain release. apt::pin { 'karmic-updates': priority => 700 } apt::pin { 'karmic-security': priority => 700 } +Note you can also specifying more complex pins using distribution properties. + + apt::pin { 'stable': + priority => -10, + originator => 'Debian', + release_version => '3.0', + component => 'main', + label => 'Debian' + } + ###apt::ppa Adds a ppa repository using `add-apt-repository`. From 3191f0552aabee93017ef4c2a3069f3350e81fc1 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Fri, 28 Jun 2013 14:06:05 +0200 Subject: [PATCH 150/574] Support APT pinning by codename (e.g. squeeze, wheezy) --- manifests/pin.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifests/pin.pp b/manifests/pin.pp index 21cc3ffdef..2431af2a4d 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -8,6 +8,7 @@ $packages = '*', $priority = 0, $release = '', + $codename = '', $origin = '', $originator = '', $version = '' @@ -23,6 +24,8 @@ if $release != '' { $pin = "release a=${release}" + } elsif $codename != '' { + $pin = "release n=${codename}" } elsif $origin != '' { $pin = "origin \"${origin}\"" } elsif $originator != '' { From 733ece66e7b702097642309b14e047fa45dff7e2 Mon Sep 17 00:00:00 2001 From: Benjamin Knofe Date: Sat, 29 Jun 2013 13:06:26 +0200 Subject: [PATCH 151/574] apt::key: trim keys to 8 chars to match with apt-key list, refs puppetlabs/puppetlabs-apt#100 --- manifests/key.pp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index 98a0f3a32c..b14500ed03 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -9,6 +9,8 @@ include apt::params $upkey = upcase($key) + # trim the key to the last 8 chars so we can match longer keys with apt-key list too + $trimmedkey = regsubst($upkey, '^.*(.{8})$', '\1') if $key_content { $method = 'content' @@ -48,7 +50,7 @@ exec { $digest: command => $digest_command, path => '/bin:/usr/bin', - unless => "/usr/bin/apt-key list | /bin/grep '${upkey}'", + unless => "/usr/bin/apt-key list | /bin/grep '${trimmedkey}'", logoutput => 'on_failure', before => Anchor["apt::key ${upkey} present"], } @@ -66,7 +68,7 @@ exec { "apt::key ${upkey} absent": command => "apt-key del '${upkey}'", path => '/bin:/usr/bin', - onlyif => "apt-key list | grep '${upkey}'", + onlyif => "apt-key list | grep '${trimmedkey}'", user => 'root', group => 'root', logoutput => 'on_failure', From c1c61c65411e09c7bdcf2511b4b3a5e54e238dce Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 1 Jul 2013 16:11:34 -0700 Subject: [PATCH 152/574] Update travis and bundler - Use ruby 2.0.0 instead of ruby-head - Remove puppet 2.6 testing - Add more bundler gems --- .travis.yml | 19 ++++++++----------- Gemfile | 4 +++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index a19074d0b8..71054bb2ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,26 +4,23 @@ script: "bundle exec rake spec SPEC_OPTS='--format documentation'" rvm: - 1.8.7 - 1.9.3 - - ruby-head + - 2.0.0 env: - - PUPPET_GEM_VERSION="~> 2.6.0" - PUPPET_GEM_VERSION="~> 2.7.0" - PUPPET_GEM_VERSION="~> 3.0.0" - PUPPET_GEM_VERSION="~> 3.1.0" - PUPPET_GEM_VERSION="~> 3.2.0" matrix: exclude: - - rvm: ruby-head - env: PUPPET_GEM_VERSION="~> 3.0.0" - - rvm: ruby-head - env: PUPPET_GEM_VERSION="~> 3.1.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 2.7.0" - - rvm: ruby-head + - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 2.7.0" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.6.0" - - rvm: ruby-head - env: PUPPET_GEM_VERSION="~> 2.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.1.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.2.0" notifications: email: false diff --git a/Gemfile b/Gemfile index 8e5e04d744..881fc90e21 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ -source :rubygems +source 'https://rubygems.org' group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false end From 1e0e92c1e4e49576f9b83c312d7cc5d9f1303de3 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 1 Jul 2013 17:18:35 -0700 Subject: [PATCH 153/574] Adding one more fix --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 88cfa2d540..44fa88abb2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,8 @@ Thanks to all the community contributors below that made this patch possible. * Update travis.yml to latest versions of puppet (Ken Barber) * Fix proxy file removal (Scott Barber) * Add spec test for removing proxy configuration (Dean Reilly) +* Fix apt::key listing longer than 8 chars (Benjamin Knofe) + --------------------------------------- From 84f1cfca0daa91f1be03ce3e622cd052c2c9ad6f Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 1 Jul 2013 17:19:27 -0700 Subject: [PATCH 154/574] Revert "Merge pull request #135 from CERIT-SC/master" This reverts commit e17208a86c7483ec93e3347ab61d88728edb4761, reversing changes made to 0665a5d77a4f26d23417dce221a15b8d112cd7b0. --- manifests/pin.pp | 3 --- 1 file changed, 3 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 2431af2a4d..21cc3ffdef 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -8,7 +8,6 @@ $packages = '*', $priority = 0, $release = '', - $codename = '', $origin = '', $originator = '', $version = '' @@ -24,8 +23,6 @@ if $release != '' { $pin = "release a=${release}" - } elsif $codename != '' { - $pin = "release n=${codename}" } elsif $origin != '' { $pin = "origin \"${origin}\"" } elsif $originator != '' { From 7c66ab5f39a5fb7b039732f94a3dfac01cd8c81f Mon Sep 17 00:00:00 2001 From: Thomas Spalinger Date: Tue, 2 Jul 2013 21:59:26 +0200 Subject: [PATCH 155/574] fixed test for changing aptitude to apt-get --- spec/defines/force_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index eeea7ff094..f5d6ac22a9 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -32,7 +32,7 @@ end let :exec_title do - base_exec = "/usr/bin/aptitude -y -t #{param_hash[:release]} install #{title}" + base_exec = "/usr/bin/apt-get -y -t #{param_hash[:release]} install #{title}" base_exec + (params[:version] ? "=#{params[:version]}" : "") end it { should contain_exec(exec_title).with_unless(unless_query) } From e511a1b1529a325fd18a9ad031f55d00b2e2b4ea Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 2 Jul 2013 16:40:23 -0700 Subject: [PATCH 156/574] Adding travis github automatic forge releases --- .travis.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71054bb2ea..00924bac0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,29 @@ +--- +branches: + only: + - master language: ruby bundler_args: --without development -script: "bundle exec rake spec SPEC_OPTS='--format documentation'" +script: bundle exec rake spec SPEC_OPTS='--format documentation' +after_success: + - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release + - .forge-release/publish rvm: - 1.8.7 - 1.9.3 - 2.0.0 env: - - PUPPET_GEM_VERSION="~> 2.7.0" - - PUPPET_GEM_VERSION="~> 3.0.0" - - PUPPET_GEM_VERSION="~> 3.1.0" - - PUPPET_GEM_VERSION="~> 3.2.0" + matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.0.0" + - PUPPET_GEM_VERSION="~> 3.1.0" + - PUPPET_GEM_VERSION="~> 3.2.0" + global: + - PUBLISHER_LOGIN=puppetlabs + - secure: |- + ipB/CV1rVSTXU9ZDuzrFOlzJrRmJob36tKns2xszuH4r9s5P9qivNAngRGdV + msb69xvOlzQykM0WRF+4kJ6TZ7AbMiDI+VZ8GDtsRaU5/q3BpsvFe8aato+6 + QeyFtBG62OsosTEhGws4mqiFsPDu3dHlakuJc9zevlTuhNwbKSs= matrix: exclude: - rvm: 1.9.3 From 9a968bbead99d03c826dd5fb47e206532a705137 Mon Sep 17 00:00:00 2001 From: Andreas Teuchert Date: Sat, 23 Feb 2013 16:42:14 +0100 Subject: [PATCH 157/574] Handle release parameter more sensibly in force manifest. Use release parameter to construct $release_string. The release parameter may also be set to false to use the system's default release (so just force a specific version). Use false as the default setting instead of 'testing'. Change $install_check to also check if package is installed from the right release, instead of just checking the version. --- manifests/force.pp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index 2d33e942dc..a1ec4a6088 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -2,7 +2,7 @@ # force a package from a specific release define apt::force( - $release = 'testing', + $release = false, $version = false, $timeout = 300 ) { @@ -12,11 +12,27 @@ default => "=${version}", } - $install_check = $version ? { - false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'", - default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'", + $release_string = $release ? { + false => undef, + default => "-t ${release}", + } + + if $version == false { + if $release == false { + $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'" + } else { + # If installed version and candidate version differ, this check returns 1 (false). + $install_check = "/usr/bin/test \$(/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" + } + } else { + if $release == false { + $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" + } else { + $install_check = "/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -q 'Installed: ${version}'" + } } - exec { "/usr/bin/apt-get -y -t ${release} install ${name}${version_string}": + + exec { "/usr/bin/apt-get -y ${release_string} install ${name}${version_string}": unless => $install_check, logoutput => 'on_failure', timeout => $timeout, From 5f618da4bd8b2a97a28f299ad41f45237ed7240a Mon Sep 17 00:00:00 2001 From: Andreas Teuchert Date: Sat, 23 Feb 2013 16:45:31 +0100 Subject: [PATCH 158/574] Don't use hardcoded provider in force manifest. Use $apt::params::provider instead. --- manifests/force.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/force.pp b/manifests/force.pp index a1ec4a6088..152bb67354 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -7,6 +7,8 @@ $timeout = 300 ) { + $provider = $apt::params::provider + $version_string = $version ? { false => undef, default => "=${version}", @@ -32,7 +34,7 @@ } } - exec { "/usr/bin/apt-get -y ${release_string} install ${name}${version_string}": + exec { "${provider} -y ${release_string} install ${name}${version_string}": unless => $install_check, logoutput => 'on_failure', timeout => $timeout, From 711420739de87a8e8f31458db3ea5cd9e9236fe8 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 3 Jul 2013 11:00:12 -0700 Subject: [PATCH 159/574] Update specs to test all parameter cases --- spec/defines/force_spec.rb | 62 ++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index f5d6ac22a9..84231fa233 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -1,41 +1,57 @@ require 'spec_helper' describe 'apt::force', :type => :define do + let :pre_condition do + 'include apt::params' + end + let :title do 'my_package' end let :default_params do { - :release => 'testing', + :release => false, :version => false } end - [{}, - { - :release => 'stable', - :version => '1' - } - ].each do |param_set| - describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do - let :param_hash do - default_params.merge(param_set) - end + describe "when using default parameters" do + let :params do + default_params + end + it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'", + :timeout => '300' + ) } + end - let :params do - param_set - end + describe "when specifying release parameter" do + let :params do + default_params.merge(:release => 'testing') + end + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( + :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" + ) } + end - let :unless_query do - base_command = "/usr/bin/dpkg -s #{title} | grep -q " - base_command + (params[:version] ? "'Version: #{params[:version]}'" : "'Status: install'") - end + describe "when specifying version parameter" do + let :params do + default_params.merge(:version => '1') + end + it { should contain_exec("/usr/bin/apt-get -y install #{title}=#{params[:version]}").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" + ) } + end - let :exec_title do - base_exec = "/usr/bin/apt-get -y -t #{param_hash[:release]} install #{title}" - base_exec + (params[:version] ? "=#{params[:version]}" : "") - end - it { should contain_exec(exec_title).with_unless(unless_query) } + describe "when specifying release and version parameters" do + let :params do + default_params.merge( + :release => 'testing', + :version => '1' + ) end + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with( + :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" + ) } end end From e0bf6e082626ed906e3bc72e412b58005ec0efe9 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 3 Jul 2013 11:00:33 -0700 Subject: [PATCH 160/574] Update example apt::force tests --- tests/force.pp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/force.pp b/tests/force.pp index f3313633d0..59ad8f1b57 100644 --- a/tests/force.pp +++ b/tests/force.pp @@ -1,7 +1,17 @@ # force.pp + # force a package from a specific release +apt::force { 'package1': + release => 'backports', +} + +# force a package to be a specific version +apt::force { 'package2': + version => '1.0.0-1', +} -apt::force { 'package': - release => 'testing', - version => false +# force a package from a specific release to be a specific version +apt::force { 'package3': + release => 'sid', + version => '2.0.0-1', } From 197904df9a8964657c4f1087bbcb24b968cd6c37 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 3 Jul 2013 16:58:09 -0700 Subject: [PATCH 161/574] Release 1.2.0 Features: - Add geppetto `.project` natures - Add GH auto-release - Add `apt::key::key_options` parameter - Add complex pin support using distribution properties for `apt::pin` via new properties: - `apt::pin::codename` - `apt::pin::release_version` - `apt::pin::component` - `apt::pin::originator` - `apt::pin::label` - Add source architecture support to `apt::source::architecture` Bugfixes: - Use apt-get instead of aptitude in apt::force - Update default backports location - Add dependency for required packages before apt-get update --- CHANGELOG | 21 +++++++++++++++++++++ Modulefile | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 44fa88abb2..34b8fb5819 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,27 @@ Release notes for the puppetlabs-apt module. +1.2.0 +===== + +Features: +- Add geppetto `.project` natures +- Add GH auto-release +- Add `apt::key::key_options` parameter +- Add complex pin support using distribution properties for `apt::pin` via new properties: + - `apt::pin::codename` + - `apt::pin::release_version` + - `apt::pin::component` + - `apt::pin::originator` + - `apt::pin::label` +- Add source architecture support to `apt::source::architecture` + +Bugfixes: +- Use apt-get instead of aptitude in apt::force +- Update default backports location +- Add dependency for required packages before apt-get update + + 1.1.1 ===== diff --git a/Modulefile b/Modulefile index 2b1b21c3f8..eeeebceaf9 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.1.1' +version '1.2.0' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From c21730c01de7ace9713f914636a539e2a310b116 Mon Sep 17 00:00:00 2001 From: Pierre Gambarotto Date: Thu, 11 Jul 2013 15:29:38 +0200 Subject: [PATCH 162/574] proxy support for apt::ppa --- manifests/ppa.pp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 725170d2dc..f234f748e7 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -26,7 +26,20 @@ package { $package: } } + if defined(Class[apt]) { + $proxy_host = getparam(Class[apt], "proxy_host") + $proxy_port = getparam(Class[apt], "proxy_port") + case $proxy_host { + false: { + $proxy_env = "" + } + default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]} + } + } else { + $proxy_env = "" + } exec { "add-apt-repository-${name}": + environment => $proxy_env, command => "/usr/bin/add-apt-repository ${name}", creates => "${sources_list_d}/${sources_list_d_filename}", logoutput => 'on_failure', From 4d8a99aead5c64556503f21599977b066395fae7 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 11 Jul 2013 15:49:00 -0700 Subject: [PATCH 163/574] Adding specs for proxy and apt::ppa --- spec/defines/ppa_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 6be9ab9142..3baa7e8657 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -55,6 +55,31 @@ } end end + describe 'behind a proxy' do + let :title do + 'rspec_ppa' + end + let :pre_condition do + 'class { "apt": + proxy_host => "user:pass@proxy", + }' + end + let :filename do + "#{title}-#{release}.list" + end + + it { should contain_exec("add-apt-repository-#{title}").with( + 'environment' => [ + "http_proxy=http://user:pass@proxy:8080", + "https_proxy=http://user:pass@proxy:8080", + ], + 'command' => "/usr/bin/add-apt-repository #{title}", + 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], + 'notify' => "Exec[apt_update]" + ) + } + end end end From 19fbdab7945cb9bdb42ef53de2106a03f6bbd236 Mon Sep 17 00:00:00 2001 From: Pierre Gambarotto Date: Tue, 16 Jul 2013 09:52:06 +0200 Subject: [PATCH 164/574] ppa: fix empty environment definition in exec ressource when no proxy --- manifests/ppa.pp | 6 +++--- spec/defines/ppa_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index f234f748e7..6cb921f19b 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -30,13 +30,13 @@ $proxy_host = getparam(Class[apt], "proxy_host") $proxy_port = getparam(Class[apt], "proxy_port") case $proxy_host { - false: { - $proxy_env = "" + false, "": { + $proxy_env = [] } default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]} } } else { - $proxy_env = "" + $proxy_env = [] } exec { "add-apt-repository-${name}": environment => $proxy_env, diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 3baa7e8657..b768b25d3f 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -55,6 +55,29 @@ } end end + describe 'without a proxy defined' do + let :title do + 'rspec_ppa' + end + let :pre_condition do + 'class { "apt": + proxy_host => false + }' + end + let :filename do + "#{title}-#{release}.list" + end + + it { should contain_exec("add-apt-repository-#{title}").with( + 'environment' => [], + 'command' => "/usr/bin/add-apt-repository #{title}", + 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], + 'notify' => "Exec[apt_update]" + ) + } + end + describe 'behind a proxy' do let :title do 'rspec_ppa' From 878bc0217e2ada60d82aa2b92718d85384d4467e Mon Sep 17 00:00:00 2001 From: Oleiade Date: Tue, 16 Jul 2013 15:31:19 +0200 Subject: [PATCH 165/574] Fix: apt::ppa options parameter to pass options to apt-add-repository command --- manifests/ppa.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index f234f748e7..c4b9941d1d 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,7 +1,8 @@ # ppa.pp define apt::ppa( - $release = $::lsbdistcodename + $release = $::lsbdistcodename, + $options = "-y" ) { include apt::params include apt::update @@ -40,7 +41,7 @@ } exec { "add-apt-repository-${name}": environment => $proxy_env, - command => "/usr/bin/add-apt-repository ${name}", + command => "/usr/bin/add-apt-repository ${options} ${name}", creates => "${sources_list_d}/${sources_list_d_filename}", logoutput => 'on_failure', require => [ From 1e940d19f643be877697f69812bb5dbca00bc2e8 Mon Sep 17 00:00:00 2001 From: Oleiade Date: Wed, 17 Jul 2013 09:55:47 +0200 Subject: [PATCH 166/574] Fix: ppa options support specs --- spec/defines/ppa_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 3baa7e8657..d12c70c84d 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -20,6 +20,9 @@ let :package do "#{platform[:package]}" end + let :options do + "-y" + end ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t| describe "with title #{t}" do let :pre_condition do @@ -41,7 +44,7 @@ } it { should contain_exec("add-apt-repository-#{t}").with( - 'command' => "/usr/bin/add-apt-repository #{t}", + 'command' => "/usr/bin/add-apt-repository #{options} #{t}", 'creates' => "/etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" @@ -73,7 +76,7 @@ "http_proxy=http://user:pass@proxy:8080", "https_proxy=http://user:pass@proxy:8080", ], - 'command' => "/usr/bin/add-apt-repository #{title}", + 'command' => "/usr/bin/add-apt-repository #{options} #{title}", 'creates' => "/etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" From 63a0db4cf2335bf65f52c89d095b401a75512d48 Mon Sep 17 00:00:00 2001 From: nagas Date: Mon, 22 Jul 2013 14:48:32 +0200 Subject: [PATCH 167/574] pass flags as string of single letter --- manifests/ppa.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index c4b9941d1d..db312ea135 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -13,9 +13,9 @@ fail('lsbdistcodename fact not available: release parameter required') } - $filename_without_slashes = regsubst($name, '/', '-', G) - $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', G) - $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', G) + $filename_without_slashes = regsubst($name, '/', '-', 'G') + $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G') + $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') $sources_list_d_filename = "${filename_without_ppa}-${release}.list" $package = $::lsbdistrelease ? { From a1a677da66a0746724f22f3b0cd745847306b5fc Mon Sep 17 00:00:00 2001 From: Markus Rekkenbeil Date: Mon, 5 Aug 2013 13:06:54 +0200 Subject: [PATCH 168/574] Add wheezy backports support Signed-off-by: Markus Rekkenbeil --- manifests/params.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifests/params.pp b/manifests/params.pp index aa0f80d60c..c9d0344bcb 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,6 +11,9 @@ 'squeeze': { $backports_location = 'http://backports.debian.org/debian-backports' } + 'wheezy': { + $backports_location = 'http://ftp.debian.org/debian/' + } default: { $backports_location = 'http://ftp.debian.org/debian/' } From 5af4667f3227930fbeedd67f32e76c9a808d676e Mon Sep 17 00:00:00 2001 From: Markus Rekkenbeil Date: Mon, 5 Aug 2013 13:19:50 +0200 Subject: [PATCH 169/574] Use the geoDNS http.debian.net instead of the main debian ftp server Signed-off-by: Markus Rekkenbeil --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index aa0f80d60c..99e8d40d86 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -12,7 +12,7 @@ $backports_location = 'http://backports.debian.org/debian-backports' } default: { - $backports_location = 'http://ftp.debian.org/debian/' + $backports_location = 'http://http.debian.net/debian/' } } } From 5db24d8e3388aefb5e7a4fc830cbf4617a44f9f8 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 5 Aug 2013 13:41:25 -0700 Subject: [PATCH 170/574] Update specs for #145 --- spec/defines/ppa_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index ae91e585fa..dfaf09c572 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -67,13 +67,13 @@ proxy_host => false }' end - let :filename do - "#{title}-#{release}.list" - end + let :filename do + "#{title}-#{release}.list" + end it { should contain_exec("add-apt-repository-#{title}").with( 'environment' => [], - 'command' => "/usr/bin/add-apt-repository #{title}", + 'command' => "/usr/bin/add-apt-repository #{options} #{title}", 'creates' => "/etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" From e97942f2d647d1c1f8c969056dc279c92d7d1ce3 Mon Sep 17 00:00:00 2001 From: Ryan Culbertson Date: Wed, 4 Sep 2013 17:32:42 -0400 Subject: [PATCH 171/574] Fixed several lint warnings and errors --- manifests/init.pp | 2 +- manifests/pin.pp | 2 +- manifests/ppa.pp | 20 ++++++++++---------- tests/key.pp | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2319771950..8f0c87bb54 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -105,10 +105,10 @@ } file { 'configure-apt-proxy': + ensure => $proxy_set, path => "${apt_conf_d}/proxy", content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", notify => Exec['apt_update'], - ensure => $proxy_set, } # Need anchor to provide containment for dependencies. diff --git a/manifests/pin.pp b/manifests/pin.pp index 39de3d8f1f..402e79ede7 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -31,7 +31,7 @@ $release_version, $component, $originator, - $label] + $label] $pin_release = join($pin_release_array, '') # Read the manpage 'apt_preferences(5)', especially the chapter diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 92b6c0e0b2..61b9b3a768 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -2,7 +2,7 @@ define apt::ppa( $release = $::lsbdistcodename, - $options = "-y" + $options = '-y' ) { include apt::params include apt::update @@ -28,10 +28,10 @@ } if defined(Class[apt]) { - $proxy_host = getparam(Class[apt], "proxy_host") - $proxy_port = getparam(Class[apt], "proxy_port") + $proxy_host = getparam(Class[apt], 'proxy_host') + $proxy_port = getparam(Class[apt], 'proxy_port') case $proxy_host { - false, "": { + false, '': { $proxy_env = [] } default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]} @@ -41,14 +41,14 @@ } exec { "add-apt-repository-${name}": environment => $proxy_env, - command => "/usr/bin/add-apt-repository ${options} ${name}", - creates => "${sources_list_d}/${sources_list_d_filename}", - logoutput => 'on_failure', - require => [ + command => "/usr/bin/add-apt-repository ${options} ${name}", + creates => "${sources_list_d}/${sources_list_d_filename}", + logoutput => 'on_failure', + notify => Exec['apt_update'], + require => [ File[$sources_list_d], - Package["${package}"], + Package[$package], ], - notify => Exec['apt_update'], } file { "${sources_list_d}/${sources_list_d_filename}": diff --git a/tests/key.pp b/tests/key.pp index cc90f909c0..9dd574b2a3 100644 --- a/tests/key.pp +++ b/tests/key.pp @@ -1,6 +1,6 @@ # Declare Apt key for apt.puppetlabs.com source apt::key { 'puppetlabs': - key => '4BD6EC30', - key_server => 'pgp.mit.edu', - key_options => "http-proxy=\"http://proxyuser:proxypass@example.org:3128\"", + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + key_options => 'http-proxy=\"http://proxyuser:proxypass@example.org:3128\"', } From d0e478533c40539a84c5bad36cef7e0a13eb65da Mon Sep 17 00:00:00 2001 From: Ryan Culbertson Date: Thu, 5 Sep 2013 00:28:53 -0400 Subject: [PATCH 172/574] removing unnecessary backslashes --- tests/key.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/key.pp b/tests/key.pp index 9dd574b2a3..79e0e1b749 100644 --- a/tests/key.pp +++ b/tests/key.pp @@ -2,5 +2,5 @@ apt::key { 'puppetlabs': key => '4BD6EC30', key_server => 'pgp.mit.edu', - key_options => 'http-proxy=\"http://proxyuser:proxypass@example.org:3128\"', + key_options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', } From df3ba6469ce308d88bd3fe964ae4ed7b7676c541 Mon Sep 17 00:00:00 2001 From: Philip Cohoe Date: Wed, 28 Aug 2013 19:46:00 +0000 Subject: [PATCH 173/574] Added class for managing unattended-upgrades --- manifests/unattended-upgrades.pp | 58 +++++++++++++++++++++++++++++ templates/10periodic.erb | 12 ++++++ templates/50unattended-upgrades.erb | 53 ++++++++++++++++++++++++++ tests/unattended-upgrades.pp | 1 + 4 files changed, 124 insertions(+) create mode 100644 manifests/unattended-upgrades.pp create mode 100644 templates/10periodic.erb create mode 100644 templates/50unattended-upgrades.erb create mode 100644 tests/unattended-upgrades.pp diff --git a/manifests/unattended-upgrades.pp b/manifests/unattended-upgrades.pp new file mode 100644 index 0000000000..772ab047cb --- /dev/null +++ b/manifests/unattended-upgrades.pp @@ -0,0 +1,58 @@ +# unattended-upgrades.pp + +# This class manages the unattended-upgrades package and related configuration +# files for ubuntu + +# origins are the repositories to automatically upgrade included packages +# blacklist is a list of packages to not automatically upgrade +# update is how often to run "apt-get update" in days +# download is how often to run "apt-get upgrade --download-only" in days +# upgrade is how often to upgrade packages included in the origins list in days +# autoclean is how often to run "apt-get autoclean" in days + +# information on the other options can be found in the 50unattended-upgrades +# file and in /etc/cron.daily/apt + +class apt::unattended-upgrades ( + $origins = ['${distro_id}:${distro_codename}-security'], + $blacklist = [], + $update = "1", + $download = "1", + $upgrade = "1", + $autoclean = "7", + $auto_fix = "true", + $minimal_steps = "false", + $install_on_shutdown = "false", + $mail_to = "NONE", + $mail_only_on_error = "false", + $remove_unused = "true", + $auto_reboot = "false", + $dl_limit = "NONE", + $enable = "1", + $backup_interval = "0", + $backup_level = "3", + $max_age = "0", + $min_age = "0", + $max_size = "0", + $download_delta = "0", + $verbose = "0", +) { + + package { 'unattended-upgrades': + ensure => present, + } + + File { + ensure => file, + owner => 'root', + group => 'root', + mode => '0644', + } + + file { + '/etc/apt/apt.conf.d/50unattended-upgrades': + content => template('apt/50unattended-upgrades.erb'); + '/etc/apt/apt.conf.d/10periodic': + content => template('apt/10periodic.erb'); + } +} diff --git a/templates/10periodic.erb b/templates/10periodic.erb new file mode 100644 index 0000000000..5737c9ac29 --- /dev/null +++ b/templates/10periodic.erb @@ -0,0 +1,12 @@ +APT::Periodic::Enable "<%= @enable %>"; +APT::Periodic::BackUpArchiveInterval "<%= @backup_interval %>"; +APT::Periodic::BackUpLevel "<%= @backup_level %>"; +APT::Periodic::MaxAge "<%= @max_age %>"; +APT::Periodic::MinAge "<%= @min_age %>"; +APT::Periodic::MaxSize "<%= @max_size %>"; +APT::Periodic::Update-Package-Lists "<%= @update %>"; +APT::Periodic::Download-Upgradeable-Packages "<%= @download %>"; +APT::Periodic::Download-Upgradeable-Packages-Debdelta "<%= @download_delta %>"; +APT::Periodic::Unattended-Upgrade "<%= @upgrade %>"; +APT::Periodic::AutocleanInterval "<%= @autoclean %>"; +APT::Periodic::Verbose "<%= @verbose %>"; diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb new file mode 100644 index 0000000000..b026fe9dd1 --- /dev/null +++ b/templates/50unattended-upgrades.erb @@ -0,0 +1,53 @@ +// Automatically upgrade packages from these (origin:archive) pairs +Unattended-Upgrade::Allowed-Origins { +<% @origins.each do |origin| -%> + "<%= origin %>"; +<% end -%> +}; + +// List of packages to not update +Unattended-Upgrade::Package-Blacklist { +<% @blacklist.each do |package| -%> + "<%= package %>"; +<% end -%> +}; + +// This option allows you to control if on a unclean dpkg exit +// unattended-upgrades will automatically run +// dpkg --force-confold --configure -a +// The default is true, to ensure updates keep getting installed +Unattended-Upgrade::AutoFixInterruptedDpkg "<%= @auto_fix %>"; + +// Split the upgrade into the smallest possible chunks so that +// they can be interrupted with SIGUSR1. This makes the upgrade +// a bit slower but it has the benefit that shutdown while a upgrade +// is running is possible (with a small delay) +Unattended-Upgrade::MinimalSteps "<%= @minimal_steps %>"; + +// Install all unattended-upgrades when the machine is shuting down +// instead of doing it in the background while the machine is running +// This will (obviously) make shutdown slower +Unattended-Upgrade::InstallOnShutdown "<%= @install_on_shutdown %>"; + +// Send email to this address for problems or packages upgrades +// If empty or unset then no email is sent, make sure that you +// have a working mail setup on your system. A package that provides +// 'mailx' must be installed. +<% if @mail_to != "NONE" %> Unattended-Upgrade::Mail "<%= @mail_to %>"; <% end %> + +// Set this value to "true" to get emails only on errors. Default +// is to always send a mail if Unattended-Upgrade::Mail is set +<% if @mail_to != "NONE" %> Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>"; <% end %> + +// Do automatic removal of new unused dependencies after the upgrade +// (equivalent to apt-get autoremove) +Unattended-Upgrade::Remove-Unused-Dependencies "<%= @remove_unused %>"; + +// Automatically reboot *WITHOUT CONFIRMATION* if a +// the file /var/run/reboot-required is found after the upgrade +Unattended-Upgrade::Automatic-Reboot "<%= @auto_reboot %>"; + + +// Use apt bandwidth limit feature, this example limits the download +// speed to 70kb/sec +<% if @dl_limit != "NONE" %> Acquire::http::Dl-Limit "<%= @dl_limit %>"; <% end %> diff --git a/tests/unattended-upgrades.pp b/tests/unattended-upgrades.pp new file mode 100644 index 0000000000..7f65ab4f57 --- /dev/null +++ b/tests/unattended-upgrades.pp @@ -0,0 +1 @@ +include apt::unattended-upgrades From ee047f6593bbe412d72376b52b4361199b16722b Mon Sep 17 00:00:00 2001 From: Philip Cohoe Date: Fri, 13 Sep 2013 23:39:09 +0000 Subject: [PATCH 174/574] Added spec test for unattended-upgrades class --- spec/classes/unattended-upgrades_spec.rb | 179 +++++++++++++++++++++++ templates/50unattended-upgrades.erb | 6 +- 2 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 spec/classes/unattended-upgrades_spec.rb diff --git a/spec/classes/unattended-upgrades_spec.rb b/spec/classes/unattended-upgrades_spec.rb new file mode 100644 index 0000000000..98245ca8a5 --- /dev/null +++ b/spec/classes/unattended-upgrades_spec.rb @@ -0,0 +1,179 @@ +require 'spec_helper' +describe 'apt::unattended-upgrades', :type => :class do + + it { should contain_package("unattended-upgrades") } + + it { + should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({ + "owner" => "root", + "group" => "root", + "mode" => "0644", + }) + } + + it { + should create_file("/etc/apt/apt.conf.d/10periodic").with({ + "owner" => "root", + "group" => "root", + "mode" => "0644", + }) + } + + describe "with origins => ['ubuntu:precise-security']" do + let :params do + { :origins => ['ubuntu:precise-security'] } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } + end + + describe "with blacklist => []" do + let :params do + { :blacklist => [] } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) } + end + + describe "with update => 2" do + let :params do + { :update => "2" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Update-Package-Lists "2";$/) } + end + + describe "with download => 2" do + let :params do + { :download => "2" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) } + end + + describe "with upgrade => 2" do + let :params do + { :upgrade => "2" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) } + end + + describe "with autoclean => 2" do + let :params do + { :autoclean => "2" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::AutocleanInterval "2";$/) } + end + + describe "with auto_fix => false" do + let :params do + { :auto_fix => "false" } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) } + end + + describe "with minimal_steps => true" do + let :params do + { :minimal_steps => "true" } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) } + end + + describe "with install_on_shutdown => true" do + let :params do + { :install_on_shutdown => "true" } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) } + end + + describe "with mail_to => NONE" do + let :params do + { :mail_to => "NONE" } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^\/\/ 'mailx' must be installed.\n$/) } + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^\/\/ is to always send a mail if Unattended-Upgrade::Mail is set\n$/) } + end + + describe "with mail_to => user@website, mail_only_on_error => true" do + let :params do + { :mail_to => "user@website", + :mail_only_on_error => "true" } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Mail "user@website";$/) } + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) } + end + + describe "with remove_unused => false" do + let :params do + { :remove_unused => "false" } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) } + end + + describe "with auto_reboot => true" do + let :params do + { :auto_reboot => "true" } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) } + end + + describe "with dl_limit => 70" do + let :params do + { :dl_limit => "70" } + end + it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Acquire::http::Dl-Limit "70";$/) } + end + + describe "with enable => 0" do + let :params do + { :enable => "0" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Enable "0";$/) } + end + + describe "with backup_interval => 1" do + let :params do + { :backup_interval => "1" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) } + end + + describe "with backup_level => 0" do + let :params do + { :backup_level => "0" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::BackUpLevel "0";$/) } + end + + describe "with max_age => 1" do + let :params do + { :max_age => "1" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::MaxAge "1";$/) } + end + + describe "with min_age => 1" do + let :params do + { :min_age => "1" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::MinAge "1";$/) } + end + + describe "with max_size => 1" do + let :params do + { :max_size => "1" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::MaxSize "1";$/) } + end + + describe "with download_delta => 2" do + let :params do + { :download_delta => "2" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) } + end + + describe "with verbose => 2" do + let :params do + { :verbose => "2" } + end + it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Verbose "2";$/) } + end + +end diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb index b026fe9dd1..4df0f74401 100644 --- a/templates/50unattended-upgrades.erb +++ b/templates/50unattended-upgrades.erb @@ -33,11 +33,11 @@ Unattended-Upgrade::InstallOnShutdown "<%= @install_on_shutdown %>"; // If empty or unset then no email is sent, make sure that you // have a working mail setup on your system. A package that provides // 'mailx' must be installed. -<% if @mail_to != "NONE" %> Unattended-Upgrade::Mail "<%= @mail_to %>"; <% end %> +<% if @mail_to != "NONE" %>Unattended-Upgrade::Mail "<%= @mail_to %>";<% end %> // Set this value to "true" to get emails only on errors. Default // is to always send a mail if Unattended-Upgrade::Mail is set -<% if @mail_to != "NONE" %> Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>"; <% end %> +<% if @mail_to != "NONE" %>Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>";<% end %> // Do automatic removal of new unused dependencies after the upgrade // (equivalent to apt-get autoremove) @@ -50,4 +50,4 @@ Unattended-Upgrade::Automatic-Reboot "<%= @auto_reboot %>"; // Use apt bandwidth limit feature, this example limits the download // speed to 70kb/sec -<% if @dl_limit != "NONE" %> Acquire::http::Dl-Limit "<%= @dl_limit %>"; <% end %> +<% if @dl_limit != "NONE" %>Acquire::http::Dl-Limit "<%= @dl_limit %>";<% end %> From 2fea399a09d64addb9413a67697211a93cb803bd Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Mon, 16 Sep 2013 08:53:01 +0100 Subject: [PATCH 175/574] [#153] Rename unattended_upgrades s/-/_/ It's preferable to use underscores rather than hyphens in class names. Refs: - http://projects.puppetlabs.com/issues/5268 - http://docs.puppetlabs.com/puppet/3/reference/lang_reserved.html#classes-and-types --- ...unattended-upgrades.pp => unattended_upgrades.pp} | 12 ++++++------ ...-upgrades_spec.rb => unattended_upgrades_spec.rb} | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) rename manifests/{unattended-upgrades.pp => unattended_upgrades.pp} (95%) rename spec/classes/{unattended-upgrades_spec.rb => unattended_upgrades_spec.rb} (99%) diff --git a/manifests/unattended-upgrades.pp b/manifests/unattended_upgrades.pp similarity index 95% rename from manifests/unattended-upgrades.pp rename to manifests/unattended_upgrades.pp index 772ab047cb..e4ad4dc411 100644 --- a/manifests/unattended-upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -1,19 +1,19 @@ -# unattended-upgrades.pp - +# Class: apt::unattended_upgrades +# # This class manages the unattended-upgrades package and related configuration # files for ubuntu - +# # origins are the repositories to automatically upgrade included packages # blacklist is a list of packages to not automatically upgrade # update is how often to run "apt-get update" in days # download is how often to run "apt-get upgrade --download-only" in days # upgrade is how often to upgrade packages included in the origins list in days # autoclean is how often to run "apt-get autoclean" in days - +# # information on the other options can be found in the 50unattended-upgrades # file and in /etc/cron.daily/apt - -class apt::unattended-upgrades ( +# +class apt::unattended_upgrades ( $origins = ['${distro_id}:${distro_codename}-security'], $blacklist = [], $update = "1", diff --git a/spec/classes/unattended-upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb similarity index 99% rename from spec/classes/unattended-upgrades_spec.rb rename to spec/classes/unattended_upgrades_spec.rb index 98245ca8a5..6695550abc 100644 --- a/spec/classes/unattended-upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe 'apt::unattended-upgrades', :type => :class do +describe 'apt::unattended_upgrades', :type => :class do it { should contain_package("unattended-upgrades") } From ea40999381006587555f1e6cdcad2362292bc390 Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Mon, 16 Sep 2013 09:06:15 +0100 Subject: [PATCH 176/574] [#153] Convert t/f params to bools and validate Per lint check: http://puppet-lint.com/checks/quoted_booleans/ --- manifests/unattended_upgrades.pp | 21 +++++++++++++++------ spec/classes/unattended_upgrades_spec.rb | 12 ++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index e4ad4dc411..0c4728f35e 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -20,13 +20,13 @@ $download = "1", $upgrade = "1", $autoclean = "7", - $auto_fix = "true", - $minimal_steps = "false", - $install_on_shutdown = "false", + $auto_fix = true, + $minimal_steps = false, + $install_on_shutdown = false, $mail_to = "NONE", - $mail_only_on_error = "false", - $remove_unused = "true", - $auto_reboot = "false", + $mail_only_on_error = false, + $remove_unused = true, + $auto_reboot = false, $dl_limit = "NONE", $enable = "1", $backup_interval = "0", @@ -38,6 +38,15 @@ $verbose = "0", ) { + validate_bool( + $auto_fix, + $minimal_steps, + $install_on_shutdown, + $mail_only_on_error, + $remove_unused, + $auto_reboot + ) + package { 'unattended-upgrades': ensure => present, } diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 6695550abc..097f7a51cd 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -63,21 +63,21 @@ describe "with auto_fix => false" do let :params do - { :auto_fix => "false" } + { :auto_fix => false } end it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) } end describe "with minimal_steps => true" do let :params do - { :minimal_steps => "true" } + { :minimal_steps => true } end it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) } end describe "with install_on_shutdown => true" do let :params do - { :install_on_shutdown => "true" } + { :install_on_shutdown => true } end it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) } end @@ -93,7 +93,7 @@ describe "with mail_to => user@website, mail_only_on_error => true" do let :params do { :mail_to => "user@website", - :mail_only_on_error => "true" } + :mail_only_on_error => true } end it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Mail "user@website";$/) } it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) } @@ -101,14 +101,14 @@ describe "with remove_unused => false" do let :params do - { :remove_unused => "false" } + { :remove_unused => false } end it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) } end describe "with auto_reboot => true" do let :params do - { :auto_reboot => "true" } + { :auto_reboot => true } end it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) } end From f185a57cd64c83816b0183161956e0adc608eaa7 Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Mon, 16 Sep 2013 12:34:07 +0100 Subject: [PATCH 177/574] [#153] Variablise file paths in unattended spec Reduce some duplication of long file paths. --- spec/classes/unattended_upgrades_spec.rb | 50 ++++++++++++------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 097f7a51cd..17a21caff1 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -1,5 +1,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' } it { should contain_package("unattended-upgrades") } @@ -23,71 +25,71 @@ let :params do { :origins => ['ubuntu:precise-security'] } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } end describe "with blacklist => []" do let :params do { :blacklist => [] } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) } end describe "with update => 2" do let :params do { :update => "2" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Update-Package-Lists "2";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) } end describe "with download => 2" do let :params do { :download => "2" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) } end describe "with upgrade => 2" do let :params do { :upgrade => "2" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) } end describe "with autoclean => 2" do let :params do { :autoclean => "2" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::AutocleanInterval "2";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) } end describe "with auto_fix => false" do let :params do { :auto_fix => false } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) } end describe "with minimal_steps => true" do let :params do { :minimal_steps => true } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) } end describe "with install_on_shutdown => true" do let :params do { :install_on_shutdown => true } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) } end describe "with mail_to => NONE" do let :params do { :mail_to => "NONE" } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^\/\/ 'mailx' must be installed.\n$/) } - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^\/\/ is to always send a mail if Unattended-Upgrade::Mail is set\n$/) } + it { should contain_file(file_unattended).with_content(/^\/\/ 'mailx' must be installed.\n$/) } + it { should contain_file(file_unattended).with_content(/^\/\/ is to always send a mail if Unattended-Upgrade::Mail is set\n$/) } end describe "with mail_to => user@website, mail_only_on_error => true" do @@ -95,85 +97,85 @@ { :mail_to => "user@website", :mail_only_on_error => true } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Mail "user@website";$/) } - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) } end describe "with remove_unused => false" do let :params do { :remove_unused => false } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) } end describe "with auto_reboot => true" do let :params do { :auto_reboot => true } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) } end describe "with dl_limit => 70" do let :params do { :dl_limit => "70" } end - it { should contain_file('/etc/apt/apt.conf.d/50unattended-upgrades').with_content(/^Acquire::http::Dl-Limit "70";$/) } + it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) } end describe "with enable => 0" do let :params do { :enable => "0" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Enable "0";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) } end describe "with backup_interval => 1" do let :params do { :backup_interval => "1" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) } end describe "with backup_level => 0" do let :params do { :backup_level => "0" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::BackUpLevel "0";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) } end describe "with max_age => 1" do let :params do { :max_age => "1" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::MaxAge "1";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) } end describe "with min_age => 1" do let :params do { :min_age => "1" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::MinAge "1";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) } end describe "with max_size => 1" do let :params do { :max_size => "1" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::MaxSize "1";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) } end describe "with download_delta => 2" do let :params do { :download_delta => "2" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) } end describe "with verbose => 2" do let :params do { :verbose => "2" } end - it { should contain_file('/etc/apt/apt.conf.d/10periodic').with_content(/^APT::Periodic::Verbose "2";$/) } + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) } end end From f90805dafdb5441510f786368265bad2ee261e59 Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Mon, 16 Sep 2013 13:35:09 +0100 Subject: [PATCH 178/574] [#153] Test defaults for some unattended params For params which have any logic embedded in the template: - origins - blacklist - mail_to - dl_limit --- spec/classes/unattended_upgrades_spec.rb | 71 +++++++++++++++--------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 17a21caff1..e33f7a0470 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -21,18 +21,32 @@ }) } - describe "with origins => ['ubuntu:precise-security']" do - let :params do - { :origins => ['ubuntu:precise-security'] } + describe "origins" do + describe "with param defaults" do + let(:params) {{ }} + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id}:\${distro_codename}-security";\n\};$/) } + end + + describe "with origins => ['ubuntu:precise-security']" do + let :params do + { :origins => ['ubuntu:precise-security'] } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } end - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } end - describe "with blacklist => []" do - let :params do - { :blacklist => [] } + describe "blacklist" do + describe "with param defaults" do + let(:params) {{ }} + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) } + end + + describe "with blacklist => []" do + let :params do + { :blacklist => ['libc6', 'libc6-dev'] } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) } end - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) } end describe "with update => 2" do @@ -84,21 +98,21 @@ it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) } end - describe "with mail_to => NONE" do - let :params do - { :mail_to => "NONE" } + describe "mail_to" do + describe "param defaults" do + let(:params) {{ }} + it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) } + it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) } end - it { should contain_file(file_unattended).with_content(/^\/\/ 'mailx' must be installed.\n$/) } - it { should contain_file(file_unattended).with_content(/^\/\/ is to always send a mail if Unattended-Upgrade::Mail is set\n$/) } - end - - describe "with mail_to => user@website, mail_only_on_error => true" do - let :params do - { :mail_to => "user@website", - :mail_only_on_error => true } + + describe "with mail_to => user@website, mail_only_on_error => true" do + let :params do + { :mail_to => "user@website", + :mail_only_on_error => true } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) } end - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) } - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) } end describe "with remove_unused => false" do @@ -115,11 +129,18 @@ it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) } end - describe "with dl_limit => 70" do - let :params do - { :dl_limit => "70" } + describe "dl_limit" do + describe "param defaults" do + let(:params) {{ }} + it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) } + end + + describe "with dl_limit => 70" do + let :params do + { :dl_limit => "70" } + end + it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) } end - it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) } end describe "with enable => 0" do From dc88fe6ef67b8098d04852087972473d48aab93a Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Mon, 16 Sep 2013 13:45:03 +0100 Subject: [PATCH 179/574] [#153] Install unattended configs after package To ensure that the default configs from the package are always overwritten within a single Puppet run. --- manifests/unattended_upgrades.pp | 1 + spec/classes/unattended_upgrades_spec.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index 0c4728f35e..f006bd5289 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -56,6 +56,7 @@ owner => 'root', group => 'root', mode => '0644', + require => Package['unattended-upgrades'], } file { diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index e33f7a0470..db5c855726 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -10,6 +10,7 @@ "owner" => "root", "group" => "root", "mode" => "0644", + "require" => "Package[unattended-upgrades]", }) } @@ -18,6 +19,7 @@ "owner" => "root", "group" => "root", "mode" => "0644", + "require" => "Package[unattended-upgrades]", }) } From e0926f370d4689fda777967fec8a24a8a528a855 Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Mon, 16 Sep 2013 13:56:14 +0100 Subject: [PATCH 180/574] [#153] Remove trailing whitespace from spec. --- spec/classes/unattended_upgrades_spec.rb | 48 ++++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index db5c855726..8abc603251 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -5,7 +5,7 @@ it { should contain_package("unattended-upgrades") } - it { + it { should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({ "owner" => "root", "group" => "root", @@ -13,8 +13,8 @@ "require" => "Package[unattended-upgrades]", }) } - - it { + + it { should create_file("/etc/apt/apt.conf.d/10periodic").with({ "owner" => "root", "group" => "root", @@ -36,7 +36,7 @@ it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } end end - + describe "blacklist" do describe "with param defaults" do let(:params) {{ }} @@ -50,56 +50,56 @@ it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) } end end - + describe "with update => 2" do let :params do { :update => "2" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) } end - + describe "with download => 2" do let :params do { :download => "2" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) } end - + describe "with upgrade => 2" do let :params do { :upgrade => "2" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) } end - + describe "with autoclean => 2" do let :params do { :autoclean => "2" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) } end - + describe "with auto_fix => false" do let :params do { :auto_fix => false } end it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) } end - + describe "with minimal_steps => true" do let :params do { :minimal_steps => true } end it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) } end - + describe "with install_on_shutdown => true" do let :params do { :install_on_shutdown => true } end it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) } end - + describe "mail_to" do describe "param defaults" do let(:params) {{ }} @@ -116,21 +116,21 @@ it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) } end end - + describe "with remove_unused => false" do let :params do { :remove_unused => false } end it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) } end - + describe "with auto_reboot => true" do let :params do { :auto_reboot => true } end it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) } end - + describe "dl_limit" do describe "param defaults" do let(:params) {{ }} @@ -144,61 +144,61 @@ it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) } end end - + describe "with enable => 0" do let :params do { :enable => "0" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) } end - + describe "with backup_interval => 1" do let :params do { :backup_interval => "1" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) } end - + describe "with backup_level => 0" do let :params do { :backup_level => "0" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) } end - + describe "with max_age => 1" do let :params do { :max_age => "1" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) } end - + describe "with min_age => 1" do let :params do { :min_age => "1" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) } end - + describe "with max_size => 1" do let :params do { :max_size => "1" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) } end - + describe "with download_delta => 2" do let :params do { :download_delta => "2" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) } end - + describe "with verbose => 2" do let :params do { :verbose => "2" } end it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) } end - + end From 3442c49e264ec51cc46b5547f4dbab6ebb347555 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 17 Sep 2013 10:20:23 -0400 Subject: [PATCH 181/574] Prepare 1.3.0 release. --- CHANGELOG | 24 ++++++++++++++++++++++++ Modulefile | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 34b8fb5819..25b0ec2419 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,30 @@ Release notes for the puppetlabs-apt module. +1.3.0 +===== + +Summary: + +This major feature in this release is the new apt::unattended_upgrades class, +allowing you to handle Ubuntu's unattended feature. This allows you to select +specific packages to automatically upgrade without any further user +involvement. + +In addition we extend our Wheezy support, add proxy support to apt:ppa and do +various cleanups and tweaks. + +Features: +- Add apt::unattended_upgrades support for Ubuntu. +- Add wheezy backports support. +- Use the geoDNS http.debian.net instead of the main debian ftp server. +- Add `options` parameter to apt::ppa in order to pass options to apt-add-repository command. +- Add proxy support for apt::ppa (uses proxy_host and proxy_port from apt). + +Bugfixes: +- Fix regsubst() calls to quote single letters (for future parser). +- Fix lint warnings and other misc cleanup. + 1.2.0 ===== diff --git a/Modulefile b/Modulefile index eeeebceaf9..a73f20bf5a 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.2.0' +version '1.3.0' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From c07ab505c12428e50893451a38f7f1b38eeb0ada Mon Sep 17 00:00:00 2001 From: Edwin Hermans Date: Wed, 2 Oct 2013 14:24:30 +0200 Subject: [PATCH 182/574] add an updates_timeout option to apt::params (PR fix) --- README.md | 3 ++- manifests/init.pp | 5 ++++- manifests/update.pp | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 402d7ab021..2ce5340ab6 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ The parameters for `apt` are not required in general and are predominantly for d proxy_port => '8080', purge_sources_list => false, purge_sources_list_d => false, - purge_preferences_d => false + purge_preferences_d => false, + update_timeout => undef } Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. diff --git a/manifests/init.pp b/manifests/init.pp index 8f0c87bb54..b106ad4909 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,6 +12,8 @@ # true, Puppet will purge all unmanaged entries from sources.list # purge_sources_list_d - Accepts true or false. Defaults to false. If set # to true, Puppet will purge all unmanaged entries from sources.list.d +# update_timeout - Overrides the exec timeout in seconds for apt-get update. +# If not set defaults to Exec's default (300) # # Actions: # @@ -27,7 +29,8 @@ $proxy_port = '8080', $purge_sources_list = false, $purge_sources_list_d = false, - $purge_preferences_d = false + $purge_preferences_d = false, + $update_timeout = undef ) { include apt::params diff --git a/manifests/update.pp b/manifests/update.pp index e9b9ea9554..ce0b78fbdd 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -5,5 +5,6 @@ command => "${apt::params::provider} update", logoutput => 'on_failure', refreshonly => true, + timeout => $apt::update_timeout, } } From 621111ee73d02f3ed64c071972a047c085bac6cf Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 2 Oct 2013 12:42:56 -0400 Subject: [PATCH 183/574] Add initial rspec-system tests. This covers: apt::builddep apt::key apt::ppa apt::source apt --- .nodeset.yml | 19 ++++++++++++ Gemfile | 11 ++++--- Rakefile | 1 + spec/spec_helper_system.rb | 30 ++++++++++++++++++ spec/system/apt_builddep_spec.rb | 37 +++++++++++++++++++++++ spec/system/apt_key_spec.rb | 52 ++++++++++++++++++++++++++++++++ spec/system/apt_ppa_spec.rb | 38 +++++++++++++++++++++++ spec/system/apt_source_spec.rb | 50 ++++++++++++++++++++++++++++++ spec/system/basic_spec.rb | 22 ++++++++++++++ spec/system/class_spec.rb | 20 ++++++++++++ 10 files changed, 275 insertions(+), 5 deletions(-) create mode 100644 .nodeset.yml create mode 100644 spec/spec_helper_system.rb create mode 100644 spec/system/apt_builddep_spec.rb create mode 100644 spec/system/apt_key_spec.rb create mode 100644 spec/system/apt_ppa_spec.rb create mode 100644 spec/system/apt_source_spec.rb create mode 100644 spec/system/basic_spec.rb create mode 100644 spec/system/class_spec.rb diff --git a/.nodeset.yml b/.nodeset.yml new file mode 100644 index 0000000000..ad056fe655 --- /dev/null +++ b/.nodeset.yml @@ -0,0 +1,19 @@ +--- +default_set: 'ubuntu-server-12042-x64' +sets: + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' diff --git a/Gemfile b/Gemfile index 881fc90e21..15bd29daf0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,12 @@ source 'https://rubygems.org' group :development, :test do - gem 'rake', :require => false - gem 'rspec-puppet', :require => false - gem 'puppetlabs_spec_helper', :require => false + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-system', :require => false + gem 'rspec-system-puppet', :require => false + gem 'rspec-system-serverspec', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] @@ -11,5 +14,3 @@ if puppetversion = ENV['PUPPET_GEM_VERSION'] else gem 'puppet', :require => false end - -# vim:ft=ruby diff --git a/Rakefile b/Rakefile index cd3d379958..bb60173e57 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1,2 @@ require 'puppetlabs_spec_helper/rake_tasks' +require 'rspec-system/rake_task' diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb new file mode 100644 index 0000000000..490a6017eb --- /dev/null +++ b/spec/spec_helper_system.rb @@ -0,0 +1,30 @@ +require 'rspec-system/spec_helper' +require 'rspec-system-puppet/helpers' +require 'rspec-system-serverspec/helpers' + +include RSpecSystemPuppet::Helpers + +include Serverspec::Helper::RSpecSystem +include Serverspec::Helper::DetectOS + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Enable colour + c.tty = true + + c.include RSpecSystemPuppet::Helpers + + # This is where we 'setup' the nodes before running our tests + c.before :suite do + # May as well update here as this can only run on apt-get machines. + shell('apt-get update') + # Install puppet + puppet_install + + # Install modules and dependencies + puppet_module_install(:source => proj_root, :module_name => 'apt') + shell('puppet module install puppetlabs-stdlib') + end +end diff --git a/spec/system/apt_builddep_spec.rb b/spec/system/apt_builddep_spec.rb new file mode 100644 index 0000000000..2fb74870e5 --- /dev/null +++ b/spec/system/apt_builddep_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper_system' + +describe 'apt::builddep' do + + context 'reset' do + it 'removes packages' do + shell('apt-get -y remove glusterfs-server') + shell('apt-get -y remove g++') + end + end + + context 'apt::builddep' do + it 'should work with no errors' do + pp = <<-EOS + apt::builddep { 'glusterfs-server': } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + end + end + + describe 'should install g++ as a dependency' do + describe package('g++') do + it { should be_installed } + end + end + end + + context 'reset' do + it 'removes packages' do + shell('apt-get -y remove glusterfs-server') + shell('apt-get -y remove g++') + end + end + +end diff --git a/spec/system/apt_key_spec.rb b/spec/system/apt_key_spec.rb new file mode 100644 index 0000000000..2acc3179f2 --- /dev/null +++ b/spec/system/apt_key_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper_system' + +describe 'apt::key' do + + context 'reset' do + it 'clean up keys' do + shell('apt-key del 4BD6EC30') + shell('apt-key del D50582E6') + end + end + + context 'apt::key' do + it 'should work with no errors' do + pp = <<-EOS + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + + apt::key { 'jenkins': + key => 'D50582E6', + key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', + } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + end + end + + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') do |r| + r.exit_code.should be_zero + end + end + it 'finds jenkins key' do + shell('apt-key list | grep D50582E6') do |r| + r.exit_code.should be_zero + end + end + end + end + + context 'reset' do + it 'clean up keys' do + shell('apt-key del 4BD6EC30') + shell('apt-key del D50582E6') + end + end + +end diff --git a/spec/system/apt_ppa_spec.rb b/spec/system/apt_ppa_spec.rb new file mode 100644 index 0000000000..8e7090bd98 --- /dev/null +++ b/spec/system/apt_ppa_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper_system' + +describe 'apt::ppa' do + + context 'reset' do + it 'removes ppa' do + shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*') + end + end + + context 'apt::ppa' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:drizzle-developers/ppa': } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + end + end + + describe 'contains the source file' do + it 'contains a drizzle ppa source' do + shell('ls /etc/apt/sources.list.d/drizzle-developers-ppa-*.list') do |r| + r.exit_code.should be_zero + end + end + end + end + + context 'reset' do + it 'removes ppa' do + shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*') + end + end + +end diff --git a/spec/system/apt_source_spec.rb b/spec/system/apt_source_spec.rb new file mode 100644 index 0000000000..8c79f6f7e0 --- /dev/null +++ b/spec/system/apt_source_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper_system' + +describe 'apt::source' do + + context 'reset' do + it 'clean up puppetlabs repo' do + shell('apt-key del 4BD6EC30') + shell('rm /etc/apt/sources.list.d/puppetlabs.list') + end + end + + context 'apt::source' do + it 'should work with no errors' do + pp = <<-EOS + apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + end + end + + describe 'key should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') do |r| + r.exit_code.should be_zero + end + end + end + + describe 'source should exist' do + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + end + end + end + + context 'reset' do + it 'clean up puppetlabs repo' do + shell('apt-key del 4BD6EC30') + shell('rm /etc/apt/sources.list.d/puppetlabs.list') + end + end + +end diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb new file mode 100644 index 0000000000..a87f908411 --- /dev/null +++ b/spec/system/basic_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper_system' + +describe 'basic tests:' do + # Using puppet_apply as a subject + context puppet_apply 'notice("foo")' do + its(:stdout) { should =~ /foo/ } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end +end + +describe 'disable selinux:' do + context puppet_apply ' + exec { "setenforce 0": + path => "/bin:/sbin:/usr/bin:/usr/sbin", + onlyif => "which setenforce && getenforce | grep Enforcing", + } + ' do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + end +end diff --git a/spec/system/class_spec.rb b/spec/system/class_spec.rb new file mode 100644 index 0000000000..7bb6b8d64e --- /dev/null +++ b/spec/system/class_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper_system' + +describe 'apt class' do + + context 'default parameters' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': } + EOS + + # Run it twice and test for idempotency + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should be_zero + end + end + end +end From 2f9c16a2736e1de4eda3250984e2b1125efd849e Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 2 Oct 2013 13:56:06 -0400 Subject: [PATCH 184/574] This switches us to doing a `test -s` instead of checking for the files existence as add-apt-repository --remove leaves a 0 byte file behind instead of deleting everything properly. --- manifests/ppa.pp | 2 +- spec/defines/ppa_spec.rb | 6 +++--- spec/system/apt_ppa_spec.rb | 25 +++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 61b9b3a768..e6954af3b7 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -42,7 +42,7 @@ exec { "add-apt-repository-${name}": environment => $proxy_env, command => "/usr/bin/add-apt-repository ${options} ${name}", - creates => "${sources_list_d}/${sources_list_d_filename}", + onlyif => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", logoutput => 'on_failure', notify => Exec['apt_update'], require => [ diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index dfaf09c572..853fdb67f0 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -45,7 +45,7 @@ it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{options} #{t}", - 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) @@ -74,7 +74,7 @@ it { should contain_exec("add-apt-repository-#{title}").with( 'environment' => [], 'command' => "/usr/bin/add-apt-repository #{options} #{title}", - 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) @@ -100,7 +100,7 @@ "https_proxy=http://user:pass@proxy:8080", ], 'command' => "/usr/bin/add-apt-repository #{options} #{title}", - 'creates' => "/etc/apt/sources.list.d/#{filename}", + 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) diff --git a/spec/system/apt_ppa_spec.rb b/spec/system/apt_ppa_spec.rb index 8e7090bd98..2e2baf5d2b 100644 --- a/spec/system/apt_ppa_spec.rb +++ b/spec/system/apt_ppa_spec.rb @@ -5,10 +5,11 @@ context 'reset' do it 'removes ppa' do shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*') + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') end end - context 'apt::ppa' do + context 'adding a ppa that doesnt exist' do it 'should work with no errors' do pp = <<-EOS include '::apt' @@ -29,9 +30,29 @@ end end + context 'readding a removed ppa.' do + it 'setup' do + shell('add-apt-repository -y ppa:raravena80/collectd5') + # This leaves a blank file + shell('add-apt-repository --remove ppa:raravena80/collectd5') + end + + it 'should readd it successfully' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:raravena80/collectd5': } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + end + end + end + context 'reset' do - it 'removes ppa' do + it 'removes added ppas' do shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*') + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') end end From ee24679f6d234952832bd014d98f7d9884ffbf60 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 2 Oct 2013 14:04:51 -0400 Subject: [PATCH 185/574] Fix other tests to include apt appropriately. --- spec/system/apt_builddep_spec.rb | 1 + spec/system/apt_key_spec.rb | 1 + spec/system/apt_source_spec.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/spec/system/apt_builddep_spec.rb b/spec/system/apt_builddep_spec.rb index 2fb74870e5..fa16ab42f5 100644 --- a/spec/system/apt_builddep_spec.rb +++ b/spec/system/apt_builddep_spec.rb @@ -12,6 +12,7 @@ context 'apt::builddep' do it 'should work with no errors' do pp = <<-EOS + include '::apt' apt::builddep { 'glusterfs-server': } EOS diff --git a/spec/system/apt_key_spec.rb b/spec/system/apt_key_spec.rb index 2acc3179f2..4842cb5972 100644 --- a/spec/system/apt_key_spec.rb +++ b/spec/system/apt_key_spec.rb @@ -12,6 +12,7 @@ context 'apt::key' do it 'should work with no errors' do pp = <<-EOS + include '::apt' apt::key { 'puppetlabs': key => '4BD6EC30', key_server => 'pgp.mit.edu', diff --git a/spec/system/apt_source_spec.rb b/spec/system/apt_source_spec.rb index 8c79f6f7e0..6a445e13ef 100644 --- a/spec/system/apt_source_spec.rb +++ b/spec/system/apt_source_spec.rb @@ -12,6 +12,7 @@ context 'apt::source' do it 'should work with no errors' do pp = <<-EOS + include '::apt' apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', repos => 'main', From 245b2b178378c3783cf31348e24034b8d195a68f Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Fri, 4 Oct 2013 15:49:01 -0400 Subject: [PATCH 186/574] FM-103: Add metadata.json to all modules. --- .gitignore | 1 - metadata.json | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 metadata.json diff --git a/.gitignore b/.gitignore index 0485a727cb..b77434bea0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ pkg/ Gemfile.lock spec/fixtures/manifests -metadata.json diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000000..ccb4458443 --- /dev/null +++ b/metadata.json @@ -0,0 +1,26 @@ +{ + "name": "puppetlabs/apt", + "version": "1.3.0", + "summary": "Apt key and source management", + "source": "git@github.com/puppetlabs/puppetlabs-apt.git", + "project_page": "http://github.com/puppetlabs/puppetlabs-apt", + "author": "Puppet Labs", + "license": "Apache-2.0", + "operatingsystem_support": [ + "Debian", + "Ubuntu" + ], + "puppet_version": [ + 2.7, + 3.0, + 3.1, + 3.2, + 3.3 + ], + "dependencies": [ + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 2.2.1" + } + ] +} From 39cbeeb9d29a2c3eb0b781d4cd65d61b272c5341 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 8 Oct 2013 10:50:30 -0700 Subject: [PATCH 187/574] This work flips from onlyif to unless (mistakenly looked at the wrong return code). --- manifests/ppa.pp | 2 +- spec/defines/ppa_spec.rb | 6 +++--- spec/system/basic_spec.rb | 12 ------------ 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index e6954af3b7..7cb88c8cd5 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -42,7 +42,7 @@ exec { "add-apt-repository-${name}": environment => $proxy_env, command => "/usr/bin/add-apt-repository ${options} ${name}", - onlyif => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", + unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", logoutput => 'on_failure', notify => Exec['apt_update'], require => [ diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 853fdb67f0..5b59f57776 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -45,7 +45,7 @@ it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{options} #{t}", - 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", + 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) @@ -74,7 +74,7 @@ it { should contain_exec("add-apt-repository-#{title}").with( 'environment' => [], 'command' => "/usr/bin/add-apt-repository #{options} #{title}", - 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", + 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) @@ -100,7 +100,7 @@ "https_proxy=http://user:pass@proxy:8080", ], 'command' => "/usr/bin/add-apt-repository #{options} #{title}", - 'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", + 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb index a87f908411..3008356356 100644 --- a/spec/system/basic_spec.rb +++ b/spec/system/basic_spec.rb @@ -8,15 +8,3 @@ its(:exit_code) { should be_zero } end end - -describe 'disable selinux:' do - context puppet_apply ' - exec { "setenforce 0": - path => "/bin:/sbin:/usr/bin:/usr/sbin", - onlyif => "which setenforce && getenforce | grep Enforcing", - } - ' do - its(:stderr) { should be_empty } - its(:exit_code) { should_not == 1 } - end -end From 547d7ad96a802022e3f0c156b7e103da763ece0d Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 8 Oct 2013 11:10:08 -0700 Subject: [PATCH 188/574] Prepare 1.4.0 release. --- CHANGELOG | 14 ++++++++++++-- Modulefile | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 25b0ec2419..0d321bc299 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,16 @@ -## puppetlabs-apt changelog +2013-10-08 1.4.0 -Release notes for the puppetlabs-apt module. +Summary: + +Minor bugfix and allow the timeout to be adjusted. + +Features: +- Add an `updates_timeout` to apt::params + +Fixes: +- Ensure apt::ppa can readd a ppa removed by hand. + +Summary 1.3.0 ===== diff --git a/Modulefile b/Modulefile index a73f20bf5a..72aa142e5f 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.3.0' +version '1.4.0' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From cf04f76e1710cfbb3d39f6875d69a4e03deaee04 Mon Sep 17 00:00:00 2001 From: lkoranda Date: Mon, 14 Oct 2013 13:22:47 +0200 Subject: [PATCH 189/574] Fixed double-space typo This bug has been introduced in 1.2.0 - b3d67c8 --- templates/source.list.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/source.list.erb b/templates/source.list.erb index 845b8ae161..e8b6865940 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,5 +1,5 @@ # <%= @name %> -deb <% if @architecture %>[arch=<%= @architecture %>]<% end %> <%= @location %> <%= @release_real %> <%= @repos %> +deb <% if @architecture %>[arch=<%= @architecture %>]<% end %><%= @location %> <%= @release_real %> <%= @repos %> <%- if @include_src then -%> -deb-src <% if @architecture %>[arch=<%= @architecture %>]<% end %> <%= @location %> <%= @release_real %> <%= @repos %> +deb-src <% if @architecture %>[arch=<%= @architecture %>]<% end %><%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> From 7dd4a1484858f3396de60bc27742063e11c6479c Mon Sep 17 00:00:00 2001 From: lkoranda Date: Mon, 14 Oct 2013 14:27:17 +0200 Subject: [PATCH 190/574] Fixed tests for cf04f76 --- spec/defines/source_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 0a8da3d5a6..9ad4d463e4 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -75,10 +75,10 @@ if param_hash[:architecture] arch = "[arch=#{param_hash[:architecture]}]" end - content << "\ndeb #{arch} #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" if param_hash[:include_src] - content << "deb-src #{arch} #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" end content end From 33064128b91ef3aabaad106b2db62783c6093d06 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 16 Oct 2013 13:08:03 -0400 Subject: [PATCH 191/574] getparam() isn't available in all stdlib versions. There's no need for getparam() here when a regular variable works just fine. --- manifests/ppa.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 7cb88c8cd5..784926841a 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -28,8 +28,8 @@ } if defined(Class[apt]) { - $proxy_host = getparam(Class[apt], 'proxy_host') - $proxy_port = getparam(Class[apt], 'proxy_port') + $proxy_host = $apt::proxy_host + $proxy_port = $apt::proxy_port case $proxy_host { false, '': { $proxy_env = [] From fe594950c5e0aab25d5f4759d904b59e31c7d751 Mon Sep 17 00:00:00 2001 From: Stefan van Wouw Date: Wed, 23 Oct 2013 11:22:33 +0200 Subject: [PATCH 192/574] If architecture is provided, an invalid source line is generated (no space between location and architecture) --- templates/source.list.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/source.list.erb b/templates/source.list.erb index e8b6865940..9946966ee5 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,5 +1,5 @@ # <%= @name %> -deb <% if @architecture %>[arch=<%= @architecture %>]<% end %><%= @location %> <%= @release_real %> <%= @repos %> +deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> <%- if @include_src then -%> -deb-src <% if @architecture %>[arch=<%= @architecture %>]<% end %><%= @location %> <%= @release_real %> <%= @repos %> +deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> From 67e8968fe0f1259f08f1a248a8195da20b4b0fed Mon Sep 17 00:00:00 2001 From: Stefan van Wouw Date: Wed, 23 Oct 2013 12:29:47 +0200 Subject: [PATCH 193/574] Fixed tests for fe594950c5 We actually expect an extra space. The previous build failed because a test is issued for location='', which indeed results in 2 spaces between the architecture specification and the release. According to the sources.list man page a location is always required though (unlike the missing/empty location in the :default_params of the source_spec test). --- spec/defines/source_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 9ad4d463e4..215d1e692f 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -73,7 +73,7 @@ let :content do content = "# #{title}" if param_hash[:architecture] - arch = "[arch=#{param_hash[:architecture]}]" + arch = "[arch=#{param_hash[:architecture]}] " end content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" From 3499896505907211b80f0d2976a2d7b8dca9c583 Mon Sep 17 00:00:00 2001 From: Chris Weyl Date: Fri, 8 Nov 2013 16:50:21 -0800 Subject: [PATCH 194/574] add an 'ensure' parameter to apt::ppa ...as sometimes we want to get rid of them. :) We leave this a little loose; rather than simply requiring a boolean for $ensure, we set the stage for doing an easy switch to also allowing 'purge' at some point in the future. --- manifests/ppa.pp | 70 +++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 784926841a..253e72ffb1 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,6 +1,7 @@ # ppa.pp define apt::ppa( + $ensure = 'present', $release = $::lsbdistcodename, $options = '-y' ) { @@ -18,42 +19,51 @@ $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') $sources_list_d_filename = "${filename_without_ppa}-${release}.list" - $package = $::lsbdistrelease ? { - /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties', - default => 'software-properties-common', - } + if $ensure == 'present' { + $package = $::lsbdistrelease ? { + /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties', + default => 'software-properties-common', + } - if ! defined(Package[$package]) { - package { $package: } - } + if ! defined(Package[$package]) { + package { $package: } + } - if defined(Class[apt]) { - $proxy_host = $apt::proxy_host - $proxy_port = $apt::proxy_port - case $proxy_host { - false, '': { + if defined(Class[apt]) { + $proxy_host = $apt::proxy_host + $proxy_port = $apt::proxy_port + case $proxy_host { + false, '': { + $proxy_env = [] + } + default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]} + } + } else { $proxy_env = [] - } - default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]} } - } else { - $proxy_env = [] - } - exec { "add-apt-repository-${name}": - environment => $proxy_env, - command => "/usr/bin/add-apt-repository ${options} ${name}", - unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", - logoutput => 'on_failure', - notify => Exec['apt_update'], - require => [ - File[$sources_list_d], - Package[$package], - ], + exec { "add-apt-repository-${name}": + environment => $proxy_env, + command => "/usr/bin/add-apt-repository ${options} ${name}", + unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", + logoutput => 'on_failure', + notify => Exec['apt_update'], + require => [ + File[$sources_list_d], + Package[$package], + ], + } + + file { "${sources_list_d}/${sources_list_d_filename}": + ensure => file, + require => Exec["add-apt-repository-${name}"], + } } + else { - file { "${sources_list_d}/${sources_list_d_filename}": - ensure => file, - require => Exec["add-apt-repository-${name}"], + file { "${sources_list_d}/${sources_list_d_filename}": + ensure => 'absent', + notify => Exec['apt_update'], + } } # Need anchor to provide containment for dependencies. From 7a8e3d00f924131797fcc179c13205d3197fbe0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Dal=C3=A9n?= Date: Thu, 14 Nov 2013 11:02:18 +0100 Subject: [PATCH 195/574] Retry package installs Sometimes package installs can fail to aquire the lock file, so retry the command in that case. --- manifests/source.pp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifests/source.pp b/manifests/source.pp index 713c7e933a..bc93ad9d57 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -61,6 +61,8 @@ command => "${provider} -y install ${required_packages}", logoutput => 'on_failure', refreshonly => true, + tries => 3, + try_sleep => 1, subscribe => File["${name}.list"], before => Exec['apt_update'], } From 8ac668a3aaede4f45bea0b2591e2e385660f9490 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Thu, 21 Nov 2013 15:31:31 +0100 Subject: [PATCH 196/574] Correct spelling typo in CHANGELOG --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0d321bc299..b6ec7cf7e4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,7 +8,7 @@ Features: - Add an `updates_timeout` to apt::params Fixes: -- Ensure apt::ppa can readd a ppa removed by hand. +- Ensure apt::ppa can read a ppa removed by hand. Summary From a2105b08e07ef77037ea0a852891993beb21ef70 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Thu, 21 Nov 2013 15:33:00 +0100 Subject: [PATCH 197/574] Use include instead of parameterized class when no params are given. Instead of perpetuating the use of parameterized classes, which we do not want to do in light of Puppet v3 with Hiera integration, this change invites people to use 'include' instead of the parameterized class syntax when no params are present. --- README.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 2ce5340ab6..d07bbb0ece 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,15 @@ apt [![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-apt.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-apt) ## Description + Provides helpful definitions for dealing with Apt. + ======= + Overview -------- -The APT module provides a simple interface for managing APT source, key, and definitions with Puppet. +The APT module provides a simple interface for managing APT source, key, and definitions with Puppet. Module Description ------------------ @@ -28,11 +31,11 @@ Setup * authentication keys * wget (optional) -###Beginning with APT +### Beginning with APT To begin using the APT module with default parameters, declare the class - class { 'apt': } + include apt Puppet code that uses anything from the APT module requires that the core apt class be declared. @@ -41,7 +44,7 @@ Usage Using the APT module consists predominantly in declaring classes that provide desired functionality and features. -###apt +### apt `apt` provides a number of common resources and options that are shared by the various defined types in this module, so you MUST always include this class in your manifests. @@ -62,13 +65,13 @@ Puppet will manage your system's `sources.list` file and `sources.list.d` direct If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. -###apt::builddep +### apt::builddep Installs the build depends of a specified package. apt::builddep { 'glusterfs-server': } -###apt::force +### apt::force Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. @@ -78,7 +81,7 @@ Forces a package to be installed from a specific release. This class is particu require => Apt::Source['debian_unstable'], } -###apt::key +### apt::key Adds a key to the list of keys used by APT to authenticate packages. @@ -94,7 +97,7 @@ Adds a key to the list of keys used by APT to authenticate packages. Note that use of `key_source` requires wget to be installed and working. -###apt::pin +### apt::pin Adds an apt pin for a certain release. @@ -112,13 +115,13 @@ Note you can also specifying more complex pins using distribution properties. label => 'Debian' } -###apt::ppa +### apt::ppa Adds a ppa repository using `add-apt-repository`. apt::ppa { 'ppa:drizzle-developers/ppa': } -###apt::release +### apt::release Sets the default apt release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. @@ -126,7 +129,7 @@ Sets the default apt release. This class is particularly useful when using repos release_id => 'precise', } -###apt::source +### apt::source Adds an apt source to `/etc/apt/sources.list.d/`. @@ -150,11 +153,11 @@ If you would like to configure your system so the source is the Puppet Labs APT key_server => 'pgp.mit.edu', } -###Testing +### Testing The APT module is mostly a collection of defined resource types, which provide reusable logic that can be leveraged to manage APT. It does provide smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. -####Example Test +#### Example Test This test will set up a Puppet Labs apt repository. Start by creating a new smoke test in the apt module's test folder. Call it puppetlabs-apt.pp. Inside, declare a single resource representing the Puppet Labs APT source and gpg key @@ -183,7 +186,7 @@ The above example used a smoke test to easily lay out a resource declaration and Implementation -------------- -###apt::backports +### apt::backports Adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined behavior (read: universe exploding). From 0001a03cd93177cf966ab2b659de53d0ee4b89e4 Mon Sep 17 00:00:00 2001 From: Ryan Tandy Date: Thu, 21 Nov 2013 09:36:41 -0800 Subject: [PATCH 198/574] escape more braces properly Fixes a couple of rspec regex warnings. --- spec/classes/unattended_upgrades_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 8abc603251..e83c6e4c30 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -26,7 +26,7 @@ describe "origins" do describe "with param defaults" do let(:params) {{ }} - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id}:\${distro_codename}-security";\n\};$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\$\{distro_id\}:\$\{distro_codename\}-security";\n\};$/) } end describe "with origins => ['ubuntu:precise-security']" do From 935d3ce15b7c3c31e1a6fdca92021d9f29e19cf0 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Mon, 2 Dec 2013 13:17:00 +0100 Subject: [PATCH 199/574] Fix the name of sources.list.d file resource in apt::ppa --- manifests/ppa.pp | 2 +- spec/defines/ppa_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 253e72ffb1..730bf7d198 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -48,7 +48,7 @@ logoutput => 'on_failure', notify => Exec['apt_update'], require => [ - File[$sources_list_d], + File['sources.list.d'], Package[$package], ], } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 5b59f57776..a05ca30645 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -46,7 +46,7 @@ it { should contain_exec("add-apt-repository-#{t}").with( 'command' => "/usr/bin/add-apt-repository #{options} #{t}", 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", - 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], + 'require' => ["File[sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) } @@ -75,7 +75,7 @@ 'environment' => [], 'command' => "/usr/bin/add-apt-repository #{options} #{title}", 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", - 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], + 'require' => ["File[sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) } @@ -101,7 +101,7 @@ ], 'command' => "/usr/bin/add-apt-repository #{options} #{title}", 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", - 'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"], + 'require' => ["File[sources.list.d]", "Package[#{package}]"], 'notify' => "Exec[apt_update]" ) } From 38c020867318ed9f34b63b6c36ca984e6385545e Mon Sep 17 00:00:00 2001 From: Ryan Tandy Date: Thu, 5 Dec 2013 16:40:10 -0800 Subject: [PATCH 200/574] change include_class to contain_class in specs include_class was deprecated starting from rspec-puppet 1.0.0. --- spec/classes/apt_spec.rb | 2 +- spec/classes/release_spec.rb | 2 +- spec/defines/pin_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index a66feac788..6d87cc64dc 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -39,7 +39,7 @@ end end - it { should include_class("apt::params") } + it { should contain_class("apt::params") } it { if param_hash[:purge_sources_list] diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb index d131b22810..31252b99a9 100644 --- a/spec/classes/release_spec.rb +++ b/spec/classes/release_spec.rb @@ -8,7 +8,7 @@ let (:params) { param_set } - it { should include_class("apt::params") } + it { should contain_class("apt::params") } it { should contain_file("/etc/apt/apt.conf.d/01release").with({ diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index a4cb1e26e3..7a58e78d1f 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -85,7 +85,7 @@ param_set[:params] end - it { should include_class("apt::params") } + it { should contain_class("apt::params") } it { should contain_file("#{title}.pref").with({ 'ensure' => param_hash[:ensure], From 2f6edabc4c0757d5ccca63b4ebd9af215c5167d5 Mon Sep 17 00:00:00 2001 From: Tsuharesu Luciel Date: Mon, 30 Dec 2013 16:01:56 -0200 Subject: [PATCH 201/574] (#201) Use root to exec User root is needed to execute this command. If someone changes the default Exec user, apt-add-repository will fail. --- manifests/ppa.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 730bf7d198..f9296549ac 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -45,6 +45,7 @@ environment => $proxy_env, command => "/usr/bin/add-apt-repository ${options} ${name}", unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", + user => 'root', logoutput => 'on_failure', notify => Exec['apt_update'], require => [ From 2ae67cfd315a116b1a8fcf56c6178d6ed9719b8d Mon Sep 17 00:00:00 2001 From: braddeicide Date: Fri, 3 Jan 2014 19:23:00 +1100 Subject: [PATCH 202/574] Change - to _ I did it to please my syntax validator, but I'm assuming it wasn't functioning as expected either. --- tests/unattended-upgrades.pp | 1 - tests/unattended_upgrades.pp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 tests/unattended-upgrades.pp create mode 100644 tests/unattended_upgrades.pp diff --git a/tests/unattended-upgrades.pp b/tests/unattended-upgrades.pp deleted file mode 100644 index 7f65ab4f57..0000000000 --- a/tests/unattended-upgrades.pp +++ /dev/null @@ -1 +0,0 @@ -include apt::unattended-upgrades diff --git a/tests/unattended_upgrades.pp b/tests/unattended_upgrades.pp new file mode 100644 index 0000000000..3b9b49eb72 --- /dev/null +++ b/tests/unattended_upgrades.pp @@ -0,0 +1 @@ +include apt::unattended_upgrades From 661c6731d78f4008ace836a65953be59643a299b Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 6 Jan 2014 17:39:48 -0500 Subject: [PATCH 203/574] Convert existing tests over to beakr-rspec. --- .nodeset.yml | 19 ------------ Gemfile | 6 ++-- .../apt_builddep_spec.rb | 6 ++-- spec/{system => acceptance}/apt_key_spec.rb | 14 ++++----- spec/{system => acceptance}/apt_ppa_spec.rb | 24 ++++++--------- .../{system => acceptance}/apt_source_spec.rb | 12 ++++---- spec/{system => acceptance}/class_spec.rb | 9 ++---- spec/acceptance/nodesets/debian-70rc1-x64.yml | 8 +++++ spec/acceptance/nodesets/default.yml | 8 +++++ .../nodesets/ubuntu-server-12042-x64.yml | 8 +++++ spec/spec_helper_acceptance.rb | 26 ++++++++++++++++ spec/spec_helper_system.rb | 30 ------------------- spec/system/basic_spec.rb | 10 ------- 13 files changed, 78 insertions(+), 102 deletions(-) delete mode 100644 .nodeset.yml rename spec/{system => acceptance}/apt_builddep_spec.rb (86%) rename spec/{system => acceptance}/apt_key_spec.rb (74%) rename spec/{system => acceptance}/apt_ppa_spec.rb (57%) rename spec/{system => acceptance}/apt_source_spec.rb (75%) rename spec/{system => acceptance}/class_spec.rb (61%) create mode 100644 spec/acceptance/nodesets/debian-70rc1-x64.yml create mode 100644 spec/acceptance/nodesets/default.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-12042-x64.yml create mode 100644 spec/spec_helper_acceptance.rb delete mode 100644 spec/spec_helper_system.rb delete mode 100644 spec/system/basic_spec.rb diff --git a/.nodeset.yml b/.nodeset.yml deleted file mode 100644 index ad056fe655..0000000000 --- a/.nodeset.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -default_set: 'ubuntu-server-12042-x64' -sets: - 'debian-607-x64': - nodes: - "main.foo.vm": - prefab: 'debian-607-x64' - 'debian-70rc1-x64': - nodes: - "main.foo.vm": - prefab: 'debian-70rc1-x64' - 'ubuntu-server-10044-x64': - nodes: - "main.foo.vm": - prefab: 'ubuntu-server-10044-x64' - 'ubuntu-server-12042-x64': - nodes: - "main.foo.vm": - prefab: 'ubuntu-server-12042-x64' diff --git a/Gemfile b/Gemfile index 15bd29daf0..b89b579d5d 100644 --- a/Gemfile +++ b/Gemfile @@ -4,9 +4,9 @@ group :development, :test do gem 'rake', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-system', :require => false - gem 'rspec-system-puppet', :require => false - gem 'rspec-system-serverspec', :require => false + gem 'serverspec', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] diff --git a/spec/system/apt_builddep_spec.rb b/spec/acceptance/apt_builddep_spec.rb similarity index 86% rename from spec/system/apt_builddep_spec.rb rename to spec/acceptance/apt_builddep_spec.rb index fa16ab42f5..b61fca2955 100644 --- a/spec/system/apt_builddep_spec.rb +++ b/spec/acceptance/apt_builddep_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'apt::builddep' do @@ -16,9 +16,7 @@ apt::builddep { 'glusterfs-server': } EOS - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - end + apply_manifest(pp, :catch_failures => true) end describe 'should install g++ as a dependency' do diff --git a/spec/system/apt_key_spec.rb b/spec/acceptance/apt_key_spec.rb similarity index 74% rename from spec/system/apt_key_spec.rb rename to spec/acceptance/apt_key_spec.rb index 4842cb5972..5f69e25e0b 100644 --- a/spec/system/apt_key_spec.rb +++ b/spec/acceptance/apt_key_spec.rb @@ -1,11 +1,11 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'apt::key' do context 'reset' do it 'clean up keys' do - shell('apt-key del 4BD6EC30') - shell('apt-key del D50582E6') + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2]) end end @@ -24,20 +24,18 @@ } EOS - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - end + apply_manifest(pp, :catch_failures => true) end describe 'keys should exist' do it 'finds puppetlabs key' do shell('apt-key list | grep 4BD6EC30') do |r| - r.exit_code.should be_zero + expect(r.exit_code).to be_zero end end it 'finds jenkins key' do shell('apt-key list | grep D50582E6') do |r| - r.exit_code.should be_zero + expect(r.exit_code).to be_zero end end end diff --git a/spec/system/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb similarity index 57% rename from spec/system/apt_ppa_spec.rb rename to spec/acceptance/apt_ppa_spec.rb index 2e2baf5d2b..5bee3c69ef 100644 --- a/spec/system/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -1,11 +1,11 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'apt::ppa' do context 'reset' do it 'removes ppa' do - shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*') - shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') + shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2]) + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2]) end end @@ -13,19 +13,15 @@ it 'should work with no errors' do pp = <<-EOS include '::apt' - apt::ppa { 'ppa:drizzle-developers/ppa': } + apt::ppa { 'ppa:canonical-kernel-team/ppa': } EOS - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - end + apply_manifest(pp, :catch_failures => true) end describe 'contains the source file' do - it 'contains a drizzle ppa source' do - shell('ls /etc/apt/sources.list.d/drizzle-developers-ppa-*.list') do |r| - r.exit_code.should be_zero - end + it 'contains a kernel ppa source' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0]) end end end @@ -43,15 +39,13 @@ apt::ppa { 'ppa:raravena80/collectd5': } EOS - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - end + apply_manifest(pp, :catch_failures => true) end end context 'reset' do it 'removes added ppas' do - shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*') + shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*') shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') end end diff --git a/spec/system/apt_source_spec.rb b/spec/acceptance/apt_source_spec.rb similarity index 75% rename from spec/system/apt_source_spec.rb rename to spec/acceptance/apt_source_spec.rb index 6a445e13ef..044af57148 100644 --- a/spec/system/apt_source_spec.rb +++ b/spec/acceptance/apt_source_spec.rb @@ -1,11 +1,11 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'apt::source' do context 'reset' do it 'clean up puppetlabs repo' do - shell('apt-key del 4BD6EC30') - shell('rm /etc/apt/sources.list.d/puppetlabs.list') + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2]) end end @@ -21,15 +21,13 @@ } EOS - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - end + apply_manifest(pp, :catch_failures => true) end describe 'key should exist' do it 'finds puppetlabs key' do shell('apt-key list | grep 4BD6EC30') do |r| - r.exit_code.should be_zero + expect(r.exit_code).to be_zero end end end diff --git a/spec/system/class_spec.rb b/spec/acceptance/class_spec.rb similarity index 61% rename from spec/system/class_spec.rb rename to spec/acceptance/class_spec.rb index 7bb6b8d64e..f228e4c456 100644 --- a/spec/system/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper_system' +require 'spec_helper_acceptance' describe 'apt class' do @@ -10,11 +10,8 @@ class { 'apt': } EOS # Run it twice and test for idempotency - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - r.refresh - r.exit_code.should be_zero - end + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) end end end diff --git a/spec/acceptance/nodesets/debian-70rc1-x64.yml b/spec/acceptance/nodesets/debian-70rc1-x64.yml new file mode 100644 index 0000000000..a1b59c085e --- /dev/null +++ b/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -0,0 +1,8 @@ +HOSTS: + debian-70rc1-x64: + roles: + - master + platform: debian-70rc1-x64 + box : debian-70rc1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box + hypervisor : vagrant diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000000..2b8fe4a121 --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,8 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-server-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000000..2b8fe4a121 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,8 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-server-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000000..0073e4d8da --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,26 @@ +require 'beaker-rspec' + +hosts.each do |host| + # Install Puppet + install_package host, 'rubygems' + on host, 'gem install puppet --no-ri --no-rdoc' + on host, "mkdir -p #{host['distmoduledir']}" +end + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'apt') + hosts.each do |host| + shell('/bin/touch /etc/puppet/hiera.yaml') + shell('puppet module install puppetlabs-stdlib', { :acceptable_exit_codes => [0,1] }) + end + end +end diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb deleted file mode 100644 index 490a6017eb..0000000000 --- a/spec/spec_helper_system.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rspec-system/spec_helper' -require 'rspec-system-puppet/helpers' -require 'rspec-system-serverspec/helpers' - -include RSpecSystemPuppet::Helpers - -include Serverspec::Helper::RSpecSystem -include Serverspec::Helper::DetectOS - -RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - - # Enable colour - c.tty = true - - c.include RSpecSystemPuppet::Helpers - - # This is where we 'setup' the nodes before running our tests - c.before :suite do - # May as well update here as this can only run on apt-get machines. - shell('apt-get update') - # Install puppet - puppet_install - - # Install modules and dependencies - puppet_module_install(:source => proj_root, :module_name => 'apt') - shell('puppet module install puppetlabs-stdlib') - end -end diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb deleted file mode 100644 index 3008356356..0000000000 --- a/spec/system/basic_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'spec_helper_system' - -describe 'basic tests:' do - # Using puppet_apply as a subject - context puppet_apply 'notice("foo")' do - its(:stdout) { should =~ /foo/ } - its(:stderr) { should be_empty } - its(:exit_code) { should be_zero } - end -end From 16e57d4e4525b83d865db71f3bba300c54467255 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 6 Jan 2014 19:53:19 -0500 Subject: [PATCH 204/574] Add additional acceptance testing. This work adds a test for every parameter in every class/define in apt. --- spec/acceptance/apt_key_spec.rb | 179 ++++++- spec/acceptance/apt_ppa_spec.rb | 85 ++++ spec/acceptance/apt_source_spec.rb | 332 ++++++++++-- spec/acceptance/apt_spec.rb | 220 ++++++++ spec/acceptance/backports_spec.rb | 43 ++ spec/acceptance/conf_spec.rb | 66 +++ spec/acceptance/force_spec.rb | 19 + spec/acceptance/pin_spec.rb | 266 ++++++++++ spec/acceptance/release_spec.rb | 20 + spec/acceptance/unattended_upgrade_spec.rb | 558 +++++++++++++++++++++ 10 files changed, 1745 insertions(+), 43 deletions(-) create mode 100644 spec/acceptance/apt_spec.rb create mode 100644 spec/acceptance/backports_spec.rb create mode 100644 spec/acceptance/conf_spec.rb create mode 100644 spec/acceptance/force_spec.rb create mode 100644 spec/acceptance/pin_spec.rb create mode 100644 spec/acceptance/release_spec.rb create mode 100644 spec/acceptance/unattended_upgrade_spec.rb diff --git a/spec/acceptance/apt_key_spec.rb b/spec/acceptance/apt_key_spec.rb index 5f69e25e0b..36cba5eeff 100644 --- a/spec/acceptance/apt_key_spec.rb +++ b/spec/acceptance/apt_key_spec.rb @@ -1,14 +1,6 @@ require 'spec_helper_acceptance' describe 'apt::key' do - - context 'reset' do - it 'clean up keys' do - shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) - shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2]) - end - end - context 'apt::key' do it 'should work with no errors' do pp = <<-EOS @@ -24,18 +16,47 @@ } EOS + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2]) apply_manifest(pp, :catch_failures => true) end describe 'keys should exist' do it 'finds puppetlabs key' do - shell('apt-key list | grep 4BD6EC30') do |r| - expect(r.exit_code).to be_zero - end + shell('apt-key list | grep 4BD6EC30') end it 'finds jenkins key' do - shell('apt-key list | grep D50582E6') do |r| - expect(r.exit_code).to be_zero + shell('apt-key list | grep D50582E6') + end + end + end + context 'ensure' do + context 'absent' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + ensure => absent, + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + + apt::key { 'jenkins': + ensure => absent, + key => 'D50582E6', + key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'keys shouldnt exist' do + it 'fails' do + shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [1]) + end + it 'fails' do + shell('apt-key list | grep D50582E6', :acceptable_exit_codes => [1]) end end end @@ -43,8 +64,136 @@ context 'reset' do it 'clean up keys' do - shell('apt-key del 4BD6EC30') - shell('apt-key del D50582E6') + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2]) + end + end + + context 'key options' do + context 'key_content' do + + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_content => '-----BEGIN PGP PUBLIC KEY BLOCK----- + Version: GnuPG v1.4.12 (GNU/Linux) + Comment: GPGTools - http://gpgtools.org + + mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b + fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg + 5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ + S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY + GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH + Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v + VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 + Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI + wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN + NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl + f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB + tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL + ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn + AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob + pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF + eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+ + aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M + 2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ + VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU + 3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh + qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1 + IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8 + 1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp + HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN + MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+ + UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh + R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+ + N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc + kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e + lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT + DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb + kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf + DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei + BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z + XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2 + +zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU + fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH + dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4 + qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2 + 7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq + UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x + Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA + KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3 + okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7 + bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4 + 4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX + vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0 + jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y + ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD + 7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR + M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf + REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y + DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk + ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= + =a34C + -----END PGP PUBLIC KEY BLOCK----- + ', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + end + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + end + + context 'key_source' do + + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_source => 'http://apt.puppetlabs.com/pubkey.gpg', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + end + end + + context 'key_options' do + + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_source => 'http://apt.puppetlabs.com/pubkey.gpg', + key_options => 'debug' + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + end end end diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb index 5bee3c69ef..f936980243 100644 --- a/spec/acceptance/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -50,4 +50,89 @@ end end + context 'ensure' do + context 'present' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'contains the source file' do + it 'contains a kernel ppa source' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0]) + end + end + end + end + + context 'ensure' do + context 'absent' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'doesnt contain the source file' do + it 'fails' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2]) + end + end + end + end + + context 'release' do + context 'precise' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': + ensure => present, + release => precise, + } + EOS + + shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do + it { should be_file } + end + end + end + + context 'options' do + context '-y' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': + ensure => present, + release => precise, + options => '-y', + } + EOS + + shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do + it { should be_file } + end + end + end + + context 'reset' do + it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } + end + end diff --git a/spec/acceptance/apt_source_spec.rb b/spec/acceptance/apt_source_spec.rb index 044af57148..273add56fa 100644 --- a/spec/acceptance/apt_source_spec.rb +++ b/spec/acceptance/apt_source_spec.rb @@ -2,47 +2,323 @@ describe 'apt::source' do - context 'reset' do - it 'clean up puppetlabs repo' do - shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) - shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2]) + context 'apt::source' do + context 'ensure => present' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe 'key should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0]) + end + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + end end + + context 'ensure => absent' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => absent, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + # The key should remain -we don't delete those when deleting a source. + describe 'key should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0]) + end + end + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should_not be_file } + end + end + end - context 'apt::source' do - it 'should work with no errors' do - pp = <<-EOS - include '::apt' - apt::source { 'puppetlabs': - location => 'http://apt.puppetlabs.com', - repos => 'main', - key => '4BD6EC30', - key_server => 'pgp.mit.edu', - } - EOS - - apply_manifest(pp, :catch_failures => true) - end - - describe 'key should exist' do - it 'finds puppetlabs key' do - shell('apt-key list | grep 4BD6EC30') do |r| - expect(r.exit_code).to be_zero + context 'release' do + context 'test' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + release => 'precise', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + it { should contain 'deb http://apt.puppetlabs.com precise main' } + end + end + end + + context 'include_src' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + include_src => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + it { should contain 'deb-src http://apt.puppetlabs.com' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + include_src => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + it { should_not contain 'deb-src http://apt.puppetlabs.com' } + end + end + end + + context 'required_packages' do + context 'vim' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + required_packages => 'vim', + } + EOS + + shell('apt-get -y remove vim') + apply_manifest(pp, :catch_failures => true) + end + + describe package('vim') do + it { should be_installed } + end + end + end + + context 'key content' do + context 'giant key' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_content => '-----BEGIN PGP PUBLIC KEY BLOCK----- + Version: GnuPG v1.4.12 (GNU/Linux) + Comment: GPGTools - http://gpgtools.org + + mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b + fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg + 5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ + S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY + GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH + Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v + VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 + Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI + wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN + NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl + f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB + tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL + ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn + AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob + pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF + eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+ + aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M + 2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ + VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU + 3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh + qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1 + IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8 + 1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp + HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN + MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+ + UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh + R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+ + N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc + kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e + lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT + DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb + kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf + DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei + BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z + XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2 + +zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU + fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH + dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4 + qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2 + 7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq + UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x + Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA + KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3 + okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7 + bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4 + 4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX + vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0 + jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y + ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD + 7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR + M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf + REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y + DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk + ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= + =a34C + -----END PGP PUBLIC KEY BLOCK-----', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + end + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') end end end + end + + context 'key_source' do + context 'http://apt.puppetlabs.com/pubkey.gpg' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_source => 'http://apt.puppetlabs.com/pubkey.gpg', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end - describe 'source should exist' do describe file('/etc/apt/sources.list.d/puppetlabs.list') do it { should be_file } + it { should contain 'deb http://apt.puppetlabs.com precise main' } + end + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end end end end - context 'reset' do - it 'clean up puppetlabs repo' do - shell('apt-key del 4BD6EC30') - shell('rm /etc/apt/sources.list.d/puppetlabs.list') + context 'pin' do + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + pin => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/puppetlabs.pref') do + it { should_not be_file } + end + end + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + pin => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/puppetlabs.pref') do + it { should be_file } + end end end diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb new file mode 100644 index 0000000000..4dbb54a0e9 --- /dev/null +++ b/spec/acceptance/apt_spec.rb @@ -0,0 +1,220 @@ +require 'spec_helper_acceptance' + +describe 'apt class' do + + context 'always_apt_update => true' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': always_apt_update => true } + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/apt_update/) + end + end + end + context 'always_apt_update => false' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': always_apt_update => false } + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to_not match(/apt_update/) + end + end + end + + # disable_keys drops in a 99unauth file to ignore keys in + # other files. + context 'disable_keys => true' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': disable_keys => true } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/99unauth') do + it { should be_file } + it { should contain 'APT::Get::AllowUnauthenticated 1;' } + end + end + context 'disable_keys => false' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': disable_keys => false } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/99unauth') do + it { should_not be_file } + end + end + + # proxy_host sets the proxy to use for transfers. + # proxy_port sets the proxy port to use. + context 'proxy settings' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': + proxy_host => 'localhost', + proxy_port => '8080', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/proxy') do + it { should be_file } + it { should contain 'Acquire::http::Proxy "http://localhost:8080\";' } + end + end + + context 'purge_sources' do + it 'creates a fake apt file' do + shell('touch /etc/apt/sources.list.d/fake.list') + shell('echo "deb fake" >> /etc/apt/sources.list') + end + it 'purge_sources_list and purge_sources_list_d => true' do + pp = <<-EOS + class { 'apt': + purge_sources_list => true, + purge_sources_list_d => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list') do + it { should_not contain 'deb fake' } + end + + describe file('/etc/apt/sources.list.d/fake.list') do + it { should_not be_file } + end + end + context 'proxy settings' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': + proxy_host => 'localhost', + proxy_port => '8080', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/proxy') do + it { should be_file } + it { should contain 'Acquire::http::Proxy "http://localhost:8080\";' } + end + end + + context 'purge_sources' do + context 'false' do + it 'creates a fake apt file' do + shell('touch /etc/apt/sources.list.d/fake.list') + shell('echo "deb fake" >> /etc/apt/sources.list') + end + it 'purge_sources_list and purge_sources_list_d => false' do + pp = <<-EOS + class { 'apt': + purge_sources_list => false, + purge_sources_list_d => false, + } + EOS + + apply_manifest(pp, :catch_failures => false) + end + + describe file('/etc/apt/sources.list') do + it { should contain 'deb fake' } + end + + describe file('/etc/apt/sources.list.d/fake.list') do + it { should be_file } + end + end + + context 'true' do + it 'creates a fake apt file' do + shell('touch /etc/apt/sources.list.d/fake.list') + shell('echo "deb fake" >> /etc/apt/sources.list') + end + it 'purge_sources_list and purge_sources_list_d => true' do + pp = <<-EOS + class { 'apt': + purge_sources_list => true, + purge_sources_list_d => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list') do + it { should_not contain 'deb fake' } + end + + describe file('/etc/apt/sources.list.d/fake.list') do + it { should_not be_file } + end + end + end + + context 'purge_preferences_d' do + context 'false' do + it 'creates a preferences file' do + shell('touch /etc/apt/preferences.d/test') + end + + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': purge_preferences_d => false } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/test') do + it { should be_file } + end + end + context 'true' do + it 'creates a preferences file' do + shell('touch /etc/apt/preferences.d/test') + end + + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': purge_preferences_d => true } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/test') do + it { should_not be_file } + end + end + end + + context 'update_timeout' do + context '5000' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': update_timeout => '5000' } + EOS + + apply_manifest(pp, :catch_failures => true) + end + end + end +end diff --git a/spec/acceptance/backports_spec.rb b/spec/acceptance/backports_spec.rb new file mode 100644 index 0000000000..596be23954 --- /dev/null +++ b/spec/acceptance/backports_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper_acceptance' + +describe 'apt::backports class' do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt::backports': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + end + + context 'release' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt::backports': release => 'precise' } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/backports.list') do + it { should be_file } + it { should contain 'precise-backports main universe multiverse restricted' } + end + end + + context 'location' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt::backports': release => 'precise', location => 'http://localhost/ubuntu' } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/backports.list') do + it { should be_file } + it { should contain 'deb http://localhost/ubuntu precise-backports main universe multiverse restricted' } + end + end +end diff --git a/spec/acceptance/conf_spec.rb b/spec/acceptance/conf_spec.rb new file mode 100644 index 0000000000..98898c2749 --- /dev/null +++ b/spec/acceptance/conf_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper_acceptance' + +describe 'apt::conf define' do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + apt::conf { 'test': + content => 'test', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50test') do + it { should be_file } + it { should contain 'test' } + end + end + + context 'ensure' do + context 'absent' do + it 'should work with no errors' do + pp = <<-EOS + apt::conf { 'test': + ensure => absent, + content => 'test', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50test') do + it { should_not be_file } + end + end + end + + context 'priority' do + context '99' do + it 'should work with no errors' do + pp = <<-EOS + apt::conf { 'test': + ensure => present, + content => 'test', + priority => '99', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/99test') do + it { should be_file } + it { should contain 'test' } + end + end + end + + context 'cleanup' do + it 'deletes 99test' do + shell ('rm -rf /etc/apt/apt.conf.d/99test') + end + end +end diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb new file mode 100644 index 0000000000..4f74ff01fd --- /dev/null +++ b/spec/acceptance/force_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper_acceptance' + +describe 'apt::force define' do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::force { 'vim': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe package('vim') do + it { should be_installed } + end + end + +end diff --git a/spec/acceptance/pin_spec.rb b/spec/acceptance/pin_spec.rb new file mode 100644 index 0000000000..b5a004429b --- /dev/null +++ b/spec/acceptance/pin_spec.rb @@ -0,0 +1,266 @@ +require 'spec_helper_acceptance' + +describe 'apt::pin define' do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release a=vim-puppet' } + end + end + + context 'ensure' do + context 'present' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': ensure => present } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release a=vim-puppet' } + end + end + + context 'absent' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': ensure => absent } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should_not be_file } + end + end + end + + context 'order' do + context '99' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + order => '99', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/99-vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release a=vim-puppet' } + end + end + end + + context 'packages' do + context 'test' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + packages => 'test', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Package: test' } + it { should contain 'Pin: release a=vim-puppet' } + end + end + end + + context 'release' do + context 'testrelease' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + release => 'testrelease', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release a=testrelease' } + end + end + end + + context 'origin' do + context 'testrelease' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + origin => 'testrelease', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: origin "testrelease"' } + end + end + end + + context 'version' do + context '1.0.0' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + packages => 'test', + version => '1.0.0', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Package: test' } + it { should contain 'Pin: version 1.0.0' } + end + end + end + + context 'codename' do + context 'testname' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + codename => 'testname', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release n=testname' } + end + end + end + + context 'release_version' do + context '1.1.1' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + release_version => '1.1.1', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release v=1.1.1' } + end + end + end + + context 'component' do + context 'testcomponent' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + component => 'testcomponent', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release c=testcomponent' } + end + end + end + + context 'originator' do + context 'testorigin' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + originator => 'testorigin', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release o=testorigin' } + end + end + end + + context 'label' do + context 'testlabel' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + label => 'testlabel', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release l=testlabel' } + end + end + end + +end diff --git a/spec/acceptance/release_spec.rb b/spec/acceptance/release_spec.rb new file mode 100644 index 0000000000..44491e3ef9 --- /dev/null +++ b/spec/acceptance/release_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper_acceptance' + +describe 'apt::release class' do + context 'release_id' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::release': release_id => 'precise', } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/01release') do + it { should be_file } + it { should contain 'APT::Default-Release "precise";' } + end + end + +end diff --git a/spec/acceptance/unattended_upgrade_spec.rb b/spec/acceptance/unattended_upgrade_spec.rb new file mode 100644 index 0000000000..287e5ec8e8 --- /dev/null +++ b/spec/acceptance/unattended_upgrade_spec.rb @@ -0,0 +1,558 @@ +require 'spec_helper_acceptance' + +describe 'apt::unattended_upgrades class' do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + include apt + include apt::unattended_upgrades + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + end + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + end + end + + context 'origins' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + origins => ['${distro_id}:${distro_codename}-test'], + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain '${distro_id}:${distro_codename}-test' } + end + end + + context 'blacklist' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + blacklist => ['puppet'] + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'puppet' } + end + end + + context 'update' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + update => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Update-Package-Lists "99";' } + end + end + + context 'download' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + download => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Download-Upgradeable-Packages "99";' } + end + end + + context 'upgrade' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + upgrade => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Unattended-Upgrade "99";' } + end + end + + context 'autoclean' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + autoclean => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::AutocleanInterval "99";' } + end + end + + context 'auto_fix' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + auto_fix => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + auto_fix => false + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "false";' } + end + end + end + + context 'minimal_steps' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + minimal_steps => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::MinimalSteps "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + minimal_steps => false + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::MinimalSteps "false";' } + end + end + end + + context 'install_on_shutdown' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + install_on_shutdown => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::InstallOnShutdown "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + install_on_shutdown => false + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::InstallOnShutdown "false";' } + end + end + end + + context 'mail_to' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + mail_to => 'test@example.com' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Mail "test@example.com";' } + end + end + + context 'mail_only_on_error' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + mail_to => 'test@example.com', + mail_only_on_error => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::MailOnlyOnError "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + mail_to => 'test@example.com', + mail_only_on_error => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::MailOnlyOnError "false";' } + end + end + + context 'mail_to missing' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + mail_only_on_error => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should_not contain 'Unattended-Upgrade::MailOnlyOnError "true";' } + end + end + end + + context 'remove_unused' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + remove_unused => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + remove_unused => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "false";' } + end + end + end + + context 'auto_reboot' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + auto_reboot => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Automatic-Reboot "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + auto_reboot => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Automatic-Reboot "false";' } + end + end + end + + context 'dl_limit' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + dl_limit => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Acquire::http::Dl-Limit "99"' } + end + end + + context 'enable' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + enable => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Enable "2"' } + end + end + + context 'backup_interval' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + backup_interval => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::BackUpArchiveInterval "2";' } + end + end + + context 'backup_level' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + backup_level => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::BackUpLevel "2";' } + end + end + + context 'max_age' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + max_age => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::MaxAge "2";' } + end + end + + context 'min_age' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + min_age => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::MinAge "2";' } + end + end + + context 'max_size' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + max_size => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::MaxSize "2";' } + end + end + + context 'download_delta' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + download_delta => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";' } + end + end + + context 'verbose' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + verbose => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Verbose "2";' } + end + end + +end From c2f0ed219e23ccc3faaf2512082240102921e4a9 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 9 Jan 2014 14:26:59 -0500 Subject: [PATCH 205/574] Improve apt::force tests and ensure cleanup happens consistently. --- spec/acceptance/apt_spec.rb | 13 ++++++++ spec/acceptance/backports_spec.rb | 8 +++++ spec/acceptance/force_spec.rb | 55 +++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 4dbb54a0e9..5b7379fb12 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -2,6 +2,12 @@ describe 'apt class' do + context 'reset' do + it 'fixes the sources.list' do + shell('cp /etc/apt/sources.list /tmp') + end + end + context 'always_apt_update => true' do it 'should work with no errors' do pp = <<-EOS @@ -217,4 +223,11 @@ class { 'apt': update_timeout => '5000' } end end end + + context 'reset' do + it 'fixes the sources.list' do + shell('cp /tmp/sources.list /etc/apt') + end + end + end diff --git a/spec/acceptance/backports_spec.rb b/spec/acceptance/backports_spec.rb index 596be23954..ffb14ce628 100644 --- a/spec/acceptance/backports_spec.rb +++ b/spec/acceptance/backports_spec.rb @@ -40,4 +40,12 @@ class { 'apt::backports': release => 'precise', location => 'http://localhost/ub it { should contain 'deb http://localhost/ubuntu precise-backports main universe multiverse restricted' } end end + + context 'reset' do + it 'deletes backport files' do + shell('rm -rf /etc/apt/sources.list.d/backports.list') + shell('rm -rf /etc/apt/preferences.d/backports.pref') + end + end + end diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index 4f74ff01fd..f7e374be3a 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -8,6 +8,7 @@ apt::force { 'vim': } EOS + shell('apt-get remove -y vim') apply_manifest(pp, :catch_failures => true) end @@ -16,4 +17,58 @@ end end + context 'release' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::force { 'vim': release => 'precise' } + EOS + + shell('apt-get remove -y vim') + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/apt-get -y -t precise install vim/) + end + end + + describe package('vim') do + it { should be_installed } + end + end + + context 'version' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::force { 'vim': version => '1.1.1' } + EOS + + shell('apt-get remove -y vim') + apply_manifest(pp, :catch_failures => false) do |r| + expect(r.stdout).to match(/apt-get -y install vim=1.1.1/) + end + end + + describe package('vim') do + it { should_not be_installed } + end + end + + context 'timeout' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::force { 'tomcat7': timeout => '1' } + EOS + + shell('apt-get clean') + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Error: Command exceeded timeout/) + end + end + + describe package('vim') do + it { should_not be_installed } + end + end + end From 558954bedf707dd206180de5e0bfd10edfe563fa Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 9 Jan 2014 14:35:17 -0500 Subject: [PATCH 206/574] 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 bb60173e57..cd3d379958 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 f9296549ac..14fbbceba4 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -14,6 +14,10 @@ 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 a05ca30645..dc1173b897 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -2,9 +2,11 @@ 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 @@ { :lsbdistrelease => platform[:lsbdistrelease], :lsbdistcodename => platform[:lsbdistcodename], + :operatingsystem => platform[:operatingsystem], } end let :release do @@ -109,7 +112,7 @@ end end - [ { :lsbdistcodename => 'natty', + [ { :lsbdistcodename => 'natty', :package => 'python-software-properties' }, { :lsbdistcodename => 'quantal', :package => 'software-properties-common'}, @@ -121,7 +124,8 @@ '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]}" } From 04ca249ee0393858ac9acf8456fd4bf3afe8e48f Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 9 Jan 2014 18:26:32 -0500 Subject: [PATCH 207/574] Fixes to make the tests run under Debian as well as Ubuntu. --- spec/acceptance/apt_ppa_spec.rb | 190 +++++++++++---------- spec/acceptance/apt_source_spec.rb | 1 + spec/acceptance/backports_spec.rb | 14 +- spec/acceptance/force_spec.rb | 8 +- spec/acceptance/release_spec.rb | 6 + spec/acceptance/unattended_upgrade_spec.rb | 4 + 6 files changed, 123 insertions(+), 100 deletions(-) diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb index f936980243..c0d216107d 100644 --- a/spec/acceptance/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -1,61 +1,20 @@ require 'spec_helper_acceptance' -describe 'apt::ppa' do +if fact('operatingsystem') == 'Ubuntu' + describe 'apt::ppa' do - context 'reset' do - it 'removes ppa' do - shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2]) - shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2]) - end - end - - context 'adding a ppa that doesnt exist' do - it 'should work with no errors' do - pp = <<-EOS - include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': } - EOS - - apply_manifest(pp, :catch_failures => true) - end - - describe 'contains the source file' do - it 'contains a kernel ppa source' do - shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0]) + context 'reset' do + it 'removes ppa' do + shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2]) + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2]) end end - end - - context 'readding a removed ppa.' do - it 'setup' do - shell('add-apt-repository -y ppa:raravena80/collectd5') - # This leaves a blank file - shell('add-apt-repository --remove ppa:raravena80/collectd5') - end - - it 'should readd it successfully' do - pp = <<-EOS - include '::apt' - apt::ppa { 'ppa:raravena80/collectd5': } - EOS - - apply_manifest(pp, :catch_failures => true) - end - end - context 'reset' do - it 'removes added ppas' do - shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*') - shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') - end - end - - context 'ensure' do - context 'present' do - it 'works without failure' do + context 'adding a ppa that doesnt exist' do + it 'should work with no errors' do pp = <<-EOS include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present } + apt::ppa { 'ppa:canonical-kernel-team/ppa': } EOS apply_manifest(pp, :catch_failures => true) @@ -67,72 +26,115 @@ end end end - end - context 'ensure' do - context 'absent' do - it 'works without failure' do + context 'readding a removed ppa.' do + it 'setup' do + shell('add-apt-repository -y ppa:raravena80/collectd5') + # This leaves a blank file + shell('add-apt-repository --remove ppa:raravena80/collectd5') + end + + it 'should readd it successfully' do pp = <<-EOS include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent } + apt::ppa { 'ppa:raravena80/collectd5': } EOS apply_manifest(pp, :catch_failures => true) end + end - describe 'doesnt contain the source file' do - it 'fails' do - shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2]) - end + context 'reset' do + it 'removes added ppas' do + shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*') + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') end end - end - context 'release' do - context 'precise' do - it 'works without failure' do - pp = <<-EOS - include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': - ensure => present, - release => precise, - } - EOS + context 'ensure' do + context 'present' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present } + EOS - shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) - apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) + end + + describe 'contains the source file' do + it 'contains a kernel ppa source' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0]) + end + end end + end + + context 'ensure' do + context 'absent' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent } + EOS - describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do - it { should be_file } + apply_manifest(pp, :catch_failures => true) + end + + describe 'doesnt contain the source file' do + it 'fails' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2]) + end + end end end - end - context 'options' do - context '-y' do - it 'works without failure' do - pp = <<-EOS - include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': - ensure => present, - release => precise, - options => '-y', - } - EOS + context 'release' do + context 'precise' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': + ensure => present, + release => precise, + } + EOS + + shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end - shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) - apply_manifest(pp, :catch_failures => true) + describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do + it { should be_file } + end end + end + + context 'options' do + context '-y' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': + ensure => present, + release => precise, + options => '-y', + } + EOS + + shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end - describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do - it { should be_file } + describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do + it { should be_file } + end end end - end - context 'reset' do - it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } - end + context 'reset' do + it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } + end + end end diff --git a/spec/acceptance/apt_source_spec.rb b/spec/acceptance/apt_source_spec.rb index 273add56fa..6b026b88c9 100644 --- a/spec/acceptance/apt_source_spec.rb +++ b/spec/acceptance/apt_source_spec.rb @@ -255,6 +255,7 @@ apt::source { 'puppetlabs': ensure => present, location => 'http://apt.puppetlabs.com', + release => 'precise', repos => 'main', key => '4BD6EC30', key_source => 'http://apt.puppetlabs.com/pubkey.gpg', diff --git a/spec/acceptance/backports_spec.rb b/spec/acceptance/backports_spec.rb index ffb14ce628..80e2093848 100644 --- a/spec/acceptance/backports_spec.rb +++ b/spec/acceptance/backports_spec.rb @@ -1,5 +1,13 @@ require 'spec_helper_acceptance' +codename = fact('lsbdistcodename') +case fact('operatingsystem') +when 'Ubuntu' + repos = 'main universe multiverse restricted' +when 'Debian' + repos = 'main contrib non-free' +end + describe 'apt::backports class' do context 'defaults' do it 'should work with no errors' do @@ -14,7 +22,7 @@ class { 'apt::backports': } context 'release' do it 'should work with no errors' do pp = <<-EOS - class { 'apt::backports': release => 'precise' } + class { 'apt::backports': release => '#{codename}' } EOS apply_manifest(pp, :catch_failures => true) @@ -22,7 +30,7 @@ class { 'apt::backports': release => 'precise' } describe file('/etc/apt/sources.list.d/backports.list') do it { should be_file } - it { should contain 'precise-backports main universe multiverse restricted' } + it { should contain "#{codename}-backports #{repos}" } end end @@ -37,7 +45,7 @@ class { 'apt::backports': release => 'precise', location => 'http://localhost/ub describe file('/etc/apt/sources.list.d/backports.list') do it { should be_file } - it { should contain 'deb http://localhost/ubuntu precise-backports main universe multiverse restricted' } + it { should contain "deb http://localhost/ubuntu precise-backports #{repos}" } end end diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index f7e374be3a..c364d5fe15 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -1,5 +1,7 @@ require 'spec_helper_acceptance' +codename = fact('lsbdistcodename') + describe 'apt::force define' do context 'defaults' do it 'should work with no errors' do @@ -21,12 +23,12 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': release => 'precise' } + apt::force { 'vim': release => '#{codename}' } EOS shell('apt-get remove -y vim') apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/apt-get -y -t precise install vim/) + expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/) end end @@ -57,7 +59,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'tomcat7': timeout => '1' } + apt::force { 'vim': timeout => '1' } EOS shell('apt-get clean') diff --git a/spec/acceptance/release_spec.rb b/spec/acceptance/release_spec.rb index 44491e3ef9..81d7ca0c4d 100644 --- a/spec/acceptance/release_spec.rb +++ b/spec/acceptance/release_spec.rb @@ -17,4 +17,10 @@ class { 'apt::release': release_id => 'precise', } end end + context 'reset' do + it 'cleans up' do + shell('rm -rf /etc/apt/apt.conf.d/01release') + end + end + end diff --git a/spec/acceptance/unattended_upgrade_spec.rb b/spec/acceptance/unattended_upgrade_spec.rb index 287e5ec8e8..a0349d40d7 100644 --- a/spec/acceptance/unattended_upgrade_spec.rb +++ b/spec/acceptance/unattended_upgrade_spec.rb @@ -8,6 +8,10 @@ include apt::unattended_upgrades EOS + # Attempted workaround for problems seen on debian with + # something holding the package database open. + #shell('killall -9 apt-get') + #shell('killall -9 dpkg') apply_manifest(pp, :catch_failures => true) end From c8c365718f32dbde71f72035a807ac52721e55e3 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Thu, 23 Jan 2014 12:47:51 -0500 Subject: [PATCH 208/574] Enable fast finish in Travis http://blog.travis-ci.com/2013-11-27-fast-finishing-builds/ --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 00924bac0a..582efdf70a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ env: msb69xvOlzQykM0WRF+4kJ6TZ7AbMiDI+VZ8GDtsRaU5/q3BpsvFe8aato+6 QeyFtBG62OsosTEhGws4mqiFsPDu3dHlakuJc9zevlTuhNwbKSs= matrix: + fast_finish: true exclude: - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 2.7.0" From bbfa2cf1b599afc17e90990b09ba140e81fa6574 Mon Sep 17 00:00:00 2001 From: Konrad Lother Date: Thu, 30 Jan 2014 00:33:45 +0100 Subject: [PATCH 209/574] changed proxy_host default value from true to undef. fixes #211 --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b106ad4909..364ce8cb4e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -25,7 +25,7 @@ class apt( $always_apt_update = false, $disable_keys = undef, - $proxy_host = false, + $proxy_host = undef, $proxy_port = '8080', $purge_sources_list = false, $purge_sources_list_d = false, @@ -103,7 +103,7 @@ } $proxy_set = $proxy_host ? { - false => absent, + undef => absent, default => present } From 0207fcd19a91b4cbdb356c230ded64799a8615cd Mon Sep 17 00:00:00 2001 From: Konrad Lother Date: Thu, 30 Jan 2014 00:33:45 +0100 Subject: [PATCH 210/574] changed proxy_host default value from false to undef. fixes #211 --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b106ad4909..364ce8cb4e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -25,7 +25,7 @@ class apt( $always_apt_update = false, $disable_keys = undef, - $proxy_host = false, + $proxy_host = undef, $proxy_port = '8080', $purge_sources_list = false, $purge_sources_list_d = false, @@ -103,7 +103,7 @@ } $proxy_set = $proxy_host ? { - false => absent, + undef => absent, default => present } From 3922a1bdf505947bd2425378035f0edaffc385e6 Mon Sep 17 00:00:00 2001 From: Matt Callaway Date: Fri, 31 Jan 2014 15:56:28 -0600 Subject: [PATCH 211/574] Remove the quotes from the origin line. This doesn't matter on Ubuntu Precise with apt 0.8, but for those of us still using Ubuntu Lucid, apt 0.7 silently ignores preferences with the quotes. --- templates/pin.pref.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb index 62c44c7241..eed0c10db6 100644 --- a/templates/pin.pref.erb +++ b/templates/pin.pref.erb @@ -12,7 +12,7 @@ if @pin_release.length > 0 elsif @version.length > 0 @pin = "version #{@version}" elsif @origin.length > 0 - @pin = "origin \"#{@origin}\"" + @pin = "origin #{@origin}" end -%> # <%= @name %> From 386c48bad03e56bc410282301fa9c96d3ef3ac20 Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Sat, 8 Feb 2014 22:21:34 -0800 Subject: [PATCH 212/574] include puppet-lint in the bundle and rake tasks --- Gemfile | 1 + Rakefile | 1 + 2 files changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index b89b579d5d..09f0589fb7 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source 'https://rubygems.org' group :development, :test do gem 'rake', :require => false gem 'rspec-puppet', :require => false + gem 'puppet-lint', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'serverspec', :require => false gem 'beaker', :require => false diff --git a/Rakefile b/Rakefile index cd3d379958..4fea69bcfb 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1,2 @@ require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' From fcdbafd74b1d21c7fd648fc510ef15dc7a0d0618 Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Sat, 8 Feb 2014 22:22:47 -0800 Subject: [PATCH 213/574] disable lint check for single quoted variables Previously we weren't linting, there's a number of warning but there was only one actual error reported when linting was enabled. It was erroring on a valid usage of a single quoted variable-like string. To allow linting to succeed (and the warning to show themselves) I've disable the check that is giving a false positive. --- Rakefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Rakefile b/Rakefile index 4fea69bcfb..6d067dc56c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,4 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send('disable_single_quote_string_with_variables') From 63277db4f1fc81b75940503624c389fbebc495f7 Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Sat, 8 Feb 2014 22:28:45 -0800 Subject: [PATCH 214/574] allow specifying gem source via env var --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b89b579d5d..b126d1ede6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source 'https://rubygems.org' +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :development, :test do gem 'rake', :require => false From 07e3f74d5726625d2d8e054c4e50da3376af0a6a Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Sat, 8 Feb 2014 22:33:06 -0800 Subject: [PATCH 215/574] put disabled checks in .puppet-lint.rc for non rake usage --- .puppet-lint.rc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .puppet-lint.rc diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000000..f4abb47dc5 --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1 @@ +--no-single_quote_string_with_variables-check From f9e2fe2a7ce3b2aee5535591b9f6882c29ccc2cb Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 14 Feb 2014 14:33:30 -0800 Subject: [PATCH 216/574] Undo backwards-incompatible changes and features. Undoes the parameter changes in #140 and #184 --- manifests/force.pp | 2 +- manifests/ppa.pp | 2 +- spec/acceptance/apt_ppa_spec.rb | 40 --------------------------------- spec/acceptance/force_spec.rb | 6 ++--- spec/defines/force_spec.rb | 26 ++++++++++----------- 5 files changed, 18 insertions(+), 58 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index 152bb67354..70b7d47239 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -2,7 +2,7 @@ # force a package from a specific release define apt::force( - $release = false, + $release = 'testing', $version = false, $timeout = 300 ) { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 14fbbceba4..caff436bdf 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,10 +1,10 @@ # ppa.pp define apt::ppa( - $ensure = 'present', $release = $::lsbdistcodename, $options = '-y' ) { + $ensure = 'present' include apt::params include apt::update diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb index c0d216107d..2b156bc532 100644 --- a/spec/acceptance/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -51,51 +51,12 @@ end end - context 'ensure' do - context 'present' do - it 'works without failure' do - pp = <<-EOS - include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present } - EOS - - apply_manifest(pp, :catch_failures => true) - end - - describe 'contains the source file' do - it 'contains a kernel ppa source' do - shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0]) - end - end - end - end - - context 'ensure' do - context 'absent' do - it 'works without failure' do - pp = <<-EOS - include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent } - EOS - - apply_manifest(pp, :catch_failures => true) - end - - describe 'doesnt contain the source file' do - it 'fails' do - shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2]) - end - end - end - end - context 'release' do context 'precise' do it 'works without failure' do pp = <<-EOS include '::apt' apt::ppa { 'ppa:canonical-kernel-team/ppa': - ensure => present, release => precise, } EOS @@ -116,7 +77,6 @@ pp = <<-EOS include '::apt' apt::ppa { 'ppa:canonical-kernel-team/ppa': - ensure => present, release => precise, options => '-y', } diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index c364d5fe15..aab77a1a76 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -7,7 +7,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': } + apt::force { 'vim': release => false, } EOS shell('apt-get remove -y vim') @@ -41,7 +41,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': version => '1.1.1' } + apt::force { 'vim': version => '1.1.1', release => false, } EOS shell('apt-get remove -y vim') @@ -59,7 +59,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': timeout => '1' } + apt::force { 'vim': release => false, timeout => '1' } EOS shell('apt-get clean') diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index 84231fa233..829ec4748f 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -10,7 +10,7 @@ let :default_params do { - :release => false, + :release => 'testing', :version => false } end @@ -19,18 +19,18 @@ let :params do default_params end - it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'", + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( + :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1", :timeout => '300' ) } end - describe "when specifying release parameter" do + describe "when specifying false release parameter" do let :params do - default_params.merge(:release => 'testing') + default_params.merge(:release => false) end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( - :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" + it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" ) } end @@ -38,20 +38,20 @@ let :params do default_params.merge(:version => '1') end - it { should contain_exec("/usr/bin/apt-get -y install #{title}=#{params[:version]}").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=#{params[:version]}").with( + :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" ) } end - describe "when specifying release and version parameters" do + describe "when specifying false release and version parameters" do let :params do default_params.merge( - :release => 'testing', + :release => false, :version => '1' ) end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with( - :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" + it { should contain_exec("/usr/bin/apt-get -y install #{title}=1").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" ) } end end From 387681384538e7940869e4dc2d5950d346101c64 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 14 Feb 2014 14:34:08 -0800 Subject: [PATCH 217/574] Add foss types to nodesets --- spec/acceptance/nodesets/debian-70rc1-x64.yml | 2 ++ spec/acceptance/nodesets/default.yml | 2 ++ spec/acceptance/nodesets/ubuntu-server-12042-x64.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/spec/acceptance/nodesets/debian-70rc1-x64.yml b/spec/acceptance/nodesets/debian-70rc1-x64.yml index a1b59c085e..4b55677f4c 100644 --- a/spec/acceptance/nodesets/debian-70rc1-x64.yml +++ b/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -6,3 +6,5 @@ HOSTS: box : debian-70rc1-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index 2b8fe4a121..a5f38f784c 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -6,3 +6,5 @@ HOSTS: box : ubuntu-server-12042-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml index 2b8fe4a121..a5f38f784c 100644 --- a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -6,3 +6,5 @@ HOSTS: box : ubuntu-server-12042-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant +CONFIG: + type: foss From 398309fc3758eea5c55bccf285ccd8aa84268ea8 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 14 Feb 2014 14:34:37 -0800 Subject: [PATCH 218/574] Enforce dependency version in tests --- .fixtures.yml | 4 +++- spec/spec_helper_acceptance.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index dbd5621dea..2bb941de23 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,5 +1,7 @@ fixtures: repositories: - "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" + "stdlib": + "repo": "git://github.com/puppetlabs/puppetlabs-stdlib.git" + "ref": "v2.2.1" symlinks: "apt": "#{source_dir}" diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 0073e4d8da..a4fc1bd6a2 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -20,7 +20,7 @@ puppet_module_install(:source => proj_root, :module_name => 'apt') hosts.each do |host| shell('/bin/touch /etc/puppet/hiera.yaml') - shell('puppet module install puppetlabs-stdlib', { :acceptable_exit_codes => [0,1] }) + shell('puppet module install puppetlabs-stdlib --version 2.2.1', { :acceptable_exit_codes => [0,1] }) end end end From 291c47eb060948f5743e50ef6ce6bb6e939e8961 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 13 Feb 2014 17:16:37 -0800 Subject: [PATCH 219/574] Release 1.4.1 Summary: This is a bugfix release. Bugfixes: - Fix apt::force unable to upgrade packages from releases other than its original - Removed a few refeneces to aptitude instead of apt-get for portability - Removed call to getparam() due to stdlib dependency - Correct apt::source template when architecture is provided - Retry package installs if apt is locked - Use root to exec in apt::ppa - Updated tests and converted acceptance tests to beaker --- CHANGELOG | 13 +++++++++++++ Modulefile | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b6ec7cf7e4..6ded6ea5a3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,16 @@ +2014-02-13 1.4.1 +Summary: +This is a bugfix release. + +Bugfixes: +- Fix apt::force unable to upgrade packages from releases other than its original +- Removed a few refeneces to aptitude instead of apt-get for portability +- Removed call to getparam() due to stdlib dependency +- Correct apt::source template when architecture is provided +- Retry package installs if apt is locked +- Use root to exec in apt::ppa +- Updated tests and converted acceptance tests to beaker + 2013-10-08 1.4.0 Summary: diff --git a/Modulefile b/Modulefile index 72aa142e5f..e44c27597e 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.4.0' +version '1.4.1' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From 4b8aa9e55a25d63db0c1c6fcf22a6333f1810e76 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 14 Feb 2014 14:49:43 -0800 Subject: [PATCH 220/574] Revert "Undo backwards-incompatible changes and features." This reverts commit f9e2fe2a7ce3b2aee5535591b9f6882c29ccc2cb. --- manifests/force.pp | 2 +- manifests/ppa.pp | 2 +- spec/acceptance/apt_ppa_spec.rb | 40 +++++++++++++++++++++++++++++++++ spec/acceptance/force_spec.rb | 6 ++--- spec/defines/force_spec.rb | 26 ++++++++++----------- 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index 70b7d47239..152bb67354 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -2,7 +2,7 @@ # force a package from a specific release define apt::force( - $release = 'testing', + $release = false, $version = false, $timeout = 300 ) { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index caff436bdf..14fbbceba4 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,10 +1,10 @@ # ppa.pp define apt::ppa( + $ensure = 'present', $release = $::lsbdistcodename, $options = '-y' ) { - $ensure = 'present' include apt::params include apt::update diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb index 2b156bc532..c0d216107d 100644 --- a/spec/acceptance/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -51,12 +51,51 @@ end end + context 'ensure' do + context 'present' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'contains the source file' do + it 'contains a kernel ppa source' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0]) + end + end + end + end + + context 'ensure' do + context 'absent' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'doesnt contain the source file' do + it 'fails' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2]) + end + end + end + end + context 'release' do context 'precise' do it 'works without failure' do pp = <<-EOS include '::apt' apt::ppa { 'ppa:canonical-kernel-team/ppa': + ensure => present, release => precise, } EOS @@ -77,6 +116,7 @@ pp = <<-EOS include '::apt' apt::ppa { 'ppa:canonical-kernel-team/ppa': + ensure => present, release => precise, options => '-y', } diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index aab77a1a76..c364d5fe15 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -7,7 +7,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': release => false, } + apt::force { 'vim': } EOS shell('apt-get remove -y vim') @@ -41,7 +41,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': version => '1.1.1', release => false, } + apt::force { 'vim': version => '1.1.1' } EOS shell('apt-get remove -y vim') @@ -59,7 +59,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': release => false, timeout => '1' } + apt::force { 'vim': timeout => '1' } EOS shell('apt-get clean') diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index 829ec4748f..84231fa233 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -10,7 +10,7 @@ let :default_params do { - :release => 'testing', + :release => false, :version => false } end @@ -19,18 +19,18 @@ let :params do default_params end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( - :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1", + it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'", :timeout => '300' ) } end - describe "when specifying false release parameter" do + describe "when specifying release parameter" do let :params do - default_params.merge(:release => false) + default_params.merge(:release => 'testing') end - it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( + :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" ) } end @@ -38,20 +38,20 @@ let :params do default_params.merge(:version => '1') end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=#{params[:version]}").with( - :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" + it { should contain_exec("/usr/bin/apt-get -y install #{title}=#{params[:version]}").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" ) } end - describe "when specifying false release and version parameters" do + describe "when specifying release and version parameters" do let :params do default_params.merge( - :release => false, + :release => 'testing', :version => '1' ) end - it { should contain_exec("/usr/bin/apt-get -y install #{title}=1").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with( + :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" ) } end end From 80ea5a72ca25d919874548349c93d8eaf8349e04 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 14 Feb 2014 16:12:05 -0800 Subject: [PATCH 221/574] Port 8080 is a bad choice and bumps into puppetdb --- spec/acceptance/apt_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 5b7379fb12..35a0d3e70b 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -68,7 +68,7 @@ class { 'apt': disable_keys => false } pp = <<-EOS class { 'apt': proxy_host => 'localhost', - proxy_port => '8080', + proxy_port => '7042', } EOS @@ -77,7 +77,7 @@ class { 'apt': describe file('/etc/apt/apt.conf.d/proxy') do it { should be_file } - it { should contain 'Acquire::http::Proxy "http://localhost:8080\";' } + it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' } end end @@ -110,7 +110,7 @@ class { 'apt': pp = <<-EOS class { 'apt': proxy_host => 'localhost', - proxy_port => '8080', + proxy_port => '7042', } EOS @@ -119,7 +119,7 @@ class { 'apt': describe file('/etc/apt/apt.conf.d/proxy') do it { should be_file } - it { should contain 'Acquire::http::Proxy "http://localhost:8080\";' } + it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' } end end From ef7d149d5a6b014b53b12925bb5d6638192ac08d Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 14 Feb 2014 16:13:14 +0100 Subject: [PATCH 222/574] apt::pin: Allow for packages to be an array. --- README.md | 4 ++++ manifests/pin.pp | 8 +++++++- spec/acceptance/pin_spec.rb | 20 ++++++++++++++++++++ spec/defines/pin_spec.rb | 8 +++++++- templates/pin.pref.erb | 2 +- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d07bbb0ece..3a7bc8ca0c 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,10 @@ Note you can also specifying more complex pins using distribution properties. label => 'Debian' } +If you wish to pin a number of packages you may specify the packages as a space +delimited string using the `packages` attribute or pass in an array of package +names. + ### apt::ppa Adds a ppa repository using `add-apt-repository`. diff --git a/manifests/pin.pp b/manifests/pin.pp index 402e79ede7..9cb4a8e798 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -37,7 +37,13 @@ # Read the manpage 'apt_preferences(5)', especially the chapter # 'Thea Effect of APT Preferences' to understand the following logic # and the difference between specific and general form - if $packages != '*' { # specific form + if is_array($packages) { + $packages_string = join($packages, ' ') + } else { + $packages_string = $packages + } + + if $packages_string != '*' { # specific form if ( $pin_release != '' and ( $origin != '' or $version != '' )) or ( $origin != '' and ( $pin_release != '' or $version != '' )) or diff --git a/spec/acceptance/pin_spec.rb b/spec/acceptance/pin_spec.rb index b5a004429b..a38dfa4b27 100644 --- a/spec/acceptance/pin_spec.rb +++ b/spec/acceptance/pin_spec.rb @@ -91,6 +91,26 @@ it { should contain 'Pin: release a=vim-puppet' } end end + + context 'array' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'array': + ensure => present, + packages => ['apache', 'ntop'], + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/array.pref') do + it { should be_file } + it { should contain 'Package: apache ntop' } + it { should contain 'Pin: release a=array' } + end + end end context 'release' do diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 7a58e78d1f..179a2f3ac5 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -65,7 +65,7 @@ { :params => { :packages => 'apache', - :priority => '1', + :priority => '1', :release => 'stable', :codename => 'wheezy', :release_version => '3.0', @@ -75,6 +75,12 @@ }, :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n" }, + { + :params => { + :packages => ['apache', 'ntop'], + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache ntop\nPin: release a=my_pin\nPin-Priority: 0\n" + }, ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do let :param_hash do diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb index 62c44c7241..42e23c7edd 100644 --- a/templates/pin.pref.erb +++ b/templates/pin.pref.erb @@ -17,6 +17,6 @@ end -%> # <%= @name %> Explanation: <%= @explanation %> -Package: <%= @packages %> +Package: <%= @packages_string %> Pin: <%= @pin %> Pin-Priority: <%= @priority %> From ffe55a9758a778d3d800dc2b73427de273b2514b Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sun, 16 Feb 2014 14:45:48 +0100 Subject: [PATCH 223/574] beaker: Randomize SSH port. --- spec/acceptance/nodesets/default.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index a5f38f784c..45af989347 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -8,3 +8,4 @@ HOSTS: hypervisor : vagrant CONFIG: type: foss + vagrant_ssh_port_random: true From d28dc494aae1f0cd2117183a54684f5095ab50cf Mon Sep 17 00:00:00 2001 From: Matt Callaway Date: Tue, 18 Feb 2014 08:08:19 -0600 Subject: [PATCH 224/574] Update pin_spec test to match quote removal. --- spec/defines/pin_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 7a58e78d1f..e7976ad612 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -60,7 +60,7 @@ :priority => '1', :origin => 'ftp.de.debian.org' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin \"ftp.de.debian.org\"\nPin-Priority: 1\n" + :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n" }, { :params => { From d5efdf0016a535068660c3dd52a1554d8880e3bc Mon Sep 17 00:00:00 2001 From: Martin Konrad Date: Tue, 18 Feb 2014 13:37:05 -0500 Subject: [PATCH 225/574] Update Debian signing key for backports. --- manifests/backports.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index e9180c48c2..9cfa1c0113 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -29,7 +29,7 @@ $release_real = downcase($release) $key = $::lsbdistid ? { - 'debian' => '55BE302B', + 'debian' => '46925553', 'ubuntu' => '437D05B5', } $repos = $::lsbdistid ? { From 374101612c035ec5765c767d234d127d5c7a4870 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 17 Jan 2014 09:11:56 +0100 Subject: [PATCH 226/574] Add a type and provider to manage apt keys. This commits introduces: * The apt_key type; * The apt_key provider; * Unit tests for the type; * Beaker/acceptance tests for the type/provider. The idea behind apt_key is that apt::key will simply become a wrapper that uses apt_key. Being a native type/provider apt_key is a lot less error prone than the current exec behaviour of apt::key and adds a few nice bonuses like inventory capabilities for mcollective users. --- lib/puppet/provider/apt_key/apt_key.rb | 170 ++++++++++ lib/puppet/type/apt_key.rb | 112 +++++++ spec/acceptance/apt_key_provider_spec.rb | 394 +++++++++++++++++++++++ spec/unit/puppet/type/apt_key_spec.rb | 153 +++++++++ 4 files changed, 829 insertions(+) create mode 100644 lib/puppet/provider/apt_key/apt_key.rb create mode 100644 lib/puppet/type/apt_key.rb create mode 100644 spec/acceptance/apt_key_provider_spec.rb create mode 100644 spec/unit/puppet/type/apt_key_spec.rb diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb new file mode 100644 index 0000000000..7e221dded5 --- /dev/null +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -0,0 +1,170 @@ +require 'date' +require 'open-uri' +require 'tempfile' + +Puppet::Type.type(:apt_key).provide(:apt_key) do + + KEY_LINE = { + :date => '[0-9]{4}-[0-9]{2}-[0-9]{2}', + :key_type => '(R|D)', + :key_size => '\d{4}', + :key_id => '[0-9a-fA-F]+', + :expires => 'expire(d|s)', + } + + confine :osfamily => :debian + defaultfor :osfamily => :debian + commands :apt_key => 'apt-key' + + def self.instances + key_array = apt_key('list').split("\n").collect do |line| + line_hash = key_line_hash(line) + next unless line_hash + expired = false + + if line_hash[:key_expiry] + expired = Date.today > Date.parse(line_hash[:key_expiry]) + end + + new( + :name => line_hash[:key_id], + :id => line_hash[:key_id], + :ensure => :present, + :expired => expired, + :expiry => line_hash[:key_expiry], + :size => line_hash[:key_size], + :type => line_hash[:key_type] == 'R' ? :rsa : :dsa, + :created => line_hash[:key_created] + ) + end + key_array.compact! + end + + def self.prefetch(resources) + apt_keys = instances + resources.keys.each do |name| + if provider = apt_keys.find{ |key| key.name == name } + resources[name].provider = provider + end + end + end + + def self.key_line_hash(line) + line_array = line.match(key_line_regexp).to_a + return nil if line_array.length < 5 + + return_hash = { + :key_id => line_array[3], + :key_size => line_array[1], + :key_type => line_array[2], + :key_created => line_array[4], + :key_expiry => nil, + } + + return_hash[:key_expiry] = line_array[7] if line_array.length == 8 + return return_hash + end + + def self.key_line_regexp + # This regexp is trying to match the following output + # pub 4096R/4BD6EC30 2010-07-10 [expires: 2016-07-08] + # pub 1024D/CD2EFD2A 2009-12-15 + regexp = /\A + pub # match only the public key, not signatures + \s+ # bunch of spaces after that + (#{KEY_LINE[:key_size]}) # size of the key, usually a multiple of 1024 + #{KEY_LINE[:key_type]} # type of the key, usually R or D + \/ # separator between key_type and key_id + (#{KEY_LINE[:key_id]}) # hex id of the key + \s+ # bunch of spaces after that + (#{KEY_LINE[:date]}) # date the key was added to the keyring + # following an optional block which indicates if the key has an expiration + # date and if it has expired yet + ( + \s+ # again with thes paces + \[ # we open with a square bracket + #{KEY_LINE[:expires]} # expires or expired + \: # a colon + \s+ # more spaces + (#{KEY_LINE[:date]}) # date indicating key expiry + \] # we close with a square bracket + )? # end of the optional block + \Z/x + regexp + end + + def source_to_file(value) + if URI::parse(value).scheme.nil? + fail("The file #{value} does not exist") unless File.exists?(value) + value + else + begin + key = open(value).read + rescue OpenURI::HTTPError => e + fail("#{e.message} for #{resource[:source]}") + rescue SocketError + fail("could not resolve #{resource[:source]}") + else + tempfile(key) + end + end + end + + def tempfile(content) + file = Tempfile.new('apt_key') + file.write content + file.close + file.path + end + + def exists? + @property_hash[:ensure] == :present + end + + def create + command = [] + if resource[:source].nil? and resource[:content].nil? + # Breaking up the command like this is needed because it blows up + # if --recv-keys isn't the last argument. + command.push('adv', '--keyserver', resource[:server]) + unless resource[:keyserver_options].nil? + command.push('--keyserver-options', resource[:keyserver_options]) + end + command.push('--recv-keys', resource[:id]) + elsif resource[:content] + command.push('add', tempfile(resource[:content])) + elsif resource[:source] + command.push('add', source_to_file(resource[:source])) + # In case we really screwed up, better safe than sorry. + else + fail("an unexpected condition occurred while trying to add the key: #{resource[:id]}") + end + apt_key(command) + @property_hash[:ensure] = :present + end + + def destroy + apt_key('del', resource[:id]) + @property_hash.clear + end + + def read_only(value) + fail('This is a read-only property.') + end + + mk_resource_methods + + # Needed until PUP-1470 is fixed and we can drop support for Puppet versions + # before that. + def expired + @property_hash[:expired] + end + + # Alias the setters of read-only properties + # to the read_only function. + alias :created= :read_only + alias :expired= :read_only + alias :expiry= :read_only + alias :size= :read_only + alias :type= :read_only +end diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb new file mode 100644 index 0000000000..67420de0fa --- /dev/null +++ b/lib/puppet/type/apt_key.rb @@ -0,0 +1,112 @@ +require 'pathname' + +Puppet::Type.newtype(:apt_key) do + + @doc = <<-EOS + This type provides Puppet with the capabilities to manage GPG keys needed + by apt to perform package validation. Apt has it's own GPG keyring that can + be manipulated through the `apt-key` command. + + apt_key { '4BD6EC30': + source => 'http://apt.puppetlabs.com/pubkey.gpg' + } + + **Autorequires**: + + If Puppet is given the location of a key file which looks like an absolute + path this type will autorequire that file. + EOS + + ensurable + + validate do + if self[:content] and self[:source] + fail('The properties content and source are mutually exclusive.') + end + end + + newparam(:id, :namevar => true) do + desc 'The ID of the key you want to manage.' + # GPG key ID's should be either 32-bit (short) or 64-bit (long) key ID's + # and may start with the optional 0x + newvalues(/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/) + munge do |value| + if value.start_with?('0x') + id = value.partition('0x').last.upcase + else + id = value.upcase + end + if id.length == 16 + id[8..-1] + else + id + end + end + end + + newparam(:content) do + desc 'The content of, or string representing, a GPG key.' + end + + newparam(:source) do + desc 'Location of a GPG key file, /path/to/file, http:// or https://' + newvalues(/\Ahttps?:\/\//, /\A\/\w+/) + end + + autorequire(:file) do + if self[:source] and Pathname.new(self[:source]).absolute? + self[:source] + end + end + + newparam(:server) do + desc 'The key server to fetch the key from based on the ID.' + defaultto :'keyserver.ubuntu.com' + # Need to validate this, preferably through stdlib is_fqdn + # but still working on getting to that. + end + + newparam(:keyserver_options) do + desc 'Additional options to pass to apt-key\'s --keyserver-options.' + end + + newproperty(:expired) do + desc <<-EOS + Indicates if the key has expired. + + This property is read-only. + EOS + end + + newproperty(:expiry) do + desc <<-EOS + The date the key will expire, or nil if it has no expiry date. + + This property is read-only. + EOS + end + + newproperty(:size) do + desc <<-EOS + The key size, usually a multiple of 1024. + + This property is read-only. + EOS + end + + newproperty(:type) do + desc <<-EOS + The key type, either RSA or DSA. + + This property is read-only. + EOS + end + + newproperty(:created) do + desc <<-EOS + Date the key was created. + + This property is read-only. + EOS + end +end diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb new file mode 100644 index 0000000000..1c1274f9c7 --- /dev/null +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -0,0 +1,394 @@ +require 'spec_helper_acceptance' + +PUPPETLABS_GPG_KEY_ID = '4BD6EC30' +PUPPETLABS_APT_URL = 'apt.puppetlabs.com' +PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg' + +describe 'apt_key' do + before(:each) do + shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}", + :acceptable_exit_codes => [0,1,2]) + end + + describe 'default options' do + key_versions = { + '32bit key id' => '4BD6EC30', + '64bit key id' => '1054B7A24BD6EC30', + '32bit lowercase key id' => '4bd6ec30', + '64bit lowercase key id' => '1054b7a24bd6ec30', + '0x formatted 32bit key id' => '0x4BD6EC30', + '0x formatted 64bit key id' => '0x1054B7A24BD6EC30', + '0x formatted 32bit lowercase key id' => '0x4bd6ec30', + '0x formatted 64bit lowercase key id' => '0x1054b7a24bd6ec30', + } + + key_versions.each do |key, value| + context "#{key}" do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{value}', + ensure => 'present', + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + end + end + end + + context 'invalid length key id' do + it 'fails' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '4B7A24BD6EC30', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Valid values match/) + end + end + end + end + + describe 'ensure =>' do + context 'absent' do + it 'is removed' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'absent', + } + EOS + + # Install the key first + shell("apt-key adv --keyserver keyserver.ubuntu.com \ + --recv-keys #{PUPPETLABS_GPG_KEY_ID}") + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + + # Time to remove it using Puppet + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}", + :acceptable_exit_codes => [1]) + end + end + end + + describe 'content =>' do + context 'puppetlabs gpg key' do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + content => "-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.12 (GNU/Linux) +Comment: GPGTools - http://gpgtools.org + +mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b +fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg +5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ +S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY +GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH +Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v +VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 +Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI +wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN +NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl +f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB +tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL +ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn +AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob +pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF +eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+ +aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M +2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ +VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU +3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh +qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1 +IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8 +1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp +HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN +MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+ +UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh +R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+ +N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc +kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e +lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT +DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb +kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf +DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei +BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z +XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2 ++zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU +fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH +dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4 +qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2 +7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq +UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x +Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA +KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3 +okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7 +bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4 +4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX +vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0 +jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y +ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD +7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR +M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf +REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y +DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk +ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= +=a34C +-----END PGP PUBLIC KEY BLOCK-----", + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + end + end + + context 'bogus key' do + it 'fails' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + content => 'For posterity: such content, much bogus, wow', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/no valid OpenPGP data found/) + end + end + end + end + + describe 'server =>' do + context 'pgp.mit.edu' do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + server => 'pgp.mit.edu', + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + end + end + + context 'nonexistant.key.server' do + it 'fails' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + server => 'nonexistant.key.server', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Host not found/) + end + end + end + end + + describe 'source =>' do + context 'http://' do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + end + + it 'fails with a 404' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/404 Not Found/) + end + end + + it 'fails with a socket error' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + source => 'http://apt.puppetlabss.com/herpderp.gpg', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/could not resolve/) + end + end + end + + context 'https://' do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + end + + it 'fails with a 404' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '4BD6EC30', + ensure => 'present', + source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/404 Not Found/) + end + end + + it 'fails with a socket error' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '4BD6EC30', + ensure => 'present', + source => 'https://apt.puppetlabss.com/herpderp.gpg', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/could not resolve/) + end + end + end + + context '/path/that/exists' do + before(:each) do + shell("curl -o /tmp/puppetlabs-pubkey.gpg \ + http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}") + end + + after(:each) do + shell('rm /tmp/puppetlabs-pubkey.gpg') + end + + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '4BD6EC30', + ensure => 'present', + source => '/tmp/puppetlabs-pubkey.gpg', + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + end + end + + context '/path/that/does/not/exist' do + it 'fails' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + source => '/tmp/totally_bogus.file', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/does not exist/) + end + end + end + + context '/path/that/exists/with/bogus/content' do + before(:each) do + shell('echo "here be dragons" > /tmp/fake-key.gpg') + end + + after(:each) do + shell('rm /tmp/fake-key.gpg') + end + it 'fails' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + source => '/tmp/fake-key.gpg', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/no valid OpenPGP data found/) + end + end + end + end + + describe 'keyserver_options =>' do + context 'debug' do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + keyserver_options => 'debug', + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + end + + it 'fails on invalid options' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + keyserver_options => 'this is totally bonkers', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/--keyserver-options this is totally/) + end + end + end + end +end diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb new file mode 100644 index 0000000000..cfdd16b38f --- /dev/null +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -0,0 +1,153 @@ +require 'spec_helper' +require 'puppet' + +describe Puppet::Type::type(:apt_key) do + context 'only namevar 32bit key id' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30' + )} + it 'id is set' do + resource[:id].should eq '4BD6EC30' + end + + it 'name is set to id' do + resource[:name].should eq '4BD6EC30' + end + + it 'keyserver is default' do + resource[:server].should eq :'keyserver.ubuntu.com' + end + + it 'source is not set' do + resource[:source].should eq nil + end + + it 'content is not set' do + resource[:content].should eq nil + end + end + + context 'with a lowercase 32bit key id' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => '4bd6ec30' + )} + it 'id is set' do + resource[:id].should eq '4BD6EC30' + end + end + + context 'with a 64bit key id' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => 'FFFFFFFF4BD6EC30' + )} + it 'id is set' do + resource[:id].should eq '4BD6EC30' + end + end + + context 'with a 0x formatted key id' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => '0x4BD6EC30' + )} + it 'id is set' do + resource[:id].should eq '4BD6EC30' + end + end + + context 'with a 0x formatted lowercase key id' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => '0x4bd6ec30' + )} + it 'id is set' do + resource[:id].should eq '4BD6EC30' + end + end + + context 'with a 0x formatted 64bit key id' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => '0xFFFFFFFF4BD6EC30' + )} + it 'id is set' do + resource[:id].should eq '4BD6EC30' + end + end + + context 'with source' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'http://apt.puppetlabs.com/pubkey.gpg' + )} + + it 'source is set to the URL' do + resource[:source].should eq 'http://apt.puppetlabs.com/pubkey.gpg' + end + end + + context 'with content' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :content => 'http://apt.puppetlabs.com/pubkey.gpg' + )} + + it 'content is set to the string' do + resource[:content].should eq 'http://apt.puppetlabs.com/pubkey.gpg' + end + end + + context 'with keyserver' do + let(:resource) { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :server => 'http://keyring.debian.org' + )} + + it 'keyserver is set to Debian' do + resource[:server].should eq 'http://keyring.debian.org' + end + end + + context 'validation' do + it 'raises an error if content and source are set' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'http://apt.puppetlabs.com/pubkey.gpg', + :content => 'Completely invalid as a GPG key' + )}.to raise_error(/content and source are mutually exclusive/) + end + + it 'raises an error if a weird length key is used' do + expect { Puppet::Type.type(:apt_key).new( + :id => 'F4BD6EC30', + :source => 'http://apt.puppetlabs.com/pubkey.gpg', + :content => 'Completely invalid as a GPG key' + )}.to raise_error(/Valid values match/) + end + + it 'raises an error when an invalid URI scheme is used in source' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'hkp://pgp.mit.edu' + )}.to raise_error(/Valid values match/) + end + + it 'allows the http URI scheme in source' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'http://pgp.mit.edu' + )}.to_not raise_error + end + + it 'allows the https URI scheme in source' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'https://pgp.mit.edu' + )}.to_not raise_error + end + + it 'allows an absolute path in source' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => '/path/to/a/file' + )}.to_not raise_error + end + end +end From 9ade658b7a93ee4c6283a98dc361cc952486abe1 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sun, 16 Feb 2014 17:14:47 +0100 Subject: [PATCH 227/574] Travis: Remove 3.0, add newer 3.x releases. 3.0 is just broken in tests, something is wrong with the module loading rendering tests completely useless. Start testing on Puppet 3.3 and 3.4. --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 582efdf70a..a6cfda6506 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,10 @@ rvm: env: matrix: - PUPPET_GEM_VERSION="~> 2.7.0" - - PUPPET_GEM_VERSION="~> 3.0.0" - PUPPET_GEM_VERSION="~> 3.1.0" - PUPPET_GEM_VERSION="~> 3.2.0" + - PUPPET_GEM_VERSION="~> 3.3.0" + - PUPPET_GEM_VERSION="~> 3.4.0" global: - PUBLISHER_LOGIN=puppetlabs - secure: |- @@ -31,11 +32,7 @@ matrix: env: PUPPET_GEM_VERSION="~> 2.7.0" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 2.7.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0.0" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 3.1.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.2.0" notifications: email: false From 3aa293a53fb7a2bd789ce3db35950778968079fd Mon Sep 17 00:00:00 2001 From: Martin Konrad Date: Tue, 18 Feb 2014 16:57:01 -0500 Subject: [PATCH 228/574] Update out-of-date Debian signing key in remaining files. --- README.md | 2 +- manifests/debian/testing.pp | 4 ++-- manifests/debian/unstable.pp | 4 ++-- spec/classes/backports_spec.rb | 4 ++-- spec/classes/debian_testing_spec.rb | 2 +- spec/classes/debian_unstable_spec.rb | 2 +- tests/source.pp | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3a7bc8ca0c..1e4c3bb2d8 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ Adds an apt source to `/etc/apt/sources.list.d/`. release => 'unstable', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', include_src => true diff --git a/manifests/debian/testing.pp b/manifests/debian/testing.pp index 45133470fa..3a82b4f7fd 100644 --- a/manifests/debian/testing.pp +++ b/manifests/debian/testing.pp @@ -5,7 +5,7 @@ # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free - # Key: 55BE302B Server: subkeys.pgp.net + # Key: 46925553 Server: subkeys.pgp.net # debian-keyring # debian-archive-keyring @@ -14,7 +14,7 @@ release => 'testing', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', } diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp index 401c9c5cda..77df94b0af 100644 --- a/manifests/debian/unstable.pp +++ b/manifests/debian/unstable.pp @@ -5,7 +5,7 @@ # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free - # Key: 55BE302B Server: subkeys.pgp.net + # Key: 46925553 Server: subkeys.pgp.net # debian-keyring # debian-archive-keyring @@ -14,7 +14,7 @@ release => 'unstable', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', } diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb index 27c6708f25..98ad873af5 100644 --- a/spec/classes/backports_spec.rb +++ b/spec/classes/backports_spec.rb @@ -34,7 +34,7 @@ 'location' => 'http://backports.debian.org/debian-backports', 'release' => 'squeeze-backports', 'repos' => 'main contrib non-free', - 'key' => '55BE302B', + 'key' => '46925553', 'key_server' => 'pgp.mit.edu', 'pin' => '200', }) @@ -62,7 +62,7 @@ 'location' => location, 'release' => 'squeeze-backports', 'repos' => 'main contrib non-free', - 'key' => '55BE302B', + 'key' => '46925553', 'key_server' => 'pgp.mit.edu', 'pin' => '200', }) diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb index 6006afb418..d5aa896a6d 100644 --- a/spec/classes/debian_testing_spec.rb +++ b/spec/classes/debian_testing_spec.rb @@ -6,7 +6,7 @@ "release" => "testing", "repos" => "main contrib non-free", "required_packages" => "debian-keyring debian-archive-keyring", - "key" => "55BE302B", + "key" => "46925553", "key_server" => "subkeys.pgp.net", "pin" => "-10" }) diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb index 411182df11..31f51129ce 100644 --- a/spec/classes/debian_unstable_spec.rb +++ b/spec/classes/debian_unstable_spec.rb @@ -6,7 +6,7 @@ "release" => "unstable", "repos" => "main contrib non-free", "required_packages" => "debian-keyring debian-archive-keyring", - "key" => "55BE302B", + "key" => "46925553", "key_server" => "subkeys.pgp.net", "pin" => "-10" }) diff --git a/tests/source.pp b/tests/source.pp index d83cb9787a..c20b59662a 100644 --- a/tests/source.pp +++ b/tests/source.pp @@ -15,7 +15,7 @@ location => 'http://debian.mirror.iweb.ca/debian/', release => 'testing', repos => 'main contrib non-free', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', } @@ -23,7 +23,7 @@ location => 'http://debian.mirror.iweb.ca/debian/', release => 'unstable', repos => 'main contrib non-free', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', } From 0bf44fc167405a6a0e6faae35f3fa4caa9ce8658 Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Wed, 19 Feb 2014 11:41:01 +1100 Subject: [PATCH 229/574] Force owner and mode on ppa files --- manifests/ppa.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 14fbbceba4..3c4dc3194e 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -67,6 +67,9 @@ file { "${sources_list_d}/${sources_list_d_filename}": ensure => 'absent', + mode => '0644', + owner => 'root', + gruop => 'root', notify => Exec['apt_update'], } } From bafc11df7692e73cf4d017c68094a5053a92ae9c Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 19 Feb 2014 19:52:05 +0000 Subject: [PATCH 230/574] Make sure we handle PE properly. --- spec/spec_helper_acceptance.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index a4fc1bd6a2..55c2fd4a4d 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,10 +1,16 @@ require 'beaker-rspec' -hosts.each do |host| - # Install Puppet - install_package host, 'rubygems' - on host, 'gem install puppet --no-ri --no-rdoc' - on host, "mkdir -p #{host['distmoduledir']}" +unless ENV['RS_PROVISION'] == 'no' + hosts.each do |host| + # Install Puppet + if host.is_pe? + install_pe + else + install_package host, 'rubygems' + on host, 'gem install puppet --no-ri --no-rdoc' + on host, "mkdir -p #{host['distmoduledir']}" + end + end end RSpec.configure do |c| From 296fdd217313b118cefb665d705e68456be0cbd6 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 19 Feb 2014 19:52:05 +0000 Subject: [PATCH 231/574] Make sure we handle PE properly. --- spec/spec_helper_acceptance.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index a4fc1bd6a2..55c2fd4a4d 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,10 +1,16 @@ require 'beaker-rspec' -hosts.each do |host| - # Install Puppet - install_package host, 'rubygems' - on host, 'gem install puppet --no-ri --no-rdoc' - on host, "mkdir -p #{host['distmoduledir']}" +unless ENV['RS_PROVISION'] == 'no' + hosts.each do |host| + # Install Puppet + if host.is_pe? + install_pe + else + install_package host, 'rubygems' + on host, 'gem install puppet --no-ri --no-rdoc' + on host, "mkdir -p #{host['distmoduledir']}" + end + end end RSpec.configure do |c| From 904fb4a2937932b4e24b526583bd563ee549fb14 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 20 Feb 2014 16:43:48 -0800 Subject: [PATCH 232/574] Don't pass options to ppa on lucid Lucid (10.04) has `add-apt-repository` but it doesn't accept any options. The define defaulted to `-y` but this changes that on lucid. This was made 7 months ago, so apparently no one cares about 10.04 any more. --- manifests/params.pp | 8 ++- manifests/ppa.pp | 2 +- spec/acceptance/apt_ppa_spec.rb | 50 +++++++++---------- .../nodesets/ubuntu-server-10044-x64.yml | 11 ++++ spec/spec_helper_acceptance.rb | 7 +-- 5 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 spec/acceptance/nodesets/ubuntu-server-10044-x64.yml diff --git a/manifests/params.pp b/manifests/params.pp index 955954fe89..ae464436da 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,11 +21,17 @@ } 'ubuntu': { case $::lsbdistcodename { - 'hardy','lucid','maverick','natty','oneiric','precise': { + 'hardy','maverick','natty','oneiric','precise': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' + $ppa_options = 'y' + } + 'lucid': { + $backports_location = 'http://us.archive.ubuntu.com/ubuntu' + $ppa_options = undef } default: { $backports_location = 'http://old-releases.ubuntu.com/ubuntu' + $ppa_options = 'y' } } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index caff436bdf..7ec6b20375 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -2,7 +2,7 @@ define apt::ppa( $release = $::lsbdistcodename, - $options = '-y' + $options = $apt::params::ppa_options, ) { $ensure = 'present' include apt::params diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb index 2b156bc532..60e6d4d4b2 100644 --- a/spec/acceptance/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -27,14 +27,13 @@ end end - context 'readding a removed ppa.' do + context 'reading a removed ppa.' do it 'setup' do - shell('add-apt-repository -y ppa:raravena80/collectd5') # This leaves a blank file - shell('add-apt-repository --remove ppa:raravena80/collectd5') + shell('echo > /etc/apt/sources.list.d/raravena80-collectd5-$(lsb_release -c -s).list') end - it 'should readd it successfully' do + it 'should read it successfully' do pp = <<-EOS include '::apt' apt::ppa { 'ppa:raravena80/collectd5': } @@ -71,30 +70,31 @@ end end - context 'options' do - context '-y' do - it 'works without failure' do - pp = <<-EOS - include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': - release => precise, - options => '-y', - } - EOS - - shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) - apply_manifest(pp, :catch_failures => true) - end - - describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do - it { should be_file } + if ! default[:platform].match(/10\.04/) + context 'options' do + context '-y' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': + release => precise, + options => '-y', + } + EOS + + shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do + it { should be_file } + end end end - end - context 'reset' do - it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } + context 'reset' do + it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } + end end - end end diff --git a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml new file mode 100644 index 0000000000..c1b8bdf8fa --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - master + platform: ubuntu-10.04-amd64 + box : ubuntu-server-10044-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 55c2fd4a4d..37afbfc1b7 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,18 +1,19 @@ require 'beaker-rspec' +# Install Puppet unless ENV['RS_PROVISION'] == 'no' hosts.each do |host| - # Install Puppet if host.is_pe? install_pe else - install_package host, 'rubygems' - on host, 'gem install puppet --no-ri --no-rdoc' + install_puppet on host, "mkdir -p #{host['distmoduledir']}" end end end +UNSUPPORTED_PLATFORMS = ['windows','aix','solaris',/el-(4|5|6)/] + RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) From c3b3f5bb42a754c5fdda42a9af74b1227ad2a9f5 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 20 Feb 2014 10:34:22 +0100 Subject: [PATCH 233/574] apt_key: Support fetching keys over FTP. --- lib/puppet/provider/apt_key/apt_key.rb | 12 ++++- lib/puppet/type/apt_key.rb | 4 +- lib/puppet_x/apt_key/patch_openuri.rb | 63 ++++++++++++++++++++++++ spec/acceptance/apt_key_provider_spec.rb | 52 +++++++++++++++++++ spec/unit/puppet/type/apt_key_spec.rb | 7 +++ 5 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 lib/puppet_x/apt_key/patch_openuri.rb diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 7e221dded5..51791d0248 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -1,7 +1,15 @@ require 'date' require 'open-uri' +require 'net/ftp' require 'tempfile' +if RUBY_VERSION == '1.8.7' + # Mothers cry, puppies die and Ruby 1.8.7's open-uri needs to be + # monkeypatched to support passing in :ftp_passive_mode. + require 'puppet_x/apt_key/patch_openuri' + OpenURI::Options.merge!({:ftp_active_mode => false,}) +end + Puppet::Type.type(:apt_key).provide(:apt_key) do KEY_LINE = { @@ -99,8 +107,8 @@ def source_to_file(value) value else begin - key = open(value).read - rescue OpenURI::HTTPError => e + key = open(value, :ftp_active_mode => false).read + rescue OpenURI::HTTPError, Net::FTPPermError => e fail("#{e.message} for #{resource[:source]}") rescue SocketError fail("could not resolve #{resource[:source]}") diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 67420de0fa..fa7b0c676c 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -49,8 +49,8 @@ end newparam(:source) do - desc 'Location of a GPG key file, /path/to/file, http:// or https://' - newvalues(/\Ahttps?:\/\//, /\A\/\w+/) + desc 'Location of a GPG key file, /path/to/file, ftp://, http:// or https://' + newvalues(/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/) end autorequire(:file) do diff --git a/lib/puppet_x/apt_key/patch_openuri.rb b/lib/puppet_x/apt_key/patch_openuri.rb new file mode 100644 index 0000000000..722c7bdeba --- /dev/null +++ b/lib/puppet_x/apt_key/patch_openuri.rb @@ -0,0 +1,63 @@ +require 'uri' +require 'stringio' +require 'time' + +module URI + class FTP + def buffer_open(buf, proxy, options) # :nodoc: + if proxy + OpenURI.open_http(buf, self, proxy, options) + return + end + require 'net/ftp' + + directories = self.path.split(%r{/}, -1) + directories.shift if directories[0] == '' # strip a field before leading slash + directories.each {|d| + d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") } + } + unless filename = directories.pop + raise ArgumentError, "no filename: #{self.inspect}" + end + directories.each {|d| + if /[\r\n]/ =~ d + raise ArgumentError, "invalid directory: #{d.inspect}" + end + } + if /[\r\n]/ =~ filename + raise ArgumentError, "invalid filename: #{filename.inspect}" + end + typecode = self.typecode + if typecode && /\A[aid]\z/ !~ typecode + raise ArgumentError, "invalid typecode: #{typecode.inspect}" + end + + # The access sequence is defined by RFC 1738 + ftp = Net::FTP.open(self.host) + ftp.passive = true if !options[:ftp_active_mode] + # todo: extract user/passwd from .netrc. + user = 'anonymous' + passwd = nil + user, passwd = self.userinfo.split(/:/) if self.userinfo + ftp.login(user, passwd) + directories.each {|cwd| + ftp.voidcmd("CWD #{cwd}") + } + if typecode + # xxx: typecode D is not handled. + ftp.voidcmd("TYPE #{typecode.upcase}") + end + if options[:content_length_proc] + options[:content_length_proc].call(ftp.size(filename)) + end + ftp.retrbinary("RETR #{filename}", 4096) { |str| + buf << str + options[:progress_proc].call(buf.size) if options[:progress_proc] + } + ftp.close + buf.io.rewind + end + + include OpenURI::OpenRead + end +end diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 1c1274f9c7..1d39a973b2 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -3,6 +3,9 @@ PUPPETLABS_GPG_KEY_ID = '4BD6EC30' PUPPETLABS_APT_URL = 'apt.puppetlabs.com' PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg' +CENTOS_GPG_KEY_ID = 'C105B9DE' +CENTOS_REPO_URL = 'ftp.cvut.cz/centos' +CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' describe 'apt_key' do before(:each) do @@ -251,6 +254,55 @@ end end + context 'ftp://' do + before(:each) do + shell("apt-key del #{CENTOS_GPG_KEY_ID}", + :acceptable_exit_codes => [0,1,2]) + end + + it 'works' do + pp = <<-EOS + apt_key { 'CentOS 6': + id => '#{CENTOS_GPG_KEY_ID}', + ensure => 'present', + source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}") + end + + it 'fails with a 550' do + pp = <<-EOS + apt_key { 'CentOS 6': + id => '#{CENTOS_GPG_KEY_ID}', + ensure => 'present', + source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/550 Failed to open/) + end + end + + it 'fails with a socket error' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + source => 'ftp://apt.puppetlabss.com/herpderp.gpg', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/could not resolve/) + end + end + end + context 'https://' do it 'works' do pp = <<-EOS diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index cfdd16b38f..c29f82b088 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -143,6 +143,13 @@ )}.to_not raise_error end + it 'allows the ftp URI scheme in source' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'ftp://pgp.mit.edu' + )}.to_not raise_error + end + it 'allows an absolute path in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', From 8453d40138e0f94fea8291c8299fc15aced9afed Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 21 Feb 2014 09:34:46 -0800 Subject: [PATCH 234/574] Missed the - for -y, but also tests were missing lsbdistid --- Gemfile | 1 + manifests/params.pp | 4 ++-- spec/defines/ppa_spec.rb | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index cd7fbc89b8..1e359d07b5 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :development, :test do gem 'rake', :require => false + gem 'pry', :require => false gem 'rspec-puppet', :require => false gem 'puppet-lint', :require => false gem 'puppetlabs_spec_helper', :require => false diff --git a/manifests/params.pp b/manifests/params.pp index ae464436da..51a01be91a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -23,7 +23,7 @@ case $::lsbdistcodename { 'hardy','maverick','natty','oneiric','precise': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' - $ppa_options = 'y' + $ppa_options = '-y' } 'lucid': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' @@ -31,7 +31,7 @@ } default: { $backports_location = 'http://old-releases.ubuntu.com/ubuntu' - $ppa_options = 'y' + $ppa_options = '-y' } } } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index dc1173b897..6a571a81fb 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -1,20 +1,28 @@ require 'spec_helper' describe 'apt::ppa', :type => :define do - [ { :lsbdistrelease => '11.04', + [ + { + :lsbdistrelease => '11.04', :lsbdistcodename => 'natty', :operatingsystem => 'Ubuntu', - :package => 'python-software-properties'}, - { :lsbdistrelease => '12.10', + :lsbdistid => 'Ubuntu', + :package => 'python-software-properties' + }, + { + :lsbdistrelease => '12.10', :lsbdistcodename => 'quantal', :operatingsystem => 'Ubuntu', - :package => 'software-properties-common'}, + :lsbdistid => 'Ubuntu', + :package => 'software-properties-common' + }, ].each do |platform| context "on #{platform[:lsbdistcodename]}" do let :facts do { - :lsbdistrelease => platform[:lsbdistrelease], + :lsbdistrelease => platform[:lsbdistrelease], :lsbdistcodename => platform[:lsbdistcodename], :operatingsystem => platform[:operatingsystem], + :lsbdistid => platform[:lsbdistid], } end let :release do From 08c1283437e2a7072e788f489f1de73dbc9a6c5d Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 21 Feb 2014 18:39:39 +0100 Subject: [PATCH 235/574] README/LICENSE: Fix licensing. Closes #152 --- LICENSE | 15 +++++++++++++++ README.md | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/LICENSE b/LICENSE index 638c347b17..30ce036d5e 100644 --- a/LICENSE +++ b/LICENSE @@ -17,3 +17,18 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Copyright 2014 Puppet Labs + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/README.md b/README.md index 3a7bc8ca0c..a30b72eaf4 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,13 @@ We want to keep it as easy as possible to contribute changes so that our modules You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) +License +------- + +The original code for this module comes from Evolving Web and was licensed under the MIT license. Code added since the fork of this module is licensed under the Apache 2.0 License like the rest of the Puppet Labs products. + +The LICENSE contains both licenses. + Contributors ------------ From 47c8def0f7acde99ddb0b1820a7a2e5a7566418d Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 21 Feb 2014 18:39:52 +0100 Subject: [PATCH 236/574] README: Fix white space / mixed indents. --- README.md | 60 +++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index a30b72eaf4..000d6599aa 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,14 @@ The APT module provides a simple interface for managing APT source, key, and def Module Description ------------------ -APT automates obtaining and installing software packages on *nix systems. +APT automates obtaining and installing software packages on \*nix systems. Setup ----- **What APT affects:** -* package/service/configuration files for APT +* package/service/configuration files for APT * your system's `sources.list` file and `sources.list.d` directory * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'. * system repositories @@ -36,14 +36,14 @@ Setup To begin using the APT module with default parameters, declare the class include apt - -Puppet code that uses anything from the APT module requires that the core apt class be declared. + +Puppet code that uses anything from the APT module requires that the core apt class be declared/\s\+$//e Usage ----- -Using the APT module consists predominantly in declaring classes that provide desired functionality and features. - +Using the APT module consists predominantly in declaring classes that provide desired functionality and features. + ### apt `apt` provides a number of common resources and options that are shared by the various defined types in this module, so you MUST always include this class in your manifests. @@ -61,9 +61,9 @@ The parameters for `apt` are not required in general and are predominantly for d update_timeout => undef } -Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. +Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. -If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. +If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. ### apt::builddep @@ -76,9 +76,9 @@ Installs the build depends of a specified package. Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. apt::force { 'glusterfs-server': - release => 'unstable', - version => '3.0.3', - require => Apt::Source['debian_unstable'], + release => 'unstable', + version => '3.0.3', + require => Apt::Source['debian_unstable'], } ### apt::key @@ -171,7 +171,7 @@ This test will set up a Puppet Labs apt repository. Start by creating a new smok key => '4BD6EC30', key_server => 'pgp.mit.edu', } - + This resource creates an apt source named puppetlabs and gives Puppet information about the repository's location and key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set it directly by adding the release type. Check your smoke test for syntax errors @@ -185,7 +185,7 @@ If you receive no output from that command, it means nothing is wrong. Then appl info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update] notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events> -The above example used a smoke test to easily lay out a resource declaration and apply it on your system. In production, you may want to declare your APT sources inside the classes where they’re needed. +The above example used a smoke test to easily lay out a resource declaration and apply it on your system. In production, you may want to declare your APT sources inside the classes where they’re needed. Implementation -------------- @@ -197,7 +197,7 @@ Adds the necessary components to get backports for Ubuntu and Debian. The releas Limitations ----------- -This module should work across all versions of Debian/Ubuntu and support all major APT repository management features. +This module should work across all versions of Debian/Ubuntu and support all major APT repository management features. Development ------------ @@ -222,19 +222,19 @@ A lot of great people have contributed to this module. A somewhat current list f * Ben Godfrey * Branan Purvine-Riley -* Christian G. Warden -* Dan Bode -* Garrett Honeycutt -* Jeff Wallace -* Ken Barber -* Matthaus Litteken -* Matthias Pigulla -* Monty Taylor -* Peter Drake -* Reid Vandewiele -* Robert Navarro -* Ryan Coleman -* Scott McLeod -* Spencer Krum -* William Van Hevelingen -* Zach Leslie +* Christian G. Warden +* Dan Bode +* Garrett Honeycutt +* Jeff Wallace +* Ken Barber +* Matthaus Litteken +* Matthias Pigulla +* Monty Taylor +* Peter Drake +* Reid Vandewiele +* Robert Navarro +* Ryan Coleman +* Scott McLeod +* Spencer Krum +* William Van Hevelingen +* Zach Leslie From e2b7ef2da2213dd3f7ae9bf4f4dde0e0db9f1ab4 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 21 Feb 2014 11:45:21 -0800 Subject: [PATCH 237/574] Using rspec filters works better And this will make merging back to master cleaner --- spec/acceptance/apt_ppa_spec.rb | 42 ++++++++++++++++----------------- spec/spec_helper_acceptance.rb | 2 -- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb index 60e6d4d4b2..5948461421 100644 --- a/spec/acceptance/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -70,31 +70,29 @@ end end - if ! default[:platform].match(/10\.04/) - context 'options' do - context '-y' do - it 'works without failure' do - pp = <<-EOS - include '::apt' - apt::ppa { 'ppa:canonical-kernel-team/ppa': - release => precise, - options => '-y', - } - EOS - - shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) - apply_manifest(pp, :catch_failures => true) - end - - describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do - it { should be_file } - end + context 'options' do + context '-y', :unless => default[:platform].match(/10\.04/) do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': + release => precise, + options => '-y', + } + EOS + + shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) end - end - context 'reset' do - it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } + describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do + it { should be_file } + end end end + + context 'reset' do + it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } + end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 37afbfc1b7..142e4a6734 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -12,8 +12,6 @@ end end -UNSUPPORTED_PLATFORMS = ['windows','aix','solaris',/el-(4|5|6)/] - RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) From afeaf571262935ad4c458a5ad8d2db9ca0befb79 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 21 Feb 2014 11:55:16 -0800 Subject: [PATCH 238/574] Use smaller build-dep package --- spec/acceptance/apt_builddep_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/apt_builddep_spec.rb b/spec/acceptance/apt_builddep_spec.rb index b61fca2955..cb01a1b047 100644 --- a/spec/acceptance/apt_builddep_spec.rb +++ b/spec/acceptance/apt_builddep_spec.rb @@ -4,7 +4,7 @@ context 'reset' do it 'removes packages' do - shell('apt-get -y remove glusterfs-server') + shell('apt-get -y remove znc') shell('apt-get -y remove g++') end end @@ -13,7 +13,7 @@ it 'should work with no errors' do pp = <<-EOS include '::apt' - apt::builddep { 'glusterfs-server': } + apt::builddep { 'znc': } EOS apply_manifest(pp, :catch_failures => true) @@ -28,7 +28,7 @@ context 'reset' do it 'removes packages' do - shell('apt-get -y remove glusterfs-server') + shell('apt-get -y remove znc') shell('apt-get -y remove g++') end end From 2ca97c82105f07c993eca15e1d19f3b8243aa4f7 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sat, 22 Feb 2014 10:56:50 +0100 Subject: [PATCH 239/574] apt: Allow managing of preferences file. We already had a feature to manage and purge entries in preferences.d but not the preferences file in /etc/apt. This commit adds that capability. Fixes #199 --- manifests/init.pp | 20 +++++++++++++++- spec/acceptance/apt_spec.rb | 44 ++++++++++++++++++++++++++++++++++ spec/classes/apt_spec.rb | 47 +++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index b106ad4909..2de6aa056f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,6 +29,7 @@ $proxy_port = '8080', $purge_sources_list = false, $purge_sources_list_d = false, + $purge_preferences = false, $purge_preferences_d = false, $update_timeout = undef ) { @@ -36,13 +37,21 @@ include apt::params include apt::update - validate_bool($purge_sources_list, $purge_sources_list_d, $purge_preferences_d) + validate_bool($purge_sources_list, $purge_sources_list_d, + $purge_preferences, $purge_preferences_d) $sources_list_content = $purge_sources_list ? { false => undef, true => "# Repos managed by puppet.\n", } + $preferences_content = $purge_preferences ? { + false => undef, + true => "Explanation: Preferences managed by Puppet\n +Explanation: We need a bogus package line because of Debian Bug #732746\n +Package: bogus-package\n", + } + if $always_apt_update == true { Exec <| title=='apt_update' |> { refreshonly => false, @@ -75,6 +84,15 @@ notify => Exec['apt_update'], } + file { 'apt-preferences': + ensure => present, + path => "${root}/preferences", + owner => root, + group => root, + mode => '0644', + content => $preferences_content, + } + file { 'preferences.d': ensure => directory, path => $preferences_d, diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 35a0d3e70b..336161cc6d 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -175,6 +175,50 @@ class { 'apt': end end + context 'purge_preferences' do + context 'false' do + it 'creates a preferences file' do + shell("echo 'original' > /etc/apt/preferences") + end + + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': purge_preferences => false } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences') do + it { should be_file } + it 'is not managed by Puppet' do + shell("grep 'original' /etc/apt/preferences", {:acceptable_exit_codes => 0}) + end + end + end + + context 'true' do + it 'creates a preferences file' do + shell('touch /etc/apt/preferences') + end + + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': purge_preferences => true } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences') do + it { should be_file } + it 'is managed by Puppet' do + shell("grep 'Explanation' /etc/apt/preferences", {:acceptable_exit_codes => 0}) + end + end + end + end + context 'purge_preferences_d' do context 'false' do it 'creates a preferences file' do diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 6d87cc64dc..5d8a597b90 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -18,6 +18,10 @@ :purge_sources_list => true, :purge_sources_list_d => true, }, + { + :purge_preferences => true, + :purge_preferences_d => true, + }, { :disable_keys => false } @@ -85,6 +89,49 @@ }) end } + it { + if param_hash[:purge_preferences] + should create_file('apt-preferences').with({ + :ensure => 'present', + :path => '/etc/apt/preferences', + :owner => 'root', + :group => 'root', + :mode => '0644', + :content => /Explanation/, + }) + else + should create_file('apt-preferences').with({ + :ensure => 'present', + :path => '/etc/apt/preferences', + :owner => 'root', + :group => 'root', + :mode => '0644', + :content => nil, + }) + end + } + + it { + if param_hash[:purge_preferences_d] + should create_file("preferences.d").with({ + 'path' => "/etc/apt/preferences.d", + 'ensure' => "directory", + 'owner' => "root", + 'group' => "root", + 'purge' => true, + 'recurse' => true, + }) + else + should create_file("preferences.d").with({ + 'path' => "/etc/apt/preferences.d", + 'ensure' => "directory", + 'owner' => "root", + 'group' => "root", + 'purge' => false, + 'recurse' => false, + }) + end + } it { should contain_exec("apt_update").with({ From f6816c6bb3ec29594c792c1bac05d264c99fcdfd Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 24 Feb 2014 13:52:13 -0800 Subject: [PATCH 240/574] Add non Debian os family unsupported test. --- manifests/params.pp | 3 +++ manifests/unattended_upgrades.pp | 1 + spec/acceptance/apt_builddep_spec.rb | 2 +- spec/acceptance/apt_key_spec.rb | 2 +- spec/acceptance/apt_ppa_spec.rb | 2 +- spec/acceptance/apt_source_spec.rb | 2 +- spec/acceptance/apt_spec.rb | 2 +- spec/acceptance/backports_spec.rb | 2 +- spec/acceptance/class_spec.rb | 2 +- spec/acceptance/conf_spec.rb | 2 +- spec/acceptance/force_spec.rb | 2 +- spec/acceptance/pin_spec.rb | 2 +- spec/acceptance/release_spec.rb | 2 +- spec/acceptance/unattended_upgrade_spec.rb | 2 +- spec/acceptance/unsupported_spec.rb | 10 ++++++++++ spec/spec_helper_acceptance.rb | 2 ++ 16 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 spec/acceptance/unsupported_spec.rb diff --git a/manifests/params.pp b/manifests/params.pp index 51a01be91a..b35bb1c8d9 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -35,5 +35,8 @@ } } } + default: { + fail("Unsupported osfamily (${::osfamily}) or lsbdistid (${::lsbdistid})") + } } } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index f006bd5289..b0bd8ab1e0 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -37,6 +37,7 @@ $download_delta = "0", $verbose = "0", ) { + include apt::params validate_bool( $auto_fix, diff --git a/spec/acceptance/apt_builddep_spec.rb b/spec/acceptance/apt_builddep_spec.rb index cb01a1b047..1e35e4aa68 100644 --- a/spec/acceptance/apt_builddep_spec.rb +++ b/spec/acceptance/apt_builddep_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt::builddep' do +describe 'apt::builddep', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'reset' do it 'removes packages' do diff --git a/spec/acceptance/apt_key_spec.rb b/spec/acceptance/apt_key_spec.rb index 36cba5eeff..9f2ba395ad 100644 --- a/spec/acceptance/apt_key_spec.rb +++ b/spec/acceptance/apt_key_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt::key' do +describe 'apt::key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'apt::key' do it 'should work with no errors' do pp = <<-EOS diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb index 5948461421..c11da9123b 100644 --- a/spec/acceptance/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper_acceptance' if fact('operatingsystem') == 'Ubuntu' - describe 'apt::ppa' do + describe 'apt::ppa', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'reset' do it 'removes ppa' do diff --git a/spec/acceptance/apt_source_spec.rb b/spec/acceptance/apt_source_spec.rb index 6b026b88c9..c2d076cbff 100644 --- a/spec/acceptance/apt_source_spec.rb +++ b/spec/acceptance/apt_source_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt::source' do +describe 'apt::source', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'apt::source' do context 'ensure => present' do diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 35a0d3e70b..775139145e 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt class' do +describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'reset' do it 'fixes the sources.list' do diff --git a/spec/acceptance/backports_spec.rb b/spec/acceptance/backports_spec.rb index 80e2093848..6d3f7f0e68 100644 --- a/spec/acceptance/backports_spec.rb +++ b/spec/acceptance/backports_spec.rb @@ -8,7 +8,7 @@ repos = 'main contrib non-free' end -describe 'apt::backports class' do +describe 'apt::backports class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'defaults' do it 'should work with no errors' do pp = <<-EOS diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index f228e4c456..e5994498b9 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt class' do +describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'default parameters' do # Using puppet_apply as a helper diff --git a/spec/acceptance/conf_spec.rb b/spec/acceptance/conf_spec.rb index 98898c2749..8a8ed63db4 100644 --- a/spec/acceptance/conf_spec.rb +++ b/spec/acceptance/conf_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt::conf define' do +describe 'apt::conf define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'defaults' do it 'should work with no errors' do pp = <<-EOS diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index aab77a1a76..00572eae37 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -2,7 +2,7 @@ codename = fact('lsbdistcodename') -describe 'apt::force define' do +describe 'apt::force define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'defaults' do it 'should work with no errors' do pp = <<-EOS diff --git a/spec/acceptance/pin_spec.rb b/spec/acceptance/pin_spec.rb index b5a004429b..4011e73c10 100644 --- a/spec/acceptance/pin_spec.rb +++ b/spec/acceptance/pin_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt::pin define' do +describe 'apt::pin define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'defaults' do it 'should work with no errors' do pp = <<-EOS diff --git a/spec/acceptance/release_spec.rb b/spec/acceptance/release_spec.rb index 81d7ca0c4d..e7467bf62d 100644 --- a/spec/acceptance/release_spec.rb +++ b/spec/acceptance/release_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt::release class' do +describe 'apt::release class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'release_id' do it 'should work with no errors' do pp = <<-EOS diff --git a/spec/acceptance/unattended_upgrade_spec.rb b/spec/acceptance/unattended_upgrade_spec.rb index a0349d40d7..6a19f4e74e 100644 --- a/spec/acceptance/unattended_upgrade_spec.rb +++ b/spec/acceptance/unattended_upgrade_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'apt::unattended_upgrades class' do +describe 'apt::unattended_upgrades class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do context 'defaults' do it 'should work with no errors' do pp = <<-EOS diff --git a/spec/acceptance/unsupported_spec.rb b/spec/acceptance/unsupported_spec.rb new file mode 100644 index 0000000000..08dca76b84 --- /dev/null +++ b/spec/acceptance/unsupported_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper_acceptance' + +describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + it 'class apt fails' do + pp = <<-EOS + class { 'apt': } + EOS + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported/i) + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 142e4a6734..3352564ce7 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -12,6 +12,8 @@ end end +UNSUPPORTED_PLATFORMS = ['RedHat','Suse','windows','AIX','Solaris'] + RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) From 4d188443bc4f7b10581fedf2180573308bb2bf7b Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 24 Feb 2014 22:31:16 +0000 Subject: [PATCH 241/574] Add lsbdistid facts where appropriate. --- spec/classes/apt_spec.rb | 1 + spec/classes/debian_testing_spec.rb | 1 + spec/classes/debian_unstable_spec.rb | 1 + spec/classes/params_spec.rb | 1 + spec/classes/release_spec.rb | 1 + spec/classes/unattended_upgrades_spec.rb | 1 + spec/defines/builddep_spec.rb | 1 + spec/defines/conf_spec.rb | 1 + spec/defines/force_spec.rb | 1 + spec/defines/key_spec.rb | 1 + spec/defines/pin_spec.rb | 9 +++++---- spec/defines/ppa_spec.rb | 3 ++- spec/defines/source_spec.rb | 5 +++-- 13 files changed, 20 insertions(+), 7 deletions(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 6d87cc64dc..080bc81760 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } let :default_params do { :disable_keys => :undef, diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb index 6006afb418..ca55ef687b 100644 --- a/spec/classes/debian_testing_spec.rb +++ b/spec/classes/debian_testing_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::debian::testing', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } it { should contain_apt__source("debian_testing").with({ "location" => "http://debian.mirror.iweb.ca/debian/", diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb index 411182df11..f5ed4558a7 100644 --- a/spec/classes/debian_unstable_spec.rb +++ b/spec/classes/debian_unstable_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::debian::unstable', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } it { should contain_apt__source("debian_unstable").with({ "location" => "http://debian.mirror.iweb.ca/debian/", diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index f2790b0adb..2d3ec3c71a 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::params', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } let (:title) { 'my_package' } it { should contain_apt__params } diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb index 31252b99a9..e43f449d62 100644 --- a/spec/classes/release_spec.rb +++ b/spec/classes/release_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::release', :type => :class do + let(:facts) { { :lsbdistid => '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 e83c6e4c30..f5cad53a5b 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -2,6 +2,7 @@ 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' } } it { should contain_package("unattended-upgrades") } diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb index 4e2b698d93..a0cbaa4cc0 100644 --- a/spec/defines/builddep_spec.rb +++ b/spec/defines/builddep_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe 'apt::builddep', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let(:title) { 'my_package' } describe "should require apt-get update" do diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 5a81b5148c..cda5900c03 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::conf', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let :title do 'norecommends' end diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index 84231fa233..0d3d6e5940 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::force', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let :pre_condition do 'include apt::params' end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index aea197a7b2..4ba7b87eae 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::key', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let :title do '8347A27F' end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 179a2f3ac5..5d3d312ed6 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::pin', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let(:title) { 'my_pin' } let :default_params do @@ -12,21 +13,21 @@ } end - [ + [ { :params => {}, :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n" }, { :params => { - :packages => 'apache', + :packages => 'apache', :priority => '1' }, :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" }, { :params => { - :order => 50, - :packages => 'apache', + :order => 50, + :packages => 'apache', :priority => '1' }, :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 6a571a81fb..0c3bd75ed7 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -133,7 +133,8 @@ end let :facts do {:lsbdistcodename => '#{platform[:lsbdistcodename]}', - :operatingsystem => 'Ubuntu'} + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu'} end let(:title) { "ppa" } let(:release) { "#{platform[:lsbdistcodename]}" } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 215d1e692f..9da8b235fe 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::source', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let :title do 'my_source' end @@ -59,7 +60,7 @@ end let :facts do - {:lsbdistcodename => 'karmic'} + {:lsbdistcodename => 'karmic', :lsbdistid => 'Ubuntu'} end let :params do @@ -160,7 +161,7 @@ let(:default_params) { Hash.new } let(:facts) { Hash.new } it { expect { should raise_error(Puppet::Error) } } - let(:facts) { { :lsbdistcodename => 'lucid' } } + let(:facts) { { :lsbdistcodename => 'lucid', :lsbdistid => 'Ubuntu' } } it { should contain_apt__source(title) } end end From 450fadb86a507fc8d268aec8ab872ab502db992c Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 24 Feb 2014 22:31:16 +0000 Subject: [PATCH 242/574] Add lsbdistid facts where appropriate. (cherry picked from commit 4d188443bc4f7b10581fedf2180573308bb2bf7b) --- spec/classes/apt_spec.rb | 1 + spec/classes/debian_testing_spec.rb | 1 + spec/classes/debian_unstable_spec.rb | 1 + spec/classes/params_spec.rb | 1 + spec/classes/release_spec.rb | 1 + spec/classes/unattended_upgrades_spec.rb | 1 + spec/defines/builddep_spec.rb | 1 + spec/defines/conf_spec.rb | 1 + spec/defines/force_spec.rb | 1 + spec/defines/key_spec.rb | 1 + spec/defines/pin_spec.rb | 9 +++++---- spec/defines/ppa_spec.rb | 3 ++- spec/defines/source_spec.rb | 5 +++-- 13 files changed, 20 insertions(+), 7 deletions(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 6d87cc64dc..080bc81760 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } let :default_params do { :disable_keys => :undef, diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb index 6006afb418..ca55ef687b 100644 --- a/spec/classes/debian_testing_spec.rb +++ b/spec/classes/debian_testing_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::debian::testing', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } it { should contain_apt__source("debian_testing").with({ "location" => "http://debian.mirror.iweb.ca/debian/", diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb index 411182df11..f5ed4558a7 100644 --- a/spec/classes/debian_unstable_spec.rb +++ b/spec/classes/debian_unstable_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::debian::unstable', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } it { should contain_apt__source("debian_unstable").with({ "location" => "http://debian.mirror.iweb.ca/debian/", diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index f2790b0adb..2d3ec3c71a 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::params', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } let (:title) { 'my_package' } it { should contain_apt__params } diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb index 31252b99a9..e43f449d62 100644 --- a/spec/classes/release_spec.rb +++ b/spec/classes/release_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::release', :type => :class do + let(:facts) { { :lsbdistid => '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 e83c6e4c30..f5cad53a5b 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -2,6 +2,7 @@ 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' } } it { should contain_package("unattended-upgrades") } diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb index 4e2b698d93..a0cbaa4cc0 100644 --- a/spec/defines/builddep_spec.rb +++ b/spec/defines/builddep_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe 'apt::builddep', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let(:title) { 'my_package' } describe "should require apt-get update" do diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 5a81b5148c..cda5900c03 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::conf', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let :title do 'norecommends' end diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index 829ec4748f..b8665e6dab 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::force', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let :pre_condition do 'include apt::params' end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index aea197a7b2..4ba7b87eae 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::key', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let :title do '8347A27F' end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 7a58e78d1f..7537251dde 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::pin', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let(:title) { 'my_pin' } let :default_params do @@ -12,21 +13,21 @@ } end - [ + [ { :params => {}, :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n" }, { :params => { - :packages => 'apache', + :packages => 'apache', :priority => '1' }, :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" }, { :params => { - :order => 50, - :packages => 'apache', + :order => 50, + :packages => 'apache', :priority => '1' }, :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 6a571a81fb..0c3bd75ed7 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -133,7 +133,8 @@ end let :facts do {:lsbdistcodename => '#{platform[:lsbdistcodename]}', - :operatingsystem => 'Ubuntu'} + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu'} end let(:title) { "ppa" } let(:release) { "#{platform[:lsbdistcodename]}" } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 215d1e692f..9da8b235fe 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'apt::source', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } let :title do 'my_source' end @@ -59,7 +60,7 @@ end let :facts do - {:lsbdistcodename => 'karmic'} + {:lsbdistcodename => 'karmic', :lsbdistid => 'Ubuntu'} end let :params do @@ -160,7 +161,7 @@ let(:default_params) { Hash.new } let(:facts) { Hash.new } it { expect { should raise_error(Puppet::Error) } } - let(:facts) { { :lsbdistcodename => 'lucid' } } + let(:facts) { { :lsbdistcodename => 'lucid', :lsbdistid => 'Ubuntu' } } it { should contain_apt__source(title) } end end From 5d43c20d1ebfe1ad5a0f1774814264dbb37ceef2 Mon Sep 17 00:00:00 2001 From: Matt Callaway Date: Fri, 31 Jan 2014 15:56:28 -0600 Subject: [PATCH 243/574] Remove the quotes from the origin line. This doesn't matter on Ubuntu Precise with apt 0.8, but for those of us still using Ubuntu Lucid, apt 0.7 silently ignores preferences with the quotes. (cherry picked from commit 3922a1bdf505947bd2425378035f0edaffc385e6) --- templates/pin.pref.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb index 62c44c7241..eed0c10db6 100644 --- a/templates/pin.pref.erb +++ b/templates/pin.pref.erb @@ -12,7 +12,7 @@ if @pin_release.length > 0 elsif @version.length > 0 @pin = "version #{@version}" elsif @origin.length > 0 - @pin = "origin \"#{@origin}\"" + @pin = "origin #{@origin}" end -%> # <%= @name %> From bffef4142a1458300cd20d3a225dc78168288e99 Mon Sep 17 00:00:00 2001 From: Matt Callaway Date: Tue, 18 Feb 2014 08:08:19 -0600 Subject: [PATCH 244/574] Update pin_spec test to match quote removal. (cherry picked from commit d28dc494aae1f0cd2117183a54684f5095ab50cf) --- spec/defines/pin_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 7537251dde..78a9b12690 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -61,7 +61,7 @@ :priority => '1', :origin => 'ftp.de.debian.org' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin \"ftp.de.debian.org\"\nPin-Priority: 1\n" + :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n" }, { :params => { From b4e430f4db1a99d646aaf8d247346fc9176df6ca Mon Sep 17 00:00:00 2001 From: Daniel Lawrence Date: Wed, 19 Feb 2014 11:41:01 +1100 Subject: [PATCH 245/574] Force owner and mode on ppa files (cherry picked from commit 0bf44fc167405a6a0e6faae35f3fa4caa9ce8658) --- manifests/ppa.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 7ec6b20375..f2629809e0 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -67,6 +67,9 @@ file { "${sources_list_d}/${sources_list_d_filename}": ensure => 'absent', + mode => '0644', + owner => 'root', + gruop => 'root', notify => Exec['apt_update'], } } From 334f4030a74e5a0146865f39d8636a18d8d64cc5 Mon Sep 17 00:00:00 2001 From: Konrad Lother Date: Thu, 30 Jan 2014 00:33:45 +0100 Subject: [PATCH 246/574] changed proxy_host default value from false to undef. fixes #211 (cherry picked from commit 0207fcd19a91b4cbdb356c230ded64799a8615cd) --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b106ad4909..364ce8cb4e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -25,7 +25,7 @@ class apt( $always_apt_update = false, $disable_keys = undef, - $proxy_host = false, + $proxy_host = undef, $proxy_port = '8080', $purge_sources_list = false, $purge_sources_list_d = false, @@ -103,7 +103,7 @@ } $proxy_set = $proxy_host ? { - false => absent, + undef => absent, default => present } From 2a2620f597c9a35249d62aa0fa61a5083d0b4caf Mon Sep 17 00:00:00 2001 From: Martin Konrad Date: Tue, 18 Feb 2014 16:57:01 -0500 Subject: [PATCH 247/574] Update out-of-date Debian signing key in remaining files. (cherry picked from commit 3aa293a53fb7a2bd789ce3db35950778968079fd) --- README.md | 2 +- manifests/debian/testing.pp | 4 ++-- manifests/debian/unstable.pp | 4 ++-- spec/classes/backports_spec.rb | 4 ++-- spec/classes/debian_testing_spec.rb | 2 +- spec/classes/debian_unstable_spec.rb | 2 +- tests/source.pp | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d07bbb0ece..e4bd14a2be 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ Adds an apt source to `/etc/apt/sources.list.d/`. release => 'unstable', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', include_src => true diff --git a/manifests/debian/testing.pp b/manifests/debian/testing.pp index 45133470fa..3a82b4f7fd 100644 --- a/manifests/debian/testing.pp +++ b/manifests/debian/testing.pp @@ -5,7 +5,7 @@ # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free - # Key: 55BE302B Server: subkeys.pgp.net + # Key: 46925553 Server: subkeys.pgp.net # debian-keyring # debian-archive-keyring @@ -14,7 +14,7 @@ release => 'testing', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', } diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp index 401c9c5cda..77df94b0af 100644 --- a/manifests/debian/unstable.pp +++ b/manifests/debian/unstable.pp @@ -5,7 +5,7 @@ # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free - # Key: 55BE302B Server: subkeys.pgp.net + # Key: 46925553 Server: subkeys.pgp.net # debian-keyring # debian-archive-keyring @@ -14,7 +14,7 @@ release => 'unstable', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', } diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb index 27c6708f25..98ad873af5 100644 --- a/spec/classes/backports_spec.rb +++ b/spec/classes/backports_spec.rb @@ -34,7 +34,7 @@ 'location' => 'http://backports.debian.org/debian-backports', 'release' => 'squeeze-backports', 'repos' => 'main contrib non-free', - 'key' => '55BE302B', + 'key' => '46925553', 'key_server' => 'pgp.mit.edu', 'pin' => '200', }) @@ -62,7 +62,7 @@ 'location' => location, 'release' => 'squeeze-backports', 'repos' => 'main contrib non-free', - 'key' => '55BE302B', + 'key' => '46925553', 'key_server' => 'pgp.mit.edu', 'pin' => '200', }) diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb index ca55ef687b..20487333f6 100644 --- a/spec/classes/debian_testing_spec.rb +++ b/spec/classes/debian_testing_spec.rb @@ -7,7 +7,7 @@ "release" => "testing", "repos" => "main contrib non-free", "required_packages" => "debian-keyring debian-archive-keyring", - "key" => "55BE302B", + "key" => "46925553", "key_server" => "subkeys.pgp.net", "pin" => "-10" }) diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb index f5ed4558a7..70724f90bd 100644 --- a/spec/classes/debian_unstable_spec.rb +++ b/spec/classes/debian_unstable_spec.rb @@ -7,7 +7,7 @@ "release" => "unstable", "repos" => "main contrib non-free", "required_packages" => "debian-keyring debian-archive-keyring", - "key" => "55BE302B", + "key" => "46925553", "key_server" => "subkeys.pgp.net", "pin" => "-10" }) diff --git a/tests/source.pp b/tests/source.pp index d83cb9787a..c20b59662a 100644 --- a/tests/source.pp +++ b/tests/source.pp @@ -15,7 +15,7 @@ location => 'http://debian.mirror.iweb.ca/debian/', release => 'testing', repos => 'main contrib non-free', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', } @@ -23,7 +23,7 @@ location => 'http://debian.mirror.iweb.ca/debian/', release => 'unstable', repos => 'main contrib non-free', - key => '55BE302B', + key => '46925553', key_server => 'subkeys.pgp.net', pin => '-10', } From 14bf0043815a5dfd9cc514d51042e5d16b25697d Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 21 Feb 2014 18:39:39 +0100 Subject: [PATCH 248/574] README/LICENSE: Fix licensing. Closes #152 (cherry picked from commit 08c1283437e2a7072e788f489f1de73dbc9a6c5d) --- LICENSE | 15 +++++++++++++++ README.md | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/LICENSE b/LICENSE index 638c347b17..30ce036d5e 100644 --- a/LICENSE +++ b/LICENSE @@ -17,3 +17,18 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Copyright 2014 Puppet Labs + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/README.md b/README.md index e4bd14a2be..73e2aa2786 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,13 @@ We want to keep it as easy as possible to contribute changes so that our modules You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) +License +------- + +The original code for this module comes from Evolving Web and was licensed under the MIT license. Code added since the fork of this module is licensed under the Apache 2.0 License like the rest of the Puppet Labs products. + +The LICENSE contains both licenses. + Contributors ------------ From b92eec5ea1641203b575ba43e98b14afe311e65c Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 21 Feb 2014 18:39:52 +0100 Subject: [PATCH 249/574] README: Fix white space / mixed indents. (cherry picked from commit 47c8def0f7acde99ddb0b1820a7a2e5a7566418d) --- README.md | 60 +++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 73e2aa2786..ec8b4c5e49 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,14 @@ The APT module provides a simple interface for managing APT source, key, and def Module Description ------------------ -APT automates obtaining and installing software packages on *nix systems. +APT automates obtaining and installing software packages on \*nix systems. Setup ----- **What APT affects:** -* package/service/configuration files for APT +* package/service/configuration files for APT * your system's `sources.list` file and `sources.list.d` directory * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'. * system repositories @@ -36,14 +36,14 @@ Setup To begin using the APT module with default parameters, declare the class include apt - -Puppet code that uses anything from the APT module requires that the core apt class be declared. + +Puppet code that uses anything from the APT module requires that the core apt class be declared/\s\+$//e Usage ----- -Using the APT module consists predominantly in declaring classes that provide desired functionality and features. - +Using the APT module consists predominantly in declaring classes that provide desired functionality and features. + ### apt `apt` provides a number of common resources and options that are shared by the various defined types in this module, so you MUST always include this class in your manifests. @@ -61,9 +61,9 @@ The parameters for `apt` are not required in general and are predominantly for d update_timeout => undef } -Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. +Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. -If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. +If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. ### apt::builddep @@ -76,9 +76,9 @@ Installs the build depends of a specified package. Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. apt::force { 'glusterfs-server': - release => 'unstable', - version => '3.0.3', - require => Apt::Source['debian_unstable'], + release => 'unstable', + version => '3.0.3', + require => Apt::Source['debian_unstable'], } ### apt::key @@ -167,7 +167,7 @@ This test will set up a Puppet Labs apt repository. Start by creating a new smok key => '4BD6EC30', key_server => 'pgp.mit.edu', } - + This resource creates an apt source named puppetlabs and gives Puppet information about the repository's location and key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set it directly by adding the release type. Check your smoke test for syntax errors @@ -181,7 +181,7 @@ If you receive no output from that command, it means nothing is wrong. Then appl info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update] notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events> -The above example used a smoke test to easily lay out a resource declaration and apply it on your system. In production, you may want to declare your APT sources inside the classes where they’re needed. +The above example used a smoke test to easily lay out a resource declaration and apply it on your system. In production, you may want to declare your APT sources inside the classes where they’re needed. Implementation -------------- @@ -193,7 +193,7 @@ Adds the necessary components to get backports for Ubuntu and Debian. The releas Limitations ----------- -This module should work across all versions of Debian/Ubuntu and support all major APT repository management features. +This module should work across all versions of Debian/Ubuntu and support all major APT repository management features. Development ------------ @@ -218,19 +218,19 @@ A lot of great people have contributed to this module. A somewhat current list f * Ben Godfrey * Branan Purvine-Riley -* Christian G. Warden -* Dan Bode -* Garrett Honeycutt -* Jeff Wallace -* Ken Barber -* Matthaus Litteken -* Matthias Pigulla -* Monty Taylor -* Peter Drake -* Reid Vandewiele -* Robert Navarro -* Ryan Coleman -* Scott McLeod -* Spencer Krum -* William Van Hevelingen -* Zach Leslie +* Christian G. Warden +* Dan Bode +* Garrett Honeycutt +* Jeff Wallace +* Ken Barber +* Matthaus Litteken +* Matthias Pigulla +* Monty Taylor +* Peter Drake +* Reid Vandewiele +* Robert Navarro +* Ryan Coleman +* Scott McLeod +* Spencer Krum +* William Van Hevelingen +* Zach Leslie From eb40a7ae7822bfea30e8e95fb1108676192a8541 Mon Sep 17 00:00:00 2001 From: Henrik Ahlgren Date: Fri, 10 Jan 2014 17:09:18 +0200 Subject: [PATCH 250/574] Make apt.conf.d/proxy world readable and add a newline --- manifests/init.pp | 5 ++++- spec/classes/apt_spec.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 12db61a6df..b0621fe1fb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -128,8 +128,11 @@ file { 'configure-apt-proxy': ensure => $proxy_set, path => "${apt_conf_d}/proxy", - content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", + content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n", notify => Exec['apt_update'], + mode => '0644', + owner => root, + group => root, } # Need anchor to provide containment for dependencies. diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 0da7d32db0..7f88dddc39 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -164,7 +164,7 @@ if param_hash[:proxy_host] should contain_file('configure-apt-proxy').with( 'path' => '/etc/apt/apt.conf.d/proxy', - 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";", + 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";\n", 'notify' => "Exec[apt_update]" ) else From 31918a94888c4fbfe05795dcf1a80029f19e7303 Mon Sep 17 00:00:00 2001 From: Martin Konrad Date: Tue, 18 Feb 2014 13:37:05 -0500 Subject: [PATCH 251/574] Update Debian signing key for backports. (cherry picked from commit d5efdf0016a535068660c3dd52a1554d8880e3bc) --- manifests/backports.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index e9180c48c2..9cfa1c0113 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -29,7 +29,7 @@ $release_real = downcase($release) $key = $::lsbdistid ? { - 'debian' => '55BE302B', + 'debian' => '46925553', 'ubuntu' => '437D05B5', } $repos = $::lsbdistid ? { From 0a645c53ff8d729c23e5f91121f6725003923cca Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Tue, 25 Feb 2014 11:34:12 -0800 Subject: [PATCH 252/574] Pin quotes were removed for a Lucid bugfix --- spec/acceptance/pin_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/pin_spec.rb b/spec/acceptance/pin_spec.rb index 4011e73c10..6de11748d0 100644 --- a/spec/acceptance/pin_spec.rb +++ b/spec/acceptance/pin_spec.rb @@ -130,7 +130,7 @@ describe file('/etc/apt/preferences.d/vim-puppet.pref') do it { should be_file } - it { should contain 'Pin: origin "testrelease"' } + it { should contain 'Pin: origin testrelease' } end end end From 95c0634897465d4a34b26b27978bd11d01a3f2d0 Mon Sep 17 00:00:00 2001 From: Richard Pijnenburg Date: Wed, 26 Feb 2014 11:52:54 +0100 Subject: [PATCH 253/574] Fix fail message the fail message was including a fact that was not used in the whole case statement and caused some confusion. --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index b35bb1c8d9..84d5d0f67a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -36,7 +36,7 @@ } } default: { - fail("Unsupported osfamily (${::osfamily}) or lsbdistid (${::lsbdistid})") + fail("Unsupported lsbdistid (${::lsbdistid})") } } } From 46606c9a2b1c9b2b29aabcbbfe40312f54d00757 Mon Sep 17 00:00:00 2001 From: Daniel Tremblay Date: Wed, 4 Dec 2013 18:05:26 +0000 Subject: [PATCH 254/574] Add ability to specify hash of apt sources in hiera This patch uses create_resources() to call apt::source which lets you specify your sources in hiera. --- README.md | 22 +++++++++++++++ manifests/init.pp | 9 ++++++- spec/classes/init_spec.rb | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 spec/classes/init_spec.rb diff --git a/README.md b/README.md index 9c0e45cc36..5828d805ce 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,27 @@ If you would like to configure your system so the source is the Puppet Labs APT key_server => 'pgp.mit.edu', } + +#### Hiera example +
+apt::sources:
+  'debian_unstable':
+      location: 'http://debian.mirror.iweb.ca/debian/'
+      release: 'unstable'
+      repos: 'main contrib non-free'
+      required_packages: 'debian-keyring debian-archive-keyring'
+      key: '55BE302B'
+      key_server: 'subkeys.pgp.net'
+      pin: '-10'
+      include_src: 'true'
+
+  'puppetlabs':
+      location: 'http://apt.puppetlabs.com'
+      repos: 'main'
+      key: '4BD6EC30'
+      key_server: 'pgp.mit.edu'
+
+ ### Testing The APT module is mostly a collection of defined resource types, which provide reusable logic that can be leveraged to manage APT. It does provide smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. @@ -224,6 +245,7 @@ A lot of great people have contributed to this module. A somewhat current list f * Branan Purvine-Riley * Christian G. Warden * Dan Bode +* Daniel Tremblay * Garrett Honeycutt * Jeff Wallace * Ken Barber diff --git a/manifests/init.pp b/manifests/init.pp index 12db61a6df..33bf773043 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -31,7 +31,8 @@ $purge_sources_list_d = false, $purge_preferences = false, $purge_preferences_d = false, - $update_timeout = undef + $update_timeout = undef, + $sources = undef ) { include apt::params @@ -136,4 +137,10 @@ anchor { 'apt::update': require => Class['apt::update'], } + + # manage sources if present + if $sources != undef { + validate_hash($sources) + create_resources('apt::source', $sources) + } } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000000..120b7e8239 --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' +describe 'apt' do + context 'with sources defined on valid osfamily' do + let :facts do + { :osfamily => 'Debian', + :lsbdistcodename => 'precise', + :lsbdistid => 'Debian', + } + end + let(:params) { { :sources => { + 'debian_unstable' => { + 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'release' => 'unstable', + 'repos' => 'main contrib non-free', + 'required_packages' => 'debian-keyring debian-archive-keyring', + 'key' => '55BE302B', + 'key_server' => 'subkeys.pgp.net', + 'pin' => '-10', + 'include_src' => true + }, + 'puppetlabs' => { + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'key' => '4BD6EC30', + 'key_server' => 'pgp.mit.edu', + } + } } } + + it { + should contain_file('debian_unstable.list').with({ + 'ensure' => 'present', + 'path' => '/etc/apt/sources.list.d/debian_unstable.list', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'notify' => 'Exec[apt_update]', + }) + } + + it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } + it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } + + it { + should contain_file('puppetlabs.list').with({ + 'ensure' => 'present', + 'path' => '/etc/apt/sources.list.d/puppetlabs.list', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'notify' => 'Exec[apt_update]', + }) + } + + it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } + it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) } + end +end From 440484d26ab9ccfda21ef247c87dc155a878ef2b Mon Sep 17 00:00:00 2001 From: Richard Pijnenburg Date: Thu, 27 Feb 2014 10:23:11 +0100 Subject: [PATCH 255/574] Add spec test to test for failure --- spec/classes/params_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index 2d3ec3c71a..5c43bc64d2 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -11,4 +11,17 @@ it "Should not contain any resources" do subject.resources.size.should == 4 end + + describe "With unknown lsbdistid" do + + let(:facts) { { :lsbdistid => 'CentOS' } } + let (:title) { 'my_package' } + + it do + expect { + should compile + }.to raise_error(Puppet::Error, /Unsupported lsbdistid/) + end + + end end From a649fbd2d81e28a3c2da23be439bb7c359d58f4e Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Sat, 1 Mar 2014 08:09:09 -0800 Subject: [PATCH 256/574] Add "Release Notes/Known Bugs" to Changelogdds "Release Notes/Known Bugs" to Changelog, updates file format to markdown, standardizes the format of previous entries Per a request to have initial release notes that specifically listed known issues for this PE 3.2 release, and barred by time constraints from automating a pull from open issues in JIRA, this commit adds a Release Note and Known Bug section to the Changelog for the imminent 3.2 release. As it will display on the Forge, updates file type to markdown and standardizes previous entries. --- CHANGELOG | 196 ---------------------------------------------- CHANGELOG.md | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+), 196 deletions(-) delete mode 100644 CHANGELOG create mode 100644 CHANGELOG.md diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 6ded6ea5a3..0000000000 --- a/CHANGELOG +++ /dev/null @@ -1,196 +0,0 @@ -2014-02-13 1.4.1 -Summary: -This is a bugfix release. - -Bugfixes: -- Fix apt::force unable to upgrade packages from releases other than its original -- Removed a few refeneces to aptitude instead of apt-get for portability -- Removed call to getparam() due to stdlib dependency -- Correct apt::source template when architecture is provided -- Retry package installs if apt is locked -- Use root to exec in apt::ppa -- Updated tests and converted acceptance tests to beaker - -2013-10-08 1.4.0 - -Summary: - -Minor bugfix and allow the timeout to be adjusted. - -Features: -- Add an `updates_timeout` to apt::params - -Fixes: -- Ensure apt::ppa can read a ppa removed by hand. - -Summary - -1.3.0 -===== - -Summary: - -This major feature in this release is the new apt::unattended_upgrades class, -allowing you to handle Ubuntu's unattended feature. This allows you to select -specific packages to automatically upgrade without any further user -involvement. - -In addition we extend our Wheezy support, add proxy support to apt:ppa and do -various cleanups and tweaks. - -Features: -- Add apt::unattended_upgrades support for Ubuntu. -- Add wheezy backports support. -- Use the geoDNS http.debian.net instead of the main debian ftp server. -- Add `options` parameter to apt::ppa in order to pass options to apt-add-repository command. -- Add proxy support for apt::ppa (uses proxy_host and proxy_port from apt). - -Bugfixes: -- Fix regsubst() calls to quote single letters (for future parser). -- Fix lint warnings and other misc cleanup. - -1.2.0 -===== - -Features: -- Add geppetto `.project` natures -- Add GH auto-release -- Add `apt::key::key_options` parameter -- Add complex pin support using distribution properties for `apt::pin` via new properties: - - `apt::pin::codename` - - `apt::pin::release_version` - - `apt::pin::component` - - `apt::pin::originator` - - `apt::pin::label` -- Add source architecture support to `apt::source::architecture` - -Bugfixes: -- Use apt-get instead of aptitude in apt::force -- Update default backports location -- Add dependency for required packages before apt-get update - - -1.1.1 -===== - -This is a bug fix release that resolves a number of issues: - -* By changing template variable usage, we remove the deprecation warnings - for Puppet 3.2.x -* Fixed proxy file removal, when proxy absent - -Some documentation, style and whitespaces changes were also merged. This -release also introduced proper rspec-puppet unit testing on Travis-CI to help -reduce regression. - -Thanks to all the community contributors below that made this patch possible. - -#### Detail Changes - -* fix minor comment type (Chris Rutter) -* whitespace fixes (Michael Moll) -* Update travis config file (William Van Hevelingen) -* Build all branches on travis (William Van Hevelingen) -* Standardize travis.yml on pattern introduced in stdlib (William Van Hevelingen) -* Updated content to conform to README best practices template (Lauren Rother) -* Fix apt::release example in readme (Brian Galey) -* add @ to variables in template (Peter Hoeg) -* Remove deprecation warnings for pin.pref.erb as well (Ken Barber) -* Update travis.yml to latest versions of puppet (Ken Barber) -* Fix proxy file removal (Scott Barber) -* Add spec test for removing proxy configuration (Dean Reilly) -* Fix apt::key listing longer than 8 chars (Benjamin Knofe) - - ---------------------------------------- - -1.1.0 -===== - -This release includes Ubuntu 12.10 (Quantal) support for PPAs. - ---------------------------------------- - -2012-05-25 Puppet Labs - 0.0.4 - * Fix ppa list filename when there is a period in the PPA name - * Add .pref extension to apt preferences files - * Allow preferences to be purged - * Extend pin support - -2012-05-04 Puppet Labs - 0.0.3 - * only invoke apt-get update once - * only install python-software-properties if a ppa is added - * support 'ensure => absent' for all defined types - * add apt::conf - * add apt::backports - * fixed Modulefile for module tool dependency resolution - * configure proxy before doing apt-get update - * use apt-get update instead of aptitude for apt::ppa - * add support to pin release - - -2012-03-26 Puppet Labs - 0.0.2 -41cedbb (#13261) Add real examples to smoke tests. -d159a78 (#13261) Add key.pp smoke test -7116c7a (#13261) Replace foo source with puppetlabs source -1ead0bf Ignore pkg directory. -9c13872 (#13289) Fix some more style violations -0ea4ffa (#13289) Change test scaffolding to use a module & manifest dir fixture path -a758247 (#13289) Clean up style violations and fix corresponding tests -99c3fd3 (#13289) Add puppet lint tests to Rakefile -5148cbf (#13125) Apt keys should be case insensitive -b9607a4 Convert apt::key to use anchors - -2012-03-07 Puppet Labs - 0.0.1 -d4fec56 Modify apt::source release parameter test -1132a07 (#12917) Add contributors to README -8cdaf85 (#12823) Add apt::key defined type and modify apt::source to use it -7c0d10b (#12809) $release should use $lsbdistcodename and fall back to manual input -be2cc3e (#12522) Adjust spec test for splitting purge -7dc60ae (#12522) Split purge option to spare sources.list -9059c4e Fix source specs to test all key permutations -8acb202 Add test for python-software-properties package -a4af11f Check if python-software-properties is defined before attempting to define it. -1dcbf3d Add tests for required_packages change -f3735d2 Allow duplicate $required_packages -74c8371 (#12430) Add tests for changes to apt module -97ebb2d Test two sources with the same key -1160bcd (#12526) Add ability to reverse apt { disable_keys => true } -2842d73 Add Modulefile to puppet-apt -c657742 Allow the use of the same key in multiple sources -8c27963 (#12522) Adding purge option to apt class -997c9fd (#12529) Add unit test for apt proxy settings -50f3cca (#12529) Add parameter to support setting a proxy for apt -d522877 (#12094) Replace chained .with_* with a hash -8cf1bd0 (#12094) Remove deprecated spec.opts file -2d688f4 (#12094) Add rspec-puppet tests for apt -0fb5f78 (#12094) Replace name with path in file resources -f759bc0 (#11953) Apt::force passes $version to aptitude -f71db53 (#11413) Add spec test for apt::force to verify changes to unless -2f5d317 (#11413) Update dpkg query used by apt::force -cf6caa1 (#10451) Add test coverage to apt::ppa -0dd697d include_src parameter in example; Whitespace cleanup -b662eb8 fix typos in "repositories" -1be7457 Fix (#10451) - apt::ppa fails to "apt-get update" when new PPA source is added -864302a Set the pin priority before adding the source (Fix #10449) -1de4e0a Refactored as per mlitteken -1af9a13 Added some crazy bash madness to check if the ppa is installed already. Otherwise the manifest tries to add it on every run! -52ca73e (#8720) Replace Apt::Ppa with Apt::Builddep -5c05fa0 added builddep command. -a11af50 added the ability to specify the content of a key -c42db0f Fixes ppa test. -77d2b0d reformatted whitespace to match recommended style of 2 space indentation. -27ebdfc ignore swap files. -377d58a added smoke tests for module. -18f614b reformatted apt::ppa according to recommended style. -d8a1e4e Created a params class to hold global data. -636ae85 Added two params for apt class -148fc73 Update LICENSE. -ed2d19e Support ability to add more than one PPA -420d537 Add call to apt-update after add-apt-repository in apt::ppa -945be77 Add package definition for python-software-properties -71fc425 Abs paths for all commands -9d51cd1 Adding LICENSE -71796e3 Heading fix in README -87777d8 Typo in README -f848bac First commit diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..baa3ad77da --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,216 @@ +##2014-03-04 - Supported Release +###Summary + +####Features + +####Bugfixes + +####Known Bugs + +* No known issues. + + + +##2014-02-13 1.4.1 +###Summary +This is a bugfix release. + +####Bugfixes +- Fix apt::force unable to upgrade packages from releases other than its original +- Removed a few refeneces to aptitude instead of apt-get for portability +- Removed call to getparam() due to stdlib dependency +- Correct apt::source template when architecture is provided +- Retry package installs if apt is locked +- Use root to exec in apt::ppa +- Updated tests and converted acceptance tests to beaker + +##2013-10-08 - Release 1.4.0 + +###Summary + +Minor bugfix and allow the timeout to be adjusted. + +####Features +- Add an `updates_timeout` to apt::params + +####Bugfixes +- Ensure apt::ppa can read a ppa removed by hand. + + +##2013-10-08 - Release 1.3.0 +###Summary + +This major feature in this release is the new apt::unattended_upgrades class, +allowing you to handle Ubuntu's unattended feature. This allows you to select +specific packages to automatically upgrade without any further user +involvement. + +In addition we extend our Wheezy support, add proxy support to apt:ppa and do +various cleanups and tweaks. + +####Features +- Add apt::unattended_upgrades support for Ubuntu. +- Add wheezy backports support. +- Use the geoDNS http.debian.net instead of the main debian ftp server. +- Add `options` parameter to apt::ppa in order to pass options to apt-add-repository command. +- Add proxy support for apt::ppa (uses proxy_host and proxy_port from apt). + +####Bugfixes +- Fix regsubst() calls to quote single letters (for future parser). +- Fix lint warnings and other misc cleanup. + + +##2013-07-03 - Release 1.2.0 + +####Features +- Add geppetto `.project` natures +- Add GH auto-release +- Add `apt::key::key_options` parameter +- Add complex pin support using distribution properties for `apt::pin` via new properties: + - `apt::pin::codename` + - `apt::pin::release_version` + - `apt::pin::component` + - `apt::pin::originator` + - `apt::pin::label` +- Add source architecture support to `apt::source::architecture` + +####Bugfixes +- Use apt-get instead of aptitude in apt::force +- Update default backports location +- Add dependency for required packages before apt-get update + + +##2013-06-02 - Release 1.1.1 +###Summary + +This is a bug fix release that resolves a number of issues: + +* By changing template variable usage, we remove the deprecation warnings + for Puppet 3.2.x +* Fixed proxy file removal, when proxy absent + +Some documentation, style and whitespaces changes were also merged. This +release also introduced proper rspec-puppet unit testing on Travis-CI to help +reduce regression. + +Thanks to all the community contributors below that made this patch possible. + +#### Detail Changes + +* fix minor comment type (Chris Rutter) +* whitespace fixes (Michael Moll) +* Update travis config file (William Van Hevelingen) +* Build all branches on travis (William Van Hevelingen) +* Standardize travis.yml on pattern introduced in stdlib (William Van Hevelingen) +* Updated content to conform to README best practices template (Lauren Rother) +* Fix apt::release example in readme (Brian Galey) +* add @ to variables in template (Peter Hoeg) +* Remove deprecation warnings for pin.pref.erb as well (Ken Barber) +* Update travis.yml to latest versions of puppet (Ken Barber) +* Fix proxy file removal (Scott Barber) +* Add spec test for removing proxy configuration (Dean Reilly) +* Fix apt::key listing longer than 8 chars (Benjamin Knofe) + + + + +## Release 1.1.0 +###Summary + +This release includes Ubuntu 12.10 (Quantal) support for PPAs. + +--- + +##2012-05-25 - Puppet Labs - Release 0.0.4 +###Summary + + * Fix ppa list filename when there is a period in the PPA name + * Add .pref extension to apt preferences files + * Allow preferences to be purged + * Extend pin support + + +##2012-05-04 - Puppet Labs - Release 0.0.3 +###Summary + + * only invoke apt-get update once + * only install python-software-properties if a ppa is added + * support 'ensure => absent' for all defined types + * add apt::conf + * add apt::backports + * fixed Modulefile for module tool dependency resolution + * configure proxy before doing apt-get update + * use apt-get update instead of aptitude for apt::ppa + * add support to pin release + + +##2012-03-26 - Puppet Labs - Release 0.0.2 +###Summary + +* 41cedbb (#13261) Add real examples to smoke tests. +* d159a78 (#13261) Add key.pp smoke test +* 7116c7a (#13261) Replace foo source with puppetlabs source +* 1ead0bf Ignore pkg directory. +* 9c13872 (#13289) Fix some more style violations +* 0ea4ffa (#13289) Change test scaffolding to use a module & manifest dir fixture path +* a758247 (#13289) Clean up style violations and fix corresponding tests +* 99c3fd3 (#13289) Add puppet lint tests to Rakefile +* 5148cbf (#13125) Apt keys should be case insensitive +* b9607a4 Convert apt::key to use anchors + + +##2012-03-07 - Puppet Labs - Release 0.0.1 +###Summary + +* d4fec56 Modify apt::source release parameter test +* 1132a07 (#12917) Add contributors to README +* 8cdaf85 (#12823) Add apt::key defined type and modify apt::source to use it +* 7c0d10b (#12809) $release should use $lsbdistcodename and fall back to manual input +* be2cc3e (#12522) Adjust spec test for splitting purge +* 7dc60ae (#12522) Split purge option to spare sources.list +* 9059c4e Fix source specs to test all key permutations +* 8acb202 Add test for python-software-properties package +* a4af11f Check if python-software-properties is defined before attempting to define it. +* 1dcbf3d Add tests for required_packages change +* f3735d2 Allow duplicate $required_packages +* 74c8371 (#12430) Add tests for changes to apt module +* 97ebb2d Test two sources with the same key +* 1160bcd (#12526) Add ability to reverse apt { disable_keys => true } +* 2842d73 Add Modulefile to puppet-apt +* c657742 Allow the use of the same key in multiple sources +* 8c27963 (#12522) Adding purge option to apt class +* 997c9fd (#12529) Add unit test for apt proxy settings +* 50f3cca (#12529) Add parameter to support setting a proxy for apt +* d522877 (#12094) Replace chained .with_* with a hash +* 8cf1bd0 (#12094) Remove deprecated spec.opts file +* 2d688f4 (#12094) Add rspec-puppet tests for apt +* 0fb5f78 (#12094) Replace name with path in file resources +* f759bc0 (#11953) Apt::force passes $version to aptitude +* f71db53 (#11413) Add spec test for apt::force to verify changes to unless +* 2f5d317 (#11413) Update dpkg query used by apt::force +* cf6caa1 (#10451) Add test coverage to apt::ppa +* 0dd697d include_src parameter in example; Whitespace cleanup +* b662eb8 fix typos in "repositories" +* 1be7457 Fix (#10451) - apt::ppa fails to "apt-get update" when new PPA source is added +* 864302a Set the pin priority before adding the source (Fix #10449) +* 1de4e0a Refactored as per mlitteken +* 1af9a13 Added some crazy bash madness to check if the ppa is installed already. Otherwise the manifest tries to add it on every run! +* 52ca73e (#8720) Replace Apt::Ppa with Apt::Builddep +* 5c05fa0 added builddep command. +* a11af50 added the ability to specify the content of a key +* c42db0f Fixes ppa test. +* 77d2b0d reformatted whitespace to match recommended style of 2 space indentation. +* 27ebdfc ignore swap files. +* 377d58a added smoke tests for module. +* 18f614b reformatted apt::ppa according to recommended style. +* d8a1e4e Created a params class to hold global data. +* 636ae85 Added two params for apt class +* 148fc73 Update LICENSE. +* ed2d19e Support ability to add more than one PPA +* 420d537 Add call to apt-update after add-apt-repository in apt::ppa +* 945be77 Add package definition for python-software-properties +* 71fc425 Abs paths for all commands +* 9d51cd1 Adding LICENSE +* 71796e3 Heading fix in README +* 87777d8 Typo in README +* f848bac First commit \ No newline at end of file From ab03a989df37df3660f0916519d0f78f7ab73a13 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Fri, 28 Feb 2014 15:34:08 +0000 Subject: [PATCH 257/574] Prepare metadata for supported module release. --- metadata.json | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/metadata.json b/metadata.json index ccb4458443..8122b5c3f6 100644 --- a/metadata.json +++ b/metadata.json @@ -1,26 +1,22 @@ { - "name": "puppetlabs/apt", - "version": "1.3.0", - "summary": "Apt key and source management", - "source": "git@github.com/puppetlabs/puppetlabs-apt.git", - "project_page": "http://github.com/puppetlabs/puppetlabs-apt", - "author": "Puppet Labs", - "license": "Apache-2.0", "operatingsystem_support": [ - "Debian", - "Ubuntu" + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04" + ] + } ], - "puppet_version": [ - 2.7, - 3.0, - 3.1, - 3.2, - 3.3 - ], - "dependencies": [ - { - "name": "puppetlabs/stdlib", - "version_requirement": ">= 2.2.1" - } + "requirements": [ + { "name": "pe", "version_requirement": "3.2.x" }, + { "name": "puppet", "version_requirement": "3.x" } ] } From 42d7c221786417358ab0d5b19b5875c764f5048f Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 3 Mar 2014 19:08:54 +0000 Subject: [PATCH 258/574] Prepare supported module 1.4.2 --- CHANGELOG.md | 10 ++++++++-- Modulefile | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index baa3ad77da..10503c9144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ -##2014-03-04 - Supported Release +##2014-03-04 - Supported Release 1.4.2 ###Summary +This is a supported release. This release tidies up 1.4.1 and re-enables +support for Ubuntu 10.04 + ####Features ####Bugfixes +- Fix apt:ppa to include the -y Ubuntu 10.04 requires. +- Documentation changes. +- Test fixups. ####Known Bugs @@ -213,4 +219,4 @@ This release includes Ubuntu 12.10 (Quantal) support for PPAs. * 9d51cd1 Adding LICENSE * 71796e3 Heading fix in README * 87777d8 Typo in README -* f848bac First commit \ No newline at end of file +* f848bac First commit diff --git a/Modulefile b/Modulefile index e44c27597e..40a87f4ef3 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.4.1' +version '1.4.2' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' From dc472717163d30a4463f687a577238ec2539601c Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 3 Mar 2014 21:39:10 +0000 Subject: [PATCH 259/574] Add back in missing fields to work around Puppet bug. --- metadata.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 8122b5c3f6..f1e8663059 100644 --- a/metadata.json +++ b/metadata.json @@ -1,4 +1,11 @@ { + "name": "puppetlabs-apt", + "version": "1.4.1", + "source": "https://github.com/puppetlabs/puppetlabs-apt", + "author": "Puppet Labs", + "license": "Apache-2.0", + "project_page": "https://github.com/puppetlabs/puppetlabs-apt", + "summary": "Puppet Labs Apt Module", "operatingsystem_support": [ { "operatingsystem": "Debian", @@ -18,5 +25,6 @@ "requirements": [ { "name": "pe", "version_requirement": "3.2.x" }, { "name": "puppet", "version_requirement": "3.x" } - ] + ], + "dependencies": [] } From 57903418909c3c3344a4c4fa41c054e954451227 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 20 Feb 2014 16:18:37 +0100 Subject: [PATCH 260/574] apt::key: Redo apt::key, make it use apt_key. Introducing a totally rewritten and tested apt::key. This commit also patches the spec's of apt::source because it was passing in data that is no longer allowed by the new validation rules in apt::key. It does its best to not touch any other specs and where we touch them only minimally to ensure that we're not introducing breaking changes. --- manifests/key.pp | 163 +++++++++------- manifests/source.pp | 8 +- spec/defines/key_spec.rb | 357 ++++++++++++++++++++++++++---------- spec/defines/source_spec.rb | 19 +- 4 files changed, 372 insertions(+), 175 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index c78bf658ce..9ccbfcb6bb 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -1,90 +1,121 @@ +# == Define: apt::key +# +# The apt::key defined type allows for keys to be added to apt's keyring +# which is used for package validation. This defined type uses the apt_key +# native type to manage keys. This is a simple wrapper around apt_key with +# a few safeguards in place. +# +# === Parameters +# +# [*key*] +# _default_: +$title+, the title/name of the resource +# +# Is a GPG key ID. This key ID is validated with a regex enforcing it +# to only contain valid hexadecimal characters, be precisely 8 or 16 +# characters long and optionally prefixed with 0x. +# +# [*ensure*] +# _default_: +present+ +# +# The state we want this key in, may be either one of: +# * +present+ +# * +absent+ +# +# [*key_content*] +# _default_: +undef+ +# +# This parameter can be used to pass in a GPG key as a +# string in case it cannot be fetched from a remote location +# and using a file resource is for other reasons inconvenient. +# +# [*key_source*] +# _default_: +undef+ +# +# This parameter can be used to pass in the location of a GPG +# key. This URI can take the form of a: +# * +URL+: ftp, http or https +# * +path+: absolute path to a file on the target system. +# +# [*key_server*] +# _default_: +undef+ +# +# The keyserver from where to fetch our GPG key. It defaults to +# undef which results in apt_key's default keyserver being used, +# currently +keyserver.ubuntu.com+. +# +# [*key_options*] +# _default_: +undef+ +# +# Additional options to pass on to `apt-key adv --keyserver-options`. define apt::key ( - $key = $title, - $ensure = present, - $key_content = false, - $key_source = false, - $key_server = 'keyserver.ubuntu.com', - $key_options = false + $key = $title, + $ensure = present, + $key_content = undef, + $key_source = undef, + $key_server = undef, + $key_options = undef, ) { - include apt::params - - $upkey = upcase($key) - # trim the key to the last 8 chars so we can match longer keys with apt-key list too - $trimmedkey = regsubst($upkey, '^.*(.{8})$', '\1') + validate_re($key, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z']) + validate_re($ensure, ['\Aabsent|present\Z',]) if $key_content { - $method = 'content' - } elsif $key_source { - $method = 'source' - } elsif $key_server { - $method = 'server' + validate_string($key_content) } - # This is a hash of the parts of the key definition that we care about. - # It is used as a unique identifier for this instance of apt::key. It gets - # hashed to ensure that the resource name doesn't end up being pages and - # pages (e.g. in the situation where key_content is specified). - $digest = sha1("${upkey}/${key_content}/${key_source}/${key_server}/") - - # Allow multiple ensure => present for the same key to account for many - # apt::source resources that all reference the same key. - case $ensure { - present: { - - anchor { "apt::key/${title}": } + if $key_source { + validate_re($key_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+']) + } - if defined(Exec["apt::key ${upkey} absent"]) { - fail("Cannot ensure Apt::Key[${upkey}] present; ${upkey} already ensured absent") - } + if $key_server { + if !is_domain_name($key_server) { + fail('$key_server must be a valid domain name') + } + } - if !defined(Anchor["apt::key ${upkey} present"]) { - anchor { "apt::key ${upkey} present": } - } + if $key_options { + validate_string($key_options) + } - if $key_options{ - $options_string = "--keyserver-options ${key_options}" - } - else{ - $options_string = '' + case $ensure { + present: { + if defined(Anchor["apt_key ${key} absent"]){ + fail("key with id ${key} already ensured as absent") } - if !defined(Exec[$digest]) { - $digest_command = $method ? { - 'content' => "echo '${key_content}' | /usr/bin/apt-key add -", - 'source' => "wget -q '${key_source}' -O- | apt-key add -", - 'server' => "apt-key adv --keyserver '${key_server}' ${options_string} --recv-keys '${upkey}'", - } - exec { $digest: - command => $digest_command, - path => '/bin:/usr/bin', - unless => "/usr/bin/apt-key list | /bin/grep '${trimmedkey}'", - logoutput => 'on_failure', - before => Anchor["apt::key ${upkey} present"], - } + if !defined(Anchor["apt_key ${key} present"]) { + apt_key { $title: + ensure => $ensure, + id => $key, + source => $key_source, + content => $key_content, + server => $key_server, + keyserver_options => $key_options, + } -> + anchor { "apt_key ${key} present": } } - - Anchor["apt::key ${upkey} present"] -> Anchor["apt::key/${title}"] - } - absent: { - if defined(Anchor["apt::key ${upkey} present"]) { - fail("Cannot ensure Apt::Key[${upkey}] absent; ${upkey} already ensured present") + absent: { + if defined(Anchor["apt_key ${key} present"]){ + fail("key with id ${key} already ensured as present") } - exec { "apt::key ${upkey} absent": - command => "apt-key del '${upkey}'", - path => '/bin:/usr/bin', - onlyif => "apt-key list | grep '${trimmedkey}'", - user => 'root', - group => 'root', - logoutput => 'on_failure', + if !defined(Anchor["apt_key ${key} absent"]){ + apt_key { $title: + ensure => $ensure, + id => $key, + source => $key_source, + content => $key_content, + server => $key_server, + keyserver_options => $key_options, + } -> + anchor { "apt_key ${key} absent": } } } default: { - fail "Invalid 'ensure' value '${ensure}' for aptkey" + fail "Invalid 'ensure' value '${ensure}' for apt::key" } } } diff --git a/manifests/source.pp b/manifests/source.pp index bc93ad9d57..196fc92586 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -8,10 +8,10 @@ $repos = 'main', $include_src = true, $required_packages = false, - $key = false, + $key = undef, $key_server = 'keyserver.ubuntu.com', - $key_content = false, - $key_source = false, + $key_content = undef, + $key_source = undef, $pin = false, $architecture = undef ) { @@ -69,7 +69,7 @@ } # We do not want to remove keys when the source is absent. - if ($key != false) and ($ensure == 'present') { + if $key and ($ensure == 'present') { apt::key { "Add key: ${key} from Apt::Source ${title}": ensure => present, key => $key, diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 4ba7b87eae..a85d1710b4 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -1,124 +1,285 @@ require 'spec_helper' + describe 'apt::key', :type => :define do let(:facts) { { :lsbdistid => 'Debian' } } + GPG_KEY_ID = '4BD6EC30' + let :title do - '8347A27F' + GPG_KEY_ID end - let :default_params do - { - :key => title, - :ensure => 'present', - :key_server => "keyserver.ubuntu.com", - :key_source => false, - :key_content => false - } - end + describe 'normal operation' do + describe 'default options' do + it 'contains the apt::key' do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + }) + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{title} present") + end + end + + describe 'title and key =>' do + let :title do + 'puppetlabs' + end + + let :params do { + :key => GPG_KEY_ID, + } end + + it 'contains the apt::key' do + should contain_apt__key(title).with({ + :key => GPG_KEY_ID, + :ensure => 'present', + }) + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => GPG_KEY_ID, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{GPG_KEY_ID} present") + end + end - [{}, - { - :ensure => 'absent' - }, - { - :ensure => 'random' - }, - { - :key_source => 'ftp://ftp.example.org/key', - }, - { - :key_content => 'deadbeef', - } - ].each do |param_set| - - let :param_hash do - param_hash = default_params.merge(param_set) - param_hash[:key].upcase! if param_hash[:key] - param_hash + describe 'ensure => absent' do + let :params do { + :ensure => 'absent', + } end + + it 'contains the apt::key' do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'absent', + }) + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'absent', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key absent anchor' do + should contain_anchor("apt_key #{title} absent") + end end - let :params do - param_set + describe 'key_content =>' do + let :params do { + :key_content => 'GPG key content', + } end + + it 'contains the apt::key' do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_content => params[:key_content], + }) + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'present', + :source => nil, + :server => nil, + :content => params[:key_content], + :keyserver_options => nil, + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{title} present") + end end - let :digest do - str = String.new - str << param_hash[:key].to_s << '/' - str << param_hash[:key_content].to_s << '/' - str << param_hash[:key_source].to_s << '/' - str << param_hash[:key_server].to_s << '/' - Digest::SHA1.hexdigest(str) + describe 'key_source =>' do + let :params do { + :key_source => 'http://apt.puppetlabs.com/pubkey.gpg', + } end + + it 'contains the apt::key' do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_source => params[:key_source], + }) + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'present', + :source => params[:key_source], + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{title} present") + end + end + + describe 'key_server =>' do + let :params do { + :key_server => 'pgp.mit.edu', + } end + + it 'contains the apt::key' do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_server => 'pgp.mit.edu', + }) + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'present', + :source => nil, + :server => params[:key_server], + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{title} present") + end end - describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do - - it { - if [:present, 'present', :absent, 'absent'].include? param_hash[:ensure] - should contain_apt__params - end - } - - it { - if [:present, 'present'].include? param_hash[:ensure] - should_not contain_exec("apt::key #{param_hash[:key]} absent") - should contain_anchor("apt::key #{param_hash[:key]} present") - should contain_exec(digest).with({ - "path" => "/bin:/usr/bin", - "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'" - }) - elsif [:absent, 'absent'].include? param_hash[:ensure] - should_not contain_anchor("apt::key #{param_hash[:key]} present") - should contain_exec("apt::key #{param_hash[:key]} absent").with({ - "path" => "/bin:/usr/bin", - "onlyif" => "apt-key list | grep '#{param_hash[:key]}'", - "command" => "apt-key del '#{param_hash[:key]}'" - }) - else - expect { should raise_error(Puppet::Error) } - end - } - - it { - if [:present, 'present'].include? param_hash[:ensure] - if param_hash[:key_content] - should contain_exec(digest).with({ - "command" => "echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -" - }) - elsif param_hash[:key_source] - should contain_exec(digest).with({ - "command" => "wget -q '#{param_hash[:key_source]}' -O- | apt-key add -" - }) - elsif param_hash[:key_server] - should contain_exec(digest).with({ - "command" => "apt-key adv --keyserver '#{param_hash[:key_server]}' --recv-keys '#{param_hash[:key]}'" - }) - end - end - } + describe 'key_options =>' do + let :params do { + :key_options => 'debug', + } end + it 'contains the apt::key' do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_options => 'debug', + }) + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => params[:key_options], + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{title} present") + end end end - [{ :ensure => 'present' }, { :ensure => 'absent' }].each do |param_set| - describe "should correctly handle duplicate definitions" do + describe 'validation' do + context 'invalid key' do + let :title do + 'Out of rum. Why? Why are we out of rum?' + end + it 'fails' do + expect { subject }.to raise_error(/does not match/) + end + end - let :pre_condition do - "apt::key { 'duplicate': key => '#{title}'; }" + context 'invalid source' do + let :params do { + :key_source => 'afp://puppetlabs.com/key.gpg', + } end + it 'fails' do + expect { subject }.to raise_error(/does not match/) end + end - let(:params) { param_set } + context 'invalid content' do + let :params do { + :key_content => [], + } end + it 'fails' do + expect { subject }.to raise_error(/is not a string/) + end + end - it { - if param_set[:ensure] == 'present' - should contain_anchor("apt::key #{title} present") - should contain_apt__key(title) - should contain_apt__key("duplicate") - elsif param_set[:ensure] == 'absent' - expect { should raise_error(Puppet::Error) } - end - } + context 'invalid server' do + let :params do { + :key_server => 'two bottles of rum', + } end + it 'fails' do + expect { subject }.to raise_error(/must be a valid domain name/) + end + end + context 'invalid keyserver_options' do + let :params do { + :key_options => {}, + } end + it 'fails' do + expect { subject }.to raise_error(/is not a string/) + end end end -end + describe 'duplication' do + context 'two apt::key resources for same key, different titles' do + let :pre_condition do + "apt::key { 'duplicate': key => #{title}, }" + end + it 'contains two apt::key resources' do + should contain_apt__key('duplicate').with({ + :key => title, + :ensure => 'present', + }) + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + }) + end + + it 'contains only a single apt_key' do + should contain_apt_key('duplicate').with({ + :id => title, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + should_not contain_apt_key(title) + end + end + + context 'two apt::key resources, different ensure' do + let :pre_condition do + "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }" + end + it 'informs the user of the impossibility' do + expect { subject }.to raise_error(/already ensured as absent/) + end + end + end +end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 9da8b235fe..34b394282f 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -1,6 +1,9 @@ require 'spec_helper' + describe 'apt::source', :type => :define do let(:facts) { { :lsbdistid => 'Debian' } } + GPG_KEY_ID = '4BD6EC30' + let :title do 'my_source' end @@ -14,7 +17,7 @@ :include_src => true, :required_packages => false, :key => false, - :key_server => 'keyserver.ubuntu.com', + :key_server => false, :key_content => false, :key_source => false, :pin => false @@ -28,15 +31,14 @@ :repos => 'security', :include_src => false, :required_packages => 'apache', - :key => 'key_name', + :key => GPG_KEY_ID, :key_server => 'keyserver.debian.com', :pin => '600', :key_content => 'ABCD1234' }, { - :key => 'key_name', + :key => GPG_KEY_ID, :key_server => 'keyserver.debian.com', - :key_content => false, }, { :ensure => 'absent', @@ -135,13 +137,16 @@ } it { + key_server = param_hash[:key_server] || nil + key_content = param_hash[:key_content] || nil + key_source = param_hash[:key_source] || nil if param_hash[:key] should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({ "key" => param_hash[:key], "ensure" => :present, - "key_server" => param_hash[:key_server], - "key_content" => param_hash[:key_content], - "key_source" => param_hash[:key_source], + "key_server" => key_server, + "key_content" => key_content, + "key_source" => key_source, "before" => "File[#{title}.list]" }) else From cba6bb4a42d28f452c4973beac9827da885d7107 Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Tue, 4 Mar 2014 12:46:27 -0800 Subject: [PATCH 261/574] Add Ubuntu Trusty It's in Beta now and has landed on the main mirrors. --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index b35bb1c8d9..4b863ac127 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,7 +21,7 @@ } 'ubuntu': { case $::lsbdistcodename { - 'hardy','maverick','natty','oneiric','precise': { + 'hardy','maverick','natty','oneiric','precise','trusty': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = '-y' } From 62ea527c3e8c479d5d65efa022545065d4222ed7 Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Tue, 4 Mar 2014 12:50:37 -0800 Subject: [PATCH 262/574] Remove hardy, maverick, natty They are not on the mirrors anymore. --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 4b863ac127..b5090e0e8c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,7 +21,7 @@ } 'ubuntu': { case $::lsbdistcodename { - 'hardy','maverick','natty','oneiric','precise','trusty': { + 'oneiric','precise','trusty': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = '-y' } From f110d4a366c9ab30ef79ddc5de36986bb8c9d21e Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Tue, 4 Mar 2014 12:51:32 -0800 Subject: [PATCH 263/574] Oneiric is available on the old-releases mirror --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index b5090e0e8c..5ef3ccd5c1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,7 +21,7 @@ } 'ubuntu': { case $::lsbdistcodename { - 'oneiric','precise','trusty': { + 'precise','trusty': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = '-y' } From 519babcfb68dc5e224ab8da4848220b6c69707c4 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Wed, 5 Mar 2014 10:13:42 +0100 Subject: [PATCH 264/574] apt::hold: Add a mechanism to hold a package. I am aware this can be done with `dpkg --set-selections`, `apt-mark` or `ensure => 'held'` on a package resource. The changes to the README include the full rationale for wanting another mechanism. --- README.md | 40 +++++++++++++++ manifests/hold.pp | 54 ++++++++++++++++++++ spec/defines/hold_spec.rb | 100 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 manifests/hold.pp create mode 100644 spec/defines/hold_spec.rb diff --git a/README.md b/README.md index 9c0e45cc36..6e2642f4c7 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,45 @@ If you wish to pin a number of packages you may specify the packages as a space delimited string using the `packages` attribute or pass in an array of package names. +### apt::hold + +When you wish to hold a package in Puppet is should be done by passing in +'held' as the ensure attribute to the package resource. However, a lot of +public modules do not take this into account and generally do not work well +with an ensure of 'held'. + +There is an additional issue that when Puppet is told to hold a package, it +will hold it at the current version installed, there is no way to tell it in +one go to install a specific version and then hold that version without using +an exec resource that wraps `dpkg --set-selections` or `apt-mark`. + +At first glance this could also be solved by just passing the version required +to the ensure attribute but that only means that Puppet will install that +version once it processes that package. It does not inform apt that we want +this package to be held. In other words; if another package somehow wants to +upgrade this one (because of a version requirement in a dependency), apt +should not allow it. + +In order to solve this you can use apt::hold. It's implemented by creating +a preferences file with a priority of 1001, meaning that under normal +circumstances this preference will always win. Because the priority is > 1000 +apt will interpret this as 'this should be the version installed and I am +allowed to downgrade the current package if needed'. + +With this you can now set a package's ensure attribute to 'latest' but still +get the version specified by apt::hold. You can do it like this: + + apt::hold { 'vim': + version => '2:7.3.547-7', + } + +Since you might just want to hold Vim at version 7.3 and not care about the +rest you can also pass in a version with a glob: + + apt::hold { 'vim': + version => '2:7.3.*', + } + ### apt::ppa Adds a ppa repository using `add-apt-repository`. @@ -238,3 +277,4 @@ A lot of great people have contributed to this module. A somewhat current list f * Spencer Krum * William Van Hevelingen * Zach Leslie +* Daniele Sluijters diff --git a/manifests/hold.pp b/manifests/hold.pp new file mode 100644 index 0000000000..c4016c6e34 --- /dev/null +++ b/manifests/hold.pp @@ -0,0 +1,54 @@ +# == Define apt::hold +# +# This defined type allows you to hold a package based on the version you +# require. It's implemented by dropping an apt preferences file pinning the +# package to the version you require. +# +# === Parameters +# +# [*version*] +# The version at which you wish to pin a package. +# +# This can either be the full version, such as 4:2.11.8.1-5, or +# a partial version, such as 4:2.11.* +# +# [*package*] +# _default_: +$title+, the title/name of the resource. +# +# Name of the package that apt is to hold. +# +# [*priority*] +# _default_: +1001+ +# +# The default priority of 1001 causes this preference to always win. By +# setting the priority to a number greater than 1000 apt will always install +# this version even if it means downgrading the currently installed version. +define apt::hold( + $version, + $ensure = 'present', + $package = $title, + $priority = 1001, +){ + + validate_string($title) + validate_re($ensure, ['^present|absent',]) + validate_string($package) + validate_string($version) + + if ! is_integer($priority) { + fail('$priority must be an integer') + } + + if $ensure == 'present' { + ::apt::pin { "hold ${package} at ${version}": + packages => $package, + version => $version, + priority => $priority, + } + } else { + ::apt::pin { "hold ${package} at ${version}": + ensure => 'absent', + } + } + +} diff --git a/spec/defines/hold_spec.rb b/spec/defines/hold_spec.rb new file mode 100644 index 0000000000..731e218d84 --- /dev/null +++ b/spec/defines/hold_spec.rb @@ -0,0 +1,100 @@ +require 'spec_helper' +describe 'apt::hold' do + let :facts do { + :osfamily => 'Debian', + :lsbdistid => 'Debian', + :lsbrelease => 'wheezy', + } end + + let :title do + 'vim' + end + + let :default_params do { + :version => '1.1.1', + } end + + describe 'default params' do + let :params do default_params end + + it 'creates an apt preferences file' do + should contain_apt__hold(title).with({ + :ensure => 'present', + :package => title, + :version => params[:version], + :priority => 1001, + }) + + should contain_apt__pin("hold #{title} at #{params[:version]}").with({ + :ensure => 'present', + :packages => title, + :version => params[:version], + :priority => 1001, + }) + end + end + + describe 'ensure => absent' do + let :params do default_params.merge({:ensure => 'absent',}) end + + it 'creates an apt preferences file' do + should contain_apt__hold(title).with({ + :ensure => params[:ensure], + }) + + should contain_apt__pin("hold #{title} at #{params[:version]}").with({ + :ensure => params[:ensure], + }) + end + end + + describe 'priority => 990' do + let :params do default_params.merge({:priority => 990,}) end + + it 'creates an apt preferences file' do + should contain_apt__hold(title).with({ + :ensure => 'present', + :package => title, + :version => params[:version], + :priority => params[:priority], + }) + + should contain_apt__pin("hold #{title} at #{params[:version]}").with({ + :ensure => 'present', + :packages => title, + :version => params[:version], + :priority => params[:priority], + }) + end + end + + describe 'validation' do + context 'version => {}' do + let :params do { :version => {}, } end + it 'should fail' do + expect { subject }.to raise_error(/is not a string/) + end + end + + context 'ensure => bananana' do + let :params do default_params.merge({:ensure => 'bananana',}) end + it 'should fail' do + expect { subject }.to raise_error(/does not match/) + end + end + + context 'package => []' do + let :params do default_params.merge({:package => [],}) end + it 'should fail' do + expect { subject }.to raise_error(/is not a string/) + end + end + + context 'priority => bananana' do + let :params do default_params.merge({:priority => 'bananana',}) end + it 'should fail' do + expect { subject }.to raise_error(/must be an integer/) + end + end + end +end From b2ae1cb08d54b87977dc370601fb662469b256f4 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Wed, 5 Mar 2014 15:02:06 +0100 Subject: [PATCH 265/574] Update the README about apt_key and apt::key. --- README.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c0e45cc36..e2271b847f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ Setup * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'. * system repositories * authentication keys -* wget (optional) ### Beginning with APT @@ -81,9 +80,31 @@ Forces a package to be installed from a specific release. This class is particu require => Apt::Source['debian_unstable'], } +### apt_key + +A native Puppet type and provider for managing GPG keys for APT is provided by +this module. + + apt_key { 'puppetlabs': + ensure => 'present', + id => '4BD6EC30', + } + +You can additionally set the following attributes: + + * `source`: HTTP, HTTPS or FTP location of a GPG key or path to a file on the + target host; + * `content`: Instead of pointing to a file, pass the key in as a string; + * `server`: The GPG key server to use. It defaults to *keyserver.ubuntu.com*; + * `keyserver_options`: Additional options to pass to `--keyserver`. + +Because it is a native type it can be used in and queried for with MCollective. + ### apt::key -Adds a key to the list of keys used by APT to authenticate packages. +Adds a key to the list of keys used by APT to authenticate packages. This type +uses the aforementioned `apt_key` native type. As such it no longer requires +the wget command that the old implementation depended on. apt::key { 'puppetlabs': key => '4BD6EC30', @@ -95,8 +116,6 @@ Adds a key to the list of keys used by APT to authenticate packages. key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', } -Note that use of `key_source` requires wget to be installed and working. - ### apt::pin Adds an apt pin for a certain release. From 722c4198259bfab2f99a40e2f28583ffb42c91e3 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 5 Mar 2014 09:14:39 -0800 Subject: [PATCH 266/574] Remove autorelease --- .travis.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6cfda6506..5a26d90806 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ branches: language: ruby bundler_args: --without development script: bundle exec rake spec SPEC_OPTS='--format documentation' -after_success: - - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release - - .forge-release/publish rvm: - 1.8.7 - 1.9.3 @@ -19,12 +16,6 @@ env: - PUPPET_GEM_VERSION="~> 3.2.0" - PUPPET_GEM_VERSION="~> 3.3.0" - PUPPET_GEM_VERSION="~> 3.4.0" - global: - - PUBLISHER_LOGIN=puppetlabs - - secure: |- - ipB/CV1rVSTXU9ZDuzrFOlzJrRmJob36tKns2xszuH4r9s5P9qivNAngRGdV - msb69xvOlzQykM0WRF+4kJ6TZ7AbMiDI+VZ8GDtsRaU5/q3BpsvFe8aato+6 - QeyFtBG62OsosTEhGws4mqiFsPDu3dHlakuJc9zevlTuhNwbKSs= matrix: fast_finish: true exclude: From b560fa265f12435d6a262f715dd2d885bf067e14 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Wed, 5 Mar 2014 16:12:04 +0100 Subject: [PATCH 267/574] pin: Replace invalid chars with _ in file names. This needs to be merged for #259 to work. --- manifests/pin.pp | 12 +++++++++++- spec/defines/pin_spec.rb | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 9cb4a8e798..0d4d742529 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -68,7 +68,17 @@ '' => "${preferences_d}/${name}.pref", default => "${preferences_d}/${order}-${name}.pref", } - file { "${name}.pref": + + # According to man 5 apt_preferences: + # The files have either no or "pref" as filename extension + # and only contain alphanumeric, hyphen (-), underscore (_) and period + # (.) characters. Otherwise APT will print a notice that it has ignored a + # file, unless that file matches a pattern in the + # Dir::Ignore-Files-Silently configuration list - in which case it will + # be silently ignored. + $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') + + file { "${file_name}.pref": ensure => $ensure, path => $path, owner => root, diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index f1ca43733b..6438e8cbee 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -105,4 +105,16 @@ } end end + + describe 'resource title with invalid chars' do + context 'spaces' do + let(:title) { 'oh my god this is not valid' } + it { should contain_file('oh_my_god_this_is_not_valid.pref') } + end + + context '#$&*$' do + let(:title) { 'so && many $* invalid @! things' } + it { should contain_file('so____many____invalid____things.pref') } + end + end end From 824da679d4f1818d4c30a54908a9c24623c31900 Mon Sep 17 00:00:00 2001 From: Ian Unruh Date: Wed, 5 Mar 2014 15:59:21 -0600 Subject: [PATCH 268/574] Added retry to update operation --- manifests/init.pp | 1 + manifests/update.pp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index e4e43b1787..d26a8a2d43 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -32,6 +32,7 @@ $purge_preferences = false, $purge_preferences_d = false, $update_timeout = undef, + $update_tries = undef, $sources = undef ) { diff --git a/manifests/update.pp b/manifests/update.pp index ce0b78fbdd..725bb3bea6 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -6,5 +6,7 @@ logoutput => 'on_failure', refreshonly => true, timeout => $apt::update_timeout, + tries => $apt::update_tries, + try_sleep => 1 } } From 7b932be82ca05e667e0e3cfc2f162b226183afb7 Mon Sep 17 00:00:00 2001 From: Ian Unruh Date: Wed, 5 Mar 2014 16:01:37 -0600 Subject: [PATCH 269/574] Updated documentation --- manifests/init.pp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index d26a8a2d43..7964eb7c08 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,6 +14,9 @@ # to true, Puppet will purge all unmanaged entries from sources.list.d # update_timeout - Overrides the exec timeout in seconds for apt-get update. # If not set defaults to Exec's default (300) +# update_tries - Number of times that `apt-get update` will be tried. Use this +# to work around transient DNS and HTTP errors. By default, the command +# will only be run once. # # Actions: # From 4d0bf7cbab1fc9c9fd0ff174315e69262cfe5f68 Mon Sep 17 00:00:00 2001 From: Richard Pijnenburg Date: Fri, 7 Mar 2014 16:03:44 +0100 Subject: [PATCH 270/574] Fail early when its not debian or ubuntu ( or debian like distro ) --- manifests/init.pp | 4 ++++ spec/acceptance/unsupported_spec.rb | 2 +- spec/classes/apt_spec.rb | 2 +- spec/classes/debian_testing_spec.rb | 2 +- spec/classes/debian_unstable_spec.rb | 2 +- spec/classes/params_spec.rb | 2 +- spec/defines/ppa_spec.rb | 4 +++- 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 12db61a6df..ad3f5e06e0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -34,6 +34,10 @@ $update_timeout = undef ) { + if $::osfamily != 'Debian' { + fail('This module only works on Debian or derivatives like Ubuntu') + } + include apt::params include apt::update diff --git a/spec/acceptance/unsupported_spec.rb b/spec/acceptance/unsupported_spec.rb index 08dca76b84..3f7468530b 100644 --- a/spec/acceptance/unsupported_spec.rb +++ b/spec/acceptance/unsupported_spec.rb @@ -5,6 +5,6 @@ pp = <<-EOS class { 'apt': } EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported/i) + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/This module only works on Debian or derivatives like Ubuntu/i) end end diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 0da7d32db0..8bace9b549 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt', :type => :class do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let :default_params do { :disable_keys => :undef, diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb index 20487333f6..6e0332652f 100644 --- a/spec/classes/debian_testing_spec.rb +++ b/spec/classes/debian_testing_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::debian::testing', :type => :class do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } it { should contain_apt__source("debian_testing").with({ "location" => "http://debian.mirror.iweb.ca/debian/", diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb index 70724f90bd..8477a39e58 100644 --- a/spec/classes/debian_unstable_spec.rb +++ b/spec/classes/debian_unstable_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::debian::unstable', :type => :class do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } it { should contain_apt__source("debian_unstable").with({ "location" => "http://debian.mirror.iweb.ca/debian/", diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index 5c43bc64d2..aa330bb987 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::params', :type => :class do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let (:title) { 'my_package' } it { should contain_apt__params } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 0c3bd75ed7..6944f9b2df 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -23,6 +23,7 @@ :lsbdistcodename => platform[:lsbdistcodename], :operatingsystem => platform[:operatingsystem], :lsbdistid => platform[:lsbdistid], + :osfamily => 'Debian', } end let :release do @@ -134,7 +135,8 @@ let :facts do {:lsbdistcodename => '#{platform[:lsbdistcodename]}', :operatingsystem => 'Ubuntu', - :lsbdistid => 'Ubuntu'} + :lsbdistid => 'Ubuntu', + :osfamily => 'Debian'} end let(:title) { "ppa" } let(:release) { "#{platform[:lsbdistcodename]}" } From 411ef1b0db1976590382ce2bd8878202a05d0274 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 7 Mar 2014 16:10:54 +0100 Subject: [PATCH 271/574] Remove ancient Puppet versions from matrix. With PE 3.2 out of the door shipping with 3.4.3 I think it's time to shrink the matrix and get rid of 3.1 and 3.2. PE 3.x customers should just upgrade to 3.2, OS users should really be on 3.3+ by now. --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a26d90806..aec1f0aecb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,6 @@ rvm: env: matrix: - PUPPET_GEM_VERSION="~> 2.7.0" - - PUPPET_GEM_VERSION="~> 3.1.0" - - PUPPET_GEM_VERSION="~> 3.2.0" - PUPPET_GEM_VERSION="~> 3.3.0" - PUPPET_GEM_VERSION="~> 3.4.0" matrix: @@ -23,7 +21,5 @@ matrix: env: PUPPET_GEM_VERSION="~> 2.7.0" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 2.7.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.1.0" notifications: email: false From e299f66262bed40d37fdb904896edff41a653be8 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 7 Mar 2014 18:32:37 +0100 Subject: [PATCH 272/574] Remove testing for Puppet 2.7 compatibility. With official supported modules now being a thing and having a version of the APT module to which we will backport fixes until the next major release it is time to say goodbye to Puppet 2.7. So long and thanks for all the fish. --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index aec1f0aecb..c4bb092a71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,15 +11,9 @@ rvm: - 2.0.0 env: matrix: - - PUPPET_GEM_VERSION="~> 2.7.0" - PUPPET_GEM_VERSION="~> 3.3.0" - PUPPET_GEM_VERSION="~> 3.4.0" matrix: fast_finish: true - exclude: - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 2.7.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 2.7.0" notifications: email: false From 7d058e95d88faf8dac2a088f5d323631b6341a53 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 13 Mar 2014 20:03:09 +0000 Subject: [PATCH 273/574] Fix typo. Group was incorrectly spelt, but because the file was absent this should have resulted in a noop in practice. --- manifests/ppa.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index f2629809e0..95a3dae2a3 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -69,7 +69,7 @@ ensure => 'absent', mode => '0644', owner => 'root', - gruop => 'root', + group => 'root', notify => Exec['apt_update'], } } From cc1f9c8bb900ed3da48e794a2185c9e17b4df9a4 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sun, 16 Mar 2014 12:44:05 +0100 Subject: [PATCH 274/574] Use File.expand_path with require. For some reason, even though our own tests pass with `require puppet_x/apt_key/patch_openuri` every other module that depends on puppetlabs-apt is now breaking in tests claiming it can't load that module. Somewhere along the way something is probably messing with LOADPATH causing this to trip up. This should fix the issues for everyone. This commit affects: * puppetlabs/puppetlabs-apt#229 * puppetlabs/puppetlabs-postgresql#391 --- lib/puppet/provider/apt_key/apt_key.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 51791d0248..f8d40728b0 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -6,7 +6,8 @@ if RUBY_VERSION == '1.8.7' # Mothers cry, puppies die and Ruby 1.8.7's open-uri needs to be # monkeypatched to support passing in :ftp_passive_mode. - require 'puppet_x/apt_key/patch_openuri' + require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', + 'puppet_x', 'apt_key', 'patch_openuri.rb')) OpenURI::Options.merge!({:ftp_active_mode => false,}) end From f546dc2d37ffd2a626b2a0ce6f761dacb92c2723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20DROUET?= Date: Thu, 20 Mar 2014 23:09:07 +0100 Subject: [PATCH 275/574] Fix typo in ppa.pp --- manifests/ppa.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 8a3b6f5f59..ab79b94179 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -69,7 +69,7 @@ ensure => 'absent', mode => '0644', owner => 'root', - gruop => 'root', + group => 'root', notify => Exec['apt_update'], } } From 68ef68363d42a1e16fd2697d36d0fd466d15f73e Mon Sep 17 00:00:00 2001 From: William Van Hevelingen Date: Wed, 26 Mar 2014 10:51:29 -0700 Subject: [PATCH 276/574] Pin Rake to 10.1.1 in Gemfile The latest Rake update requires Ruby >= 1.9. This update fixes the failing 1.8.7 tests by pinning Rake to the last supported version on ruby 1.8.7. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1e359d07b5..1af60fca0d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :development, :test do - gem 'rake', :require => false + gem 'rake', '10.1.1', :require => false gem 'pry', :require => false gem 'rspec-puppet', :require => false gem 'puppet-lint', :require => false From ed52e513db21eca180c4ac80cce0cfe116549653 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Wed, 26 Mar 2014 17:13:08 +0100 Subject: [PATCH 277/574] backports: Allow setting a custom priority. The module used to always pin backports to a priority of 200. This default is still retained but is now configurable. Additionally the default is now an Integer, not a 'quoted Integer' and the tests have been updated to reflect this. This matters for future parser as it will now kick people if they pass in a stringified integer as priority. --- README.md | 4 ++++ manifests/backports.pp | 17 ++++++++++++--- spec/acceptance/backports_spec.rb | 14 ++++++++++++ spec/classes/backports_spec.rb | 36 ++++++++++++++++++++++++++++--- 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 581277bde0..20c465dbfa 100644 --- a/README.md +++ b/README.md @@ -273,6 +273,10 @@ Implementation Adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined behavior (read: universe exploding). +By default this class drops a Pin-file for Backports pinning it to a priority of 200, lower than the normal Debian archive which gets a priority of 500 to ensure your packages with `ensure => latest` don't get magically upgraded from Backports without your explicit say-so. + +If you raise the priority through the `pin_priority` parameter to *500*, identical to the rest of the Debian mirrors, normal policy goes into effect and the newest version wins/becomes the candidate apt will want to install or upgrade to. This means that if a package is available from Backports it and its dependencies will be pulled in from Backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. + Limitations ----------- diff --git a/manifests/backports.pp b/manifests/backports.pp index 9cfa1c0113..eafa50692e 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -6,6 +6,12 @@ # The ubuntu/debian release name. Defaults to $lsbdistcodename. Setting this # manually can cause undefined behavior. (Read: universe exploding) # +# [*pin_priority*] +# _default_: 200 +# +# The priority that should be awarded by default to all packages coming from +# the Debian Backports project. +# # == Examples # # include apt::backports @@ -23,10 +29,15 @@ # # Copyright 2011 Puppet Labs Inc, unless otherwise noted. class apt::backports( - $release = $::lsbdistcodename, - $location = $apt::params::backports_location + $release = $::lsbdistcodename, + $location = $::apt::params::backports_location, + $pin_priority = 200, ) inherits apt::params { + if ! is_integer($pin_priority) { + fail('$pin_priority must be an integer') + } + $release_real = downcase($release) $key = $::lsbdistid ? { 'debian' => '46925553', @@ -43,6 +54,6 @@ repos => $repos, key => $key, key_server => 'pgp.mit.edu', - pin => '200', + pin => $pin_priority, } } diff --git a/spec/acceptance/backports_spec.rb b/spec/acceptance/backports_spec.rb index 6d3f7f0e68..78f21fd588 100644 --- a/spec/acceptance/backports_spec.rb +++ b/spec/acceptance/backports_spec.rb @@ -49,6 +49,20 @@ class { 'apt::backports': release => 'precise', location => 'http://localhost/ub end end + context 'pin_priority' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt::backports': pin_priority => 500, } + EOS + + apply_manifest(pp, :catch_failures => true) + end + describe file('/etc/apt/preferences.d/backports.pref') do + it { should be_file } + it { should contain "Pin-Priority: 500" } + end + end + context 'reset' do it 'deletes backport files' do shell('rm -rf /etc/apt/sources.list.d/backports.list') diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb index 98ad873af5..2f67aa4bc0 100644 --- a/spec/classes/backports_spec.rb +++ b/spec/classes/backports_spec.rb @@ -1,6 +1,36 @@ require 'spec_helper' describe 'apt::backports', :type => :class do + describe 'when asigning a custom priority to backports' do + let :facts do + { + 'lsbdistcodename' => 'Karmic', + 'lsbdistid' => 'Ubuntu' + } + end + + context 'integer priority' do + let :params do { :pin_priority => 500 } end + + it { should contain_apt__source('backports').with({ + 'location' => 'http://old-releases.ubuntu.com/ubuntu', + 'release' => 'karmic-backports', + 'repos' => 'main universe multiverse restricted', + 'key' => '437D05B5', + 'key_server' => 'pgp.mit.edu', + 'pin' => 500, + }) + } + end + + context 'invalid priority' do + let :params do { :pin_priority => 'banana' } end + it 'should fail' do + expect { subject }.to raise_error(/must be an integer/) + end + end + end + describe 'when turning on backports for ubuntu karmic' do let :facts do @@ -16,7 +46,7 @@ 'repos' => 'main universe multiverse restricted', 'key' => '437D05B5', 'key_server' => 'pgp.mit.edu', - 'pin' => '200', + 'pin' => 200, }) } end @@ -36,7 +66,7 @@ 'repos' => 'main contrib non-free', 'key' => '46925553', 'key_server' => 'pgp.mit.edu', - 'pin' => '200', + 'pin' => 200, }) } end @@ -64,7 +94,7 @@ 'repos' => 'main contrib non-free', 'key' => '46925553', 'key_server' => 'pgp.mit.edu', - 'pin' => '200', + 'pin' => 200, }) } end From eaebe2f82d6b9f27be5f5d5d8258fafad230af2a Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 27 Mar 2014 13:51:08 +0100 Subject: [PATCH 278/574] unattended_upgrades: Fix matching security archive The default configuration we were writing for Debian was only working for Squeeze, from Wheezy and onwards this wasn't working anymore. This has to do with the fact that we should now be using Origins-Pattern according to the unattended-upgrades docs. However, Ubuntu didn't entirely get with the program yet... This change reflects the defaults that unattended-upgrade installs on every platform we support. In order to do so the unattended-upgrades Debian archive for Squeeze, Wheezy, Lucid, Precise and Trusty were downloaded and the default /etc/apt/apt.conf.d/50unattended-upgrades checked for its content with regard to using Allow-Origins or Origins-Pattern. Fixes #277 --- manifests/params.pp | 22 ++++-- manifests/unattended_upgrades.pp | 46 +++++------ spec/classes/unattended_upgrades_spec.rb | 98 ++++++++++++++++++++++-- templates/50unattended-upgrades.erb | 4 + 4 files changed, 135 insertions(+), 35 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index d23b2db071..2f6c7238c2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -10,28 +10,40 @@ case $::lsbdistcodename { 'squeeze': { $backports_location = 'http://backports.debian.org/debian-backports' + $legacy_origin = true + $origins = ['${distro_id} ${distro_codename}-security'] } 'wheezy': { $backports_location = 'http://ftp.debian.org/debian/' + $legacy_origin = false + $origins = ['origin=Debian,archive=stable,label=Debian-Security'] } default: { $backports_location = 'http://http.debian.net/debian/' + $legacy_origin = false + $origins = ['origin=Debian,archive=stable,label=Debian-Security'] } } } 'ubuntu': { case $::lsbdistcodename { - 'precise','trusty': { + 'lucid': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' - $ppa_options = '-y' + $ppa_options = undef + $legacy_origin = true + $origins = ['${distro_id} ${distro_codename}-security'] } - 'lucid': { + 'precise', 'trusty': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' - $ppa_options = undef + $ppa_options = '-y' + $legacy_origin = true + $origins = ['${distro_id}:${distro_codename}-security'] } default: { $backports_location = 'http://old-releases.ubuntu.com/ubuntu' - $ppa_options = '-y' + $ppa_options = '-y' + $legacy_origin = true + $origins = ['${distro_id}:${distro_codename}-security'] } } } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index b0bd8ab1e0..c57a9ee7f5 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -14,30 +14,29 @@ # file and in /etc/cron.daily/apt # class apt::unattended_upgrades ( - $origins = ['${distro_id}:${distro_codename}-security'], - $blacklist = [], - $update = "1", - $download = "1", - $upgrade = "1", - $autoclean = "7", - $auto_fix = true, - $minimal_steps = false, + $origins = $::apt::params::origins, + $blacklist = [], + $update = "1", + $download = "1", + $upgrade = "1", + $autoclean = "7", + $auto_fix = true, + $minimal_steps = false, $install_on_shutdown = false, - $mail_to = "NONE", - $mail_only_on_error = false, - $remove_unused = true, - $auto_reboot = false, - $dl_limit = "NONE", - $enable = "1", - $backup_interval = "0", - $backup_level = "3", - $max_age = "0", - $min_age = "0", - $max_size = "0", - $download_delta = "0", - $verbose = "0", -) { - include apt::params + $mail_to = "NONE", + $mail_only_on_error = false, + $remove_unused = true, + $auto_reboot = false, + $dl_limit = "NONE", + $enable = "1", + $backup_interval = "0", + $backup_level = "3", + $max_age = "0", + $min_age = "0", + $max_size = "0", + $download_delta = "0", + $verbose = "0", +) inherits ::apt::params { validate_bool( $auto_fix, @@ -47,6 +46,7 @@ $remove_unused, $auto_reboot ) + validate_array($origins) package { 'unattended-upgrades': ensure => present, diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index f5cad53a5b..25a1f7aed3 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -25,16 +25,100 @@ } describe "origins" do - describe "with param defaults" do - let(:params) {{ }} - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\$\{distro_id\}:\$\{distro_codename\}-security";\n\};$/) } + describe 'on Debian' do + default_facts = { :lsbdistid => 'Debian' } + context 'defaults' do + let :facts do default_facts end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Origins-Pattern/ + ).with_content( + /"origin=Debian,archive=stable,label=Debian-Security";/ + ) + } + end + context 'defaults with custom origin' do + let :facts do default_facts end + let :params do { :origins => ['bananana']} end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Origins-Pattern/ + ).with_content( + /"bananana";/ + ) + } + end + context 'defaults with invalid origin' do + let :facts do default_facts end + let :params do { :origins => 'bananana'} end + it { + expect {subject}.to raise_error(/is not an Array/) + } + end + context 'squeeze' do + let :facts do default_facts.merge({:lsbdistcodename => 'squeeze'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id} \${distro_codename}-security";/ + ) + } + end + context 'wheezy' do + let :facts do default_facts.merge({:lsbdistcodename => 'wheezy'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Origins-Pattern/ + ).with_content( + /"origin=Debian,archive=stable,label=Debian-Security";/ + ) + } + end end - describe "with origins => ['ubuntu:precise-security']" do - let :params do - { :origins => ['ubuntu:precise-security'] } + describe 'on Ubuntu' do + default_facts = { :lsbdistid => 'Ubuntu' } + context 'default' do + let :facts do default_facts end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id}\:\${distro_codename}-security";/ + ) + } + end + context 'lucid' do + let :facts do default_facts.merge({:lsbdistcodename => 'lucid'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id} \${distro_codename}-security";/ + ) + } + end + context 'precise' do + let :facts do default_facts.merge({:lsbdistcodename => 'precise'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id}\:\${distro_codename}-security";/ + ) + } + end + context 'trusty' do + let :facts do default_facts.merge({:lsbdistcodename => 'trusty'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id}\:\${distro_codename}-security";/ + ) + } end - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } end end diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb index 4df0f74401..1177922de0 100644 --- a/templates/50unattended-upgrades.erb +++ b/templates/50unattended-upgrades.erb @@ -1,5 +1,9 @@ // Automatically upgrade packages from these (origin:archive) pairs +<%- if @legacy_origin -%> Unattended-Upgrade::Allowed-Origins { +<%- else -%> +Unattended-Upgrade::Origins-Pattern { +<%- end -%> <% @origins.each do |origin| -%> "<%= origin %>"; <% end -%> From 553611b16ba41f72ad173bff36477a720a36524b Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 27 Mar 2014 16:40:36 +0000 Subject: [PATCH 279/574] Small patch to fix the spacing that makes lint fail. --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 517391535a..85055c8119 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -151,7 +151,7 @@ # manage sources if present if $sources != undef { - validate_hash($sources) - create_resources('apt::source', $sources) + validate_hash($sources) + create_resources('apt::source', $sources) } } From 9f59f1b33a4a8fd1a62d0b3f682d8592eefb4659 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 28 Mar 2014 08:47:19 +0100 Subject: [PATCH 280/574] pin: Fix the template. In APT preferences files the only allowed comments are lines that start with `Explanation:`, commented lines that start with a # trigger a myriad of interesting bugs. This is considered a feature of APT. Because we're only ever writing a single file at a time with only a # comment at the top we were getting away with this but it shouldn't be there in the first place. --- spec/defines/pin_spec.rb | 18 +++++++++--------- templates/pin.pref.erb | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 6438e8cbee..d79462cd48 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -15,14 +15,14 @@ [ { :params => {}, - :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n" + :content => "Explanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n" }, { :params => { :packages => 'apache', :priority => '1' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" + :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" }, { :params => { @@ -30,7 +30,7 @@ :packages => 'apache', :priority => '1' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" + :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" }, { :params => { @@ -38,7 +38,7 @@ :packages => 'apache', :priority => '1' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" + :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" }, { :params => { @@ -46,7 +46,7 @@ :priority => '1', :release => 'my_newpin' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n" + :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n" }, { :params => { @@ -54,14 +54,14 @@ :priority => '1', :version => '2.2.16*' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n" + :content => "Explanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n" }, { :params => { :priority => '1', :origin => 'ftp.de.debian.org' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n" + :content => "Explanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n" }, { :params => { @@ -74,13 +74,13 @@ :originator => 'Debian', :label => 'Debian' }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n" + :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n" }, { :params => { :packages => ['apache', 'ntop'], }, - :content => "# my_pin\nExplanation: : my_pin\nPackage: apache ntop\nPin: release a=my_pin\nPin-Priority: 0\n" + :content => "Explanation: : my_pin\nPackage: apache ntop\nPin: release a=my_pin\nPin-Priority: 0\n" }, ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb index a19e2536fc..26b2516c47 100644 --- a/templates/pin.pref.erb +++ b/templates/pin.pref.erb @@ -15,7 +15,6 @@ elsif @origin.length > 0 @pin = "origin #{@origin}" end -%> -# <%= @name %> Explanation: <%= @explanation %> Package: <%= @packages_string %> Pin: <%= @pin %> From 13788395e66b524d3a63f393876ff830218843ea Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 28 Mar 2014 08:49:18 +0100 Subject: [PATCH 281/574] pin: caller_module_name is not a topscope variable --- manifests/pin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 0d4d742529..2563fc4681 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -3,7 +3,7 @@ define apt::pin( $ensure = present, - $explanation = "${::caller_module_name}: ${name}", + $explanation = "${caller_module_name}: ${name}", $order = '', $packages = '*', $priority = 0, From fefd53036259692fb33e00b89f4ac77ccb96de50 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Wed, 2 Apr 2014 11:17:04 +0200 Subject: [PATCH 282/574] unattended-upgrades: Fix origins for Squeeze. Because Squeeze is now oldstable we need to add an oldstable line too otherwise security updates won't be picked up. This is still because we can't match on codename. --- manifests/params.pp | 3 ++- spec/classes/unattended_upgrades_spec.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 2f6c7238c2..4e974ba48b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,7 +11,8 @@ 'squeeze': { $backports_location = 'http://backports.debian.org/debian-backports' $legacy_origin = true - $origins = ['${distro_id} ${distro_codename}-security'] + $origins = ['${distro_id} oldstable', + '${distro_id} ${distro_codename}-security'] } 'wheezy': { $backports_location = 'http://ftp.debian.org/debian/' diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 25a1f7aed3..a2fb48b126 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -62,6 +62,8 @@ /^Unattended-Upgrade::Allowed-Origins/ ).with_content( /"\${distro_id} \${distro_codename}-security";/ + ).with_content( + /"\${distro_id} oldstable";/ ) } end From d7da1cef383663bb2ecee3d8afa612aea74219f7 Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Mon, 7 Apr 2014 10:56:20 -0700 Subject: [PATCH 283/574] Add security warning re: short keys --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ec8b4c5e49..7a4e0dfb36 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,6 @@ apt [![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-apt.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-apt) -## Description - -Provides helpful definitions for dealing with Apt. - -======= - Overview -------- @@ -19,6 +13,8 @@ Module Description APT automates obtaining and installing software packages on \*nix systems. +***Note:** While this module allows the use of short keys, we STRONGLY RECOMMEND that you DO NOT USE short keys, as they pose a serious security issue in that they open you up to collision attacks.* + Setup ----- From c230e21c1d27c0062720255eab5cbfa60e3aa9fd Mon Sep 17 00:00:00 2001 From: Lauren Rother Date: Mon, 7 Apr 2014 10:56:20 -0700 Subject: [PATCH 284/574] Add security warning re: short keys (cherry picked from commit d7da1cef383663bb2ecee3d8afa612aea74219f7) --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ec8b4c5e49..7a4e0dfb36 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,6 @@ apt [![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-apt.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-apt) -## Description - -Provides helpful definitions for dealing with Apt. - -======= - Overview -------- @@ -19,6 +13,8 @@ Module Description APT automates obtaining and installing software packages on \*nix systems. +***Note:** While this module allows the use of short keys, we STRONGLY RECOMMEND that you DO NOT USE short keys, as they pose a serious security issue in that they open you up to collision attacks.* + Setup ----- From 9e789255c84eec71727ff1dfb05cec63258ac0d1 Mon Sep 17 00:00:00 2001 From: Johan Fleury Date: Fri, 11 Apr 2014 08:35:25 +0200 Subject: [PATCH 285/574] Writing proxy configuration in apt.conf.d/01proxy. This commit changes the proxy file name to be more consistent with other files in `apt.conf.d`. The old file (`apt.conf.d/proxy`) is removed. Tests has been updated. --- manifests/init.pp | 10 ++++++++-- spec/acceptance/apt_spec.rb | 10 ++++++++-- spec/classes/apt_spec.rb | 8 ++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 85055c8119..1c3f902ada 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -134,15 +134,21 @@ default => present } - file { 'configure-apt-proxy': + file { '01proxy': ensure => $proxy_set, - path => "${apt_conf_d}/proxy", + path => "${apt_conf_d}/01proxy", content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n", notify => Exec['apt_update'], mode => '0644', owner => root, group => root, } + + file { 'old-proxy-file': + ensure => absent, + path => "${apt_conf_d}/proxy", + notify => Exec['apt_update'], + } # Need anchor to provide containment for dependencies. anchor { 'apt::update': diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 84b7f88281..f89976e400 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -75,10 +75,13 @@ class { 'apt': apply_manifest(pp, :catch_failures => true) end - describe file('/etc/apt/apt.conf.d/proxy') do + describe file('/etc/apt/apt.conf.d/01proxy') do it { should be_file } it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' } end + describe file('/etc/apt/apt.conf.d/proxy') do + it { should_not be_file } + end end context 'purge_sources' do @@ -117,10 +120,13 @@ class { 'apt': apply_manifest(pp, :catch_failures => true) end - describe file('/etc/apt/apt.conf.d/proxy') do + describe file('/etc/apt/apt.conf.d/01proxy') do it { should be_file } it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' } end + describe file('/etc/apt/apt.conf.d/proxy') do + it { should_not be_file } + end end context 'purge_sources' do diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 0b677564d1..9f18a91264 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -162,14 +162,14 @@ describe 'when setting a proxy' do it { if param_hash[:proxy_host] - should contain_file('configure-apt-proxy').with( - 'path' => '/etc/apt/apt.conf.d/proxy', + should contain_file('01proxy').with( + 'path' => '/etc/apt/apt.conf.d/01proxy', 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";\n", 'notify' => "Exec[apt_update]" ) else - should contain_file('configure-apt-proxy').with( - 'path' => '/etc/apt/apt.conf.d/proxy', + should contain_file('01proxy').with( + 'path' => '/etc/apt/apt.conf.d/01proxy', 'notify' => 'Exec[apt_update]', 'ensure' => 'absent' ) From 4c8a99b9ebca7e794e355cd08799dc53d72832d2 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Fri, 28 Feb 2014 15:34:08 +0000 Subject: [PATCH 286/574] Prepare metadata for supported module release. (cherry picked from commit ab03a989df37df3660f0916519d0f78f7ab73a13) --- metadata.json | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/metadata.json b/metadata.json index ccb4458443..8122b5c3f6 100644 --- a/metadata.json +++ b/metadata.json @@ -1,26 +1,22 @@ { - "name": "puppetlabs/apt", - "version": "1.3.0", - "summary": "Apt key and source management", - "source": "git@github.com/puppetlabs/puppetlabs-apt.git", - "project_page": "http://github.com/puppetlabs/puppetlabs-apt", - "author": "Puppet Labs", - "license": "Apache-2.0", "operatingsystem_support": [ - "Debian", - "Ubuntu" + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04" + ] + } ], - "puppet_version": [ - 2.7, - 3.0, - 3.1, - 3.2, - 3.3 - ], - "dependencies": [ - { - "name": "puppetlabs/stdlib", - "version_requirement": ">= 2.2.1" - } + "requirements": [ + { "name": "pe", "version_requirement": "3.2.x" }, + { "name": "puppet", "version_requirement": "3.x" } ] } From 4c7150a5be39affee96de5763f926b7888043215 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 3 Mar 2014 21:39:10 +0000 Subject: [PATCH 287/574] Add back in missing fields to work around Puppet bug. (cherry picked from commit dc472717163d30a4463f687a577238ec2539601c) --- metadata.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 8122b5c3f6..f1e8663059 100644 --- a/metadata.json +++ b/metadata.json @@ -1,4 +1,11 @@ { + "name": "puppetlabs-apt", + "version": "1.4.1", + "source": "https://github.com/puppetlabs/puppetlabs-apt", + "author": "Puppet Labs", + "license": "Apache-2.0", + "project_page": "https://github.com/puppetlabs/puppetlabs-apt", + "summary": "Puppet Labs Apt Module", "operatingsystem_support": [ { "operatingsystem": "Debian", @@ -18,5 +25,6 @@ "requirements": [ { "name": "pe", "version_requirement": "3.2.x" }, { "name": "puppet", "version_requirement": "3.x" } - ] + ], + "dependencies": [] } From 156eaac061edb8643f6d56084063af38a5538de6 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 27 Mar 2014 13:51:08 +0100 Subject: [PATCH 288/574] unattended_upgrades: Fix matching security archive The default configuration we were writing for Debian was only working for Squeeze, from Wheezy and onwards this wasn't working anymore. This has to do with the fact that we should now be using Origins-Pattern according to the unattended-upgrades docs. However, Ubuntu didn't entirely get with the program yet... This change reflects the defaults that unattended-upgrade installs on every platform we support. In order to do so the unattended-upgrades Debian archive for Squeeze, Wheezy, Lucid, Precise and Trusty were downloaded and the default /etc/apt/apt.conf.d/50unattended-upgrades checked for its content with regard to using Allow-Origins or Origins-Pattern. Fixes #277 --- manifests/params.pp | 22 ++++-- manifests/unattended_upgrades.pp | 46 +++++------ spec/classes/unattended_upgrades_spec.rb | 98 ++++++++++++++++++++++-- templates/50unattended-upgrades.erb | 4 + 4 files changed, 135 insertions(+), 35 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index b35bb1c8d9..cb2d2d3005 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -10,28 +10,40 @@ case $::lsbdistcodename { 'squeeze': { $backports_location = 'http://backports.debian.org/debian-backports' + $legacy_origin = true + $origins = ['${distro_id} ${distro_codename}-security'] } 'wheezy': { $backports_location = 'http://ftp.debian.org/debian/' + $legacy_origin = false + $origins = ['origin=Debian,archive=stable,label=Debian-Security'] } default: { $backports_location = 'http://http.debian.net/debian/' + $legacy_origin = false + $origins = ['origin=Debian,archive=stable,label=Debian-Security'] } } } 'ubuntu': { case $::lsbdistcodename { - 'hardy','maverick','natty','oneiric','precise': { + 'lucid': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' - $ppa_options = '-y' + $ppa_options = undef + $legacy_origin = true + $origins = ['${distro_id} ${distro_codename}-security'] } - 'lucid': { + 'precise', 'trusty': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' - $ppa_options = undef + $ppa_options = '-y' + $legacy_origin = true + $origins = ['${distro_id}:${distro_codename}-security'] } default: { $backports_location = 'http://old-releases.ubuntu.com/ubuntu' - $ppa_options = '-y' + $ppa_options = '-y' + $legacy_origin = true + $origins = ['${distro_id}:${distro_codename}-security'] } } } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index b0bd8ab1e0..c57a9ee7f5 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -14,30 +14,29 @@ # file and in /etc/cron.daily/apt # class apt::unattended_upgrades ( - $origins = ['${distro_id}:${distro_codename}-security'], - $blacklist = [], - $update = "1", - $download = "1", - $upgrade = "1", - $autoclean = "7", - $auto_fix = true, - $minimal_steps = false, + $origins = $::apt::params::origins, + $blacklist = [], + $update = "1", + $download = "1", + $upgrade = "1", + $autoclean = "7", + $auto_fix = true, + $minimal_steps = false, $install_on_shutdown = false, - $mail_to = "NONE", - $mail_only_on_error = false, - $remove_unused = true, - $auto_reboot = false, - $dl_limit = "NONE", - $enable = "1", - $backup_interval = "0", - $backup_level = "3", - $max_age = "0", - $min_age = "0", - $max_size = "0", - $download_delta = "0", - $verbose = "0", -) { - include apt::params + $mail_to = "NONE", + $mail_only_on_error = false, + $remove_unused = true, + $auto_reboot = false, + $dl_limit = "NONE", + $enable = "1", + $backup_interval = "0", + $backup_level = "3", + $max_age = "0", + $min_age = "0", + $max_size = "0", + $download_delta = "0", + $verbose = "0", +) inherits ::apt::params { validate_bool( $auto_fix, @@ -47,6 +46,7 @@ $remove_unused, $auto_reboot ) + validate_array($origins) package { 'unattended-upgrades': ensure => present, diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index f5cad53a5b..25a1f7aed3 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -25,16 +25,100 @@ } describe "origins" do - describe "with param defaults" do - let(:params) {{ }} - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\$\{distro_id\}:\$\{distro_codename\}-security";\n\};$/) } + describe 'on Debian' do + default_facts = { :lsbdistid => 'Debian' } + context 'defaults' do + let :facts do default_facts end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Origins-Pattern/ + ).with_content( + /"origin=Debian,archive=stable,label=Debian-Security";/ + ) + } + end + context 'defaults with custom origin' do + let :facts do default_facts end + let :params do { :origins => ['bananana']} end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Origins-Pattern/ + ).with_content( + /"bananana";/ + ) + } + end + context 'defaults with invalid origin' do + let :facts do default_facts end + let :params do { :origins => 'bananana'} end + it { + expect {subject}.to raise_error(/is not an Array/) + } + end + context 'squeeze' do + let :facts do default_facts.merge({:lsbdistcodename => 'squeeze'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id} \${distro_codename}-security";/ + ) + } + end + context 'wheezy' do + let :facts do default_facts.merge({:lsbdistcodename => 'wheezy'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Origins-Pattern/ + ).with_content( + /"origin=Debian,archive=stable,label=Debian-Security";/ + ) + } + end end - describe "with origins => ['ubuntu:precise-security']" do - let :params do - { :origins => ['ubuntu:precise-security'] } + describe 'on Ubuntu' do + default_facts = { :lsbdistid => 'Ubuntu' } + context 'default' do + let :facts do default_facts end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id}\:\${distro_codename}-security";/ + ) + } + end + context 'lucid' do + let :facts do default_facts.merge({:lsbdistcodename => 'lucid'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id} \${distro_codename}-security";/ + ) + } + end + context 'precise' do + let :facts do default_facts.merge({:lsbdistcodename => 'precise'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id}\:\${distro_codename}-security";/ + ) + } + end + context 'trusty' do + let :facts do default_facts.merge({:lsbdistcodename => 'trusty'}) end + it { + should contain_file(file_unattended).with_content( + /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id}\:\${distro_codename}-security";/ + ) + } end - it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } end end diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb index 4df0f74401..1177922de0 100644 --- a/templates/50unattended-upgrades.erb +++ b/templates/50unattended-upgrades.erb @@ -1,5 +1,9 @@ // Automatically upgrade packages from these (origin:archive) pairs +<%- if @legacy_origin -%> Unattended-Upgrade::Allowed-Origins { +<%- else -%> +Unattended-Upgrade::Origins-Pattern { +<%- end -%> <% @origins.each do |origin| -%> "<%= origin %>"; <% end -%> From d3d6fde6e7aee520c8b659a641fdf50dcd5e20f4 Mon Sep 17 00:00:00 2001 From: Daniel Paulus Date: Fri, 2 May 2014 17:56:06 +0200 Subject: [PATCH 289/574] Do not add bogus line to apt preference file on Debian Wheezy --- manifests/init.pp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 1c3f902ada..a55d584a13 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -54,11 +54,16 @@ true => "# Repos managed by puppet.\n", } - $preferences_content = $purge_preferences ? { - false => undef, - true => "Explanation: Preferences managed by Puppet\n + if $lsbdistcodename == 'wheezy' { + $preferences_content = undef + } + else { + $preferences_content = $purge_preferences ? { + false => undef, + true => "Explanation: Preferences managed by Puppet\n Explanation: We need a bogus package line because of Debian Bug #732746\n Package: bogus-package\n", + } } if $always_apt_update == true { From e337a243897dfd5d009fc3937c69d3c814a84305 Mon Sep 17 00:00:00 2001 From: Daniel Paulus Date: Fri, 2 May 2014 23:35:54 +0200 Subject: [PATCH 290/574] Remove the preference file for all supported platforms when in purge mode --- manifests/init.pp | 24 +++++------------------- spec/classes/apt_spec.rb | 15 +-------------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index a55d584a13..c778b6fd4b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -54,18 +54,6 @@ true => "# Repos managed by puppet.\n", } - if $lsbdistcodename == 'wheezy' { - $preferences_content = undef - } - else { - $preferences_content = $purge_preferences ? { - false => undef, - true => "Explanation: Preferences managed by Puppet\n -Explanation: We need a bogus package line because of Debian Bug #732746\n -Package: bogus-package\n", - } - } - if $always_apt_update == true { Exec <| title=='apt_update' |> { refreshonly => false, @@ -98,13 +86,11 @@ notify => Exec['apt_update'], } - file { 'apt-preferences': - ensure => present, - path => "${root}/preferences", - owner => root, - group => root, - mode => '0644', - content => $preferences_content, + if $purge_preferences == true { + file { 'apt-preferences': + ensure => absent, + path => "${root}/preferences", + } } file { 'preferences.d': diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 9f18a91264..11d90cb571 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -93,21 +93,8 @@ it { if param_hash[:purge_preferences] should create_file('apt-preferences').with({ - :ensure => 'present', + :ensure => 'absent', :path => '/etc/apt/preferences', - :owner => 'root', - :group => 'root', - :mode => '0644', - :content => /Explanation/, - }) - else - should create_file('apt-preferences').with({ - :ensure => 'present', - :path => '/etc/apt/preferences', - :owner => 'root', - :group => 'root', - :mode => '0644', - :content => nil, }) end } From 36b7b8abff7e21d6810b60d55e6225fb2371e5da Mon Sep 17 00:00:00 2001 From: Daniel Paulus Date: Sat, 3 May 2014 00:06:23 +0200 Subject: [PATCH 291/574] Updated readme to indicate danger of setting preference purge options --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8230f1437d..99e808b8cc 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Setup **What APT affects:** * package/service/configuration files for APT + * NOTE: Setting the `purge_preferences` or `purge_preferences_d` parameters to 'true' will destroy any existing configuration that was not declared with puppet. The default for these parameters is 'false'. * your system's `sources.list` file and `sources.list.d` directory * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'. * system repositories @@ -58,7 +59,7 @@ The parameters for `apt` are not required in general and are predominantly for d Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. -If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. +If you declare your apt class with `purge_sources_list`, `purge_sources_list_d`, `purge_preferences` and `purge_preferences_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. ### apt::builddep From c327d3d7bf906a64047a25266477b5cee71cd48f Mon Sep 17 00:00:00 2001 From: Daniel Paulus Date: Sat, 3 May 2014 00:13:17 +0200 Subject: [PATCH 292/574] Testing if we are not touching the preference file when purge mode is off --- spec/classes/apt_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 11d90cb571..a21e0443e2 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -96,6 +96,8 @@ :ensure => 'absent', :path => '/etc/apt/preferences', }) + else + should_not contain_file('apt-preferences') end } From 15630989dae13d4491fc309231e55d70b165795e Mon Sep 17 00:00:00 2001 From: Daniel Paulus Date: Mon, 5 May 2014 11:57:42 +0200 Subject: [PATCH 293/574] Fixed acceptance spec and add debian nodeset --- spec/acceptance/apt_spec.rb | 5 +---- spec/acceptance/nodesets/debian-73-x64.yml | 11 +++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 spec/acceptance/nodesets/debian-73-x64.yml diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index f89976e400..13f1d50536 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -217,10 +217,7 @@ class { 'apt': purge_preferences => true } end describe file('/etc/apt/preferences') do - it { should be_file } - it 'is managed by Puppet' do - shell("grep 'Explanation' /etc/apt/preferences", {:acceptable_exit_codes => 0}) - end + it { should_not be_file } end end end diff --git a/spec/acceptance/nodesets/debian-73-x64.yml b/spec/acceptance/nodesets/debian-73-x64.yml new file mode 100644 index 0000000000..d71434551a --- /dev/null +++ b/spec/acceptance/nodesets/debian-73-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-73-x64: + roles: + - master + platform: debian-7-amd64 + box : debian-73-x64-virtualbox-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git \ No newline at end of file From ee0233066e7dd11e22ce85bbf5afd4257e9adff6 Mon Sep 17 00:00:00 2001 From: Daniel Paulus Date: Mon, 5 May 2014 12:06:39 +0200 Subject: [PATCH 294/574] Some code cleaning --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index c778b6fd4b..48b62d178a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -86,7 +86,7 @@ notify => Exec['apt_update'], } - if $purge_preferences == true { + if $purge_preferences { file { 'apt-preferences': ensure => absent, path => "${root}/preferences", From f62678b22ede7f95c00450b56025c8ef3e5ee649 Mon Sep 17 00:00:00 2001 From: Daniel Paulus Date: Mon, 5 May 2014 14:39:25 +0200 Subject: [PATCH 295/574] Add dpaulus to the contributors list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 99e808b8cc..9443cd561d 100644 --- a/README.md +++ b/README.md @@ -320,3 +320,4 @@ A lot of great people have contributed to this module. A somewhat current list f * William Van Hevelingen * Zach Leslie * Daniele Sluijters +* Daniel Paulus From b7bd7f43d9b48d1010fce999c4d1675aa4cf2970 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 8 May 2014 09:54:08 +0200 Subject: [PATCH 296/574] Drop testing on 3.3, add 3.5. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c4bb092a71..b9abaccc41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ rvm: - 2.0.0 env: matrix: - - PUPPET_GEM_VERSION="~> 3.3.0" - PUPPET_GEM_VERSION="~> 3.4.0" + - PUPPET_GEM_VERSION="~> 3.5.0" matrix: fast_finish: true notifications: From 2cdcd3b06dd199d400c70c1c36f508583330b428 Mon Sep 17 00:00:00 2001 From: Oliver Chick Date: Thu, 24 Apr 2014 08:52:12 +0100 Subject: [PATCH 297/574] Implement fancy progress bars configuration. Ubuntu 14.04 ships with apt 0.9.15, has a ``fancy progress bar'', which is a green bar that shows at the bottom of the terminal showing progress throughout install. This patch enables the progress bar, which is usually done by running echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar --- README.md | 3 ++- manifests/init.pp | 21 ++++++++++++++++++++- spec/acceptance/apt_spec.rb | 28 ++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8230f1437d..ee353854c6 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ The parameters for `apt` are not required in general and are predominantly for d purge_sources_list => false, purge_sources_list_d => false, purge_preferences_d => false, - update_timeout => undef + update_timeout => undef, + fancy_progress => undef } Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. diff --git a/manifests/init.pp b/manifests/init.pp index 1c3f902ada..03856a273b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,7 +36,8 @@ $purge_preferences_d = false, $update_timeout = undef, $update_tries = undef, - $sources = undef + $sources = undef, + $fancy_progress = undef ) { if $::osfamily != 'Debian' { @@ -111,6 +112,24 @@ recurse => $purge_preferences_d, } + case $fancy_progress { + true: { + file { '99progressbar': + ensure => present, + content => 'Dpkg::Progress-Fancy "1";', + path => "${apt_conf_d}/99progressbar", + } + } + false: { + file { '99progressbar': + ensure => absent, + path => "${apt_conf_d}/99progressbar", + } + } + undef: {} # do nothing + default: { fail('Valid values for fancy_progress are true or false') } + } + case $disable_keys { true: { file { '99unauth': diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index f89976e400..4daab09b7b 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -274,6 +274,34 @@ class { 'apt': update_timeout => '5000' } end end + context 'fancy_progress => true' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': fancy_progress => true } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/99progressbar') do + it { should be_file } + it { should contain 'Dpkg::Progress-Fancy "1";' } + end + end + context 'fancy_progress => false' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': fancy_progress => false } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/99progressbar') do + it { should_not be_file } + end + end + context 'reset' do it 'fixes the sources.list' do shell('cp /tmp/sources.list /etc/apt') From d7889cf47b7595396fe88dc9161746e4221f966e Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 14 May 2014 16:28:06 -0400 Subject: [PATCH 298/574] Prepare for 1.5.0. --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ Modulefile | 2 +- metadata.json | 5 +++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10503c9144..80e70802f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +##2014-05-14 - Supported Release 1.5.0 +###Summary + +This release adds support for Ubuntu 14.04. It also includes many new features +and important bugfixes. One huge change is that apt::key was replaced with +apt_key, which allows you to use puppet resource apt_key to inventory keys on +your system. + +Special thanks to daenney, our intrepid unofficial apt maintainer! + +####Features +- Add support for Ubuntu Trusty! +- Add apt::hold define +- Generate valid *.pref files in apt::pin +- Made pin_priority configurable for apt::backports +- Add apt_key type and provider +- Rename "${apt_conf_d}/proxy" to "${apt_conf_d}/01proxy" +- apt::key rewritten to use apt_key type +- Add support for update_tries to apt::update + +####Bugfixes +- Typo fixes +- Fix unattended upgrades +- Removed bogus line when using purge_preferences +- Fix apt::force to upgrade allow packages to be upgraded to the pacakge from the specified release + ##2014-03-04 - Supported Release 1.4.2 ###Summary diff --git a/Modulefile b/Modulefile index 40a87f4ef3..45169b31e8 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-apt' -version '1.4.2' +version '1.5.0' source 'https://github.com/puppetlabs/puppetlabs-apt' author 'Evolving Web / Puppet Labs' license 'Apache License 2.0' diff --git a/metadata.json b/metadata.json index f1e8663059..1a18cf8837 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-apt", - "version": "1.4.1", + "version": "1.5.0", "source": "https://github.com/puppetlabs/puppetlabs-apt", "author": "Puppet Labs", "license": "Apache-2.0", @@ -18,7 +18,8 @@ "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", - "12.04" + "12.04", + "14.04" ] } ], From f3350663785e9460c4334990c3673b1a9ab40d57 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 15 May 2014 14:58:49 -0400 Subject: [PATCH 299/574] Claim PE3.3 support. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 1a18cf8837..a69a0c0e95 100644 --- a/metadata.json +++ b/metadata.json @@ -24,7 +24,7 @@ } ], "requirements": [ - { "name": "pe", "version_requirement": "3.2.x" }, + { "name": "pe", "version_requirement": "3.3.x" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [] From 3fad56d26627c3e19561c319ddf124d22639c801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Conil?= Date: Mon, 19 May 2014 15:12:36 +1000 Subject: [PATCH 300/574] adding notice on top of sourceslist files Useful to figure out what is managed by puppet and what isn't when not setting up the option to purge sourceslist files --- spec/defines/source_spec.rb | 2 +- templates/source.list.erb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 34b394282f..bf5e50e401 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -74,7 +74,7 @@ end let :content do - content = "# #{title}" + content = "#file generated by puppet\n# #{title}" if param_hash[:architecture] arch = "[arch=#{param_hash[:architecture]}] " end diff --git a/templates/source.list.erb b/templates/source.list.erb index 9946966ee5..541534e65b 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,3 +1,4 @@ +#file generated by puppet # <%= @name %> deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> <%- if @include_src then -%> From 1891912f8472da66d9d227f7392b601a24b2f32f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Conil?= Date: Mon, 19 May 2014 15:33:06 +1000 Subject: [PATCH 301/574] Fixed regex to actually follow APT requirements Previous implementation would overwrite the file name and potentially include characters that would cause apt to ignore the pref file --- manifests/pin.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index 2563fc4681..2ce81fd6bb 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -64,10 +64,6 @@ } - $path = $order ? { - '' => "${preferences_d}/${name}.pref", - default => "${preferences_d}/${order}-${name}.pref", - } # According to man 5 apt_preferences: # The files have either no or "pref" as filename extension @@ -78,6 +74,10 @@ # be silently ignored. $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') + $path = $order ? { + '' => "${preferences_d}/${file_name}.pref", + default => "${preferences_d}/${order}-${file_name}.pref", + } file { "${file_name}.pref": ensure => $ensure, path => $path, From b2381c6673a8e86d38232bbef3276de0839b5d86 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 20 May 2014 16:24:28 -0400 Subject: [PATCH 302/574] Fixing lint and adding the trusty nodeset (not sure how that was missed) --- Rakefile | 6 ++++ manifests/init.pp | 2 +- manifests/ppa.pp | 2 +- manifests/unattended_upgrades.pp | 28 +++++++++---------- .../nodesets/ubuntu-server-1404-x64.yml | 11 ++++++++ 5 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml diff --git a/Rakefile b/Rakefile index 6d067dc56c..5868545f20 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,10 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' +PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_class_parameter_defaults') +PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] diff --git a/manifests/init.pp b/manifests/init.pp index 48b62d178a..5f5d0ac49f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -134,7 +134,7 @@ owner => root, group => root, } - + file { 'old-proxy-file': ensure => absent, path => "${apt_conf_d}/proxy", diff --git a/manifests/ppa.pp b/manifests/ppa.pp index ab79b94179..a55e1e0e5c 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -15,7 +15,7 @@ } if $::operatingsystem != 'Ubuntu' { - fail("apt::ppa is currently supported on Ubuntu only.") + fail('apt::ppa is currently supported on Ubuntu only.') } $filename_without_slashes = regsubst($name, '/', '-', 'G') diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index c57a9ee7f5..7e3ccc44b0 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -16,26 +16,26 @@ class apt::unattended_upgrades ( $origins = $::apt::params::origins, $blacklist = [], - $update = "1", - $download = "1", - $upgrade = "1", - $autoclean = "7", + $update = '1', + $download = '1', + $upgrade = '1', + $autoclean = '7', $auto_fix = true, $minimal_steps = false, $install_on_shutdown = false, - $mail_to = "NONE", + $mail_to = 'NONE', $mail_only_on_error = false, $remove_unused = true, $auto_reboot = false, - $dl_limit = "NONE", - $enable = "1", - $backup_interval = "0", - $backup_level = "3", - $max_age = "0", - $min_age = "0", - $max_size = "0", - $download_delta = "0", - $verbose = "0", + $dl_limit = 'NONE', + $enable = '1', + $backup_interval = '0', + $backup_level = '3', + $max_age = '0', + $min_age = '0', + $max_size = '0', + $download_delta = '0', + $verbose = '0', ) inherits ::apt::params { validate_bool( diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000000..cba1cd04c2 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : puppetlabs/ubuntu-14.04-64-nocm + box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git From 71ebb94283618ca99faf9c3fd9d65557f2d774d6 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 21 May 2014 10:38:24 -0700 Subject: [PATCH 303/574] Block this from running on unsupported platforms. --- spec/acceptance/apt_key_provider_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 1d39a973b2..9becd25684 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -7,7 +7,7 @@ CENTOS_REPO_URL = 'ftp.cvut.cz/centos' CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' -describe 'apt_key' do +describe 'apt_key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do before(:each) do shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}", :acceptable_exit_codes => [0,1,2]) From ba074344fee5cae33ed1d0d32ee4496d0a4884ff Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 21 May 2014 10:39:17 -0700 Subject: [PATCH 304/574] Merge pull request #300 from apenney/fix-tests Block this from running on unsupported platforms. --- spec/acceptance/apt_key_provider_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 1d39a973b2..9becd25684 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -7,7 +7,7 @@ CENTOS_REPO_URL = 'ftp.cvut.cz/centos' CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' -describe 'apt_key' do +describe 'apt_key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do before(:each) do shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}", :acceptable_exit_codes => [0,1,2]) From 26ea5cc6f2fe746252908eb2f5097e17dc4dc9ee Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 21 May 2014 19:26:07 -0400 Subject: [PATCH 305/574] Update PE version requirements. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index a69a0c0e95..7365c67f86 100644 --- a/metadata.json +++ b/metadata.json @@ -24,7 +24,7 @@ } ], "requirements": [ - { "name": "pe", "version_requirement": "3.3.x" }, + { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [] From ec077973999ee46e993954a747cc36b88769fab3 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 29 May 2014 13:05:51 -0400 Subject: [PATCH 306/574] Fix the tests for Ubuntu 10.04. --- spec/acceptance/apt_key_provider_spec.rb | 2 +- spec/acceptance/force_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 9becd25684..0a31495957 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -203,7 +203,7 @@ EOS apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/Host not found/) + expect(r.stderr).to match(/(Host not found|Couldn't resolve host)/) end end end diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index a43902300d..5f4dec3fc7 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -59,7 +59,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': timeout => '1' } + apt::force { 'ocaml': timeout => '1' } EOS shell('apt-get clean') @@ -68,7 +68,7 @@ end end - describe package('vim') do + describe package('ocaml') do it { should_not be_installed } end end From 199bd52cf373bfc55f1b31f8721931777472b6c0 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 29 May 2014 13:07:38 -0400 Subject: [PATCH 307/574] Merge pull request #303 from apenney/fix-ubuntu-10-tests Fix the tests for Ubuntu 10.04. --- spec/acceptance/apt_key_provider_spec.rb | 2 +- spec/acceptance/force_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 9becd25684..0a31495957 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -203,7 +203,7 @@ EOS apply_manifest(pp, :expect_failures => true) do |r| - expect(r.stderr).to match(/Host not found/) + expect(r.stderr).to match(/(Host not found|Couldn't resolve host)/) end end end diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index a43902300d..5f4dec3fc7 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -59,7 +59,7 @@ it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': timeout => '1' } + apt::force { 'ocaml': timeout => '1' } EOS shell('apt-get clean') @@ -68,7 +68,7 @@ end end - describe package('vim') do + describe package('ocaml') do it { should_not be_installed } end end From 1a3d6625f477345e9eb71ad2e9c1bb9682ac692b Mon Sep 17 00:00:00 2001 From: innyso Date: Thu, 29 May 2014 01:01:37 +0100 Subject: [PATCH 308/574] Allow url or domain name for key_server parameter As some places dont have port 11371 open, they are required to use URL as key_server instead of domain name therefore adding the capability to use URL or domain name as key_server parameter --- manifests/key.pp | 7 +-- spec/defines/key_spec.rb | 115 +++++++++++++++++++++++++++++++-------- 2 files changed, 95 insertions(+), 27 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index 9ccbfcb6bb..231992b30c 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -39,7 +39,8 @@ # [*key_server*] # _default_: +undef+ # -# The keyserver from where to fetch our GPG key. It defaults to +# The keyserver from where to fetch our GPG key. It can either be a domain +# name or url. It defaults to # undef which results in apt_key's default keyserver being used, # currently +keyserver.ubuntu.com+. # @@ -68,9 +69,7 @@ } if $key_server { - if !is_domain_name($key_server) { - fail('$key_server must be a valid domain name') - } + validate_re($key_server,['\A((hkp|http|https):\/\/)?([a-z\d]{0,62}\.)+[a-z\d]+(:\d{2,4})?$']) } if $key_options { diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index a85d1710b4..c20d05d43a 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -142,31 +142,100 @@ end describe 'key_server =>' do - let :params do { - :key_server => 'pgp.mit.edu', - } end + context 'domain name' do + let :params do { + :key_server => 'pgp.mit.edu', + } end - it 'contains the apt::key' do - should contain_apt__key(title).with({ - :key => title, - :ensure => 'present', - :key_server => 'pgp.mit.edu', - }) - end - it 'contains the apt_key' do - should contain_apt_key(title).with({ - :id => title, - :ensure => 'present', - :source => nil, - :server => params[:key_server], - :content => nil, - :keyserver_options => nil, - }) + it 'contains the apt::key' do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_server => 'pgp.mit.edu', + }) + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'present', + :source => nil, + :server => params[:key_server], + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{title} present") + end + end + + context "url" do + let (:params) do{ + :key_server => 'hkp://pgp.mit.edu', + } end + it "should contain apt::key" do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_server => 'hkp://pgp.mit.edu', + }) + end + end + context "url with port number" do + let (:params) do{ + :key_server => 'hkp://pgp.mit.edu:80', + } end + it "should contain apt::key" do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_server => 'hkp://pgp.mit.edu:80', + }) + end end - it 'contains the apt_key present anchor' do - should contain_anchor("apt_key #{title} present") + + context "incorrect port number url" do + let (:params) do{ + :key_server => 'hkp://pgp.mit.edu:8008080' + } end + it 'fails' do + expect { subject }.to raise_error(/does not match/) + end + end + context "incorrect protocol for url" do + let (:params) do{ + :key_server => 'abc://pgp.mit.edu:80' + } end + it 'fails' do + expect { subject }.to raise_error(/does not match/) + end + end + context "missing port number url" do + let (:params) do{ + :key_server => 'hkp://pgp.mit.edu:' + } end + it 'fails' do + expect { subject }.to raise_error(/does not match/) + end + end + context "malform url" do + let (:params) do{ + :key_server => 'hkp://pgp.mit.edu.' + } end + it 'fails' do + expect { subject }.to raise_error(/does not match/) + end + end + context "exceed characher url" do + let (:params) do{ + :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' + } end + it 'fails' do + expect { subject }.to raise_error(/does not match/) + end end - end + + end describe 'key_options =>' do let :params do { @@ -229,7 +298,7 @@ :key_server => 'two bottles of rum', } end it 'fails' do - expect { subject }.to raise_error(/must be a valid domain name/) + expect { subject }.to raise_error(/does not match/) end end From 2a49e41656873fcc5a518d8ab18dbf14062a17b2 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 21 May 2014 19:26:07 -0400 Subject: [PATCH 309/574] Update PE version requirements. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index a69a0c0e95..7365c67f86 100644 --- a/metadata.json +++ b/metadata.json @@ -24,7 +24,7 @@ } ], "requirements": [ - { "name": "pe", "version_requirement": "3.3.x" }, + { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" }, { "name": "puppet", "version_requirement": "3.x" } ], "dependencies": [] From ce5d19b3deaf2aa748efb2e5a60fa6cb33f09e4b Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 4 Jun 2014 13:54:22 -0400 Subject: [PATCH 310/574] Remove claims of support. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80e70802f3..bf8553d8b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -##2014-05-14 - Supported Release 1.5.0 +##2014-06-04 - Release 1.5.0 ###Summary This release adds support for Ubuntu 14.04. It also includes many new features From 6766ed90c6e6f3b5cab0dec80b06792e12fdbf77 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 9 Jun 2014 11:29:29 -0400 Subject: [PATCH 311/574] Pin rspec to 2.x. --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 1af60fca0d..78cf9f4376 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :development, :test do gem 'rake', '10.1.1', :require => false + gem 'rspec', '~> 2.11', :require => false gem 'pry', :require => false gem 'rspec-puppet', :require => false gem 'puppet-lint', :require => false From 3cbe24e18e071f0da9623d0752f7d9c1ee0efa5e Mon Sep 17 00:00:00 2001 From: innyso Date: Tue, 10 Jun 2014 00:09:28 +0100 Subject: [PATCH 312/574] Adding dash to key_server validate regex Dashes should be allow when defining domain or url for key_server. Rspec test cases are included to make sure no malform domain name or url are used. --- lib/puppet/type/apt_key.rb | 6 +-- manifests/key.pp | 2 +- spec/acceptance/apt_key_provider_spec.rb | 32 ++++++++++++ spec/defines/key_spec.rb | 63 +++++++++++++++++++++++- 4 files changed, 97 insertions(+), 6 deletions(-) diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index fa7b0c676c..e2cb8d9cf9 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -60,10 +60,10 @@ end newparam(:server) do - desc 'The key server to fetch the key from based on the ID.' + desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' defaultto :'keyserver.ubuntu.com' - # Need to validate this, preferably through stdlib is_fqdn - # but still working on getting to that. + + newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,4})?$/) end newparam(:keyserver_options) do diff --git a/manifests/key.pp b/manifests/key.pp index 231992b30c..8d3bcf045c 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -69,7 +69,7 @@ } if $key_server { - validate_re($key_server,['\A((hkp|http|https):\/\/)?([a-z\d]{0,62}\.)+[a-z\d]+(:\d{2,4})?$']) + validate_re($key_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,4})?$']) } if $key_options { diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 9becd25684..573452e28b 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -192,6 +192,22 @@ end end + context 'hkp://pgp.mit.edu:80' do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + server => 'hkp://pgp.mit.edu:80', + } + EOS + + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + end + end + context 'nonexistant.key.server' do it 'fails' do pp = <<-EOS @@ -207,6 +223,22 @@ end end end + + context 'key server start with dot' do + it 'fails' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_ID}', + ensure => 'present', + server => '.pgp.key.server', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Invalid value \".pgp.key.server\"/) + end + end + end end describe 'source =>' do diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index c20d05d43a..005c95e469 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -169,6 +169,46 @@ end end + context "domain with dash" do + let(:params) do{ + :key_server => 'p-gp.m-it.edu', + } end + it "should contain apt::key" do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_server => 'p-gp.m-it.edu', + }) + end + end + + context "domain begin with dash" do + let(:params) do{ + :key_server => '-pgp.mit.edu', + } end + it 'fails' do + expect { subject } .to raise_error(/does not match/) + end + end + + context "domain begin with dot" do + let(:params) do{ + :key_server => '.pgp.mit.edu', + } end + it 'fails' do + expect { subject } .to raise_error(/does not match/) + end + end + + context "domain end with dot" do + let(:params) do{ + :key_server => "pgp.mit.edu.", + } end + it 'fails' do + expect { subject } .to raise_error(/does not match/) + end + end + context "url" do let (:params) do{ :key_server => 'hkp://pgp.mit.edu', @@ -218,7 +258,7 @@ expect { subject }.to raise_error(/does not match/) end end - context "malform url" do + context "url ending with a dot" do let (:params) do{ :key_server => 'hkp://pgp.mit.edu.' } end @@ -226,6 +266,26 @@ expect { subject }.to raise_error(/does not match/) end end + context "url begin with a dash" do + let(:params) do{ + :key_server => "hkp://-pgp.mit.edu", + } end + it 'fails' do + expect { subject }.to raise_error(/does not match/) + end + end + context "url with dash" do + let(:params) do{ + :key_server => 'hkp://p-gp.m-it.edu', + } end + it "should contain apt::key" do + should contain_apt__key(title).with({ + :key => title, + :ensure => 'present', + :key_server => 'hkp://p-gp.m-it.edu', + }) + end + end context "exceed characher url" do let (:params) do{ :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' @@ -234,7 +294,6 @@ expect { subject }.to raise_error(/does not match/) end end - end describe 'key_options =>' do From 986bf8b02d254334a6c3f22f18be5769e02a9c3a Mon Sep 17 00:00:00 2001 From: juniorsysadmin Date: Tue, 10 Jun 2014 16:42:06 +1000 Subject: [PATCH 313/574] Allow custom comment for sources list --- manifests/source.pp | 1 + spec/defines/source_spec.rb | 7 ++++++- templates/source.list.erb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 196fc92586..dd00adc6a4 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -2,6 +2,7 @@ # add an apt source define apt::source( + $comment = $name, $ensure = present, $location = '', $release = 'UNDEF', diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index bf5e50e401..7c7ae399e8 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -74,7 +74,12 @@ end let :content do - content = "#file generated by puppet\n# #{title}" + content = "#file generated by puppet\n" + if param_hash[:comment] + content << "# #{comment}" + else + content << "# #{title}" + end if param_hash[:architecture] arch = "[arch=#{param_hash[:architecture]}] " end diff --git a/templates/source.list.erb b/templates/source.list.erb index 541534e65b..a57244fce8 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,5 +1,5 @@ #file generated by puppet -# <%= @name %> +# <%= @comment %> deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> <%- if @include_src then -%> deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> From 1e1c8b287a95014f91f00776b0e36c2dfa7c2c82 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 11 Jun 2014 13:31:53 -0400 Subject: [PATCH 314/574] Add test case to ensure graceful failure on OSX. --- spec/classes/init_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 120b7e8239..c5e938a9aa 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -54,4 +54,16 @@ it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) } end + + context 'with unsupported osfamily' do + let :facts do + { :osfamily => 'Darwin', } + end + + it do + expect { + should compile + }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/) + end + end end From d8df67f17f38c7f3d4269aabd737bb0b950e17e6 Mon Sep 17 00:00:00 2001 From: juniorsysadmin Date: Mon, 23 Jun 2014 12:47:52 +1000 Subject: [PATCH 315/574] Update apt::source example in README.md for #311 This patch updates the apt::source example to include a comment (see #311) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cbaab72472..f92122fb34 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ Sets the default apt release. This class is particularly useful when using repos Adds an apt source to `/etc/apt/sources.list.d/`. apt::source { 'debian_unstable': + comment => 'This is the iWeb Debian unstable mirror', location => 'http://debian.mirror.iweb.ca/debian/', release => 'unstable', repos => 'main contrib non-free', From 6f06c9b6967e22b4793a59ec40a547ae684de031 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 25 Jun 2014 16:33:47 -0700 Subject: [PATCH 316/574] Add configuration file for modulesync https://github.com/puppetlabs/modulesync --- .sync.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .sync.yml diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 0000000000..1b7c84ec84 --- /dev/null +++ b/.sync.yml @@ -0,0 +1,5 @@ +--- +.travis.yml: + env_matrix: + - PUPPET_GEM_VERSION="~> 3.4.0" + - PUPPET_GEM_VERSION="~> 3.5.0" From fd1e2ec12cc9af80534411f91f5dd0554fedac90 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 25 Jun 2014 17:23:12 -0700 Subject: [PATCH 317/574] Sync files --- .gitignore | 7 +- .travis.yml | 11 +- CONTRIBUTING.md | 234 ++++++++++++++++++ Gemfile | 11 +- Rakefile | 6 + spec/acceptance/nodesets/centos-59-x64.yml | 10 + spec/acceptance/nodesets/centos-64-x64-pe.yml | 12 + spec/acceptance/nodesets/centos-65-x64.yml | 10 + .../nodesets/ubuntu-server-10044-x64.yml | 3 +- .../nodesets/ubuntu-server-12042-x64.yml | 2 +- .../nodesets/ubuntu-server-1404-x64.yml | 11 + spec/spec.opts | 6 + 12 files changed, 311 insertions(+), 12 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 spec/acceptance/nodesets/centos-59-x64.yml create mode 100644 spec/acceptance/nodesets/centos-64-x64-pe.yml create mode 100644 spec/acceptance/nodesets/centos-65-x64.yml create mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-x64.yml create mode 100644 spec/spec.opts diff --git a/.gitignore b/.gitignore index b77434bea0..b5b7a00d67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -*.swp pkg/ Gemfile.lock -spec/fixtures/manifests +vendor/ +spec/fixtures/ +.vagrant/ +.bundle/ +coverage/ diff --git a/.travis.yml b/.travis.yml index b9abaccc41..f48d71a847 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,16 +4,21 @@ branches: - master language: ruby bundler_args: --without development -script: bundle exec rake spec SPEC_OPTS='--format documentation' +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" rvm: - 1.8.7 - 1.9.3 - 2.0.0 env: matrix: - - PUPPET_GEM_VERSION="~> 3.4.0" - - PUPPET_GEM_VERSION="~> 3.5.0" + - PUPPET_GEM_VERSION="~> 3.4.0" + - PUPPET_GEM_VERSION="~> 3.5.0" matrix: fast_finish: true + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" notifications: email: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..e1288478a2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,234 @@ +Checklist (and a short version for the impatient) +================================================= + + * Commits: + + - Make commits of logical units. + + - Check for unnecessary whitespace with "git diff --check" before + committing. + + - Commit using Unix line endings (check the settings around "crlf" in + git-config(1)). + + - Do not check in commented out code or unneeded files. + + - The first line of the commit message should be a short + description (50 characters is the soft limit, excluding ticket + number(s)), and should skip the full stop. + + - Associate the issue in the message. The first line should include + the issue number in the form "(#XXXX) Rest of message". + + - The body should provide a meaningful commit message, which: + + - uses the imperative, present tense: "change", not "changed" or + "changes". + + - includes motivation for the change, and contrasts its + implementation with the previous behavior. + + - Make sure that you have tests for the bug you are fixing, or + feature you are adding. + + - Make sure the test suites passes after your commit: + `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below + + - When introducing a new feature, make sure it is properly + documented in the README.md + + * Submission: + + * Pre-requisites: + + - Sign the [Contributor License Agreement](https://cla.puppetlabs.com/) + + - Make sure you have a [GitHub account](https://github.com/join) + + - [Create a ticket](http://projects.puppetlabs.com/projects/modules/issues/new), or [watch the ticket](http://projects.puppetlabs.com/projects/modules/issues) you are patching for. + + * Preferred method: + + - Fork the repository on GitHub. + + - Push your changes to a topic branch in your fork of the + repository. (the format ticket/1234-short_description_of_change is + usually preferred for this project). + + - Submit a pull request to the repository in the puppetlabs + organization. + +The long version +================ + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sign the Contributor License Agreement + + Before we can accept your changes, we do need a signed Puppet + Labs Contributor License Agreement (CLA). + + You can access the CLA via the [Contributor License Agreement link](https://cla.puppetlabs.com/) + + If you have any questions about the CLA, please feel free to + contact Puppet Labs via email at cla-submissions@puppetlabs.com. + + 3. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on "master". + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 4. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. + +Testing +======= + +Getting Started +--------------- + +Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby +package manager such as [bundler](http://bundler.io/) what Ruby packages, +or Gems, are required to build, develop, and test this software. + +Please make sure you have [bundler installed](http://bundler.io/#getting-started) +on your system, then use it to install all dependencies needed for this project, +by running + +```shell +% bundle install +Fetching gem metadata from https://rubygems.org/........ +Fetching gem metadata from https://rubygems.org/.. +Using rake (10.1.0) +Using builder (3.2.2) +-- 8><-- many more --><8 -- +Using rspec-system-puppet (2.2.0) +Using serverspec (0.6.3) +Using rspec-system-serverspec (1.0.0) +Using bundler (1.3.5) +Your bundle is complete! +Use `bundle show [gemname]` to see where a bundled gem is installed. +``` + +NOTE some systems may require you to run this command with sudo. + +If you already have those gems installed, make sure they are up-to-date: + +```shell +% bundle update +``` + +With all dependencies in place and up-to-date we can now run the tests: + +```shell +% rake spec +``` + +This will execute all the [rspec tests](http://rspec-puppet.com/) tests +under [spec/defines](./spec/defines), [spec/classes](./spec/classes), +and so on. rspec tests may have the same kind of dependencies as the +module they are testing. While the module defines in its [Modulefile](./Modulefile), +rspec tests define them in [.fixtures.yml](./fixtures.yml). + +Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) +tests. These tests spin up a virtual machine under +[VirtualBox](https://www.virtualbox.org/)) with, controlling it with +[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test +scenarios. In order to run these, you will need both of those tools +installed on your system. + +You can run them by issuing the following command + +```shell +% rake spec_clean +% rspec spec/acceptance +``` + +This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), +install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) +and then run all the tests under [spec/acceptance](./spec/acceptance). + +Writing Tests +------------- + +XXX getting started writing tests. + +If you have commit access to the repository +=========================================== + +Even if you have commit access to the repository, you will still need to +go through the process above, and have someone else review and merge +in your changes. The rule is that all changes must be reviewed by a +developer on the project (that did not write the code) to ensure that +all changes go through a code review process. + +Having someone other than the author of the topic branch recorded as +performing the merge is the record that they performed the code +review. + + +Additional Resources +==================== + +* [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help) + +* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) + +* [Patchwork](https://patchwork.puppetlabs.com) + +* [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) + +* [General GitHub documentation](http://help.github.com/) + +* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) + diff --git a/Gemfile b/Gemfile index 1af60fca0d..9074f1e75b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,15 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :test do - gem 'rake', '10.1.1', :require => false - gem 'pry', :require => false + gem 'rake', :require => false gem 'rspec-puppet', :require => false - gem 'puppet-lint', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'serverspec', :require => false + gem 'puppet-lint', :require => false gem 'beaker', :require => false gem 'beaker-rspec', :require => false + gem 'pry', :require => false + gem 'simplecov', :require => false end if puppetversion = ENV['PUPPET_GEM_VERSION'] @@ -16,3 +17,5 @@ if puppetversion = ENV['PUPPET_GEM_VERSION'] else gem 'puppet', :require => false end + +# vim:ft=ruby diff --git a/Rakefile b/Rakefile index 6d067dc56c..5868545f20 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,10 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' +PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_class_parameter_defaults') +PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] diff --git a/spec/acceptance/nodesets/centos-59-x64.yml b/spec/acceptance/nodesets/centos-59-x64.yml new file mode 100644 index 0000000000..2ad90b86aa --- /dev/null +++ b/spec/acceptance/nodesets/centos-59-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-59-x64: + roles: + - master + platform: el-5-x86_64 + box : centos-59-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/spec/acceptance/nodesets/centos-64-x64-pe.yml b/spec/acceptance/nodesets/centos-64-x64-pe.yml new file mode 100644 index 0000000000..7d9242f1b9 --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-64-x64: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: pe diff --git a/spec/acceptance/nodesets/centos-65-x64.yml b/spec/acceptance/nodesets/centos-65-x64.yml new file mode 100644 index 0000000000..4e2cb809e8 --- /dev/null +++ b/spec/acceptance/nodesets/centos-65-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-65-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-65-x64-vbox436-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml index c1b8bdf8fa..5ca1514e40 100644 --- a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -7,5 +7,4 @@ HOSTS: box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box hypervisor : vagrant CONFIG: - log_level: debug - type: git + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml index a5f38f784c..d065b304f8 100644 --- a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml +++ b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -2,7 +2,7 @@ HOSTS: ubuntu-server-12042-x64: roles: - master - platform: ubuntu-server-12.04-amd64 + platform: ubuntu-12.04-amd64 box : ubuntu-server-12042-x64-vbox4210-nocm box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box hypervisor : vagrant diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000000..cba1cd04c2 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : puppetlabs/ubuntu-14.04-64-nocm + box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000000..91cd6427ed --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace From 14b3beda74999aefc4cd02f681321e7797c1ef2f Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 26 Jun 2014 14:26:02 +0200 Subject: [PATCH 318/574] MODULES-780 Don't blow up on unicode characters. Gotta love the difference between Ruby 1.8.7 not caring and every subsequent version exploding. --- lib/puppet/provider/apt_key/apt_key.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index f8d40728b0..1d3c1744b5 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -26,6 +26,11 @@ commands :apt_key => 'apt-key' def self.instances + if RUBY_VERSION > '1.8.7' + key_output = apt_key('list').encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '') + else + key_output = apt_key('list') + end key_array = apt_key('list').split("\n").collect do |line| line_hash = key_line_hash(line) next unless line_hash From 5ed7396a313474f79d516c6fb2c894ef14f85423 Mon Sep 17 00:00:00 2001 From: Raoul Bhatia Date: Thu, 26 Jun 2014 20:03:04 +0200 Subject: [PATCH 319/574] Enable auto-update for Debian squeeze-lts Quoting https://wiki.debian.org/LTS Official security support for Debian GNU/Linux 6.0 (code name "Squeeze") has ended on 31 May 2014. However long term support for the distribution is going to be extended until February 2016, i.e. five years after the initial release. See https://wiki.debian.org/LTS for more details. --- manifests/params.pp | 3 ++- spec/classes/unattended_upgrades_spec.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 4e974ba48b..f635b5801c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -12,7 +12,8 @@ $backports_location = 'http://backports.debian.org/debian-backports' $legacy_origin = true $origins = ['${distro_id} oldstable', - '${distro_id} ${distro_codename}-security'] + '${distro_id} ${distro_codename}-security', + '${distro_id} ${distro_codename}-lts'] } 'wheezy': { $backports_location = 'http://ftp.debian.org/debian/' diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index a2fb48b126..8494f0410d 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -60,6 +60,8 @@ it { should contain_file(file_unattended).with_content( /^Unattended-Upgrade::Allowed-Origins/ + ).with_content( + /"\${distro_id} \${distro_codename}-lts";/ ).with_content( /"\${distro_id} \${distro_codename}-security";/ ).with_content( From 7eb9d00360916f51ed0bc3fa6d740d3e0e85ecc6 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Thu, 26 Jun 2014 14:50:11 +0100 Subject: [PATCH 320/574] add facts showing available updates Making use of the apt-check command from the 'update-notifier-common' package (if available) display the number of available updates, number of security updates as well as the update package names. --- README.md | 7 +++++ lib/facter/apt_package_updates.rb | 13 +++++++++ lib/facter/apt_security_updates.rb | 9 ++++++ lib/facter/apt_updates.rb | 9 ++++++ spec/unit/facter/apt_package_updates_spec.rb | 29 +++++++++++++++++++ spec/unit/facter/apt_security_updates_spec.rb | 24 +++++++++++++++ spec/unit/facter/apt_updates_spec.rb | 24 +++++++++++++++ 7 files changed, 115 insertions(+) create mode 100644 lib/facter/apt_package_updates.rb create mode 100644 lib/facter/apt_security_updates.rb create mode 100644 lib/facter/apt_updates.rb create mode 100644 spec/unit/facter/apt_package_updates_spec.rb create mode 100644 spec/unit/facter/apt_security_updates_spec.rb create mode 100644 spec/unit/facter/apt_updates_spec.rb diff --git a/README.md b/README.md index cbaab72472..e8efc3aaf9 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,13 @@ If you would like to configure your system so the source is the Puppet Labs APT key_server => 'pgp.mit.edu', } +### Facts + +There are a few facts included within the apt module describing the state of the apt system: + +* `apt_updates` - the number of updates available on the system +* `apt_security_updates` - the number of updates which are security updates +* `apt_package_updates` - the package names that are available for update. On Facter 2.0 and newer this will be a list type, in earlier versions it is a comma delimitered string. #### Hiera example
diff --git a/lib/facter/apt_package_updates.rb b/lib/facter/apt_package_updates.rb
new file mode 100644
index 0000000000..97c75c66a2
--- /dev/null
+++ b/lib/facter/apt_package_updates.rb
@@ -0,0 +1,13 @@
+Facter.add("apt_package_updates") do
+  confine :osfamily => 'Debian'
+  setcode do
+    if File.executable?("/usr/lib/update-notifier/apt-check")
+      packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1')
+      packages = packages.split("\n")
+      if Facter.version < '2.0.0'
+        packages = packages.join(',')
+      end
+      packages
+    end
+  end
+end
diff --git a/lib/facter/apt_security_updates.rb b/lib/facter/apt_security_updates.rb
new file mode 100644
index 0000000000..19bae7521d
--- /dev/null
+++ b/lib/facter/apt_security_updates.rb
@@ -0,0 +1,9 @@
+Facter.add("apt_security_updates") do
+  confine :osfamily => 'Debian'
+  setcode do
+    if File.executable?("/usr/lib/update-notifier/apt-check")
+      updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1')
+      Integer(updates.strip.split(';')[1])
+    end
+  end
+end
diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb
new file mode 100644
index 0000000000..ee177380c2
--- /dev/null
+++ b/lib/facter/apt_updates.rb
@@ -0,0 +1,9 @@
+Facter.add("apt_updates") do
+  confine :osfamily => 'Debian'
+  setcode do
+    if File.executable?("/usr/lib/update-notifier/apt-check")
+      updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1')
+      Integer(updates.strip.split(';')[0])
+    end
+  end
+end
diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb
new file mode 100644
index 0000000000..dfa09270eb
--- /dev/null
+++ b/spec/unit/facter/apt_package_updates_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+describe 'apt_package_updates fact' do
+  subject { Facter.fact(:apt_package_updates).value }
+  after(:each) { Facter.clear }
+
+  describe 'on Debian based distro missing update-notifier-common' do
+    before { 
+    Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+    File.stubs(:executable?).returns false
+  }
+  it { should == nil }
+  end
+
+  describe 'on Debian based distro' do
+    before { 
+    Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+    File.stubs(:executable?).returns true
+    Facter::Util::Resolution.stubs(:exec).returns "puppet-common\nlinux-generic\nlinux-image-generic"
+  }
+  it {
+    if Facter.version < '2.0.0'
+      should == 'puppet-common,linux-generic,linux-image-generic'
+    else
+      should == ['puppet-common', 'linux-generic', 'linux-image-generic']
+    end
+  }
+  end
+end
diff --git a/spec/unit/facter/apt_security_updates_spec.rb b/spec/unit/facter/apt_security_updates_spec.rb
new file mode 100644
index 0000000000..999603b612
--- /dev/null
+++ b/spec/unit/facter/apt_security_updates_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe 'apt_security_updates fact' do
+  subject { Facter.fact(:apt_security_updates).value }
+  after(:each) { Facter.clear }
+
+  describe 'on Debian based distro missing update-notifier-common' do
+    before { 
+    Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+    File.stubs(:executable?).returns false
+  }
+  it { should == nil }
+  end
+
+  describe 'on Debian based distro' do
+    before { 
+    Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+    File.stubs(:executable?).returns true
+    Facter::Util::Resolution.stubs(:exec).returns '14;7'
+  }
+  it { should == 7 }
+  end
+
+end
diff --git a/spec/unit/facter/apt_updates_spec.rb b/spec/unit/facter/apt_updates_spec.rb
new file mode 100644
index 0000000000..2f343bd8a1
--- /dev/null
+++ b/spec/unit/facter/apt_updates_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe 'apt_updates fact' do
+  subject { Facter.fact(:apt_updates).value }
+  after(:each) { Facter.clear }
+
+  describe 'on Debian based distro missing update-notifier-common' do
+    before { 
+    Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+    File.stubs(:executable?).returns false
+  }
+  it { should == nil }
+  end
+
+  describe 'on Debian based distro' do
+    before { 
+    Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+    File.stubs(:executable?).returns true
+    Facter::Util::Resolution.stubs(:exec).returns '14;7'
+  }
+  it { should == 14 }
+  end
+
+end

From cd9d526b0f80f4617d3b2ec6f9ac033b3a7c2a4b Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Fri, 27 Jun 2014 09:27:52 -0700
Subject: [PATCH 321/574] Update .sync.yml to support new .travis.yml configs

---
 .sync.yml | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/.sync.yml b/.sync.yml
index 1b7c84ec84..ed97d539c0 100644
--- a/.sync.yml
+++ b/.sync.yml
@@ -1,5 +1 @@
 ---
-.travis.yml:
-  env_matrix:
-  - PUPPET_GEM_VERSION="~> 3.4.0"
-  - PUPPET_GEM_VERSION="~> 3.5.0"

From 9973ebc9498976cdb5ac1d4293f0fc9e69dc453c Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Fri, 27 Jun 2014 10:52:08 -0700
Subject: [PATCH 322/574] Synchronize .travis.yml

---
 .travis.yml | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index f48d71a847..c72d5e20fd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,24 +1,17 @@
 ---
-branches:
-  only:
-    - master
 language: ruby
 bundler_args: --without development
 script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
-rvm:
-  - 1.8.7
-  - 1.9.3
-  - 2.0.0
-env:
-  matrix:
-  - PUPPET_GEM_VERSION="~> 3.4.0"
-  - PUPPET_GEM_VERSION="~> 3.5.0"
 matrix:
   fast_finish: true
-  exclude:
+  include:
+  - rvm: 1.8.7
+    env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
+  - rvm: 1.8.7
+    env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
   - rvm: 1.9.3
-    env: PUPPET_GEM_VERSION="~> 2.7.0"
+    env: PUPPET_GEM_VERSION="~> 3.0"
   - rvm: 2.0.0
-    env: PUPPET_GEM_VERSION="~> 2.7.0"
+    env: PUPPET_GEM_VERSION="~> 3.0"
 notifications:
   email: false

From 2ea894fe326755e83625270eb9a4444a85ca0864 Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Mon, 30 Jun 2014 10:57:45 -0700
Subject: [PATCH 323/574] Update Gemfile for .travis.yml defaults

---
 Gemfile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Gemfile b/Gemfile
index 9074f1e75b..e960f7c4b7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -12,6 +12,12 @@ group :development, :test do
   gem 'simplecov',               :require => false
 end
 
+if facterversion = ENV['FACTER_GEM_VERSION']
+  gem 'facter', facterversion, :require => false
+else
+  gem 'facter', :require => false
+end
+
 if puppetversion = ENV['PUPPET_GEM_VERSION']
   gem 'puppet', puppetversion, :require => false
 else

From 4d3874f19aec5fca47799831e1c73815eeb59cf7 Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Thu, 3 Jul 2014 09:53:35 -0700
Subject: [PATCH 324/574] Add validate and lint tasks to travis script

---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index c72d5e20fd..a40ae502e9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,7 @@
 ---
 language: ruby
 bundler_args: --without development
-script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
+script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'"
 matrix:
   fast_finish: true
   include:

From 0308872b86b449e81e54e4fe45c8cedf4838cbe9 Mon Sep 17 00:00:00 2001
From: Dave 
Date: Sun, 6 Jul 2014 12:09:06 +0900
Subject: [PATCH 325/574] Update builddep.pp

---
 manifests/builddep.pp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/manifests/builddep.pp b/manifests/builddep.pp
index 3294f71339..3beadeb373 100644
--- a/manifests/builddep.pp
+++ b/manifests/builddep.pp
@@ -6,7 +6,7 @@
   exec { "apt-builddep-${name}":
     command   => "/usr/bin/apt-get -y --force-yes build-dep ${name}",
     logoutput => 'on_failure',
-    notify    => Exec['apt_update'],
+    require    => Exec['apt_update'],
   }
 
   # Need anchor to provide containment for dependencies.

From f4ea10f4d88c031e0f1ae90e039252e71b25db3a Mon Sep 17 00:00:00 2001
From: Arkady Smirnov 
Date: Wed, 9 Jul 2014 14:06:40 +0300
Subject: [PATCH 326/574] MODULES-780 Don't blow up on unicode characters.

---
 lib/puppet/provider/apt_key/apt_key.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb
index 1d3c1744b5..e5020fe27d 100644
--- a/lib/puppet/provider/apt_key/apt_key.rb
+++ b/lib/puppet/provider/apt_key/apt_key.rb
@@ -31,7 +31,7 @@ def self.instances
     else
       key_output = apt_key('list')
     end
-    key_array = apt_key('list').split("\n").collect do |line|
+    key_array = key_output.split("\n").collect do |line|
       line_hash = key_line_hash(line)
       next unless line_hash
       expired = false

From 39758f4f5e757f957862dec27e586691f71a358b Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Wed, 9 Jul 2014 19:34:12 -0400
Subject: [PATCH 327/574] 1.5.1 prep.

---
 CHANGELOG.md  | 5 +++++
 Modulefile    | 2 +-
 metadata.json | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index bf8553d8b6..f16b803b57 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+##2014-07-10 - Supported Release 1.5.1
+###Summary
+
+This release has added tests to ensure graceful failure on OSX.
+
 ##2014-06-04 - Release 1.5.0
 ###Summary
 
diff --git a/Modulefile b/Modulefile
index 45169b31e8..b06eba3511 100644
--- a/Modulefile
+++ b/Modulefile
@@ -1,5 +1,5 @@
 name    'puppetlabs-apt'
-version '1.5.0'
+version '1.5.1'
 source  'https://github.com/puppetlabs/puppetlabs-apt'
 author  'Evolving Web / Puppet Labs'
 license 'Apache License 2.0'
diff --git a/metadata.json b/metadata.json
index 7365c67f86..8c93b0a158 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,6 +1,6 @@
 {
     "name": "puppetlabs-apt",
-    "version": "1.5.0",
+    "version": "1.5.1",
     "source": "https://github.com/puppetlabs/puppetlabs-apt",
     "author": "Puppet Labs",
     "license": "Apache-2.0",

From 64b8eb1e4a67e0d7515b2aa971564c08ef8903be Mon Sep 17 00:00:00 2001
From: Spencer Owen 
Date: Thu, 10 Jul 2014 11:48:54 -0600
Subject: [PATCH 328/574] Adds check to params.pp if lab-release is not
 installed Adds spec test

If lab-release is not installed, then the end user sees a confusing/ vague message
Error: Unsupported lsbdistid () at /modules/apt/manifests/params.pp:52
It is common for docker containers to not include this package by default

After fix, the user sees a friendlier message if lab-release is not installed
Error: Unable to determine lsbdistid, is lsb-release installed? at /modules/apt/manifests/params.pp:52
---
 manifests/params.pp         |  3 +++
 spec/classes/params_spec.rb | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/manifests/params.pp b/manifests/params.pp
index f635b5801c..d57b80110c 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -49,6 +49,9 @@
         }
       }
     }
+    '': {
+      fail('Unable to determine lsbdistid, is lsb-release installed?')
+    }
     default: {
       fail("Unsupported lsbdistid (${::lsbdistid})")
     }
diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb
index aa330bb987..d85e849d5a 100644
--- a/spec/classes/params_spec.rb
+++ b/spec/classes/params_spec.rb
@@ -24,4 +24,16 @@
     end
 
   end
+
+  describe "With lsb-release not installed" do
+    let(:facts) { { :lsbdistid => '' } }
+    let (:title) { 'my_package' }
+
+    it do
+      expect {
+        should compile
+      }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, is lsb-release installed/)
+    end
+  end
+
 end

From 0c2329bd57c383a1562cad474284dbf28c15d234 Mon Sep 17 00:00:00 2001
From: Daniel Friesen 
Date: Thu, 10 Jul 2014 16:38:45 -0700
Subject: [PATCH 329/574] Fix inconsistent $proxy_host handling in apt and
 apt::ppa.

- The default for $proxy_host is undef
- apt considers $proxy_set to be absent if $proxy_host is undef
- apt::ppa considers proxy_env to be empty if $proxy_host is false or ''

This results in apt::ppa to consider $proxy_host to be set when the default undef is used
breaking ppa resources because $proxy_env becomes:
  [http_proxy=http://:8080, https_proxy=http://:8080]

Fix this by making both apt and apt::ppa consider $proxy_host to be unset when it is
any of false, '', or undef.
---
 manifests/init.pp | 32 +++++++++++++++++++-------------
 manifests/ppa.pp  | 10 ++++++----
 2 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/manifests/init.pp b/manifests/init.pp
index 597774c833..08f62d15d9 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -139,19 +139,25 @@
     default: { fail('Valid values for disable_keys are true or false') }
   }
 
-  $proxy_set = $proxy_host ? {
-    undef   => absent,
-    default => present
-  }
-
-  file { '01proxy':
-    ensure  => $proxy_set,
-    path    => "${apt_conf_d}/01proxy",
-    content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n",
-    notify  => Exec['apt_update'],
-    mode    => '0644',
-    owner   => root,
-    group   => root,
+  case $proxy_host {
+    false, '', undef: {
+      file { '01proxy':
+        ensure  => absent,
+        path    => "${apt_conf_d}/01proxy",
+        content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n",
+        notify  => Exec['apt_update'],
+        mode    => '0644',
+        owner   => root,
+        group   => root,
+      }
+    }
+    default: {
+      file { '01proxy':
+        ensure  => present,
+        path    => "${apt_conf_d}/01proxy",
+        notify  => Exec['apt_update'],
+      }
+    }
   }
 
   file { 'old-proxy-file':
diff --git a/manifests/ppa.pp b/manifests/ppa.pp
index a55e1e0e5c..27edff80b2 100644
--- a/manifests/ppa.pp
+++ b/manifests/ppa.pp
@@ -36,11 +36,13 @@
     if defined(Class[apt]) {
         $proxy_host = $apt::proxy_host
         $proxy_port = $apt::proxy_port
-        case  $proxy_host {
-        false, '': {
+        case $proxy_host {
+          false, '', undef: {
             $proxy_env = []
-        }
-        default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]}
+          }
+          default: {
+            $proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]
+          }
         }
     } else {
         $proxy_env = []

From 562e702a46fa55f54bb436aa9df4267003622fa1 Mon Sep 17 00:00:00 2001
From: Daniel Friesen 
Date: Fri, 11 Jul 2014 14:33:15 -0700
Subject: [PATCH 330/574] Fix mistake in my 0c2329b implementation.

---
 manifests/init.pp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/manifests/init.pp b/manifests/init.pp
index 08f62d15d9..1c318b67ca 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -144,18 +144,18 @@
       file { '01proxy':
         ensure  => absent,
         path    => "${apt_conf_d}/01proxy",
-        content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n",
         notify  => Exec['apt_update'],
-        mode    => '0644',
-        owner   => root,
-        group   => root,
       }
     }
     default: {
       file { '01proxy':
         ensure  => present,
         path    => "${apt_conf_d}/01proxy",
+        content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n",
         notify  => Exec['apt_update'],
+        mode    => '0644',
+        owner   => root,
+        group   => root,
       }
     }
   }

From 854eabe5c393385ff52a28069bf0336cc9afc6ca Mon Sep 17 00:00:00 2001
From: Ashley Penney 
Date: Tue, 15 Jul 2014 11:32:58 -0400
Subject: [PATCH 331/574] Prepare a 1.5.2 release.

---
 CHANGELOG.md  |  6 +++++
 Modulefile    | 14 -----------
 metadata.json | 70 ++++++++++++++++++++++++++++++---------------------
 3 files changed, 47 insertions(+), 43 deletions(-)
 delete mode 100644 Modulefile

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f16b803b57..011c41d378 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+##2014-07-15 - Supported Release 1.5.2
+###Summary
+
+This release merely updates metadata.json so the module can be uninstalled and
+upgraded via the puppet module command.
+
 ##2014-07-10 - Supported Release 1.5.1
 ###Summary
 
diff --git a/Modulefile b/Modulefile
deleted file mode 100644
index b06eba3511..0000000000
--- a/Modulefile
+++ /dev/null
@@ -1,14 +0,0 @@
-name    'puppetlabs-apt'
-version '1.5.1'
-source  'https://github.com/puppetlabs/puppetlabs-apt'
-author  'Evolving Web / Puppet Labs'
-license 'Apache License 2.0'
-summary 'Puppet Labs Apt Module'
-description 'APT Module for Puppet'
-project_page 'https://github.com/puppetlabs/puppetlabs-apt'
-
-## Add dependencies, if any:
-#dependency 'puppetlabs/stdlib', '2.x'
-# The dependency should be written as above but librarian-puppet
-# does not support the expression as the PMT does.
-dependency 'puppetlabs/stdlib', '>= 2.2.1'
diff --git a/metadata.json b/metadata.json
index 8c93b0a158..f1c18a5dbc 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,31 +1,43 @@
 {
-    "name": "puppetlabs-apt",
-    "version": "1.5.1",
-    "source": "https://github.com/puppetlabs/puppetlabs-apt",
-    "author": "Puppet Labs",
-    "license": "Apache-2.0",
-    "project_page": "https://github.com/puppetlabs/puppetlabs-apt",
-    "summary": "Puppet Labs Apt Module",
-    "operatingsystem_support": [
-      {
-        "operatingsystem": "Debian",
-        "operatingsystemrelease": [
-          "6",
-          "7"
-        ]
-      },
-      {
-        "operatingsystem": "Ubuntu",
-        "operatingsystemrelease": [
-          "10.04",
-          "12.04",
-          "14.04"
-        ]
-      }
-    ],
-    "requirements": [
-      { "name": "pe", "version_requirement": ">= 3.2.0 < 3.4.0" },
-      { "name": "puppet", "version_requirement": "3.x" }
-    ],
-    "dependencies": []
+  "name": "puppetlabs-apt",
+  "version": "1.5.2",
+  "author": "Puppet Labs",
+  "summary": "Puppet Labs Apt Module",
+  "license": "Apache-2.0",
+  "source": "https://github.com/puppetlabs/puppetlabs-apt",
+  "project_page": "https://github.com/puppetlabs/puppetlabs-apt",
+  "issues_url": "https://github.com/puppetlabs/puppetlabs-apt/issues",
+  "operatingsystem_support": [
+    {
+      "operatingsystem": "Debian",
+      "operatingsystemrelease": [
+        "6",
+        "7"
+      ]
+    },
+    {
+      "operatingsystem": "Ubuntu",
+      "operatingsystemrelease": [
+        "10.04",
+        "12.04",
+        "14.04"
+      ]
+    }
+  ],
+  "requirements": [
+    {
+      "name": "pe",
+      "version_requirement": ">= 3.2.0 < 3.4.0"
+    },
+    {
+      "name": "puppet",
+      "version_requirement": "3.x"
+    }
+  ],
+  "dependencies": [
+    {
+      "name": "puppetlabs/stdlib",
+      "version_requirement": ">= 2.2.1"
+    }
+  ]
 }

From 1a0406bf3948e3d13b037b2d17b6cf8d29bcf9e5 Mon Sep 17 00:00:00 2001
From: Zachary Alex Stern 
Date: Wed, 16 Jul 2014 15:01:02 -0700
Subject: [PATCH 332/574] Fix readme typo.

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 9c52c77f74..0749cb85af 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ To begin using the APT module with default parameters, declare the class
 
     include apt
 
-Puppet code that uses anything from the APT module requires that the core apt class be declared/\s\+$//e
+Puppet code that uses anything from the APT module requires that the core apt class be declared.
 
 Usage
 -----

From 76a508c710fb415100bd96025ad324eb80485302 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Fri, 25 Jul 2014 18:20:06 -0400
Subject: [PATCH 333/574] Prep for 1.6.0 release.

---
 CHANGELOG.md  | 16 ++++++++++++++++
 metadata.json |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 011c41d378..a5bea595b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,19 @@
+##2014-07-30 - Supported Release 1.6.0
+###Summary
+
+####Features
+- Allow URL or domain name for key_server parameter
+- Allow custom comment for sources list
+- Files synced using ModuleSync!
+- Enable auto-update for Debian squeeze LTS
+- Add facts showing available updates
+
+####Bugfixes
+- Fix regex to follow apt requirements
+- Allow dashes in URL or domain for key_server parameter
+- Test fixes for Ubuntu 10.04
+- Fix for unicode characters
+
 ##2014-07-15 - Supported Release 1.5.2
 ###Summary
 
diff --git a/metadata.json b/metadata.json
index f1c18a5dbc..f6ea55e160 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,6 +1,6 @@
 {
   "name": "puppetlabs-apt",
-  "version": "1.5.2",
+  "version": "1.6.0",
   "author": "Puppet Labs",
   "summary": "Puppet Labs Apt Module",
   "license": "Apache-2.0",

From f02f9b8465fbd07a53061deaded55ffb47a6fbd2 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Wed, 30 Jul 2014 12:03:09 -0400
Subject: [PATCH 334/574] Fix broken acceptance tests.

New fact was added that matched a regex breaking the always_apt_update
tests.  Updated the tests to check for the apt_update exec, not just the
string apt_update.
---
 spec/acceptance/apt_spec.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb
index 60def0e154..97f00f1681 100644
--- a/spec/acceptance/apt_spec.rb
+++ b/spec/acceptance/apt_spec.rb
@@ -15,7 +15,7 @@ class { 'apt': always_apt_update => true }
       EOS
 
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/apt_update/)
+        expect(r.stdout).to match(/Exec\[apt_update\]/)
       end
     end
   end
@@ -26,7 +26,7 @@ class { 'apt': always_apt_update => false }
       EOS
 
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to_not match(/apt_update/)
+        expect(r.stdout).to_not match(/Exec\[apt_update\]/)
       end
     end
   end

From 66e05edbe77fc20a4d4681dbfd62376eb1f2a2d4 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Wed, 30 Jul 2014 14:40:20 -0400
Subject: [PATCH 335/574] Debian seems to have hanging apt-get and/or dpkg
 processes, so kill those.

---
 spec/acceptance/unattended_upgrade_spec.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/spec/acceptance/unattended_upgrade_spec.rb b/spec/acceptance/unattended_upgrade_spec.rb
index 6a19f4e74e..09f4e2bed0 100644
--- a/spec/acceptance/unattended_upgrade_spec.rb
+++ b/spec/acceptance/unattended_upgrade_spec.rb
@@ -10,8 +10,8 @@
 
       # Attempted workaround for problems seen on debian with
       # something holding the package database open.
-      #shell('killall -9 apt-get')
-      #shell('killall -9 dpkg')
+      shell('killall -9 apt-get', { :acceptable_exit_codes => [0,1] })
+      shell('killall -9 dpkg', { :acceptable_exit_codes => [0,1] })
       apply_manifest(pp, :catch_failures => true)
     end
 

From 538a9f9aaba94f8089c20dd33e13bd87c3b659ac Mon Sep 17 00:00:00 2001
From: wilman0 
Date: Fri, 18 Jul 2014 10:51:32 +0200
Subject: [PATCH 336/574] Update hold.pp

fix for default debian installations

all files in /etc/apt/preferences without _ will be silently ignore according to debian manpage. Addionally its not a good idea to write versionnumber in filename cause there is no way to delete this files if you increase versionumber

Update source_spec.rb

add a way to include debsrc only (useful for debian/ubuntu build server ... jenkins ect)

Update source_spec.rb

var rename

Update source.list.erb

add include_deb "switch"

Update source.pp

"include_deb" defaultvalue = true

Update hold_spec.rb

change the name of the preferences file (hold)

Update source_spec.rb

Update README.md

Doku: 'include_deb' included next to 'include_src' in examples

Update README.md

typo
---
 README.md                   | 4 +++-
 manifests/hold.pp           | 4 ++--
 manifests/source.pp         | 1 +
 spec/defines/hold_spec.rb   | 6 +++---
 spec/defines/source_spec.rb | 6 ++++--
 templates/source.list.erb   | 2 ++
 6 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 0749cb85af..9f3bbbe7b7 100644
--- a/README.md
+++ b/README.md
@@ -202,7 +202,8 @@ Adds an apt source to `/etc/apt/sources.list.d/`.
       key               => '46925553',
       key_server        => 'subkeys.pgp.net',
       pin               => '-10',
-      include_src       => true
+      include_src       => true,
+      include_deb       => true
     }
 
 If you would like to configure your system so the source is the Puppet Labs APT repository
@@ -234,6 +235,7 @@ apt::sources:
       key_server: 'subkeys.pgp.net'
       pin: '-10'
       include_src: 'true'
+      include_deb: 'true'
 
   'puppetlabs':
       location: 'http://apt.puppetlabs.com'
diff --git a/manifests/hold.pp b/manifests/hold.pp
index c4016c6e34..61e8afcb3b 100644
--- a/manifests/hold.pp
+++ b/manifests/hold.pp
@@ -40,13 +40,13 @@
   }
 
   if $ensure == 'present' {
-    ::apt::pin { "hold ${package} at ${version}":
+    ::apt::pin { "hold_${package}":
       packages => $package,
       version  => $version,
       priority => $priority,
     }
   } else {
-    ::apt::pin { "hold ${package} at ${version}":
+    ::apt::pin { "hold_${package}":
       ensure => 'absent',
     }
   }
diff --git a/manifests/source.pp b/manifests/source.pp
index dd00adc6a4..259d0ebb98 100644
--- a/manifests/source.pp
+++ b/manifests/source.pp
@@ -8,6 +8,7 @@
   $release           = 'UNDEF',
   $repos             = 'main',
   $include_src       = true,
+  $include_deb       = true,
   $required_packages = false,
   $key               = undef,
   $key_server        = 'keyserver.ubuntu.com',
diff --git a/spec/defines/hold_spec.rb b/spec/defines/hold_spec.rb
index 731e218d84..9da21d784a 100644
--- a/spec/defines/hold_spec.rb
+++ b/spec/defines/hold_spec.rb
@@ -25,7 +25,7 @@
         :priority => 1001,
       })
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
         :packages => title,
         :version  => params[:version],
@@ -42,7 +42,7 @@
         :ensure   => params[:ensure],
       })
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => params[:ensure],
       })
     end
@@ -59,7 +59,7 @@
         :priority => params[:priority],
       })
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
         :packages => title,
         :version  => params[:version],
diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb
index 7c7ae399e8..284adca27f 100644
--- a/spec/defines/source_spec.rb
+++ b/spec/defines/source_spec.rb
@@ -15,6 +15,7 @@
       :release            => 'karmic',
       :repos              => 'main',
       :include_src        => true,
+      :include_deb        => true,
       :required_packages  => false,
       :key                => false,
       :key_server         => false,
@@ -83,8 +84,9 @@
         if param_hash[:architecture]
           arch = "[arch=#{param_hash[:architecture]}] "
         end
-        content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
-
+        if param_hash[:include_deb]
+	  content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
+	end
         if param_hash[:include_src]
           content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
         end
diff --git a/templates/source.list.erb b/templates/source.list.erb
index a57244fce8..01b2176a6e 100644
--- a/templates/source.list.erb
+++ b/templates/source.list.erb
@@ -1,6 +1,8 @@
 #file generated by puppet
 # <%= @comment %>
+<%- if @include_deb then -%>
 deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %>
+<%- end -%>
 <%- if @include_src then -%>
 deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %>
 <%- end -%>

From 4ed9cb5099ac56d32eeffe3a718d2ee10c406bd3 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Wed, 30 Jul 2014 19:54:28 -0400
Subject: [PATCH 337/574] Cleaned up acceptance tests

A lot of the tests were testing things that really should be tested via
unit tests, so those were deleted and unit tests will be revamped to
make sure they are covering everything they need to be covering.
---
 spec/acceptance/apt_builddep_spec.rb       |  36 --
 spec/acceptance/apt_key_provider_spec.rb   |   2 +-
 spec/acceptance/apt_key_spec.rb            | 200 --------
 spec/acceptance/apt_ppa_spec.rb            | 138 -----
 spec/acceptance/apt_source_spec.rb         | 326 ------------
 spec/acceptance/apt_spec.rb                | 299 +----------
 spec/acceptance/backports_spec.rb          |  73 ---
 spec/acceptance/class_spec.rb              |   2 +-
 spec/acceptance/conf_spec.rb               |  66 ---
 spec/acceptance/force_spec.rb              |  76 ---
 spec/acceptance/pin_spec.rb                | 286 -----------
 spec/acceptance/release_spec.rb            |  26 -
 spec/acceptance/unattended_upgrade_spec.rb | 562 ---------------------
 spec/acceptance/unsupported_spec.rb        |  10 -
 14 files changed, 23 insertions(+), 2079 deletions(-)
 delete mode 100644 spec/acceptance/apt_builddep_spec.rb
 delete mode 100644 spec/acceptance/apt_key_spec.rb
 delete mode 100644 spec/acceptance/apt_ppa_spec.rb
 delete mode 100644 spec/acceptance/apt_source_spec.rb
 delete mode 100644 spec/acceptance/backports_spec.rb
 delete mode 100644 spec/acceptance/conf_spec.rb
 delete mode 100644 spec/acceptance/force_spec.rb
 delete mode 100644 spec/acceptance/pin_spec.rb
 delete mode 100644 spec/acceptance/release_spec.rb
 delete mode 100644 spec/acceptance/unattended_upgrade_spec.rb
 delete mode 100644 spec/acceptance/unsupported_spec.rb

diff --git a/spec/acceptance/apt_builddep_spec.rb b/spec/acceptance/apt_builddep_spec.rb
deleted file mode 100644
index 1e35e4aa68..0000000000
--- a/spec/acceptance/apt_builddep_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::builddep', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-
-  context 'reset' do
-    it 'removes packages' do
-      shell('apt-get -y remove znc')
-      shell('apt-get -y remove g++')
-    end
-  end
-
-  context 'apt::builddep' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include '::apt'
-      apt::builddep { 'znc': }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe 'should install g++ as a dependency' do
-      describe package('g++') do
-        it { should be_installed }
-      end
-    end
-  end
-
-  context 'reset' do
-    it 'removes packages' do
-      shell('apt-get -y remove znc')
-      shell('apt-get -y remove g++')
-    end
-  end
-
-end
diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb
index d9c2c0d751..497c6edb53 100644
--- a/spec/acceptance/apt_key_provider_spec.rb
+++ b/spec/acceptance/apt_key_provider_spec.rb
@@ -7,7 +7,7 @@
 CENTOS_REPO_URL         = 'ftp.cvut.cz/centos'
 CENTOS_GPG_KEY_FILE     = 'RPM-GPG-KEY-CentOS-6'
 
-describe 'apt_key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+describe 'apt_key' do
   before(:each) do
     shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}",
           :acceptable_exit_codes => [0,1,2])
diff --git a/spec/acceptance/apt_key_spec.rb b/spec/acceptance/apt_key_spec.rb
deleted file mode 100644
index 9f2ba395ad..0000000000
--- a/spec/acceptance/apt_key_spec.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'apt::key' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include '::apt'
-      apt::key { 'puppetlabs':
-        key        => '4BD6EC30',
-        key_server => 'pgp.mit.edu',
-      }
-
-      apt::key { 'jenkins':
-        key        => 'D50582E6',
-        key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
-      }
-      EOS
-
-      shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-      shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe 'keys should exist' do
-      it 'finds puppetlabs key' do
-        shell('apt-key list | grep 4BD6EC30')
-      end
-      it 'finds jenkins key' do
-        shell('apt-key list | grep D50582E6')
-      end
-    end
-  end
-  context 'ensure' do
-    context 'absent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::key { 'puppetlabs':
-          ensure     => absent,
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-        }
-
-        apt::key { 'jenkins':
-          ensure     => absent,
-          key        => 'D50582E6',
-          key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'keys shouldnt exist' do
-        it 'fails' do
-          shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [1])
-        end
-        it 'fails' do
-          shell('apt-key list | grep D50582E6', :acceptable_exit_codes => [1])
-        end
-      end
-    end
-  end
-
-  context 'reset' do
-    it 'clean up keys' do
-      shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-      shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
-    end
-  end
-
-  context 'key options' do
-    context 'key_content' do
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::key { 'puppetlabs':
-          key         => '4BD6EC30',
-          key_content => '-----BEGIN PGP PUBLIC KEY BLOCK-----
-          Version: GnuPG v1.4.12 (GNU/Linux)
-          Comment: GPGTools - http://gpgtools.org
-
-          mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b
-          fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg
-          5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+
-            S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY
-          GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH
-          Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v
-          VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0
-          Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI
-          wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN
-          NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl
-          f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB
-          tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL
-          ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn
-          AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob
-          pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF
-          eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+
-            aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M
-          2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ
-          VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU
-          3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh
-          qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1
-          IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8
-          1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp
-          HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN
-          MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+
-            UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh
-          R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+
-            N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc
-          kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e
-          lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT
-          DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb
-          kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf
-          DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei
-          BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z
-          XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2
-          +zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU
-          fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH
-          dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4
-          qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2
-          7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq
-          UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x
-          Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA
-          KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3
-          okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7
-          bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4
-          4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX
-          vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0
-          jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y
-          ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD
-          7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR
-          M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf
-          REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y
-          DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk
-          ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
-            =a34C
-          -----END PGP PUBLIC KEY BLOCK-----
-          ',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-    end
-    describe 'keys should exist' do
-      it 'finds puppetlabs key' do
-        shell('apt-key list | grep 4BD6EC30')
-      end
-    end
-
-    context 'key_source' do
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::key { 'puppetlabs':
-          key        => '4BD6EC30',
-          key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'keys should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30')
-        end
-      end
-    end
-
-    context 'key_options' do
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::key { 'puppetlabs':
-          key        => '4BD6EC30',
-          key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
-          key_options => 'debug'
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'keys should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30')
-        end
-      end
-    end
-  end
-
-end
diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb
deleted file mode 100644
index b665c5cf47..0000000000
--- a/spec/acceptance/apt_ppa_spec.rb
+++ /dev/null
@@ -1,138 +0,0 @@
-require 'spec_helper_acceptance'
-
-if fact('operatingsystem') == 'Ubuntu'
-  describe 'apt::ppa', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-
-    context 'reset' do
-      it 'removes ppa' do
-        shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
-        shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
-      end
-    end
-
-    context 'adding a ppa that doesnt exist' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::ppa { 'ppa:canonical-kernel-team/ppa': }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'contains the source file' do
-        it 'contains a kernel ppa source' do
-          shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
-        end
-      end
-    end
-
-    context 'reading a removed ppa.' do
-      it 'setup' do
-        # This leaves a blank file
-        shell('echo > /etc/apt/sources.list.d/raravena80-collectd5-$(lsb_release -c -s).list')
-      end
-
-      it 'should read it successfully' do
-        pp = <<-EOS
-        include '::apt'
-        apt::ppa { 'ppa:raravena80/collectd5': }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-    end
-
-    context 'reset' do
-      it 'removes added ppas' do
-        shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
-        shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
-      end
-    end
-
-    context 'ensure' do
-      context 'present' do
-        it 'works without failure' do
-          pp = <<-EOS
-          include '::apt'
-          apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present }
-          EOS
-
-          apply_manifest(pp, :catch_failures => true)
-        end
-
-        describe 'contains the source file' do
-          it 'contains a kernel ppa source' do
-            shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
-          end
-        end
-      end
-    end
-
-    context 'ensure' do
-      context 'absent' do
-        it 'works without failure' do
-          pp = <<-EOS
-          include '::apt'
-          apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent }
-          EOS
-
-          apply_manifest(pp, :catch_failures => true)
-        end
-
-        describe 'doesnt contain the source file' do
-          it 'fails' do
-            shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2])
-          end
-        end
-      end
-    end
-
-    context 'release' do
-      context 'precise' do
-        it 'works without failure' do
-          pp = <<-EOS
-          include '::apt'
-          apt::ppa { 'ppa:canonical-kernel-team/ppa':
-            ensure  => present,
-            release => precise,
-          }
-          EOS
-
-          shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
-          apply_manifest(pp, :catch_failures => true)
-        end
-
-        describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
-          it { should be_file }
-        end
-      end
-    end
-
-    context 'options' do
-      context '-y', :unless => default[:platform].match(/10\.04/) do
-        it 'works without failure' do
-          pp = <<-EOS
-          include '::apt'
-          apt::ppa { 'ppa:canonical-kernel-team/ppa':
-            ensure  => present,
-            release => precise,
-            options => '-y',
-          }
-          EOS
-
-          shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
-          apply_manifest(pp, :catch_failures => true)
-        end
-
-        describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
-          it { should be_file }
-        end
-      end
-    end
-
-    context 'reset' do
-      it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) }
-    end
-  end
-end
diff --git a/spec/acceptance/apt_source_spec.rb b/spec/acceptance/apt_source_spec.rb
deleted file mode 100644
index c2d076cbff..0000000000
--- a/spec/acceptance/apt_source_spec.rb
+++ /dev/null
@@ -1,326 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::source', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-
-  context 'apt::source' do
-    context 'ensure => present' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'key should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0])
-        end
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-      end
-    end
-
-    context 'ensure => absent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => absent,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      # The key should remain -we don't delete those when deleting a source.
-      describe 'key should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0])
-        end
-      end
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should_not be_file }
-      end
-    end
-
-  end
-
-  context 'release' do
-    context 'test' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-          release    => 'precise',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-        it { should contain 'deb http://apt.puppetlabs.com precise main' }
-      end
-    end
-  end
-
-  context 'include_src' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure      => present,
-          location    => 'http://apt.puppetlabs.com',
-          repos       => 'main',
-          key         => '4BD6EC30',
-          key_server  => 'pgp.mit.edu',
-          include_src => true,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-        it { should contain 'deb-src http://apt.puppetlabs.com' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure      => present,
-          location    => 'http://apt.puppetlabs.com',
-          repos       => 'main',
-          key         => '4BD6EC30',
-          key_server  => 'pgp.mit.edu',
-          include_src => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-        it { should_not contain 'deb-src http://apt.puppetlabs.com' }
-      end
-    end
-  end
-
-  context 'required_packages' do
-    context 'vim' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure             => present,
-          location           => 'http://apt.puppetlabs.com',
-          repos              => 'main',
-          key                => '4BD6EC30',
-          key_server         => 'pgp.mit.edu',
-          required_packages  => 'vim',
-        }
-        EOS
-
-        shell('apt-get -y remove vim')
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe package('vim') do
-        it { should be_installed }
-      end
-    end
-  end
-
-  context 'key content' do
-    context 'giant key' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure      => present,
-          location    => 'http://apt.puppetlabs.com',
-          repos       => 'main',
-          key         => '4BD6EC30',
-          key_content => '-----BEGIN PGP PUBLIC KEY BLOCK-----
-          Version: GnuPG v1.4.12 (GNU/Linux)
-          Comment: GPGTools - http://gpgtools.org
-
-          mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b
-          fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg
-          5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+
-          S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY
-          GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH
-          Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v
-          VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0
-          Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI
-          wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN
-          NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl
-          f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB
-          tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL
-          ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn
-          AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob
-          pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF
-          eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+
-          aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M
-          2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ
-          VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU
-          3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh
-          qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1
-          IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8
-          1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp
-          HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN
-          MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+
-          UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh
-          R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+
-          N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc
-          kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e
-          lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT
-          DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb
-          kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf
-          DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei
-          BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z
-          XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2
-          +zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU
-          fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH
-          dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4
-          qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2
-          7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq
-          UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x
-          Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA
-          KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3
-          okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7
-          bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4
-          4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX
-          vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0
-          jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y
-          ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD
-          7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR
-          M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf
-          REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y
-          DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk
-          ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
-          =a34C
-          -----END PGP PUBLIC KEY BLOCK-----',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-      end
-      describe 'keys should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30')
-        end
-      end
-    end
-  end
-
-  context 'key_source' do
-    context 'http://apt.puppetlabs.com/pubkey.gpg' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          release    => 'precise',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_source  => 'http://apt.puppetlabs.com/pubkey.gpg',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-        it { should contain 'deb http://apt.puppetlabs.com precise main' }
-      end
-      describe 'keys should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30')
-        end
-      end
-    end
-  end
-
-  context 'pin' do
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-          pin        => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/puppetlabs.pref') do
-        it { should_not be_file }
-      end
-    end
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-          pin        => true,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/puppetlabs.pref') do
-        it { should be_file }
-      end
-    end
-  end
-
-end
diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb
index 97f00f1681..3c97421ab0 100644
--- a/spec/acceptance/apt_spec.rb
+++ b/spec/acceptance/apt_spec.rb
@@ -1,6 +1,6 @@
 require 'spec_helper_acceptance'
 
-describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+describe 'apt class' do
 
   context 'reset' do
     it 'fixes the sources.list' do
@@ -8,294 +8,37 @@
     end
   end
 
-  context 'always_apt_update => true' do
+  context 'all the things' do
     it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': always_apt_update => true }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Exec\[apt_update\]/)
-      end
-    end
-  end
-  context 'always_apt_update => false' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': always_apt_update => false }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to_not match(/Exec\[apt_update\]/)
-      end
-    end
-  end
-
-  # disable_keys drops in a 99unauth file to ignore keys in
-  # other files.
-  context 'disable_keys => true' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': disable_keys => true }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/99unauth') do
-      it { should be_file }
-      it { should contain 'APT::Get::AllowUnauthenticated 1;' }
-    end
-  end
-  context 'disable_keys => false' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': disable_keys => false }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/99unauth') do
-      it { should_not be_file }
-    end
-  end
-
-  # proxy_host sets the proxy to use for transfers.
-  # proxy_port sets the proxy port to use.
-  context 'proxy settings' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': 
-        proxy_host => 'localhost',
-        proxy_port => '7042',
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/01proxy') do
-      it { should be_file }
-      it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' }
-    end
-    describe file('/etc/apt/apt.conf.d/proxy') do
-      it { should_not be_file }
-    end
-  end
-
-  context 'purge_sources' do
-    it 'creates a fake apt file' do
-      shell('touch /etc/apt/sources.list.d/fake.list')
-      shell('echo "deb fake" >> /etc/apt/sources.list')
-    end
-    it 'purge_sources_list and purge_sources_list_d => true' do
       pp = <<-EOS
       class { 'apt':
+        always_apt_update    => true,
+        disable_keys         => true,
         purge_sources_list   => true,
         purge_sources_list_d => true,
+        purge_preferences    => true,
+        purge_preferences_d  => true,
+        update_timeout       => '400',
+        update_tries         => '3',
+        sources              => {
+          'puppetlabs' => {
+            'ensure'     => present,
+            'location'   => 'http://apt.puppetlabs.com',
+            'repos'      => 'main',
+            'key'        => '4BD6EC30',
+            'key_server' => 'pgp.mit.edu',
+          }
+        },
+        fancy_progress       => true,
       }
       EOS
 
       apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/sources.list') do
-      it { should_not contain 'deb fake' }
-    end
-
-    describe file('/etc/apt/sources.list.d/fake.list') do
-      it { should_not be_file }
-    end
-  end
-  context 'proxy settings' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': 
-        proxy_host => 'localhost',
-        proxy_port => '7042',
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/01proxy') do
-      it { should be_file }
-      it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' }
-    end
-    describe file('/etc/apt/apt.conf.d/proxy') do
-      it { should_not be_file }
-    end
-  end
-
-  context 'purge_sources' do
-    context 'false' do
-      it 'creates a fake apt file' do
-        shell('touch /etc/apt/sources.list.d/fake.list')
-        shell('echo "deb fake" >> /etc/apt/sources.list')
-      end
-      it 'purge_sources_list and purge_sources_list_d => false' do
-        pp = <<-EOS
-        class { 'apt':
-          purge_sources_list   => false,
-          purge_sources_list_d => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => false)
-      end
-
-      describe file('/etc/apt/sources.list') do
-        it { should contain 'deb fake' }
-      end
-
-      describe file('/etc/apt/sources.list.d/fake.list') do
-        it { should be_file }
-      end
-    end
-
-    context 'true' do
-      it 'creates a fake apt file' do
-        shell('touch /etc/apt/sources.list.d/fake.list')
-        shell('echo "deb fake" >> /etc/apt/sources.list')
-      end
-      it 'purge_sources_list and purge_sources_list_d => true' do
-        pp = <<-EOS
-        class { 'apt':
-          purge_sources_list   => true,
-          purge_sources_list_d => true,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list') do
-        it { should_not contain 'deb fake' }
-      end
-
-      describe file('/etc/apt/sources.list.d/fake.list') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'purge_preferences' do
-    context 'false' do
-      it 'creates a preferences file' do
-        shell("echo 'original' > /etc/apt/preferences")
-      end
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': purge_preferences => false }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences') do
-        it { should be_file }
-        it 'is not managed by Puppet' do
-          shell("grep 'original' /etc/apt/preferences", {:acceptable_exit_codes => 0})
-        end
-      end
-    end
-
-    context 'true' do
-      it 'creates a preferences file' do
-        shell('touch /etc/apt/preferences')
-      end
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': purge_preferences => true }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'purge_preferences_d' do
-    context 'false' do
-      it 'creates a preferences file' do
-        shell('touch /etc/apt/preferences.d/test')
-      end
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': purge_preferences_d => false }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/test') do
-        it { should be_file }
-      end
-    end
-    context 'true' do
-      it 'creates a preferences file' do
-        shell('touch /etc/apt/preferences.d/test')
-      end
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': purge_preferences_d => true }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/test') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'update_timeout' do
-    context '5000' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': update_timeout => '5000' }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-    end
-  end
-
-  context 'fancy_progress => true' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': fancy_progress => true }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/99progressbar') do
-      it { should be_file }
-      it { should contain 'Dpkg::Progress-Fancy "1";' }
-    end
-  end
-  context 'fancy_progress => false' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': fancy_progress => false }
-      EOS
-
       apply_manifest(pp, :catch_failures => true)
     end
-
-    describe file('/etc/apt/apt.conf.d/99progressbar') do
-      it { should_not be_file }
+    it 'should still work' do
+      shell('apt-get update')
+      shell('apt-get -y upgrade')
     end
   end
 
diff --git a/spec/acceptance/backports_spec.rb b/spec/acceptance/backports_spec.rb
deleted file mode 100644
index 78f21fd588..0000000000
--- a/spec/acceptance/backports_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-require 'spec_helper_acceptance'
-
-codename = fact('lsbdistcodename')
-case fact('operatingsystem')
-when 'Ubuntu'
-  repos = 'main universe multiverse restricted'
-when 'Debian'
-  repos = 'main contrib non-free'
-end
-
-describe 'apt::backports class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt::backports': }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-  end
-
-  context 'release' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt::backports': release => '#{codename}' }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/sources.list.d/backports.list') do
-      it { should be_file }
-      it { should contain "#{codename}-backports #{repos}" }
-    end
-  end
-
-  context 'location' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt::backports': release => 'precise', location => 'http://localhost/ubuntu' }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/sources.list.d/backports.list') do
-      it { should be_file }
-      it { should contain "deb http://localhost/ubuntu precise-backports #{repos}" }
-    end
-  end
-
-  context 'pin_priority' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt::backports': pin_priority => 500, }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-    describe file('/etc/apt/preferences.d/backports.pref') do
-      it { should be_file }
-      it { should contain "Pin-Priority: 500" }
-    end
-  end
-
-  context 'reset' do
-    it 'deletes backport files' do
-      shell('rm -rf /etc/apt/sources.list.d/backports.list')
-      shell('rm -rf /etc/apt/preferences.d/backports.pref')
-    end
-  end
-
-end
diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb
index e5994498b9..f228e4c456 100644
--- a/spec/acceptance/class_spec.rb
+++ b/spec/acceptance/class_spec.rb
@@ -1,6 +1,6 @@
 require 'spec_helper_acceptance'
 
-describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+describe 'apt class' do
 
   context 'default parameters' do
     # Using puppet_apply as a helper
diff --git a/spec/acceptance/conf_spec.rb b/spec/acceptance/conf_spec.rb
deleted file mode 100644
index 8a8ed63db4..0000000000
--- a/spec/acceptance/conf_spec.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::conf define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      apt::conf { 'test':
-        content => 'test',
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50test') do
-      it { should be_file }
-      it { should contain 'test' }
-    end
-  end
-
-  context 'ensure' do
-    context 'absent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        apt::conf { 'test':
-          ensure  => absent,
-          content => 'test',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50test') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'priority' do
-    context '99' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        apt::conf { 'test':
-          ensure   => present,
-          content  => 'test',
-          priority => '99',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/99test') do
-        it { should be_file }
-        it { should contain 'test' }
-      end
-    end
-  end
-
-  context 'cleanup' do
-    it 'deletes 99test' do
-      shell ('rm -rf /etc/apt/apt.conf.d/99test')
-    end
-  end
-end
diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb
deleted file mode 100644
index 5f4dec3fc7..0000000000
--- a/spec/acceptance/force_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require 'spec_helper_acceptance'
-
-codename = fact('lsbdistcodename')
-
-describe 'apt::force define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::force { 'vim': }
-      EOS
-
-      shell('apt-get remove -y vim')
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe package('vim') do
-      it { should be_installed }
-    end
-  end
-
-  context 'release' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::force { 'vim': release => '#{codename}' }
-      EOS
-
-      shell('apt-get remove -y vim')
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/)
-      end
-    end
-
-    describe package('vim') do
-      it { should be_installed }
-    end
-  end
-
-  context 'version' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::force { 'vim': version => '1.1.1' }
-      EOS
-
-      shell('apt-get remove -y vim')
-      apply_manifest(pp, :catch_failures => false) do |r|
-        expect(r.stdout).to match(/apt-get -y  install vim=1.1.1/)
-      end
-    end
-
-    describe package('vim') do
-      it { should_not be_installed }
-    end
-  end
-
-  context 'timeout' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::force { 'ocaml': timeout => '1' }
-      EOS
-
-      shell('apt-get clean')
-      apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/Error: Command exceeded timeout/)
-      end
-    end
-
-    describe package('ocaml') do
-      it { should_not be_installed }
-    end
-  end
-
-end
diff --git a/spec/acceptance/pin_spec.rb b/spec/acceptance/pin_spec.rb
deleted file mode 100644
index 07fc607302..0000000000
--- a/spec/acceptance/pin_spec.rb
+++ /dev/null
@@ -1,286 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::pin define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::pin { 'vim-puppet': }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-      it { should be_file }
-      it { should contain 'Pin: release a=vim-puppet' }
-    end
-  end
-
-  context 'ensure' do
-    context 'present' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet': ensure => present }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release a=vim-puppet' }
-      end
-    end
-
-    context 'absent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet': ensure => absent }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'order' do
-    context '99' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure => present,
-          order  => '99',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/99-vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release a=vim-puppet' }
-      end
-    end
-  end
-
-  context 'packages' do
-    context 'test' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure   => present,
-          packages => 'test',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Package: test' }
-        it { should contain 'Pin: release a=vim-puppet' }
-      end
-    end
-
-    context 'array' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'array':
-          ensure   => present,
-          packages => ['apache', 'ntop'],
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/array.pref') do
-        it { should be_file }
-        it { should contain 'Package: apache ntop' }
-        it { should contain 'Pin: release a=array' }
-      end
-    end
-  end
-
-  context 'release' do
-    context 'testrelease' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure  => present,
-          release => 'testrelease',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release a=testrelease' }
-      end
-    end
-  end
-
-  context 'origin' do
-    context 'testrelease' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure  => present,
-          origin  => 'testrelease',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: origin testrelease' }
-      end
-    end
-  end
-
-  context 'version' do
-    context '1.0.0' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure   => present,
-          packages => 'test',
-          version  => '1.0.0',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Package: test' }
-        it { should contain 'Pin: version 1.0.0' }
-      end
-    end
-  end
-
-  context 'codename' do
-    context 'testname' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure   => present,
-          codename => 'testname',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release n=testname' }
-      end
-    end
-  end
-
-  context 'release_version' do
-    context '1.1.1' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure          => present,
-          release_version => '1.1.1',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release v=1.1.1' }
-      end
-    end
-  end
-
-  context 'component' do
-    context 'testcomponent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure    => present,
-          component => 'testcomponent',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release c=testcomponent' }
-      end
-    end
-  end
-
-  context 'originator' do
-    context 'testorigin' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure     => present,
-          originator => 'testorigin',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release o=testorigin' }
-      end
-    end
-  end
-
-  context 'label' do
-    context 'testlabel' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure => present,
-          label  => 'testlabel',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release l=testlabel' }
-      end
-    end
-  end
-
-end
diff --git a/spec/acceptance/release_spec.rb b/spec/acceptance/release_spec.rb
deleted file mode 100644
index e7467bf62d..0000000000
--- a/spec/acceptance/release_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::release class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'release_id' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::release': release_id => 'precise', }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/01release') do
-      it { should be_file }
-      it { should contain 'APT::Default-Release "precise";' }
-    end
-  end
-
-  context 'reset' do
-    it 'cleans up' do
-      shell('rm -rf /etc/apt/apt.conf.d/01release')
-    end
-  end
-
-end
diff --git a/spec/acceptance/unattended_upgrade_spec.rb b/spec/acceptance/unattended_upgrade_spec.rb
deleted file mode 100644
index 09f4e2bed0..0000000000
--- a/spec/acceptance/unattended_upgrade_spec.rb
+++ /dev/null
@@ -1,562 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::unattended_upgrades class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      include apt::unattended_upgrades
-      EOS
-
-      # Attempted workaround for problems seen on debian with
-      # something holding the package database open.
-      shell('killall -9 apt-get', { :acceptable_exit_codes => [0,1] })
-      shell('killall -9 dpkg', { :acceptable_exit_codes => [0,1] })
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-    end
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-    end
-  end
-
-  context 'origins' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        origins => ['${distro_id}:${distro_codename}-test'],
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-      it { should contain '${distro_id}:${distro_codename}-test' }
-    end
-  end
-
-  context 'blacklist' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        blacklist => ['puppet']
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-      it { should contain 'puppet' }
-    end
-  end
-
-  context 'update' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        update => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Update-Package-Lists "99";' }
-    end
-  end
-
-  context 'download' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        download => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Download-Upgradeable-Packages "99";' }
-    end
-  end
-
-  context 'upgrade' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        upgrade => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Unattended-Upgrade "99";' }
-    end
-  end
-
-  context 'autoclean' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        autoclean => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::AutocleanInterval "99";' }
-    end
-  end
-
-  context 'auto_fix' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          auto_fix => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          auto_fix => false
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "false";' }
-      end
-    end
-  end
-
-  context 'minimal_steps' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          minimal_steps => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::MinimalSteps "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          minimal_steps => false
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::MinimalSteps "false";' }
-      end
-    end
-  end
-
-  context 'install_on_shutdown' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          install_on_shutdown => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::InstallOnShutdown "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          install_on_shutdown => false
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::InstallOnShutdown "false";' }
-      end
-    end
-  end
-
-  context 'mail_to' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        mail_to => 'test@example.com'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-      it { should contain 'Unattended-Upgrade::Mail "test@example.com";' }
-    end
-  end
-
-  context 'mail_only_on_error' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          mail_to            => 'test@example.com',
-          mail_only_on_error => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::MailOnlyOnError "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          mail_to            => 'test@example.com',
-          mail_only_on_error => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::MailOnlyOnError "false";' }
-      end
-    end
-
-    context 'mail_to missing' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          mail_only_on_error => true,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should_not contain 'Unattended-Upgrade::MailOnlyOnError "true";' }
-      end
-    end
-  end
-
-  context 'remove_unused' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          remove_unused => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          remove_unused => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "false";' }
-      end
-    end
-  end
-
-  context 'auto_reboot' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          auto_reboot => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::Automatic-Reboot "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          auto_reboot => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::Automatic-Reboot "false";' }
-      end
-    end
-  end
-
-  context 'dl_limit' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        dl_limit => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-      it { should contain 'Acquire::http::Dl-Limit "99"' }
-    end
-  end
-
-  context 'enable' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        enable => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Enable "2"' }
-    end
-  end
-
-  context 'backup_interval' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        backup_interval => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::BackUpArchiveInterval "2";' }
-    end
-  end
-
-  context 'backup_level' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        backup_level => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::BackUpLevel "2";' }
-    end
-  end
-
-  context 'max_age' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        max_age => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::MaxAge "2";' }
-    end
-  end
-
-  context 'min_age' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        min_age => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::MinAge "2";' }
-    end
-  end
-
-  context 'max_size' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        max_size => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::MaxSize "2";' }
-    end
-  end
-
-  context 'download_delta' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        download_delta => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";' }
-    end
-  end
-
-  context 'verbose' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        verbose => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Verbose "2";' }
-    end
-  end
-
-end
diff --git a/spec/acceptance/unsupported_spec.rb b/spec/acceptance/unsupported_spec.rb
deleted file mode 100644
index 3f7468530b..0000000000
--- a/spec/acceptance/unsupported_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  it 'class apt fails' do
-    pp = <<-EOS
-      class { 'apt': }
-    EOS
-    expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/This module only works on Debian or derivatives like Ubuntu/i)
-  end
-end

From d6bdb4d9256415f38ac80a199afbaa8f6a7bad3a Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Thu, 31 Jul 2014 18:11:57 -0400
Subject: [PATCH 338/574] Cleaned up unit tests.

---
 manifests/pin.pp                         |  14 +-
 manifests/ppa.pp                         |   3 -
 manifests/unattended_upgrades.pp         |  15 +-
 spec/classes/apt_spec.rb                 | 389 ++++++++++++++---------
 spec/classes/init_spec.rb                |  69 ----
 spec/classes/unattended_upgrades_spec.rb | 379 ++++++++--------------
 spec/defines/builddep_spec.rb            |   8 +-
 spec/defines/conf_spec.rb                |   6 -
 spec/defines/force_spec.rb               |   8 +-
 spec/defines/hold_spec.rb                |  33 +-
 spec/defines/key_spec.rb                 | 389 +++++++++--------------
 spec/defines/pin_spec.rb                 | 247 ++++++++------
 spec/defines/ppa_spec.rb                 | 287 +++++++++--------
 spec/defines/source_spec.rb              | 256 ++++++---------
 14 files changed, 950 insertions(+), 1153 deletions(-)
 delete mode 100644 spec/classes/init_spec.rb

diff --git a/manifests/pin.pp b/manifests/pin.pp
index 2ce81fd6bb..54961ec8dd 100644
--- a/manifests/pin.pp
+++ b/manifests/pin.pp
@@ -16,7 +16,6 @@
   $originator      = '', # o=
   $label           = ''  # l=
 ) {
-
   include apt::params
 
   $preferences_d = $apt::params::preferences_d
@@ -35,7 +34,7 @@
   $pin_release = join($pin_release_array, '')
 
   # Read the manpage 'apt_preferences(5)', especially the chapter
-  # 'Thea Effect of APT Preferences' to understand the following logic
+  # 'The Effect of APT Preferences' to understand the following logic
   # and the difference between specific and general form
   if is_array($packages) {
     $packages_string = join($packages, ' ')
@@ -44,24 +43,17 @@
   }
 
   if $packages_string != '*' { # specific form
-
     if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
-      ( $origin != '' and ( $pin_release != '' or $version != '' )) or
       ( $version != '' and ( $pin_release != '' or $origin != '' )) {
       fail('parameters release, origin, and version are mutually exclusive')
     }
-
   } else { # general form
-
     if $version != '' {
       fail('parameter version cannot be used in general form')
     }
-
-    if ( $pin_release != '' and $origin != '' ) or
-      ( $origin != '' and $pin_release != '' ) {
-      fail('parmeters release and origin are mutually exclusive')
+    if ( $pin_release != '' and $origin != '' ) {
+      fail('parameters release and origin are mutually exclusive')
     }
-
   }
 
 
diff --git a/manifests/ppa.pp b/manifests/ppa.pp
index 27edff80b2..5f5c6ae574 100644
--- a/manifests/ppa.pp
+++ b/manifests/ppa.pp
@@ -69,9 +69,6 @@
 
     file { "${sources_list_d}/${sources_list_d_filename}":
         ensure => 'absent',
-        mode   => '0644',
-        owner  => 'root',
-        group  => 'root',
         notify => Exec['apt_update'],
     }
   }
diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp
index 7e3ccc44b0..2f75d5dd19 100644
--- a/manifests/unattended_upgrades.pp
+++ b/manifests/unattended_upgrades.pp
@@ -52,18 +52,21 @@
     ensure => present,
   }
 
-  File {
+  file { '/etc/apt/apt.conf.d/50unattended-upgrades':
     ensure  => file,
     owner   => 'root',
     group   => 'root',
     mode    => '0644',
+    content => template('apt/50unattended-upgrades.erb'),
     require => Package['unattended-upgrades'],
   }
 
-  file {
-    '/etc/apt/apt.conf.d/50unattended-upgrades':
-      content => template('apt/50unattended-upgrades.erb');
-    '/etc/apt/apt.conf.d/10periodic':
-      content => template('apt/10periodic.erb');
+  file { '/etc/apt/apt.conf.d/10periodic':
+    ensure  => file,
+    owner   => 'root',
+    group   => 'root',
+    mode    => '0644',
+    content => template('apt/10periodic.erb'),
+    require => Package['unattended-upgrades'],
   }
 }
diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb
index a21e0443e2..2c70e3e090 100644
--- a/spec/classes/apt_spec.rb
+++ b/spec/classes/apt_spec.rb
@@ -1,170 +1,257 @@
 require 'spec_helper'
 describe 'apt', :type => :class do
   let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-  let :default_params do
-    {
-      :disable_keys => :undef,
-      :always_apt_update => false,
-      :purge_sources_list => false,
-      :purge_sources_list_d => false,
-    }
+
+  context 'defaults' do
+    it { should contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/sources.list',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+      'notify' => 'Exec[apt_update]',
+    })}
+
+    it { should contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
+      'ensure'  => 'directory',
+      'path'    => '/etc/apt/sources.list.d',
+      'owner'   => 'root',
+      'group'   => 'root',
+      'purge'   => false,
+      'recurse' => false,
+      'notify'  => 'Exec[apt_update]',
+    })}
+
+    it { should contain_file('preferences.d').only_with({
+      'ensure'  => 'directory',
+      'path'    => '/etc/apt/preferences.d',
+      'owner'   => 'root',
+      'group'   => 'root',
+      'purge'   => false,
+      '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 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',
+    })}
   end
 
-  [{},
-    {
-      :disable_keys => true,
-      :always_apt_update => true,
-      :proxy_host => true,
-      :proxy_port => '3128',
-      :purge_sources_list => true,
-      :purge_sources_list_d => true,
-    },
-    {
-      :purge_preferences   => true,
-      :purge_preferences_d => true,
-    },
-    {
-      :disable_keys => false
-    }
-  ].each do |param_set|
-    describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
-      let :param_hash do
-        default_params.merge(param_set)
-      end
+  context 'lots of non-defaults' 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
 
-      let :params do
-        param_set
-      end
+    it { should contain_file('sources.list').with({
+      'content' => "# Repos managed by puppet.\n"
+    })}
 
-      let :refresh_only_apt_update do
-        if param_hash[:always_apt_update]
-          false
-        else
-          true
-        end
-      end
+    it { should contain_file('sources.list.d').with({
+      'purge'   => 'true',
+      'recurse' => 'true',
+    })}
+
+    it { should contain_file('apt-preferences').only_with({
+      'ensure' => 'absent',
+      'path'   => '/etc/apt/preferences',
+    })}
+
+    it { should contain_file('preferences.d').with({
+      'purge'   => 'true',
+      'recurse' => 'true',
+    })}
 
-      it { should contain_class("apt::params") }
-
-      it {
-        if param_hash[:purge_sources_list]
-        should contain_file("sources.list").with({
-            'path'    => "/etc/apt/sources.list",
-            'ensure'  => "present",
-            'owner'   => "root",
-            'group'   => "root",
-            'mode'    => "0644",
-            "content" => "# Repos managed by puppet.\n"
-          })
-        else
-        should contain_file("sources.list").with({
-            'path'    => "/etc/apt/sources.list",
-            'ensure'  => "present",
-            'owner'   => "root",
-            'group'   => "root",
-            'mode'    => "0644",
-            'content' => nil
-          })
-        end
+    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;\n",
+      '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\";\n",
+      'notify'  => 'Exec[apt_update]',
+      'mode'    => '0644',
+      'owner'   => 'root',
+      'group'   => 'root'
+    })}
+
+    it { should contain_exec('apt_update').with({
+      'refreshonly' => 'false',
+      'timeout'     => '1',
+      'tries'       => '3',
+    })}
+
+  end
+
+  context 'more non-default' do
+    let :params do
+      {
+        :fancy_progress => false,
+        :disable_keys   => false,
       }
-      it {
-        if param_hash[:purge_sources_list_d]
-          should create_file("sources.list.d").with({
-            'path'    => "/etc/apt/sources.list.d",
-            'ensure'  => "directory",
-            'owner'   => "root",
-            'group'   => "root",
-            'purge'   => true,
-            'recurse' => true,
-            'notify'  => 'Exec[apt_update]'
-          })
-        else
-          should create_file("sources.list.d").with({
-            'path'    => "/etc/apt/sources.list.d",
-            'ensure'  => "directory",
-            'owner'   => "root",
-            'group'   => "root",
-            'purge'   => false,
-            'recurse' => false,
-            'notify'  => 'Exec[apt_update]'
-          })
-        end
+    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',
+        :lsbdistcodename => 'precise',
+        :lsbdistid       => 'Debian',
       }
-      it {
-        if param_hash[:purge_preferences]
-          should create_file('apt-preferences').with({
-            :ensure  => 'absent',
-            :path    => '/etc/apt/preferences',
-          })
-        else
-          should_not contain_file('apt-preferences')
-        end
+    end
+    let(:params) { { :sources => {
+      'debian_unstable' => {
+        'location'          => 'http://debian.mirror.iweb.ca/debian/',
+        'release'           => 'unstable',
+        'repos'             => 'main contrib non-free',
+        'required_packages' => 'debian-keyring debian-archive-keyring',
+        'key'               => '55BE302B',
+        'key_server'        => 'subkeys.pgp.net',
+        'pin'               => '-10',
+        'include_src'       => true
+      },
+      'puppetlabs' => {
+        'location'   => 'http://apt.puppetlabs.com',
+        'repos'      => 'main',
+        'key'        => '4BD6EC30',
+        'key_server' => 'pgp.mit.edu',
       }
+    } } }
 
-      it {
-        if param_hash[:purge_preferences_d]
-          should create_file("preferences.d").with({
-            'path'    => "/etc/apt/preferences.d",
-            'ensure'  => "directory",
-            'owner'   => "root",
-            'group'   => "root",
-            'purge'   => true,
-            'recurse' => true,
-          })
-        else
-          should create_file("preferences.d").with({
-            'path'    => "/etc/apt/preferences.d",
-            'ensure'  => "directory",
-            'owner'   => "root",
-            'group'   => "root",
-            'purge'   => false,
-            'recurse' => false,
-          })
-        end
-      }
+    it {
+      should contain_file('debian_unstable.list').with({
+        'ensure'  => 'present',
+        'path'    => '/etc/apt/sources.list.d/debian_unstable.list',
+        'owner'   => 'root',
+        'group'   => 'root',
+        'mode'    => '0644',
+        'notify'  => 'Exec[apt_update]',
+      })
+    }
 
-      it {
-        should contain_exec("apt_update").with({
-          'command'     => "/usr/bin/apt-get update",
-          'refreshonly' => refresh_only_apt_update
-        })
-      }
+    it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
+    it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
 
-      it {
-        if param_hash[:disable_keys] == true
-          should create_file("99unauth").with({
-            'content' => "APT::Get::AllowUnauthenticated 1;\n",
-            'ensure'  => "present",
-            'path'    => "/etc/apt/apt.conf.d/99unauth"
-          })
-        elsif param_hash[:disable_keys] == false
-          should create_file("99unauth").with({
-            'ensure' => "absent",
-            'path'   => "/etc/apt/apt.conf.d/99unauth"
-          })
-        elsif param_hash[:disable_keys] != :undef
-          should_not create_file("99unauth").with({
-            'path'   => "/etc/apt/apt.conf.d/99unauth"
-          })
-        end
-      }
-      describe 'when setting a proxy' do
-        it {
-          if param_hash[:proxy_host]
-            should contain_file('01proxy').with(
-              'path'    => '/etc/apt/apt.conf.d/01proxy',
-              'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";\n",
-              'notify'  => "Exec[apt_update]"
-            )
-          else
-            should contain_file('01proxy').with(
-              'path'    => '/etc/apt/apt.conf.d/01proxy',
-              'notify'  => 'Exec[apt_update]',
-              'ensure'  => 'absent'
-            )
-          end
+    it {
+      should contain_file('puppetlabs.list').with({
+        'ensure'  => 'present',
+        'path'    => '/etc/apt/sources.list.d/puppetlabs.list',
+        'owner'   => 'root',
+        'group'   => 'root',
+        'mode'    => '0644',
+        'notify'  => 'Exec[apt_update]',
+      })
+    }
+
+    it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
+    it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
+  end
+
+  describe 'failing tests' do
+    context 'bad purge_sources_list' do
+      let :params do
+        {
+          'purge_sources_list' => 'foo'
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error)
+      end
+    end
+
+    context 'bad purge_sources_list_d' do
+      let :params do
+        {
+          'purge_sources_list_d' => 'foo'
         }
       end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error)
+      end
+    end
+
+    context 'bad purge_preferences' do
+      let :params do
+        {
+          'purge_preferences' => 'foo'
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error)
+      end
+    end
+
+    context 'bad purge_preferences_d' do
+      let :params do
+        {
+          'purge_preferences_d' => 'foo'
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error)
+      end
+    end
+
+    context 'with unsupported osfamily' do
+      let :facts do
+        { :osfamily => 'Darwin', }
+      end
+
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
+      end
     end
   end
 end
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
deleted file mode 100644
index c5e938a9aa..0000000000
--- a/spec/classes/init_spec.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require 'spec_helper'
-describe 'apt' do
-  context 'with sources defined on valid osfamily' do
-    let :facts do
-      { :osfamily        => 'Debian',
-        :lsbdistcodename => 'precise',
-        :lsbdistid       => 'Debian',
-      }
-    end
-    let(:params) { { :sources => {
-      'debian_unstable' => {
-        'location'          => 'http://debian.mirror.iweb.ca/debian/',
-        'release'           => 'unstable',
-        'repos'             => 'main contrib non-free',
-        'required_packages' => 'debian-keyring debian-archive-keyring',
-        'key'               => '55BE302B',
-        'key_server'        => 'subkeys.pgp.net',
-        'pin'               => '-10',
-        'include_src'       => true
-      },
-      'puppetlabs' => {
-        'location'   => 'http://apt.puppetlabs.com',
-        'repos'      => 'main',
-        'key'        => '4BD6EC30',
-        'key_server' => 'pgp.mit.edu',
-      }
-    } } }
-
-    it {
-      should contain_file('debian_unstable.list').with({
-        'ensure'  => 'present',
-        'path'    => '/etc/apt/sources.list.d/debian_unstable.list',
-        'owner'   => 'root',
-        'group'   => 'root',
-        'mode'    => '0644',
-        'notify'  => 'Exec[apt_update]',
-      })
-    }
-
-    it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
-    it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
-
-    it {
-      should contain_file('puppetlabs.list').with({
-        'ensure'  => 'present',
-        'path'    => '/etc/apt/sources.list.d/puppetlabs.list',
-        'owner'   => 'root',
-        'group'   => 'root',
-        'mode'    => '0644',
-        'notify'  => 'Exec[apt_update]',
-      })
-    }
-
-    it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
-    it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
-  end
-
-  context 'with unsupported osfamily' do
-    let :facts do
-      { :osfamily        => 'Darwin', }
-    end
-
-    it do
-      expect {
-       should compile
-      }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
-    end
-  end
-end
diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb
index 8494f0410d..291719b009 100644
--- a/spec/classes/unattended_upgrades_spec.rb
+++ b/spec/classes/unattended_upgrades_spec.rb
@@ -24,270 +24,165 @@
     })
   }
 
-  describe "origins" do
-    describe 'on Debian' do
-      default_facts = { :lsbdistid => 'Debian' }
-      context 'defaults' do
-        let :facts do default_facts end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Origins-Pattern/
-          ).with_content(
-            /"origin=Debian,archive=stable,label=Debian-Security";/
-          )
-        }
-      end
-      context 'defaults with custom origin' do
-        let :facts do default_facts end
-        let :params do { :origins => ['bananana']} end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Origins-Pattern/
-          ).with_content(
-            /"bananana";/
-          )
-        }
-      end
-      context 'defaults with invalid origin' do
-        let :facts do default_facts end
-        let :params do { :origins => 'bananana'} end
-        it {
-          expect {subject}.to raise_error(/is not an Array/)
-        }
-      end
-      context 'squeeze' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'squeeze'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id} \${distro_codename}-lts";/
-          ).with_content(
-            /"\${distro_id} \${distro_codename}-security";/
-          ).with_content(
-            /"\${distro_id} oldstable";/
-          )
-        }
-      end
-      context 'wheezy' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'wheezy'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Origins-Pattern/
-          ).with_content(
-            /"origin=Debian,archive=stable,label=Debian-Security";/
-          )
+  describe 'failing' do
+    let :facts do
+      {
+        'lsbdistid'       => 'debian',
+        'lsbdistcodename' => 'squeeze',
+      }
+    end
+    context 'bad auto_fix' do
+      let :params do
+        {
+          'auto_fix' => 'foo',
         }
       end
+      it { expect { should raise_error(Puppet::Error) } }
     end
 
-    describe 'on Ubuntu' do
-      default_facts = { :lsbdistid => 'Ubuntu' }
-      context 'default' do
-        let :facts do default_facts end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id}\:\${distro_codename}-security";/
-          )
-        }
-      end
-      context 'lucid' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'lucid'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id} \${distro_codename}-security";/
-          )
-        }
-      end
-      context 'precise' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'precise'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id}\:\${distro_codename}-security";/
-          )
-        }
-      end
-      context 'trusty' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'trusty'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id}\:\${distro_codename}-security";/
-          )
+    context 'bad minimal_steps' do
+      let :params do
+        {
+          'minimal_steps' => 'foo',
         }
       end
-    end
-  end
-
-  describe "blacklist" do
-    describe "with param defaults" do
-      let(:params) {{ }}
-      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
+      it { expect { should raise_error(Puppet::Error) } }
     end
 
-    describe "with blacklist => []" do
+    context 'bad install_on_shutdown' do
       let :params do
-        { :blacklist => ['libc6', 'libc6-dev'] }
+        {
+          'install_on_shutdown' => 'foo',
+        }
       end
-      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) }
-    end
-  end
-
-  describe "with update => 2" do
-    let :params do
-      { :update => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) }
-  end
-
-  describe "with download => 2" do
-    let :params do
-      { :download => "2" }
+      it { expect { should raise_error(Puppet::Error) } }
     end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) }
-  end
 
-  describe "with upgrade => 2" do
-    let :params do
-      { :upgrade => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) }
-  end
-
-  describe "with autoclean => 2" do
-    let :params do
-      { :autoclean => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) }
-  end
-
-  describe "with auto_fix => false" do
-    let :params do
-      { :auto_fix => false }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) }
-  end
-
-  describe "with minimal_steps => true" do
-    let :params do
-      { :minimal_steps => true }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) }
-  end
-
-  describe "with install_on_shutdown => true" do
-    let :params do
-      { :install_on_shutdown => true }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
-  end
-
-  describe "mail_to" do
-    describe "param defaults" do
-      let(:params) {{ }}
-      it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) }
-      it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) }
-    end
-
-    describe "with mail_to => user@website, mail_only_on_error => true" do
+    context 'bad mail_only_on_error' do
       let :params do
-        { :mail_to => "user@website",
-          :mail_only_on_error => true }
+        {
+          'mail_only_on_error' => 'foo',
+        }
       end
-      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
-      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
-    end
-  end
-
-  describe "with remove_unused => false" do
-    let :params do
-      { :remove_unused => false }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) }
-  end
-
-  describe "with auto_reboot => true" do
-    let :params do
-      { :auto_reboot => true }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
-  end
-
-  describe "dl_limit" do
-    describe "param defaults" do
-      let(:params) {{ }}
-      it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) }
+      it { expect { should raise_error(Puppet::Error) } }
     end
 
-    describe "with dl_limit => 70" do
+    context 'bad remove_unused' do
       let :params do
-        { :dl_limit => "70" }
+        {
+          'remove_unused' => 'foo',
+        }
       end
-      it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
-    end
-  end
-
-  describe "with enable => 0" do
-    let :params do
-      { :enable => "0" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) }
-  end
-
-  describe "with backup_interval => 1" do
-    let :params do
-      { :backup_interval => "1" }
+      it { expect { should raise_error(Puppet::Error) } }
     end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) }
-  end
 
-  describe "with backup_level => 0" do
-    let :params do
-      { :backup_level => "0" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) }
-  end
-
-  describe "with max_age => 1" do
-    let :params do
-      { :max_age => "1" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) }
-  end
-
-  describe "with min_age => 1" do
-    let :params do
-      { :min_age => "1" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) }
-  end
-
-  describe "with max_size => 1" do
-    let :params do
-      { :max_size => "1" }
+    context 'bad auto_reboot' do
+      let :params do
+        {
+          'auto_reboot' => 'foo',
+        }
+      end
+      it { expect { should raise_error(Puppet::Error) } }
     end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) }
-  end
 
-  describe "with download_delta => 2" do
-    let :params do
-      { :download_delta => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) }
-  end
+    context 'bad origins' do
+      let :params do
+        {
+          'origins' => 'foo'
+        }
+      end
+      it { expect { should raise_error(Puppet::Error) } }
+    end
+
+  end
+
+  context 'defaults' do
+    let :facts do
+      {
+        'lsbdistid'       => 'debian',
+        'lsbdistcodename' => 'squeeze',
+      }
+    end
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id} oldstable";\n\t"\${distro_id} \${distro_codename}-security";\n\t"\${distro_id} \${distro_codename}-lts";\n\};} }
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "false";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "false";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "false";}}
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "3";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "7";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "0";}}
+  end
+
+  context 'anything but defaults' do
+    let :facts do
+      {
+        'lsbdistid'       => 'debian',
+        'lsbdistcodename' => 'wheezy',
+      }
+    end
+
+    let :params do
+      {
+        'enable'              => '0',
+        'backup_interval'     => '3',
+        'backup_level'        => '1',
+        'max_age'             => '7',
+        'min_age'             => '1',
+        'max_size'            => '100',
+        'update'              => '0',
+        'download'            => '0',
+        'download_delta'      => '1',
+        'upgrade'             => '0',
+        'autoclean'           => '0',
+        'verbose'             => '1',
+        'origins'             => ['bananas'],
+        'blacklist'           => ['foo', 'bar'],
+        'auto_fix'            => false,
+        'minimal_steps'       => true,
+        'install_on_shutdown' => true,
+        'mail_to'             => 'root@localhost',
+        'mail_only_on_error'  => true,
+        'remove_unused'       => false,
+        'auto_reboot'         => true,
+        'dl_limit'            => '70',
+      }
+    end
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"bananas";\n\};} }
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Package-Blacklist \{\n\t"foo";\n\t"bar";\n\};} }
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "false";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Mail "root@localhost";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MailOnlyOnError "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "false";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Acquire::http::Dl-Limit "70";}}
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "3";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "7";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "100";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "1";}}
 
-  describe "with verbose => 2" do
-    let :params do
-      { :verbose => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) }
   end
-
 end
diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb
index a0cbaa4cc0..88cdf4fb6e 100644
--- a/spec/defines/builddep_spec.rb
+++ b/spec/defines/builddep_spec.rb
@@ -4,10 +4,10 @@
   let(:facts) { { :lsbdistid => 'Debian' } }
   let(:title) { 'my_package' }
 
-  describe "should require apt-get update" do
-    it { should contain_exec("apt_update").with({
-        'command' => "/usr/bin/apt-get update",
-        'refreshonly' => true
+  describe "defaults" do
+    it { should contain_exec("apt-builddep-my_package").that_notifies('Exec[apt_update]').with({
+        'command' => "/usr/bin/apt-get -y --force-yes build-dep my_package",
+        'logoutput' => 'on_failure'
       })
     }
     it { should contain_anchor("apt::builddep::my_package").with({
diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb
index cda5900c03..ec4e229c44 100644
--- a/spec/defines/conf_spec.rb
+++ b/spec/defines/conf_spec.rb
@@ -17,12 +17,6 @@
       "/etc/apt/apt.conf.d/00norecommends"
     end
 
-    it { should contain_apt__conf('norecommends').with({
-         'priority' => '00',
-         'content'  => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
-      })
-    }
-
     it { should contain_file(filename).with({
           'ensure'    => 'present',
           'content'   => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n",
diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb
index 0d3d6e5940..a3a215c0ca 100644
--- a/spec/defines/force_spec.rb
+++ b/spec/defines/force_spec.rb
@@ -17,12 +17,10 @@
   end
 
   describe "when using default parameters" do
-    let :params do
-      default_params
-    end
     it { should contain_exec("/usr/bin/apt-get -y  install #{title}").with(
-      :unless  => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
-      :timeout => '300'
+      :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
+      :logoutput => 'on_failure',
+      :timeout   => '300'
     ) }
   end
 
diff --git a/spec/defines/hold_spec.rb b/spec/defines/hold_spec.rb
index 9da21d784a..60b991f194 100644
--- a/spec/defines/hold_spec.rb
+++ b/spec/defines/hold_spec.rb
@@ -1,9 +1,9 @@
 require 'spec_helper'
 describe 'apt::hold' do
   let :facts do {
-      :osfamily   => 'Debian',
-      :lsbdistid  => 'Debian',
-      :lsbrelease => 'wheezy',
+    :osfamily   => 'Debian',
+    :lsbdistid  => 'Debian',
+    :lsbrelease => 'wheezy',
   } end
 
   let :title do
@@ -18,13 +18,6 @@
     let :params do default_params end
 
     it 'creates an apt preferences file' do
-      should contain_apt__hold(title).with({
-        :ensure   => 'present',
-        :package  => title,
-        :version  => params[:version],
-        :priority => 1001,
-      })
-
       should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
         :packages => title,
@@ -38,9 +31,6 @@
     let :params do default_params.merge({:ensure => 'absent',}) end
 
     it 'creates an apt preferences file' do
-      should contain_apt__hold(title).with({
-        :ensure   => params[:ensure],
-      })
 
       should contain_apt__pin("hold_#{title}").with({
         :ensure   => params[:ensure],
@@ -52,22 +42,29 @@
     let :params do default_params.merge({:priority => 990,}) end
 
     it 'creates an apt preferences file' do
-      should contain_apt__hold(title).with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
-        :package  => title,
+        :packages => title,
         :version  => params[:version],
         :priority => params[:priority],
       })
+    end
+  end
 
-      should contain_apt__pin("hold_#{title}").with({
+  describe 'package => foo' do
+    let :params do default_params.merge({:package => 'foo'}) end
+
+    it 'creates an apt preferences file' do
+      should contain_apt__pin("hold_foo").with({
         :ensure   => 'present',
-        :packages => title,
+        :packages => 'foo',
         :version  => params[:version],
-        :priority => params[:priority],
+        :priority => 1001,
       })
     end
   end
 
+
   describe 'validation' do
     context 'version => {}' do
       let :params do { :version => {}, } end
diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb
index 005c95e469..dbb67c4c57 100644
--- a/spec/defines/key_spec.rb
+++ b/spec/defines/key_spec.rb
@@ -10,12 +10,6 @@
 
   describe 'normal operation' do
     describe 'default options' do
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key    => title,
-          :ensure => 'present',
-        })
-      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
           :id                => title,
@@ -40,12 +34,6 @@
         :key => GPG_KEY_ID,
       } end
 
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key    => GPG_KEY_ID,
-          :ensure => 'present',
-        })
-      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
           :id                => GPG_KEY_ID,
@@ -66,12 +54,6 @@
         :ensure => 'absent',
       } end
 
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key          => title,
-          :ensure       => 'absent',
-        })
-      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
           :id                => title,
@@ -87,26 +69,22 @@
       end
     end
 
-    describe 'key_content =>' do
+    describe 'set a bunch of things!' do
       let :params do {
         :key_content => 'GPG key content',
+        :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
+        :key_server => 'pgp.mit.edu',
+        :key_options => 'debug',
       } end
 
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key         => title,
-          :ensure      => 'present',
-          :key_content => params[:key_content],
-        })
-      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
           :id                => title,
           :ensure            => 'present',
-          :source            => nil,
-          :server            => nil,
+          :source            => 'http://apt.puppetlabs.com/pubkey.gpg',
+          :server            => 'pgp.mit.edu',
           :content           => params[:key_content],
-          :keyserver_options => nil,
+          :keyserver_options => 'debug',
         })
       end
       it 'contains the apt_key present anchor' do
@@ -114,217 +92,131 @@
       end
     end
 
-    describe 'key_source =>' do
-      let :params do {
-        :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
+    context "domain with dash" do
+      let(:params) do{
+        :key_server => 'p-gp.m-it.edu',
       } end
-
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key         => title,
-          :ensure      => 'present',
-          :key_source => params[:key_source],
+      it 'contains the apt_key' do
+        should contain_apt_key(title).with({
+          :id        => title,
+          :server => 'p-gp.m-it.edu',
         })
       end
+    end
+
+    context "url" do
+      let :params do
+        {
+          :key_server => 'hkp://pgp.mit.edu',
+        }
+      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
-          :id                => title,
-          :ensure            => 'present',
-          :source            => params[:key_source],
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => nil,
+          :id        => title,
+          :server => 'hkp://pgp.mit.edu',
         })
       end
-      it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{title} present")
-      end
     end
-
-    describe 'key_server =>' do
-    	context 'domain name' do
-        let :params do {
-          :key_server => 'pgp.mit.edu',
-      	} end
-
-      	it 'contains the apt::key' do
-          should contain_apt__key(title).with({
-            :key         => title,
-            :ensure      => 'present',
-            :key_server  => 'pgp.mit.edu',
-          })
-      	end
-      	it 'contains the apt_key' do
-          should contain_apt_key(title).with({
-            :id                => title,
-            :ensure            => 'present',
-            :source            => nil,
-            :server            => params[:key_server],
-            :content           => nil,
-            :keyserver_options => nil,
-          })
-      	end
-      	it 'contains the apt_key present anchor' do
-          should contain_anchor("apt_key #{title} present")
-      	end
-			end
-
-      context "domain with dash" do
-        let(:params) do{
-          :key_server => 'p-gp.m-it.edu',
-        } end
-        it "should contain apt::key" do
-          should contain_apt__key(title).with({
-            :key        => title,
-            :ensure     => 'present',
-            :key_server => 'p-gp.m-it.edu',
-          })
-        end
+    context "url with port number" do
+      let :params do
+        {
+          :key_server => 'hkp://pgp.mit.edu:80',
+        }
       end
-
-      context "domain begin with dash" do
-        let(:params) do{
-          :key_server => '-pgp.mit.edu',
-        } end
-        it 'fails' do
-          expect { subject } .to raise_error(/does not match/)
-        end
+      it 'contains the apt_key' do
+        should contain_apt_key(title).with({
+          :id        => title,
+          :server => 'hkp://pgp.mit.edu:80',
+        })
       end
+    end
+  end
 
-      context "domain begin with dot" do
-        let(:params) do{
-          :key_server => '.pgp.mit.edu',
-        } end
-        it 'fails' do
-          expect { subject } .to raise_error(/does not match/)
-        end
+  describe 'validation' do
+    context "domain begin with dash" do
+      let(:params) do{
+        :key_server => '-pgp.mit.edu',
+      } end
+      it 'fails' do
+        expect { subject } .to raise_error(/does not match/)
       end
+    end
 
-      context "domain end with dot" do
-        let(:params) do{
-          :key_server => "pgp.mit.edu.",
-        } end
-        it 'fails' do
-          expect { subject } .to raise_error(/does not match/)
-        end
+    context "domain begin with dot" do
+      let(:params) do{
+        :key_server => '.pgp.mit.edu',
+      } end
+      it 'fails' do
+        expect { subject } .to raise_error(/does not match/)
       end
+    end
 
-      context "url" do
-        let (:params) do{
-          :key_server => 'hkp://pgp.mit.edu',
-        } end
-        it "should contain apt::key" do
-         should contain_apt__key(title).with({
-           :key         => title,
-           :ensure      => 'present',
-           :key_server  => 'hkp://pgp.mit.edu',
-         })
-        end
+    context "domain end with dot" do
+      let(:params) do{
+        :key_server => "pgp.mit.edu.",
+      } end
+      it 'fails' do
+        expect { subject } .to raise_error(/does not match/)
       end
-      context "url with port number" do
-        let (:params) do{
-          :key_server => 'hkp://pgp.mit.edu:80',
-        } end
-        it "should contain apt::key" do
-         should contain_apt__key(title).with({
-            :key        => title,
-            :ensure     => 'present',
-            :key_server => 'hkp://pgp.mit.edu:80',
-         })
-        end
+    end
+    context "exceed character url" do
+      let :params do
+        {
+          :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
+        }
       end
-
-      context "incorrect port number url" do
-        let (:params) do{
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
+      end
+    end
+    context "incorrect port number url" do
+      let :params do
+        {
           :key_server => 'hkp://pgp.mit.edu:8008080'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+        }
+      end
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
-      context "incorrect protocol for  url" do
-        let (:params) do{
+    end
+    context "incorrect protocol for  url" do
+      let :params do
+        {
           :key_server => 'abc://pgp.mit.edu:80'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+        }
       end
-      context "missing port number url" do
-        let (:params) do{
-          :key_server => 'hkp://pgp.mit.edu:'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
-      context "url ending with a dot" do
-        let (:params) do{
-          :key_server => 'hkp://pgp.mit.edu.'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+    end
+    context "missing port number url" do
+      let :params do
+        {
+          :key_server => 'hkp://pgp.mit.edu:'
+        }
       end
-      context "url begin with a dash" do
-        let(:params) do{
-          :key_server => "hkp://-pgp.mit.edu",
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
-      context "url with dash" do
-        let(:params) do{
-          :key_server => 'hkp://p-gp.m-it.edu',
-        } end
-        it "should contain apt::key" do
-          should contain_apt__key(title).with({
-            :key        => title,
-            :ensure     => 'present',
-            :key_server => 'hkp://p-gp.m-it.edu',
-          })
-        end
+    end
+    context "url ending with a dot" do
+      let :params do
+        {
+          :key_server => 'hkp://pgp.mit.edu.'
+        }
       end
-      context "exceed characher url" do
-        let (:params) do{
-          :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
-		end
-
-    describe 'key_options =>' do
-      let :params do {
-        :key_options => 'debug',
+    end
+    context "url begin with a dash" do
+      let(:params) do{
+        :key_server => "hkp://-pgp.mit.edu",
       } end
-
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key          => title,
-          :ensure       => 'present',
-          :key_options  => 'debug',
-        })
-      end
-      it 'contains the apt_key' do
-        should contain_apt_key(title).with({
-          :id                => title,
-          :ensure            => 'present',
-          :source            => nil,
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => params[:key_options],
-        })
-      end
-      it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{title} present")
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
     end
-  end
-
-  describe 'validation' do
     context 'invalid key' do
       let :title do
         'Out of rum. Why? Why are we out of rum?'
@@ -369,44 +261,55 @@
         expect { subject }.to raise_error(/is not a string/)
       end
     end
-  end
 
-  describe 'duplication' do
-    context 'two apt::key resources for same key, different titles' do
-      let :pre_condition do
-        "apt::key { 'duplicate': key => #{title}, }"
+    context 'invalid ensure' do
+      let :params do
+        {
+          :ensure => 'foo',
+        }
       end
-
-      it 'contains two apt::key resources' do
-        should contain_apt__key('duplicate').with({
-          :key    => title,
-          :ensure => 'present',
-        })
-        should contain_apt__key(title).with({
-          :key    => title,
-          :ensure => 'present',
-        })
-      end
-
-      it 'contains only a single apt_key' do
-        should contain_apt_key('duplicate').with({
-          :id                => title,
-          :ensure            => 'present',
-          :source            => nil,
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => nil,
-        })
-        should_not contain_apt_key(title)
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
     end
 
-    context 'two apt::key resources, different ensure' do
-      let :pre_condition do
-        "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }"
+    describe 'duplication' do
+      context 'two apt::key resources for same key, different titles' do
+        let :pre_condition do
+          "apt::key { 'duplicate': key => #{title}, }"
+        end
+
+        it 'contains two apt::key resources' do
+          should contain_apt__key('duplicate').with({
+            :key    => title,
+            :ensure => 'present',
+          })
+          should contain_apt__key(title).with({
+            :key    => title,
+            :ensure => 'present',
+          })
+        end
+
+        it 'contains only a single apt_key' do
+          should contain_apt_key('duplicate').with({
+            :id                => title,
+            :ensure            => 'present',
+            :source            => nil,
+            :server            => nil,
+            :content           => nil,
+            :keyserver_options => nil,
+          })
+          should_not contain_apt_key(title)
+        end
       end
-      it 'informs the user of the impossibility' do
-        expect { subject }.to raise_error(/already ensured as absent/)
+
+      context 'two apt::key resources, different ensure' do
+        let :pre_condition do
+          "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }"
+        end
+        it 'informs the user of the impossibility' do
+          expect { subject }.to raise_error(/already ensured as absent/)
+        end
       end
     end
   end
diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb
index d79462cd48..23ebd59b32 100644
--- a/spec/defines/pin_spec.rb
+++ b/spec/defines/pin_spec.rb
@@ -3,118 +3,165 @@
   let(:facts) { { :lsbdistid => 'Debian' } }
   let(:title) { 'my_pin' }
 
-  let :default_params do
-    {
-      :ensure   => 'present',
-      :order    => '',
-      :packages => '*',
-      :priority => '0',
-      :release  => nil
+  context 'defaults' do
+    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/preferences.d/my_pin.pref',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    })
     }
   end
 
-  [
-    { :params  => {},
-      :content => "Explanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n"
-    },
-    {
-      :params => {
-        :packages => 'apache',
-        :priority => '1'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :order    => 50,
-        :packages => 'apache',
-        :priority => '1'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :ensure   => 'absent',
-        :packages => 'apache',
-        :priority => '1'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :packages => 'apache',
-        :priority => '1',
-        :release  => 'my_newpin'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :packages => 'apache',
-        :priority => '1',
-        :version  => '2.2.16*'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :priority => '1',
-        :origin   => 'ftp.de.debian.org'
-      },
-      :content => "Explanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :packages        => 'apache',
-        :priority        => '1',
-        :release         => 'stable',
-        :codename        => 'wheezy',
-        :release_version => '3.0',
-        :component       => 'main',
-        :originator      => 'Debian',
-        :label           => 'Debian'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :packages        => ['apache', 'ntop'],
-      },
-      :content => "Explanation: : my_pin\nPackage: apache ntop\nPin: release a=my_pin\nPin-Priority: 0\n"
-    },
-  ].each do |param_set|
-    describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
-      let :param_hash do
-        default_params.merge(param_set[:params])
-      end
+  context 'set version' do
+    let :params do
+      {
+        'packages' => 'vim',
+        'version'  => '1',
+      }
+    end
+    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/preferences.d/my_pin.pref',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    })
+    }
+  end
 
-      let :params do
-        param_set[:params]
-      end
+  context 'set origin' do
+    let :params do
+      {
+        'packages' => 'vim',
+        'origin'   => 'test',
+      }
+    end
+    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/preferences.d/my_pin.pref',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    })
+    }
+  end
 
-      it { should contain_class("apt::params") }
+  context 'not defaults' do
+    let :params do
+      {
+        'explanation'     => 'foo',
+        'order'           => 99,
+        'release'         => '1',
+        'codename'        => 'bar',
+        'release_version' => '2',
+        'component'       => 'baz',
+        'originator'      => 'foobar',
+        'label'           => 'foobaz',
+        'priority'        => 10,
+      }
+    end
+    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) }
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/preferences.d/99-my_pin.pref',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    })
+    }
+  end
 
-      it { should contain_file("#{title}.pref").with({
-          'ensure'  => param_hash[:ensure],
-          'path'    => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
-          'owner'   => 'root',
-          'group'   => 'root',
-          'mode'    => '0644',
-          'content' => param_set[:content],
-        })
+  context 'ensure absent' do
+    let :params do
+      {
+        'ensure' => 'absent'
       }
     end
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'absent',
+    })
+    }
+  end
+
+  context 'bad characters' do
+    let(:title) { 'such  bad && wow!' }
+    it { is_expected.to contain_file("such__bad____wow_.pref") }
   end
 
-  describe 'resource title with invalid chars' do
-    context 'spaces' do
-      let(:title) { 'oh my god this is not valid' }
-      it { should contain_file('oh_my_god_this_is_not_valid.pref') }
+  describe 'validation' do
+    context 'invalid order' do
+      let :params do
+        {
+          'order' => 'foo',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /Only integers are allowed/)
+      end
+    end
+
+    context 'packages == * and version' do
+      let :params do
+        {
+          'version' => '1',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
+      end
     end
 
-    context '#$&*$' do
-      let(:title) { 'so && many $* invalid @! things' }
-      it { should contain_file('so____many____invalid____things.pref') }
+    context 'packages == * and release and origin' do
+      let :params do
+        {
+          'origin'  => 'test',
+          'release' => 'foo',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
+      end
+    end
+
+    context 'specific form with release and origin' do
+      let :params do
+        {
+          'release'  => 'foo',
+          'origin'   => 'test',
+          'packages' => 'vim',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
+      end
+    end
+
+    context 'specific form with version and origin' do
+      let :params do
+        {
+          'version'  => '1',
+          'origin'   => 'test',
+          'packages' => 'vim',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
+      end
     end
   end
 end
diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb
index 6944f9b2df..3a4c381f67 100644
--- a/spec/defines/ppa_spec.rb
+++ b/spec/defines/ppa_spec.rb
@@ -1,158 +1,163 @@
 require 'spec_helper'
 describe 'apt::ppa', :type => :define do
-  [
-    {
-      :lsbdistrelease  => '11.04',
-      :lsbdistcodename => 'natty',
-      :operatingsystem => 'Ubuntu',
-      :lsbdistid       => 'Ubuntu',
-      :package         => 'python-software-properties'
-    },
-    {
-      :lsbdistrelease  => '12.10',
-      :lsbdistcodename => 'quantal',
-      :operatingsystem => 'Ubuntu',
-      :lsbdistid       => 'Ubuntu',
-      :package         => 'software-properties-common'
-    },
-  ].each do |platform|
-    context "on #{platform[:lsbdistcodename]}" do
-      let :facts do
-        {
-          :lsbdistrelease  => platform[:lsbdistrelease],
-          :lsbdistcodename => platform[:lsbdistcodename],
-          :operatingsystem => platform[:operatingsystem],
-          :lsbdistid       => platform[:lsbdistid],
-          :osfamily        => 'Debian',
-        }
-      end
-      let :release do
-        "#{platform[:lsbdistcodename]}"
-      end
-      let :package do
-        "#{platform[:package]}"
-      end
-      let :options do
-        "-y"
-      end
-      ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
-        describe "with title #{t}" do
-          let :pre_condition do
-            'class { "apt": }'
-          end
-          let :title do
-            t
-          end
-          let :filename do
-            t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list"
-          end
-
-          it { should contain_package("#{package}") }
 
-          it { should contain_exec("apt_update").with(
-            'command'     => '/usr/bin/apt-get update',
-            'refreshonly' => true
-            )
-          }
+  describe 'defaults' do
+    let :pre_condition do
+      'class { "apt": }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '11.04',
+        :lsbdistcodename => 'natty',
+        :operatingsystem => 'Ubuntu',
+        :osfamily        => 'Debian',
+        :lsbdistid       => 'Ubuntu',
+      }
+    end
 
-          it { should contain_exec("add-apt-repository-#{t}").with(
-            'command' => "/usr/bin/add-apt-repository #{options} #{t}",
-            'unless'  => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
-            'require' => ["File[sources.list.d]", "Package[#{package}]"],
-            'notify'  => "Exec[apt_update]"
-            )
-          }
+    let(:title) { 'ppa:needs/such.substitution/wow' }
+    it { is_expected.to contain_package('python-software-properties') }
+    it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
+      'environment' => [],
+      'command'     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
+      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
+      'user'        => 'root',
+      'logoutput'   => 'on_failure',
+    })
+    }
 
-          it { should create_file("/etc/apt/sources.list.d/#{filename}").with(
-            'ensure'  => 'file',
-            'require' => "Exec[add-apt-repository-#{t}]"
-            )
-          }
-        end
-      end
-      describe 'without a proxy defined' do
-        let :title do
-          'rspec_ppa'
-        end
-        let :pre_condition do
-          'class { "apt":
-             proxy_host => false
-          }'
-        end
-        let :filename do
-          "#{title}-#{release}.list"
-        end
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({
+      'ensure' => 'file',
+    })
+    }
+  end
 
-        it { should contain_exec("add-apt-repository-#{title}").with(
-          'environment' => [],
-          'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
-          'unless'      => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
-          'require'     => ["File[sources.list.d]", "Package[#{package}]"],
-          'notify'      => "Exec[apt_update]"
-          )
-        }
-      end
+  describe 'apt included, no proxy' do
+    let :pre_condition do
+      'class { "apt": }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '14.04',
+        :lsbdistcodename => 'trusty',
+        :operatingsystem => 'Ubuntu',
+        :lsbdistid       => 'Ubuntu',
+        :osfamily        => 'Debian',
+      }
+    end
+    let :params do
+      {
+        'options' => '',
+      }
+    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' => [],
+      'command'     => '/usr/bin/add-apt-repository  ppa:foo',
+      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      'user'        => 'root',
+      'logoutput'   => 'on_failure',
+    })
+    }
 
-      describe 'behind a proxy' do
-        let :title do
-          'rspec_ppa'
-        end
-        let :pre_condition do
-          'class { "apt":
-            proxy_host => "user:pass@proxy",
-          }'
-        end
-          let :filename do
-            "#{title}-#{release}.list"
-          end
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({
+      'ensure' => 'file',
+    })
+    }
+  end
 
-        it { should contain_exec("add-apt-repository-#{title}").with(
-          'environment' => [
-            "http_proxy=http://user:pass@proxy:8080",
-            "https_proxy=http://user:pass@proxy:8080",
-          ],
-          'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
-          'unless'      => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
-          'require'     => ["File[sources.list.d]", "Package[#{package}]"],
-          'notify'      => "Exec[apt_update]"
-          )
-        }
-      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
 
-  [ { :lsbdistcodename => 'natty',
-      :package => 'python-software-properties' },
-    { :lsbdistcodename => 'quantal',
-      :package => 'software-properties-common'},
-  ].each do |platform|
-    context "on #{platform[:lsbdistcodename]}" do
-      describe "it should not error if package['#{platform[:package]}'] is already defined" do
-        let :pre_condition do
-           'class {"apt": }' +
-           'package { "#{platform[:package]}": }->Apt::Ppa["ppa"]'
-        end
-        let :facts do
-          {:lsbdistcodename => '#{platform[:lsbdistcodename]}',
-           :operatingsystem => 'Ubuntu',
-           :lsbdistid => 'Ubuntu',
-           :osfamily => 'Debian'}
-        end
-        let(:title) { "ppa" }
-        let(:release) { "#{platform[:lsbdistcodename]}" }
-        it { should contain_package('#{platform[:package]}') }
-      end
+  describe 'ensure absent' do
+    let :facts do
+      {
+        :lsbdistrelease  => '14.04',
+        :lsbdistcodename => 'trusty',
+        :operatingsystem => 'Ubuntu',
+        :lsbdistid       => 'Ubuntu',
+        :osfamily        => 'Debian',
+      }
+    end
+    let(:title) { 'ppa:foo' }
+    let :params do
+      {
+        'ensure' => 'absent'
+      }
     end
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({
+      'ensure' => 'absent',
+    })
+    }
   end
 
-  describe "without Class[apt] should raise a Puppet::Error" do
-    let(:release) { "natty" }
-    let(:title) { "ppa" }
-    it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) }
-  end
+  context 'validation' do
+    describe 'no release' do
+      let :facts do
+        {
+          :lsbdistrelease  => '14.04',
+          :operatingsystem => 'Ubuntu',
+          :lsbdistid       => 'Ubuntu',
+          :osfamily        => 'Debian',
+        }
+      end
+      let(:title) { 'ppa:foo' }
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
+      end
+    end
 
-  describe "without release should raise a Puppet::Error" do
-    let(:title) { "ppa:" }
-    it { expect { should contain_apt__ppa(:release) }.to raise_error(Puppet::Error) }
+    describe 'not ubuntu' do
+      let :facts do
+        {
+          :lsbdistrelease  => '14.04',
+          :lsbdistcodename => 'trusty',
+          :operatingsystem => 'Debian',
+          :lsbdistid       => 'Ubuntu',
+          :osfamily        => 'Debian',
+        }
+      end
+      let(:title) { 'ppa:foo' }
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /apt::ppa is currently supported on Ubuntu only./)
+      end
+    end
   end
 end
diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb
index 284adca27f..960bb620fc 100644
--- a/spec/defines/source_spec.rb
+++ b/spec/defines/source_spec.rb
@@ -1,179 +1,127 @@
 require 'spec_helper'
 
 describe 'apt::source', :type => :define do
-  let(:facts) { { :lsbdistid => 'Debian' } }
   GPG_KEY_ID = '4BD6EC30'
 
   let :title do
     'my_source'
   end
 
-  let :default_params do
-    {
-      :ensure             => 'present',
-      :location           => '',
-      :release            => 'karmic',
-      :repos              => 'main',
-      :include_src        => true,
-      :include_deb        => true,
-      :required_packages  => false,
-      :key                => false,
-      :key_server         => false,
-      :key_content        => false,
-      :key_source         => false,
-      :pin                => false
-    }
-  end
+  context 'mostly defaults' do
+    let :facts do
+      {
+        :lsbdistid       => 'Debian',
+        :lsbdistcodename => 'wheezy',
+      }
+    end
 
-  [{},
-   {
-      :location           => 'http://example.com',
-      :release            => 'precise',
-      :repos              => 'security',
-      :include_src        => false,
-      :required_packages  => 'apache',
-      :key                => GPG_KEY_ID,
-      :key_server         => 'keyserver.debian.com',
-      :pin                => '600',
-      :key_content        => 'ABCD1234'
-    },
-    {
-      :key                => GPG_KEY_ID,
-      :key_server         => 'keyserver.debian.com',
-    },
-    {
-      :ensure             => 'absent',
-      :location           => 'http://example.com',
-      :release            => 'precise',
-      :repos              => 'security',
-    },
-    {
-      :release            => '',
-    },
-    {
-      :release            => 'custom',
-    },
-    {
-      :architecture       => 'amd64',
+    let :params do
+      {
+        'include_deb' => false,
+      }
+    end
+
+    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/sources.list.d/my_source.list',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    }).with_content(/#file generated by puppet\n# my_source\ndeb-src  wheezy main\n/)
     }
-  ].each do |param_set|
-    describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
-      let :param_hash do
-        default_params.merge(param_set)
-      end
+  end
 
-      let :facts do
-        {:lsbdistcodename => 'karmic', :lsbdistid => 'Ubuntu'}
-      end
+  context 'no defaults' do
+    let :facts do
+      {
+        :lsbdistid       => 'Debian',
+        :lsbdistcodename => 'wheezy',
+      }
+    end
+    let :params do
+      {
+        'comment'           => 'foo',
+        'location'          => 'http://debian.mirror.iweb.ca/debian/',
+        'release'           => 'sid',
+        'repos'             => 'testing',
+        'include_src'       => false,
+        'required_packages' => 'vim',
+        'key'               => GPG_KEY_ID,
+        'key_server'        => 'pgp.mit.edu',
+        'key_content'       => 'GPG key content',
+        'key_source'        => 'http://apt.puppetlabs.com/pubkey.gpg',
+        'pin'               => '10',
+        'architecture'      => 'x86_64',
+      }
+    end
 
-      let :params do
-        param_set
-      end
+    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/sources.list.d/my_source.list',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    }).with_content(/#file generated by puppet\n# foo\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
+    }
 
-      let :filename do
-        "/etc/apt/sources.list.d/#{title}.list"
-      end
+    it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
+      'ensure'   => 'present',
+      'priority' => '10',
+      'origin'   => 'debian.mirror.iweb.ca',
+    })
+    }
 
-      let :content do
-        content = "#file generated by puppet\n"
-	if param_hash[:comment]
-	  content << "# #{comment}"
-	else
-	  content << "# #{title}"
-	end
-        if param_hash[:architecture]
-          arch = "[arch=#{param_hash[:architecture]}] "
-        end
-        if param_hash[:include_deb]
-	  content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
-	end
-        if param_hash[:include_src]
-          content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
-        end
-        content
-      end
+    it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Exec[apt_update]').that_subscribes_to('File[my_source.list]').with({
+      'command'     => '/usr/bin/apt-get -y install vim',
+      'logoutput'   => 'on_failure',
+      'refreshonly' => true,
+      'tries'       => '3',
+      'try_sleep'   => '1',
+    })
+    }
 
-      it { should contain_apt__params }
+    it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('File[my_source.list]').with({
+      'ensure' => 'present',
+        'key'  => GPG_KEY_ID,
+        'key_server' => 'pgp.mit.edu',
+        'key_content' => 'GPG key content',
+        'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
+    })
+    }
+  end
 
-      it { should contain_file("#{title}.list").with({
-          'ensure'    => param_hash[:ensure],
-          'path'      => filename,
-          'owner'     => 'root',
-          'group'     => 'root',
-          'mode'      => '0644',
-          'content'   => content,
-        })
+  context 'ensure => absent' do
+    let :facts do
+      {
+        :lsbdistid       => 'Debian',
+        :lsbdistcodename => 'wheezy',
       }
-
-      it {
-        if param_hash[:pin]
-          should contain_apt__pin(title).with({
-            "priority"  => param_hash[:pin],
-            "before"    => "File[#{title}.list]"
-          })
-        else
-          should_not contain_apt__pin(title).with({
-            "priority"  => param_hash[:pin],
-            "before"    => "File[#{title}.list]"
-          })
-        end
+    end
+    let :params do
+      {
+        'ensure' => 'absent',
       }
+    end
 
-      it {
-        should contain_exec("apt_update").with({
-          "command"     => "/usr/bin/apt-get update",
-          "refreshonly" => true
-        })
-      }
+    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+      'ensure' => 'absent'
+    })
+    }
+  end
 
-      it {
-        if param_hash[:required_packages]
-          should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
-            "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
-            "subscribe"   => "File[#{title}.list]",
-            "refreshonly" => true,
-            "before"      => 'Exec[apt_update]',
-          })
-        else
-          should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
-            "command"     => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
-            "subscribe"   => "File[#{title}.list]",
-            "refreshonly" => true
-          })
-        end
-      }
+  describe 'validation' do
+    context 'no release' do
+      let :facts do
+        {
+          :lsbdistid       => 'Debian',
+        }
+      end
 
-      it {
-        key_server  = param_hash[:key_server]  || nil
-        key_content = param_hash[:key_content] || nil
-        key_source  = param_hash[:key_source]  || nil
-        if param_hash[:key]
-          should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
-            "key"         => param_hash[:key],
-            "ensure"      => :present,
-            "key_server"  => key_server,
-            "key_content" => key_content,
-            "key_source"  => key_source,
-            "before"      => "File[#{title}.list]"
-          })
-        else
-          should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
-            "key"         => param_hash[:key],
-            "ensure"      => :present,
-            "key_server"  => param_hash[:key_server],
-            "key_content" => param_hash[:key_content],
-            "key_source"  => param_hash[:key_source],
-            "before"      => "File[#{title}.list]"
-          })
-        end
-      }
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
+      end
     end
   end
-  describe "without release should raise a Puppet::Error" do
-    let(:default_params) { Hash.new }
-    let(:facts) { Hash.new }
-    it { expect { should raise_error(Puppet::Error) } }
-    let(:facts) { { :lsbdistcodename => 'lucid', :lsbdistid => 'Ubuntu' } }
-    it { should contain_apt__source(title) }
-  end
 end

From 5018cb51914552d5d2f84f729870e09b18fa132f Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Fri, 25 Jul 2014 18:20:06 -0400
Subject: [PATCH 339/574] Prep for 1.6.0 release.

---
 CHANGELOG.md  | 16 ++++++++++++++++
 metadata.json |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 011c41d378..a5bea595b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,19 @@
+##2014-07-30 - Supported Release 1.6.0
+###Summary
+
+####Features
+- Allow URL or domain name for key_server parameter
+- Allow custom comment for sources list
+- Files synced using ModuleSync!
+- Enable auto-update for Debian squeeze LTS
+- Add facts showing available updates
+
+####Bugfixes
+- Fix regex to follow apt requirements
+- Allow dashes in URL or domain for key_server parameter
+- Test fixes for Ubuntu 10.04
+- Fix for unicode characters
+
 ##2014-07-15 - Supported Release 1.5.2
 ###Summary
 
diff --git a/metadata.json b/metadata.json
index f1c18a5dbc..f6ea55e160 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,6 +1,6 @@
 {
   "name": "puppetlabs-apt",
-  "version": "1.5.2",
+  "version": "1.6.0",
   "author": "Puppet Labs",
   "summary": "Puppet Labs Apt Module",
   "license": "Apache-2.0",

From 1ad3ad8da62b255bea868e20dfc86d945a4490a6 Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Wed, 25 Jun 2014 16:33:47 -0700
Subject: [PATCH 340/574] Add configuration file for modulesync

https://github.com/puppetlabs/modulesync
---
 .sync.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.sync.yml b/.sync.yml
index ed97d539c0..1b7c84ec84 100644
--- a/.sync.yml
+++ b/.sync.yml
@@ -1 +1,5 @@
 ---
+.travis.yml:
+  env_matrix:
+  - PUPPET_GEM_VERSION="~> 3.4.0"
+  - PUPPET_GEM_VERSION="~> 3.5.0"

From e15a8fa9fa06c582e71e5c7a6555c2c7261eb756 Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Fri, 27 Jun 2014 09:27:52 -0700
Subject: [PATCH 341/574] Update .sync.yml to support new .travis.yml configs

---
 .sync.yml | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/.sync.yml b/.sync.yml
index 1b7c84ec84..ed97d539c0 100644
--- a/.sync.yml
+++ b/.sync.yml
@@ -1,5 +1 @@
 ---
-.travis.yml:
-  env_matrix:
-  - PUPPET_GEM_VERSION="~> 3.4.0"
-  - PUPPET_GEM_VERSION="~> 3.5.0"

From 4688bfaf81642886626908bbdc73c970a0b8f83d Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Fri, 8 Aug 2014 09:42:35 -0400
Subject: [PATCH 342/574] 1.5.3 prep

---
 CHANGELOG.md | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5bea595b7..fda47c5e41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,18 +1,30 @@
-##2014-07-30 - Supported Release 1.6.0
+##2014-08-20 - Supported Release 1.6.0
 ###Summary
 
 ####Features
 - Allow URL or domain name for key_server parameter
 - Allow custom comment for sources list
-- Files synced using ModuleSync!
 - Enable auto-update for Debian squeeze LTS
 - Add facts showing available updates
 
 ####Bugfixes
-- Fix regex to follow apt requirements
 - Allow dashes in URL or domain for key_server parameter
-- Test fixes for Ubuntu 10.04
+
+##2014-08-13 - Supported Release 1.5.3
+###Summary
+
+This is a bugfix releases.  It addresses a bad regex, failures with unicode
+characters, and issues with the $proxy_host handling in apt::ppa.
+
+####Features
+- Synced files from Modulesync
+
+####Bugfixes
+- Fix regex to follow APT requirements in apt::pin
 - Fix for unicode characters
+- Fix inconsistent $proxy_host handling in apt and apt::ppa
+- Fix typo in README
+- Fix broken acceptance tests
 
 ##2014-07-15 - Supported Release 1.5.2
 ###Summary

From 08043adb753210c12cbd704ea800898a17751ff6 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Mon, 11 Aug 2014 15:56:32 -0400
Subject: [PATCH 343/574] Sometimes killing apt is too aggressive.

---
 spec/acceptance/unattended_upgrade_spec.rb | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/spec/acceptance/unattended_upgrade_spec.rb b/spec/acceptance/unattended_upgrade_spec.rb
index 09f4e2bed0..02ebea4ec9 100644
--- a/spec/acceptance/unattended_upgrade_spec.rb
+++ b/spec/acceptance/unattended_upgrade_spec.rb
@@ -8,10 +8,14 @@
       include apt::unattended_upgrades
       EOS
 
-      # Attempted workaround for problems seen on debian with
-      # something holding the package database open.
-      shell('killall -9 apt-get', { :acceptable_exit_codes => [0,1] })
-      shell('killall -9 dpkg', { :acceptable_exit_codes => [0,1] })
+      if fact('operatingsystem') == 'Debian'
+        # Attempted workaround for problems seen on debian with
+        # something holding the package database open.
+        shell('killall -9 apt-get', { :acceptable_exit_codes => [0,1] })
+        shell('killall -9 dpkg', { :acceptable_exit_codes => [0,1] })
+        shell('dpkg --configure -a')
+      end
+
       apply_manifest(pp, :catch_failures => true)
     end
 

From ce846d0118b4220a7f71307f089cb65b37dcccda Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Wed, 30 Jul 2014 19:54:28 -0400
Subject: [PATCH 344/574] Cleaned up acceptance tests

A lot of the tests were testing things that really should be tested via
unit tests, so those were deleted and unit tests will be revamped to
make sure they are covering everything they need to be covering.

Conflicts:
	spec/acceptance/unattended_upgrade_spec.rb
---
 spec/acceptance/apt_builddep_spec.rb       |  36 --
 spec/acceptance/apt_key_provider_spec.rb   |   2 +-
 spec/acceptance/apt_key_spec.rb            | 200 --------
 spec/acceptance/apt_ppa_spec.rb            | 138 -----
 spec/acceptance/apt_source_spec.rb         | 326 ------------
 spec/acceptance/apt_spec.rb                | 299 +----------
 spec/acceptance/backports_spec.rb          |  73 ---
 spec/acceptance/class_spec.rb              |   2 +-
 spec/acceptance/conf_spec.rb               |  66 ---
 spec/acceptance/force_spec.rb              |  76 ---
 spec/acceptance/pin_spec.rb                | 286 -----------
 spec/acceptance/release_spec.rb            |  26 -
 spec/acceptance/unattended_upgrade_spec.rb | 566 ---------------------
 spec/acceptance/unsupported_spec.rb        |  10 -
 14 files changed, 23 insertions(+), 2083 deletions(-)
 delete mode 100644 spec/acceptance/apt_builddep_spec.rb
 delete mode 100644 spec/acceptance/apt_key_spec.rb
 delete mode 100644 spec/acceptance/apt_ppa_spec.rb
 delete mode 100644 spec/acceptance/apt_source_spec.rb
 delete mode 100644 spec/acceptance/backports_spec.rb
 delete mode 100644 spec/acceptance/conf_spec.rb
 delete mode 100644 spec/acceptance/force_spec.rb
 delete mode 100644 spec/acceptance/pin_spec.rb
 delete mode 100644 spec/acceptance/release_spec.rb
 delete mode 100644 spec/acceptance/unattended_upgrade_spec.rb
 delete mode 100644 spec/acceptance/unsupported_spec.rb

diff --git a/spec/acceptance/apt_builddep_spec.rb b/spec/acceptance/apt_builddep_spec.rb
deleted file mode 100644
index 1e35e4aa68..0000000000
--- a/spec/acceptance/apt_builddep_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::builddep', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-
-  context 'reset' do
-    it 'removes packages' do
-      shell('apt-get -y remove znc')
-      shell('apt-get -y remove g++')
-    end
-  end
-
-  context 'apt::builddep' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include '::apt'
-      apt::builddep { 'znc': }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe 'should install g++ as a dependency' do
-      describe package('g++') do
-        it { should be_installed }
-      end
-    end
-  end
-
-  context 'reset' do
-    it 'removes packages' do
-      shell('apt-get -y remove znc')
-      shell('apt-get -y remove g++')
-    end
-  end
-
-end
diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb
index d9c2c0d751..497c6edb53 100644
--- a/spec/acceptance/apt_key_provider_spec.rb
+++ b/spec/acceptance/apt_key_provider_spec.rb
@@ -7,7 +7,7 @@
 CENTOS_REPO_URL         = 'ftp.cvut.cz/centos'
 CENTOS_GPG_KEY_FILE     = 'RPM-GPG-KEY-CentOS-6'
 
-describe 'apt_key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+describe 'apt_key' do
   before(:each) do
     shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}",
           :acceptable_exit_codes => [0,1,2])
diff --git a/spec/acceptance/apt_key_spec.rb b/spec/acceptance/apt_key_spec.rb
deleted file mode 100644
index 9f2ba395ad..0000000000
--- a/spec/acceptance/apt_key_spec.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'apt::key' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include '::apt'
-      apt::key { 'puppetlabs':
-        key        => '4BD6EC30',
-        key_server => 'pgp.mit.edu',
-      }
-
-      apt::key { 'jenkins':
-        key        => 'D50582E6',
-        key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
-      }
-      EOS
-
-      shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-      shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe 'keys should exist' do
-      it 'finds puppetlabs key' do
-        shell('apt-key list | grep 4BD6EC30')
-      end
-      it 'finds jenkins key' do
-        shell('apt-key list | grep D50582E6')
-      end
-    end
-  end
-  context 'ensure' do
-    context 'absent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::key { 'puppetlabs':
-          ensure     => absent,
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-        }
-
-        apt::key { 'jenkins':
-          ensure     => absent,
-          key        => 'D50582E6',
-          key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'keys shouldnt exist' do
-        it 'fails' do
-          shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [1])
-        end
-        it 'fails' do
-          shell('apt-key list | grep D50582E6', :acceptable_exit_codes => [1])
-        end
-      end
-    end
-  end
-
-  context 'reset' do
-    it 'clean up keys' do
-      shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-      shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
-    end
-  end
-
-  context 'key options' do
-    context 'key_content' do
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::key { 'puppetlabs':
-          key         => '4BD6EC30',
-          key_content => '-----BEGIN PGP PUBLIC KEY BLOCK-----
-          Version: GnuPG v1.4.12 (GNU/Linux)
-          Comment: GPGTools - http://gpgtools.org
-
-          mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b
-          fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg
-          5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+
-            S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY
-          GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH
-          Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v
-          VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0
-          Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI
-          wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN
-          NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl
-          f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB
-          tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL
-          ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn
-          AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob
-          pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF
-          eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+
-            aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M
-          2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ
-          VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU
-          3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh
-          qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1
-          IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8
-          1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp
-          HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN
-          MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+
-            UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh
-          R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+
-            N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc
-          kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e
-          lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT
-          DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb
-          kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf
-          DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei
-          BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z
-          XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2
-          +zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU
-          fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH
-          dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4
-          qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2
-          7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq
-          UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x
-          Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA
-          KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3
-          okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7
-          bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4
-          4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX
-          vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0
-          jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y
-          ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD
-          7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR
-          M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf
-          REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y
-          DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk
-          ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
-            =a34C
-          -----END PGP PUBLIC KEY BLOCK-----
-          ',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-    end
-    describe 'keys should exist' do
-      it 'finds puppetlabs key' do
-        shell('apt-key list | grep 4BD6EC30')
-      end
-    end
-
-    context 'key_source' do
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::key { 'puppetlabs':
-          key        => '4BD6EC30',
-          key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'keys should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30')
-        end
-      end
-    end
-
-    context 'key_options' do
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::key { 'puppetlabs':
-          key        => '4BD6EC30',
-          key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
-          key_options => 'debug'
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'keys should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30')
-        end
-      end
-    end
-  end
-
-end
diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb
deleted file mode 100644
index b665c5cf47..0000000000
--- a/spec/acceptance/apt_ppa_spec.rb
+++ /dev/null
@@ -1,138 +0,0 @@
-require 'spec_helper_acceptance'
-
-if fact('operatingsystem') == 'Ubuntu'
-  describe 'apt::ppa', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-
-    context 'reset' do
-      it 'removes ppa' do
-        shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
-        shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
-      end
-    end
-
-    context 'adding a ppa that doesnt exist' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::ppa { 'ppa:canonical-kernel-team/ppa': }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'contains the source file' do
-        it 'contains a kernel ppa source' do
-          shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
-        end
-      end
-    end
-
-    context 'reading a removed ppa.' do
-      it 'setup' do
-        # This leaves a blank file
-        shell('echo > /etc/apt/sources.list.d/raravena80-collectd5-$(lsb_release -c -s).list')
-      end
-
-      it 'should read it successfully' do
-        pp = <<-EOS
-        include '::apt'
-        apt::ppa { 'ppa:raravena80/collectd5': }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-    end
-
-    context 'reset' do
-      it 'removes added ppas' do
-        shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
-        shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
-      end
-    end
-
-    context 'ensure' do
-      context 'present' do
-        it 'works without failure' do
-          pp = <<-EOS
-          include '::apt'
-          apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present }
-          EOS
-
-          apply_manifest(pp, :catch_failures => true)
-        end
-
-        describe 'contains the source file' do
-          it 'contains a kernel ppa source' do
-            shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
-          end
-        end
-      end
-    end
-
-    context 'ensure' do
-      context 'absent' do
-        it 'works without failure' do
-          pp = <<-EOS
-          include '::apt'
-          apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent }
-          EOS
-
-          apply_manifest(pp, :catch_failures => true)
-        end
-
-        describe 'doesnt contain the source file' do
-          it 'fails' do
-            shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2])
-          end
-        end
-      end
-    end
-
-    context 'release' do
-      context 'precise' do
-        it 'works without failure' do
-          pp = <<-EOS
-          include '::apt'
-          apt::ppa { 'ppa:canonical-kernel-team/ppa':
-            ensure  => present,
-            release => precise,
-          }
-          EOS
-
-          shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
-          apply_manifest(pp, :catch_failures => true)
-        end
-
-        describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
-          it { should be_file }
-        end
-      end
-    end
-
-    context 'options' do
-      context '-y', :unless => default[:platform].match(/10\.04/) do
-        it 'works without failure' do
-          pp = <<-EOS
-          include '::apt'
-          apt::ppa { 'ppa:canonical-kernel-team/ppa':
-            ensure  => present,
-            release => precise,
-            options => '-y',
-          }
-          EOS
-
-          shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
-          apply_manifest(pp, :catch_failures => true)
-        end
-
-        describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
-          it { should be_file }
-        end
-      end
-    end
-
-    context 'reset' do
-      it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) }
-    end
-  end
-end
diff --git a/spec/acceptance/apt_source_spec.rb b/spec/acceptance/apt_source_spec.rb
deleted file mode 100644
index c2d076cbff..0000000000
--- a/spec/acceptance/apt_source_spec.rb
+++ /dev/null
@@ -1,326 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::source', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-
-  context 'apt::source' do
-    context 'ensure => present' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe 'key should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0])
-        end
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-      end
-    end
-
-    context 'ensure => absent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => absent,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      # The key should remain -we don't delete those when deleting a source.
-      describe 'key should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0])
-        end
-      end
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should_not be_file }
-      end
-    end
-
-  end
-
-  context 'release' do
-    context 'test' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-          release    => 'precise',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-        it { should contain 'deb http://apt.puppetlabs.com precise main' }
-      end
-    end
-  end
-
-  context 'include_src' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure      => present,
-          location    => 'http://apt.puppetlabs.com',
-          repos       => 'main',
-          key         => '4BD6EC30',
-          key_server  => 'pgp.mit.edu',
-          include_src => true,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-        it { should contain 'deb-src http://apt.puppetlabs.com' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure      => present,
-          location    => 'http://apt.puppetlabs.com',
-          repos       => 'main',
-          key         => '4BD6EC30',
-          key_server  => 'pgp.mit.edu',
-          include_src => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-        it { should_not contain 'deb-src http://apt.puppetlabs.com' }
-      end
-    end
-  end
-
-  context 'required_packages' do
-    context 'vim' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure             => present,
-          location           => 'http://apt.puppetlabs.com',
-          repos              => 'main',
-          key                => '4BD6EC30',
-          key_server         => 'pgp.mit.edu',
-          required_packages  => 'vim',
-        }
-        EOS
-
-        shell('apt-get -y remove vim')
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe package('vim') do
-        it { should be_installed }
-      end
-    end
-  end
-
-  context 'key content' do
-    context 'giant key' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure      => present,
-          location    => 'http://apt.puppetlabs.com',
-          repos       => 'main',
-          key         => '4BD6EC30',
-          key_content => '-----BEGIN PGP PUBLIC KEY BLOCK-----
-          Version: GnuPG v1.4.12 (GNU/Linux)
-          Comment: GPGTools - http://gpgtools.org
-
-          mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b
-          fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg
-          5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+
-          S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY
-          GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH
-          Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v
-          VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0
-          Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI
-          wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN
-          NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl
-          f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB
-          tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL
-          ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn
-          AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob
-          pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF
-          eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+
-          aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M
-          2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ
-          VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU
-          3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh
-          qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1
-          IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8
-          1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp
-          HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN
-          MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+
-          UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh
-          R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+
-          N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc
-          kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e
-          lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT
-          DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb
-          kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf
-          DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei
-          BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z
-          XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2
-          +zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU
-          fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH
-          dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4
-          qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2
-          7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq
-          UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x
-          Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA
-          KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3
-          okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7
-          bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4
-          4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX
-          vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0
-          jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y
-          ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD
-          7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR
-          M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf
-          REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y
-          DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk
-          ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
-          =a34C
-          -----END PGP PUBLIC KEY BLOCK-----',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-      end
-      describe 'keys should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30')
-        end
-      end
-    end
-  end
-
-  context 'key_source' do
-    context 'http://apt.puppetlabs.com/pubkey.gpg' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          release    => 'precise',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_source  => 'http://apt.puppetlabs.com/pubkey.gpg',
-        }
-        EOS
-
-        shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list.d/puppetlabs.list') do
-        it { should be_file }
-        it { should contain 'deb http://apt.puppetlabs.com precise main' }
-      end
-      describe 'keys should exist' do
-        it 'finds puppetlabs key' do
-          shell('apt-key list | grep 4BD6EC30')
-        end
-      end
-    end
-  end
-
-  context 'pin' do
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-          pin        => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/puppetlabs.pref') do
-        it { should_not be_file }
-      end
-    end
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include '::apt'
-        apt::source { 'puppetlabs':
-          ensure     => present,
-          location   => 'http://apt.puppetlabs.com',
-          repos      => 'main',
-          key        => '4BD6EC30',
-          key_server => 'pgp.mit.edu',
-          pin        => true,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/puppetlabs.pref') do
-        it { should be_file }
-      end
-    end
-  end
-
-end
diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb
index 97f00f1681..3c97421ab0 100644
--- a/spec/acceptance/apt_spec.rb
+++ b/spec/acceptance/apt_spec.rb
@@ -1,6 +1,6 @@
 require 'spec_helper_acceptance'
 
-describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+describe 'apt class' do
 
   context 'reset' do
     it 'fixes the sources.list' do
@@ -8,294 +8,37 @@
     end
   end
 
-  context 'always_apt_update => true' do
+  context 'all the things' do
     it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': always_apt_update => true }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/Exec\[apt_update\]/)
-      end
-    end
-  end
-  context 'always_apt_update => false' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': always_apt_update => false }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to_not match(/Exec\[apt_update\]/)
-      end
-    end
-  end
-
-  # disable_keys drops in a 99unauth file to ignore keys in
-  # other files.
-  context 'disable_keys => true' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': disable_keys => true }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/99unauth') do
-      it { should be_file }
-      it { should contain 'APT::Get::AllowUnauthenticated 1;' }
-    end
-  end
-  context 'disable_keys => false' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': disable_keys => false }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/99unauth') do
-      it { should_not be_file }
-    end
-  end
-
-  # proxy_host sets the proxy to use for transfers.
-  # proxy_port sets the proxy port to use.
-  context 'proxy settings' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': 
-        proxy_host => 'localhost',
-        proxy_port => '7042',
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/01proxy') do
-      it { should be_file }
-      it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' }
-    end
-    describe file('/etc/apt/apt.conf.d/proxy') do
-      it { should_not be_file }
-    end
-  end
-
-  context 'purge_sources' do
-    it 'creates a fake apt file' do
-      shell('touch /etc/apt/sources.list.d/fake.list')
-      shell('echo "deb fake" >> /etc/apt/sources.list')
-    end
-    it 'purge_sources_list and purge_sources_list_d => true' do
       pp = <<-EOS
       class { 'apt':
+        always_apt_update    => true,
+        disable_keys         => true,
         purge_sources_list   => true,
         purge_sources_list_d => true,
+        purge_preferences    => true,
+        purge_preferences_d  => true,
+        update_timeout       => '400',
+        update_tries         => '3',
+        sources              => {
+          'puppetlabs' => {
+            'ensure'     => present,
+            'location'   => 'http://apt.puppetlabs.com',
+            'repos'      => 'main',
+            'key'        => '4BD6EC30',
+            'key_server' => 'pgp.mit.edu',
+          }
+        },
+        fancy_progress       => true,
       }
       EOS
 
       apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/sources.list') do
-      it { should_not contain 'deb fake' }
-    end
-
-    describe file('/etc/apt/sources.list.d/fake.list') do
-      it { should_not be_file }
-    end
-  end
-  context 'proxy settings' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': 
-        proxy_host => 'localhost',
-        proxy_port => '7042',
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/01proxy') do
-      it { should be_file }
-      it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' }
-    end
-    describe file('/etc/apt/apt.conf.d/proxy') do
-      it { should_not be_file }
-    end
-  end
-
-  context 'purge_sources' do
-    context 'false' do
-      it 'creates a fake apt file' do
-        shell('touch /etc/apt/sources.list.d/fake.list')
-        shell('echo "deb fake" >> /etc/apt/sources.list')
-      end
-      it 'purge_sources_list and purge_sources_list_d => false' do
-        pp = <<-EOS
-        class { 'apt':
-          purge_sources_list   => false,
-          purge_sources_list_d => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => false)
-      end
-
-      describe file('/etc/apt/sources.list') do
-        it { should contain 'deb fake' }
-      end
-
-      describe file('/etc/apt/sources.list.d/fake.list') do
-        it { should be_file }
-      end
-    end
-
-    context 'true' do
-      it 'creates a fake apt file' do
-        shell('touch /etc/apt/sources.list.d/fake.list')
-        shell('echo "deb fake" >> /etc/apt/sources.list')
-      end
-      it 'purge_sources_list and purge_sources_list_d => true' do
-        pp = <<-EOS
-        class { 'apt':
-          purge_sources_list   => true,
-          purge_sources_list_d => true,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/sources.list') do
-        it { should_not contain 'deb fake' }
-      end
-
-      describe file('/etc/apt/sources.list.d/fake.list') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'purge_preferences' do
-    context 'false' do
-      it 'creates a preferences file' do
-        shell("echo 'original' > /etc/apt/preferences")
-      end
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': purge_preferences => false }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences') do
-        it { should be_file }
-        it 'is not managed by Puppet' do
-          shell("grep 'original' /etc/apt/preferences", {:acceptable_exit_codes => 0})
-        end
-      end
-    end
-
-    context 'true' do
-      it 'creates a preferences file' do
-        shell('touch /etc/apt/preferences')
-      end
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': purge_preferences => true }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'purge_preferences_d' do
-    context 'false' do
-      it 'creates a preferences file' do
-        shell('touch /etc/apt/preferences.d/test')
-      end
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': purge_preferences_d => false }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/test') do
-        it { should be_file }
-      end
-    end
-    context 'true' do
-      it 'creates a preferences file' do
-        shell('touch /etc/apt/preferences.d/test')
-      end
-
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': purge_preferences_d => true }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/test') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'update_timeout' do
-    context '5000' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        class { 'apt': update_timeout => '5000' }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-    end
-  end
-
-  context 'fancy_progress => true' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': fancy_progress => true }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/99progressbar') do
-      it { should be_file }
-      it { should contain 'Dpkg::Progress-Fancy "1";' }
-    end
-  end
-  context 'fancy_progress => false' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt': fancy_progress => false }
-      EOS
-
       apply_manifest(pp, :catch_failures => true)
     end
-
-    describe file('/etc/apt/apt.conf.d/99progressbar') do
-      it { should_not be_file }
+    it 'should still work' do
+      shell('apt-get update')
+      shell('apt-get -y upgrade')
     end
   end
 
diff --git a/spec/acceptance/backports_spec.rb b/spec/acceptance/backports_spec.rb
deleted file mode 100644
index 78f21fd588..0000000000
--- a/spec/acceptance/backports_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-require 'spec_helper_acceptance'
-
-codename = fact('lsbdistcodename')
-case fact('operatingsystem')
-when 'Ubuntu'
-  repos = 'main universe multiverse restricted'
-when 'Debian'
-  repos = 'main contrib non-free'
-end
-
-describe 'apt::backports class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt::backports': }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-  end
-
-  context 'release' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt::backports': release => '#{codename}' }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/sources.list.d/backports.list') do
-      it { should be_file }
-      it { should contain "#{codename}-backports #{repos}" }
-    end
-  end
-
-  context 'location' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt::backports': release => 'precise', location => 'http://localhost/ubuntu' }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/sources.list.d/backports.list') do
-      it { should be_file }
-      it { should contain "deb http://localhost/ubuntu precise-backports #{repos}" }
-    end
-  end
-
-  context 'pin_priority' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      class { 'apt::backports': pin_priority => 500, }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-    describe file('/etc/apt/preferences.d/backports.pref') do
-      it { should be_file }
-      it { should contain "Pin-Priority: 500" }
-    end
-  end
-
-  context 'reset' do
-    it 'deletes backport files' do
-      shell('rm -rf /etc/apt/sources.list.d/backports.list')
-      shell('rm -rf /etc/apt/preferences.d/backports.pref')
-    end
-  end
-
-end
diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb
index e5994498b9..f228e4c456 100644
--- a/spec/acceptance/class_spec.rb
+++ b/spec/acceptance/class_spec.rb
@@ -1,6 +1,6 @@
 require 'spec_helper_acceptance'
 
-describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+describe 'apt class' do
 
   context 'default parameters' do
     # Using puppet_apply as a helper
diff --git a/spec/acceptance/conf_spec.rb b/spec/acceptance/conf_spec.rb
deleted file mode 100644
index 8a8ed63db4..0000000000
--- a/spec/acceptance/conf_spec.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::conf define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      apt::conf { 'test':
-        content => 'test',
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50test') do
-      it { should be_file }
-      it { should contain 'test' }
-    end
-  end
-
-  context 'ensure' do
-    context 'absent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        apt::conf { 'test':
-          ensure  => absent,
-          content => 'test',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50test') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'priority' do
-    context '99' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        apt::conf { 'test':
-          ensure   => present,
-          content  => 'test',
-          priority => '99',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/99test') do
-        it { should be_file }
-        it { should contain 'test' }
-      end
-    end
-  end
-
-  context 'cleanup' do
-    it 'deletes 99test' do
-      shell ('rm -rf /etc/apt/apt.conf.d/99test')
-    end
-  end
-end
diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb
deleted file mode 100644
index 5f4dec3fc7..0000000000
--- a/spec/acceptance/force_spec.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require 'spec_helper_acceptance'
-
-codename = fact('lsbdistcodename')
-
-describe 'apt::force define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::force { 'vim': }
-      EOS
-
-      shell('apt-get remove -y vim')
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe package('vim') do
-      it { should be_installed }
-    end
-  end
-
-  context 'release' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::force { 'vim': release => '#{codename}' }
-      EOS
-
-      shell('apt-get remove -y vim')
-      apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/)
-      end
-    end
-
-    describe package('vim') do
-      it { should be_installed }
-    end
-  end
-
-  context 'version' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::force { 'vim': version => '1.1.1' }
-      EOS
-
-      shell('apt-get remove -y vim')
-      apply_manifest(pp, :catch_failures => false) do |r|
-        expect(r.stdout).to match(/apt-get -y  install vim=1.1.1/)
-      end
-    end
-
-    describe package('vim') do
-      it { should_not be_installed }
-    end
-  end
-
-  context 'timeout' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::force { 'ocaml': timeout => '1' }
-      EOS
-
-      shell('apt-get clean')
-      apply_manifest(pp, :expect_failures => true) do |r|
-        expect(r.stderr).to match(/Error: Command exceeded timeout/)
-      end
-    end
-
-    describe package('ocaml') do
-      it { should_not be_installed }
-    end
-  end
-
-end
diff --git a/spec/acceptance/pin_spec.rb b/spec/acceptance/pin_spec.rb
deleted file mode 100644
index 07fc607302..0000000000
--- a/spec/acceptance/pin_spec.rb
+++ /dev/null
@@ -1,286 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::pin define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      apt::pin { 'vim-puppet': }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-      it { should be_file }
-      it { should contain 'Pin: release a=vim-puppet' }
-    end
-  end
-
-  context 'ensure' do
-    context 'present' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet': ensure => present }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release a=vim-puppet' }
-      end
-    end
-
-    context 'absent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet': ensure => absent }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should_not be_file }
-      end
-    end
-  end
-
-  context 'order' do
-    context '99' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure => present,
-          order  => '99',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/99-vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release a=vim-puppet' }
-      end
-    end
-  end
-
-  context 'packages' do
-    context 'test' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure   => present,
-          packages => 'test',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Package: test' }
-        it { should contain 'Pin: release a=vim-puppet' }
-      end
-    end
-
-    context 'array' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'array':
-          ensure   => present,
-          packages => ['apache', 'ntop'],
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/array.pref') do
-        it { should be_file }
-        it { should contain 'Package: apache ntop' }
-        it { should contain 'Pin: release a=array' }
-      end
-    end
-  end
-
-  context 'release' do
-    context 'testrelease' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure  => present,
-          release => 'testrelease',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release a=testrelease' }
-      end
-    end
-  end
-
-  context 'origin' do
-    context 'testrelease' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure  => present,
-          origin  => 'testrelease',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: origin testrelease' }
-      end
-    end
-  end
-
-  context 'version' do
-    context '1.0.0' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure   => present,
-          packages => 'test',
-          version  => '1.0.0',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Package: test' }
-        it { should contain 'Pin: version 1.0.0' }
-      end
-    end
-  end
-
-  context 'codename' do
-    context 'testname' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure   => present,
-          codename => 'testname',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release n=testname' }
-      end
-    end
-  end
-
-  context 'release_version' do
-    context '1.1.1' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure          => present,
-          release_version => '1.1.1',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release v=1.1.1' }
-      end
-    end
-  end
-
-  context 'component' do
-    context 'testcomponent' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure    => present,
-          component => 'testcomponent',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release c=testcomponent' }
-      end
-    end
-  end
-
-  context 'originator' do
-    context 'testorigin' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure     => present,
-          originator => 'testorigin',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release o=testorigin' }
-      end
-    end
-  end
-
-  context 'label' do
-    context 'testlabel' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        apt::pin { 'vim-puppet':
-          ensure => present,
-          label  => 'testlabel',
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/preferences.d/vim-puppet.pref') do
-        it { should be_file }
-        it { should contain 'Pin: release l=testlabel' }
-      end
-    end
-  end
-
-end
diff --git a/spec/acceptance/release_spec.rb b/spec/acceptance/release_spec.rb
deleted file mode 100644
index e7467bf62d..0000000000
--- a/spec/acceptance/release_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::release class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'release_id' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::release': release_id => 'precise', }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/01release') do
-      it { should be_file }
-      it { should contain 'APT::Default-Release "precise";' }
-    end
-  end
-
-  context 'reset' do
-    it 'cleans up' do
-      shell('rm -rf /etc/apt/apt.conf.d/01release')
-    end
-  end
-
-end
diff --git a/spec/acceptance/unattended_upgrade_spec.rb b/spec/acceptance/unattended_upgrade_spec.rb
deleted file mode 100644
index 02ebea4ec9..0000000000
--- a/spec/acceptance/unattended_upgrade_spec.rb
+++ /dev/null
@@ -1,566 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'apt::unattended_upgrades class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  context 'defaults' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      include apt::unattended_upgrades
-      EOS
-
-      if fact('operatingsystem') == 'Debian'
-        # Attempted workaround for problems seen on debian with
-        # something holding the package database open.
-        shell('killall -9 apt-get', { :acceptable_exit_codes => [0,1] })
-        shell('killall -9 dpkg', { :acceptable_exit_codes => [0,1] })
-        shell('dpkg --configure -a')
-      end
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-    end
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-    end
-  end
-
-  context 'origins' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        origins => ['${distro_id}:${distro_codename}-test'],
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-      it { should contain '${distro_id}:${distro_codename}-test' }
-    end
-  end
-
-  context 'blacklist' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        blacklist => ['puppet']
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-      it { should contain 'puppet' }
-    end
-  end
-
-  context 'update' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        update => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Update-Package-Lists "99";' }
-    end
-  end
-
-  context 'download' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        download => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Download-Upgradeable-Packages "99";' }
-    end
-  end
-
-  context 'upgrade' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        upgrade => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Unattended-Upgrade "99";' }
-    end
-  end
-
-  context 'autoclean' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        autoclean => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::AutocleanInterval "99";' }
-    end
-  end
-
-  context 'auto_fix' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          auto_fix => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          auto_fix => false
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "false";' }
-      end
-    end
-  end
-
-  context 'minimal_steps' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          minimal_steps => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::MinimalSteps "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          minimal_steps => false
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::MinimalSteps "false";' }
-      end
-    end
-  end
-
-  context 'install_on_shutdown' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          install_on_shutdown => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::InstallOnShutdown "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          install_on_shutdown => false
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::InstallOnShutdown "false";' }
-      end
-    end
-  end
-
-  context 'mail_to' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        mail_to => 'test@example.com'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-      it { should contain 'Unattended-Upgrade::Mail "test@example.com";' }
-    end
-  end
-
-  context 'mail_only_on_error' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          mail_to            => 'test@example.com',
-          mail_only_on_error => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::MailOnlyOnError "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          mail_to            => 'test@example.com',
-          mail_only_on_error => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::MailOnlyOnError "false";' }
-      end
-    end
-
-    context 'mail_to missing' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          mail_only_on_error => true,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should_not contain 'Unattended-Upgrade::MailOnlyOnError "true";' }
-      end
-    end
-  end
-
-  context 'remove_unused' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          remove_unused => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          remove_unused => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "false";' }
-      end
-    end
-  end
-
-  context 'auto_reboot' do
-    context 'true' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          auto_reboot => true
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::Automatic-Reboot "true";' }
-      end
-    end
-
-    context 'false' do
-      it 'should work with no errors' do
-        pp = <<-EOS
-        include apt
-        class { 'apt::unattended_upgrades':
-          auto_reboot => false,
-        }
-        EOS
-
-        apply_manifest(pp, :catch_failures => true)
-      end
-
-      describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-        it { should be_file }
-        it { should contain 'Unattended-Upgrade::Automatic-Reboot "false";' }
-      end
-    end
-  end
-
-  context 'dl_limit' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        dl_limit => '99'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
-      it { should be_file }
-      it { should contain 'Acquire::http::Dl-Limit "99"' }
-    end
-  end
-
-  context 'enable' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        enable => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Enable "2"' }
-    end
-  end
-
-  context 'backup_interval' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        backup_interval => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::BackUpArchiveInterval "2";' }
-    end
-  end
-
-  context 'backup_level' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        backup_level => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::BackUpLevel "2";' }
-    end
-  end
-
-  context 'max_age' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        max_age => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::MaxAge "2";' }
-    end
-  end
-
-  context 'min_age' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        min_age => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::MinAge "2";' }
-    end
-  end
-
-  context 'max_size' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        max_size => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::MaxSize "2";' }
-    end
-  end
-
-  context 'download_delta' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        download_delta => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";' }
-    end
-  end
-
-  context 'verbose' do
-    it 'should work with no errors' do
-      pp = <<-EOS
-      include apt
-      class { 'apt::unattended_upgrades':
-        verbose => '2'
-      }
-      EOS
-
-      apply_manifest(pp, :catch_failures => true)
-    end
-
-    describe file('/etc/apt/apt.conf.d/10periodic') do
-      it { should be_file }
-      it { should contain 'APT::Periodic::Verbose "2";' }
-    end
-  end
-
-end
diff --git a/spec/acceptance/unsupported_spec.rb b/spec/acceptance/unsupported_spec.rb
deleted file mode 100644
index 3f7468530b..0000000000
--- a/spec/acceptance/unsupported_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require 'spec_helper_acceptance'
-
-describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
-  it 'class apt fails' do
-    pp = <<-EOS
-      class { 'apt': }
-    EOS
-    expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/This module only works on Debian or derivatives like Ubuntu/i)
-  end
-end

From 5d7982dba0e6c5f31f320ebc2466a1811d283d51 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Thu, 31 Jul 2014 18:11:57 -0400
Subject: [PATCH 345/574] Cleaned up unit tests.

---
 manifests/pin.pp                         |  14 +-
 manifests/ppa.pp                         |   3 -
 manifests/unattended_upgrades.pp         |  15 +-
 spec/classes/apt_spec.rb                 | 389 ++++++++++++++---------
 spec/classes/init_spec.rb                |  69 ----
 spec/classes/unattended_upgrades_spec.rb | 379 ++++++++--------------
 spec/defines/builddep_spec.rb            |   8 +-
 spec/defines/conf_spec.rb                |   6 -
 spec/defines/force_spec.rb               |   8 +-
 spec/defines/hold_spec.rb                |  33 +-
 spec/defines/key_spec.rb                 | 389 +++++++++--------------
 spec/defines/pin_spec.rb                 | 247 ++++++++------
 spec/defines/ppa_spec.rb                 | 287 +++++++++--------
 spec/defines/source_spec.rb              | 256 ++++++---------
 14 files changed, 950 insertions(+), 1153 deletions(-)
 delete mode 100644 spec/classes/init_spec.rb

diff --git a/manifests/pin.pp b/manifests/pin.pp
index 2ce81fd6bb..54961ec8dd 100644
--- a/manifests/pin.pp
+++ b/manifests/pin.pp
@@ -16,7 +16,6 @@
   $originator      = '', # o=
   $label           = ''  # l=
 ) {
-
   include apt::params
 
   $preferences_d = $apt::params::preferences_d
@@ -35,7 +34,7 @@
   $pin_release = join($pin_release_array, '')
 
   # Read the manpage 'apt_preferences(5)', especially the chapter
-  # 'Thea Effect of APT Preferences' to understand the following logic
+  # 'The Effect of APT Preferences' to understand the following logic
   # and the difference between specific and general form
   if is_array($packages) {
     $packages_string = join($packages, ' ')
@@ -44,24 +43,17 @@
   }
 
   if $packages_string != '*' { # specific form
-
     if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
-      ( $origin != '' and ( $pin_release != '' or $version != '' )) or
       ( $version != '' and ( $pin_release != '' or $origin != '' )) {
       fail('parameters release, origin, and version are mutually exclusive')
     }
-
   } else { # general form
-
     if $version != '' {
       fail('parameter version cannot be used in general form')
     }
-
-    if ( $pin_release != '' and $origin != '' ) or
-      ( $origin != '' and $pin_release != '' ) {
-      fail('parmeters release and origin are mutually exclusive')
+    if ( $pin_release != '' and $origin != '' ) {
+      fail('parameters release and origin are mutually exclusive')
     }
-
   }
 
 
diff --git a/manifests/ppa.pp b/manifests/ppa.pp
index 27edff80b2..5f5c6ae574 100644
--- a/manifests/ppa.pp
+++ b/manifests/ppa.pp
@@ -69,9 +69,6 @@
 
     file { "${sources_list_d}/${sources_list_d_filename}":
         ensure => 'absent',
-        mode   => '0644',
-        owner  => 'root',
-        group  => 'root',
         notify => Exec['apt_update'],
     }
   }
diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp
index 7e3ccc44b0..2f75d5dd19 100644
--- a/manifests/unattended_upgrades.pp
+++ b/manifests/unattended_upgrades.pp
@@ -52,18 +52,21 @@
     ensure => present,
   }
 
-  File {
+  file { '/etc/apt/apt.conf.d/50unattended-upgrades':
     ensure  => file,
     owner   => 'root',
     group   => 'root',
     mode    => '0644',
+    content => template('apt/50unattended-upgrades.erb'),
     require => Package['unattended-upgrades'],
   }
 
-  file {
-    '/etc/apt/apt.conf.d/50unattended-upgrades':
-      content => template('apt/50unattended-upgrades.erb');
-    '/etc/apt/apt.conf.d/10periodic':
-      content => template('apt/10periodic.erb');
+  file { '/etc/apt/apt.conf.d/10periodic':
+    ensure  => file,
+    owner   => 'root',
+    group   => 'root',
+    mode    => '0644',
+    content => template('apt/10periodic.erb'),
+    require => Package['unattended-upgrades'],
   }
 }
diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb
index a21e0443e2..2c70e3e090 100644
--- a/spec/classes/apt_spec.rb
+++ b/spec/classes/apt_spec.rb
@@ -1,170 +1,257 @@
 require 'spec_helper'
 describe 'apt', :type => :class do
   let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
-  let :default_params do
-    {
-      :disable_keys => :undef,
-      :always_apt_update => false,
-      :purge_sources_list => false,
-      :purge_sources_list_d => false,
-    }
+
+  context 'defaults' do
+    it { should contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/sources.list',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+      'notify' => 'Exec[apt_update]',
+    })}
+
+    it { should contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
+      'ensure'  => 'directory',
+      'path'    => '/etc/apt/sources.list.d',
+      'owner'   => 'root',
+      'group'   => 'root',
+      'purge'   => false,
+      'recurse' => false,
+      'notify'  => 'Exec[apt_update]',
+    })}
+
+    it { should contain_file('preferences.d').only_with({
+      'ensure'  => 'directory',
+      'path'    => '/etc/apt/preferences.d',
+      'owner'   => 'root',
+      'group'   => 'root',
+      'purge'   => false,
+      '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 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',
+    })}
   end
 
-  [{},
-    {
-      :disable_keys => true,
-      :always_apt_update => true,
-      :proxy_host => true,
-      :proxy_port => '3128',
-      :purge_sources_list => true,
-      :purge_sources_list_d => true,
-    },
-    {
-      :purge_preferences   => true,
-      :purge_preferences_d => true,
-    },
-    {
-      :disable_keys => false
-    }
-  ].each do |param_set|
-    describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
-      let :param_hash do
-        default_params.merge(param_set)
-      end
+  context 'lots of non-defaults' 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
 
-      let :params do
-        param_set
-      end
+    it { should contain_file('sources.list').with({
+      'content' => "# Repos managed by puppet.\n"
+    })}
 
-      let :refresh_only_apt_update do
-        if param_hash[:always_apt_update]
-          false
-        else
-          true
-        end
-      end
+    it { should contain_file('sources.list.d').with({
+      'purge'   => 'true',
+      'recurse' => 'true',
+    })}
+
+    it { should contain_file('apt-preferences').only_with({
+      'ensure' => 'absent',
+      'path'   => '/etc/apt/preferences',
+    })}
+
+    it { should contain_file('preferences.d').with({
+      'purge'   => 'true',
+      'recurse' => 'true',
+    })}
 
-      it { should contain_class("apt::params") }
-
-      it {
-        if param_hash[:purge_sources_list]
-        should contain_file("sources.list").with({
-            'path'    => "/etc/apt/sources.list",
-            'ensure'  => "present",
-            'owner'   => "root",
-            'group'   => "root",
-            'mode'    => "0644",
-            "content" => "# Repos managed by puppet.\n"
-          })
-        else
-        should contain_file("sources.list").with({
-            'path'    => "/etc/apt/sources.list",
-            'ensure'  => "present",
-            'owner'   => "root",
-            'group'   => "root",
-            'mode'    => "0644",
-            'content' => nil
-          })
-        end
+    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;\n",
+      '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\";\n",
+      'notify'  => 'Exec[apt_update]',
+      'mode'    => '0644',
+      'owner'   => 'root',
+      'group'   => 'root'
+    })}
+
+    it { should contain_exec('apt_update').with({
+      'refreshonly' => 'false',
+      'timeout'     => '1',
+      'tries'       => '3',
+    })}
+
+  end
+
+  context 'more non-default' do
+    let :params do
+      {
+        :fancy_progress => false,
+        :disable_keys   => false,
       }
-      it {
-        if param_hash[:purge_sources_list_d]
-          should create_file("sources.list.d").with({
-            'path'    => "/etc/apt/sources.list.d",
-            'ensure'  => "directory",
-            'owner'   => "root",
-            'group'   => "root",
-            'purge'   => true,
-            'recurse' => true,
-            'notify'  => 'Exec[apt_update]'
-          })
-        else
-          should create_file("sources.list.d").with({
-            'path'    => "/etc/apt/sources.list.d",
-            'ensure'  => "directory",
-            'owner'   => "root",
-            'group'   => "root",
-            'purge'   => false,
-            'recurse' => false,
-            'notify'  => 'Exec[apt_update]'
-          })
-        end
+    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',
+        :lsbdistcodename => 'precise',
+        :lsbdistid       => 'Debian',
       }
-      it {
-        if param_hash[:purge_preferences]
-          should create_file('apt-preferences').with({
-            :ensure  => 'absent',
-            :path    => '/etc/apt/preferences',
-          })
-        else
-          should_not contain_file('apt-preferences')
-        end
+    end
+    let(:params) { { :sources => {
+      'debian_unstable' => {
+        'location'          => 'http://debian.mirror.iweb.ca/debian/',
+        'release'           => 'unstable',
+        'repos'             => 'main contrib non-free',
+        'required_packages' => 'debian-keyring debian-archive-keyring',
+        'key'               => '55BE302B',
+        'key_server'        => 'subkeys.pgp.net',
+        'pin'               => '-10',
+        'include_src'       => true
+      },
+      'puppetlabs' => {
+        'location'   => 'http://apt.puppetlabs.com',
+        'repos'      => 'main',
+        'key'        => '4BD6EC30',
+        'key_server' => 'pgp.mit.edu',
       }
+    } } }
 
-      it {
-        if param_hash[:purge_preferences_d]
-          should create_file("preferences.d").with({
-            'path'    => "/etc/apt/preferences.d",
-            'ensure'  => "directory",
-            'owner'   => "root",
-            'group'   => "root",
-            'purge'   => true,
-            'recurse' => true,
-          })
-        else
-          should create_file("preferences.d").with({
-            'path'    => "/etc/apt/preferences.d",
-            'ensure'  => "directory",
-            'owner'   => "root",
-            'group'   => "root",
-            'purge'   => false,
-            'recurse' => false,
-          })
-        end
-      }
+    it {
+      should contain_file('debian_unstable.list').with({
+        'ensure'  => 'present',
+        'path'    => '/etc/apt/sources.list.d/debian_unstable.list',
+        'owner'   => 'root',
+        'group'   => 'root',
+        'mode'    => '0644',
+        'notify'  => 'Exec[apt_update]',
+      })
+    }
 
-      it {
-        should contain_exec("apt_update").with({
-          'command'     => "/usr/bin/apt-get update",
-          'refreshonly' => refresh_only_apt_update
-        })
-      }
+    it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
+    it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
 
-      it {
-        if param_hash[:disable_keys] == true
-          should create_file("99unauth").with({
-            'content' => "APT::Get::AllowUnauthenticated 1;\n",
-            'ensure'  => "present",
-            'path'    => "/etc/apt/apt.conf.d/99unauth"
-          })
-        elsif param_hash[:disable_keys] == false
-          should create_file("99unauth").with({
-            'ensure' => "absent",
-            'path'   => "/etc/apt/apt.conf.d/99unauth"
-          })
-        elsif param_hash[:disable_keys] != :undef
-          should_not create_file("99unauth").with({
-            'path'   => "/etc/apt/apt.conf.d/99unauth"
-          })
-        end
-      }
-      describe 'when setting a proxy' do
-        it {
-          if param_hash[:proxy_host]
-            should contain_file('01proxy').with(
-              'path'    => '/etc/apt/apt.conf.d/01proxy',
-              'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";\n",
-              'notify'  => "Exec[apt_update]"
-            )
-          else
-            should contain_file('01proxy').with(
-              'path'    => '/etc/apt/apt.conf.d/01proxy',
-              'notify'  => 'Exec[apt_update]',
-              'ensure'  => 'absent'
-            )
-          end
+    it {
+      should contain_file('puppetlabs.list').with({
+        'ensure'  => 'present',
+        'path'    => '/etc/apt/sources.list.d/puppetlabs.list',
+        'owner'   => 'root',
+        'group'   => 'root',
+        'mode'    => '0644',
+        'notify'  => 'Exec[apt_update]',
+      })
+    }
+
+    it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
+    it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
+  end
+
+  describe 'failing tests' do
+    context 'bad purge_sources_list' do
+      let :params do
+        {
+          'purge_sources_list' => 'foo'
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error)
+      end
+    end
+
+    context 'bad purge_sources_list_d' do
+      let :params do
+        {
+          'purge_sources_list_d' => 'foo'
         }
       end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error)
+      end
+    end
+
+    context 'bad purge_preferences' do
+      let :params do
+        {
+          'purge_preferences' => 'foo'
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error)
+      end
+    end
+
+    context 'bad purge_preferences_d' do
+      let :params do
+        {
+          'purge_preferences_d' => 'foo'
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error)
+      end
+    end
+
+    context 'with unsupported osfamily' do
+      let :facts do
+        { :osfamily => 'Darwin', }
+      end
+
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
+      end
     end
   end
 end
diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb
deleted file mode 100644
index c5e938a9aa..0000000000
--- a/spec/classes/init_spec.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-require 'spec_helper'
-describe 'apt' do
-  context 'with sources defined on valid osfamily' do
-    let :facts do
-      { :osfamily        => 'Debian',
-        :lsbdistcodename => 'precise',
-        :lsbdistid       => 'Debian',
-      }
-    end
-    let(:params) { { :sources => {
-      'debian_unstable' => {
-        'location'          => 'http://debian.mirror.iweb.ca/debian/',
-        'release'           => 'unstable',
-        'repos'             => 'main contrib non-free',
-        'required_packages' => 'debian-keyring debian-archive-keyring',
-        'key'               => '55BE302B',
-        'key_server'        => 'subkeys.pgp.net',
-        'pin'               => '-10',
-        'include_src'       => true
-      },
-      'puppetlabs' => {
-        'location'   => 'http://apt.puppetlabs.com',
-        'repos'      => 'main',
-        'key'        => '4BD6EC30',
-        'key_server' => 'pgp.mit.edu',
-      }
-    } } }
-
-    it {
-      should contain_file('debian_unstable.list').with({
-        'ensure'  => 'present',
-        'path'    => '/etc/apt/sources.list.d/debian_unstable.list',
-        'owner'   => 'root',
-        'group'   => 'root',
-        'mode'    => '0644',
-        'notify'  => 'Exec[apt_update]',
-      })
-    }
-
-    it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
-    it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
-
-    it {
-      should contain_file('puppetlabs.list').with({
-        'ensure'  => 'present',
-        'path'    => '/etc/apt/sources.list.d/puppetlabs.list',
-        'owner'   => 'root',
-        'group'   => 'root',
-        'mode'    => '0644',
-        'notify'  => 'Exec[apt_update]',
-      })
-    }
-
-    it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
-    it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
-  end
-
-  context 'with unsupported osfamily' do
-    let :facts do
-      { :osfamily        => 'Darwin', }
-    end
-
-    it do
-      expect {
-       should compile
-      }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
-    end
-  end
-end
diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb
index 8494f0410d..291719b009 100644
--- a/spec/classes/unattended_upgrades_spec.rb
+++ b/spec/classes/unattended_upgrades_spec.rb
@@ -24,270 +24,165 @@
     })
   }
 
-  describe "origins" do
-    describe 'on Debian' do
-      default_facts = { :lsbdistid => 'Debian' }
-      context 'defaults' do
-        let :facts do default_facts end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Origins-Pattern/
-          ).with_content(
-            /"origin=Debian,archive=stable,label=Debian-Security";/
-          )
-        }
-      end
-      context 'defaults with custom origin' do
-        let :facts do default_facts end
-        let :params do { :origins => ['bananana']} end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Origins-Pattern/
-          ).with_content(
-            /"bananana";/
-          )
-        }
-      end
-      context 'defaults with invalid origin' do
-        let :facts do default_facts end
-        let :params do { :origins => 'bananana'} end
-        it {
-          expect {subject}.to raise_error(/is not an Array/)
-        }
-      end
-      context 'squeeze' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'squeeze'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id} \${distro_codename}-lts";/
-          ).with_content(
-            /"\${distro_id} \${distro_codename}-security";/
-          ).with_content(
-            /"\${distro_id} oldstable";/
-          )
-        }
-      end
-      context 'wheezy' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'wheezy'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Origins-Pattern/
-          ).with_content(
-            /"origin=Debian,archive=stable,label=Debian-Security";/
-          )
+  describe 'failing' do
+    let :facts do
+      {
+        'lsbdistid'       => 'debian',
+        'lsbdistcodename' => 'squeeze',
+      }
+    end
+    context 'bad auto_fix' do
+      let :params do
+        {
+          'auto_fix' => 'foo',
         }
       end
+      it { expect { should raise_error(Puppet::Error) } }
     end
 
-    describe 'on Ubuntu' do
-      default_facts = { :lsbdistid => 'Ubuntu' }
-      context 'default' do
-        let :facts do default_facts end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id}\:\${distro_codename}-security";/
-          )
-        }
-      end
-      context 'lucid' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'lucid'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id} \${distro_codename}-security";/
-          )
-        }
-      end
-      context 'precise' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'precise'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id}\:\${distro_codename}-security";/
-          )
-        }
-      end
-      context 'trusty' do
-        let :facts do default_facts.merge({:lsbdistcodename => 'trusty'}) end
-        it {
-          should contain_file(file_unattended).with_content(
-            /^Unattended-Upgrade::Allowed-Origins/
-          ).with_content(
-            /"\${distro_id}\:\${distro_codename}-security";/
-          )
+    context 'bad minimal_steps' do
+      let :params do
+        {
+          'minimal_steps' => 'foo',
         }
       end
-    end
-  end
-
-  describe "blacklist" do
-    describe "with param defaults" do
-      let(:params) {{ }}
-      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
+      it { expect { should raise_error(Puppet::Error) } }
     end
 
-    describe "with blacklist => []" do
+    context 'bad install_on_shutdown' do
       let :params do
-        { :blacklist => ['libc6', 'libc6-dev'] }
+        {
+          'install_on_shutdown' => 'foo',
+        }
       end
-      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) }
-    end
-  end
-
-  describe "with update => 2" do
-    let :params do
-      { :update => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) }
-  end
-
-  describe "with download => 2" do
-    let :params do
-      { :download => "2" }
+      it { expect { should raise_error(Puppet::Error) } }
     end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) }
-  end
 
-  describe "with upgrade => 2" do
-    let :params do
-      { :upgrade => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) }
-  end
-
-  describe "with autoclean => 2" do
-    let :params do
-      { :autoclean => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) }
-  end
-
-  describe "with auto_fix => false" do
-    let :params do
-      { :auto_fix => false }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) }
-  end
-
-  describe "with minimal_steps => true" do
-    let :params do
-      { :minimal_steps => true }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) }
-  end
-
-  describe "with install_on_shutdown => true" do
-    let :params do
-      { :install_on_shutdown => true }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
-  end
-
-  describe "mail_to" do
-    describe "param defaults" do
-      let(:params) {{ }}
-      it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) }
-      it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) }
-    end
-
-    describe "with mail_to => user@website, mail_only_on_error => true" do
+    context 'bad mail_only_on_error' do
       let :params do
-        { :mail_to => "user@website",
-          :mail_only_on_error => true }
+        {
+          'mail_only_on_error' => 'foo',
+        }
       end
-      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
-      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
-    end
-  end
-
-  describe "with remove_unused => false" do
-    let :params do
-      { :remove_unused => false }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) }
-  end
-
-  describe "with auto_reboot => true" do
-    let :params do
-      { :auto_reboot => true }
-    end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
-  end
-
-  describe "dl_limit" do
-    describe "param defaults" do
-      let(:params) {{ }}
-      it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) }
+      it { expect { should raise_error(Puppet::Error) } }
     end
 
-    describe "with dl_limit => 70" do
+    context 'bad remove_unused' do
       let :params do
-        { :dl_limit => "70" }
+        {
+          'remove_unused' => 'foo',
+        }
       end
-      it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
-    end
-  end
-
-  describe "with enable => 0" do
-    let :params do
-      { :enable => "0" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) }
-  end
-
-  describe "with backup_interval => 1" do
-    let :params do
-      { :backup_interval => "1" }
+      it { expect { should raise_error(Puppet::Error) } }
     end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) }
-  end
 
-  describe "with backup_level => 0" do
-    let :params do
-      { :backup_level => "0" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) }
-  end
-
-  describe "with max_age => 1" do
-    let :params do
-      { :max_age => "1" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) }
-  end
-
-  describe "with min_age => 1" do
-    let :params do
-      { :min_age => "1" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) }
-  end
-
-  describe "with max_size => 1" do
-    let :params do
-      { :max_size => "1" }
+    context 'bad auto_reboot' do
+      let :params do
+        {
+          'auto_reboot' => 'foo',
+        }
+      end
+      it { expect { should raise_error(Puppet::Error) } }
     end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) }
-  end
 
-  describe "with download_delta => 2" do
-    let :params do
-      { :download_delta => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) }
-  end
+    context 'bad origins' do
+      let :params do
+        {
+          'origins' => 'foo'
+        }
+      end
+      it { expect { should raise_error(Puppet::Error) } }
+    end
+
+  end
+
+  context 'defaults' do
+    let :facts do
+      {
+        'lsbdistid'       => 'debian',
+        'lsbdistcodename' => 'squeeze',
+      }
+    end
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id} oldstable";\n\t"\${distro_id} \${distro_codename}-security";\n\t"\${distro_id} \${distro_codename}-lts";\n\};} }
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "false";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "false";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "false";}}
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "3";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "7";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "0";}}
+  end
+
+  context 'anything but defaults' do
+    let :facts do
+      {
+        'lsbdistid'       => 'debian',
+        'lsbdistcodename' => 'wheezy',
+      }
+    end
+
+    let :params do
+      {
+        'enable'              => '0',
+        'backup_interval'     => '3',
+        'backup_level'        => '1',
+        'max_age'             => '7',
+        'min_age'             => '1',
+        'max_size'            => '100',
+        'update'              => '0',
+        'download'            => '0',
+        'download_delta'      => '1',
+        'upgrade'             => '0',
+        'autoclean'           => '0',
+        'verbose'             => '1',
+        'origins'             => ['bananas'],
+        'blacklist'           => ['foo', 'bar'],
+        'auto_fix'            => false,
+        'minimal_steps'       => true,
+        'install_on_shutdown' => true,
+        'mail_to'             => 'root@localhost',
+        'mail_only_on_error'  => true,
+        'remove_unused'       => false,
+        'auto_reboot'         => true,
+        'dl_limit'            => '70',
+      }
+    end
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"bananas";\n\};} }
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Package-Blacklist \{\n\t"foo";\n\t"bar";\n\};} }
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "false";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Mail "root@localhost";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MailOnlyOnError "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "false";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "true";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Acquire::http::Dl-Limit "70";}}
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "3";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "7";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "100";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "0";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "1";}}
 
-  describe "with verbose => 2" do
-    let :params do
-      { :verbose => "2" }
-    end
-    it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) }
   end
-
 end
diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb
index a0cbaa4cc0..88cdf4fb6e 100644
--- a/spec/defines/builddep_spec.rb
+++ b/spec/defines/builddep_spec.rb
@@ -4,10 +4,10 @@
   let(:facts) { { :lsbdistid => 'Debian' } }
   let(:title) { 'my_package' }
 
-  describe "should require apt-get update" do
-    it { should contain_exec("apt_update").with({
-        'command' => "/usr/bin/apt-get update",
-        'refreshonly' => true
+  describe "defaults" do
+    it { should contain_exec("apt-builddep-my_package").that_notifies('Exec[apt_update]').with({
+        'command' => "/usr/bin/apt-get -y --force-yes build-dep my_package",
+        'logoutput' => 'on_failure'
       })
     }
     it { should contain_anchor("apt::builddep::my_package").with({
diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb
index cda5900c03..ec4e229c44 100644
--- a/spec/defines/conf_spec.rb
+++ b/spec/defines/conf_spec.rb
@@ -17,12 +17,6 @@
       "/etc/apt/apt.conf.d/00norecommends"
     end
 
-    it { should contain_apt__conf('norecommends').with({
-         'priority' => '00',
-         'content'  => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
-      })
-    }
-
     it { should contain_file(filename).with({
           'ensure'    => 'present',
           'content'   => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n",
diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb
index 0d3d6e5940..a3a215c0ca 100644
--- a/spec/defines/force_spec.rb
+++ b/spec/defines/force_spec.rb
@@ -17,12 +17,10 @@
   end
 
   describe "when using default parameters" do
-    let :params do
-      default_params
-    end
     it { should contain_exec("/usr/bin/apt-get -y  install #{title}").with(
-      :unless  => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
-      :timeout => '300'
+      :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
+      :logoutput => 'on_failure',
+      :timeout   => '300'
     ) }
   end
 
diff --git a/spec/defines/hold_spec.rb b/spec/defines/hold_spec.rb
index 9da21d784a..60b991f194 100644
--- a/spec/defines/hold_spec.rb
+++ b/spec/defines/hold_spec.rb
@@ -1,9 +1,9 @@
 require 'spec_helper'
 describe 'apt::hold' do
   let :facts do {
-      :osfamily   => 'Debian',
-      :lsbdistid  => 'Debian',
-      :lsbrelease => 'wheezy',
+    :osfamily   => 'Debian',
+    :lsbdistid  => 'Debian',
+    :lsbrelease => 'wheezy',
   } end
 
   let :title do
@@ -18,13 +18,6 @@
     let :params do default_params end
 
     it 'creates an apt preferences file' do
-      should contain_apt__hold(title).with({
-        :ensure   => 'present',
-        :package  => title,
-        :version  => params[:version],
-        :priority => 1001,
-      })
-
       should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
         :packages => title,
@@ -38,9 +31,6 @@
     let :params do default_params.merge({:ensure => 'absent',}) end
 
     it 'creates an apt preferences file' do
-      should contain_apt__hold(title).with({
-        :ensure   => params[:ensure],
-      })
 
       should contain_apt__pin("hold_#{title}").with({
         :ensure   => params[:ensure],
@@ -52,22 +42,29 @@
     let :params do default_params.merge({:priority => 990,}) end
 
     it 'creates an apt preferences file' do
-      should contain_apt__hold(title).with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
-        :package  => title,
+        :packages => title,
         :version  => params[:version],
         :priority => params[:priority],
       })
+    end
+  end
 
-      should contain_apt__pin("hold_#{title}").with({
+  describe 'package => foo' do
+    let :params do default_params.merge({:package => 'foo'}) end
+
+    it 'creates an apt preferences file' do
+      should contain_apt__pin("hold_foo").with({
         :ensure   => 'present',
-        :packages => title,
+        :packages => 'foo',
         :version  => params[:version],
-        :priority => params[:priority],
+        :priority => 1001,
       })
     end
   end
 
+
   describe 'validation' do
     context 'version => {}' do
       let :params do { :version => {}, } end
diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb
index 005c95e469..dbb67c4c57 100644
--- a/spec/defines/key_spec.rb
+++ b/spec/defines/key_spec.rb
@@ -10,12 +10,6 @@
 
   describe 'normal operation' do
     describe 'default options' do
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key    => title,
-          :ensure => 'present',
-        })
-      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
           :id                => title,
@@ -40,12 +34,6 @@
         :key => GPG_KEY_ID,
       } end
 
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key    => GPG_KEY_ID,
-          :ensure => 'present',
-        })
-      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
           :id                => GPG_KEY_ID,
@@ -66,12 +54,6 @@
         :ensure => 'absent',
       } end
 
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key          => title,
-          :ensure       => 'absent',
-        })
-      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
           :id                => title,
@@ -87,26 +69,22 @@
       end
     end
 
-    describe 'key_content =>' do
+    describe 'set a bunch of things!' do
       let :params do {
         :key_content => 'GPG key content',
+        :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
+        :key_server => 'pgp.mit.edu',
+        :key_options => 'debug',
       } end
 
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key         => title,
-          :ensure      => 'present',
-          :key_content => params[:key_content],
-        })
-      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
           :id                => title,
           :ensure            => 'present',
-          :source            => nil,
-          :server            => nil,
+          :source            => 'http://apt.puppetlabs.com/pubkey.gpg',
+          :server            => 'pgp.mit.edu',
           :content           => params[:key_content],
-          :keyserver_options => nil,
+          :keyserver_options => 'debug',
         })
       end
       it 'contains the apt_key present anchor' do
@@ -114,217 +92,131 @@
       end
     end
 
-    describe 'key_source =>' do
-      let :params do {
-        :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
+    context "domain with dash" do
+      let(:params) do{
+        :key_server => 'p-gp.m-it.edu',
       } end
-
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key         => title,
-          :ensure      => 'present',
-          :key_source => params[:key_source],
+      it 'contains the apt_key' do
+        should contain_apt_key(title).with({
+          :id        => title,
+          :server => 'p-gp.m-it.edu',
         })
       end
+    end
+
+    context "url" do
+      let :params do
+        {
+          :key_server => 'hkp://pgp.mit.edu',
+        }
+      end
       it 'contains the apt_key' do
         should contain_apt_key(title).with({
-          :id                => title,
-          :ensure            => 'present',
-          :source            => params[:key_source],
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => nil,
+          :id        => title,
+          :server => 'hkp://pgp.mit.edu',
         })
       end
-      it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{title} present")
-      end
     end
-
-    describe 'key_server =>' do
-    	context 'domain name' do
-        let :params do {
-          :key_server => 'pgp.mit.edu',
-      	} end
-
-      	it 'contains the apt::key' do
-          should contain_apt__key(title).with({
-            :key         => title,
-            :ensure      => 'present',
-            :key_server  => 'pgp.mit.edu',
-          })
-      	end
-      	it 'contains the apt_key' do
-          should contain_apt_key(title).with({
-            :id                => title,
-            :ensure            => 'present',
-            :source            => nil,
-            :server            => params[:key_server],
-            :content           => nil,
-            :keyserver_options => nil,
-          })
-      	end
-      	it 'contains the apt_key present anchor' do
-          should contain_anchor("apt_key #{title} present")
-      	end
-			end
-
-      context "domain with dash" do
-        let(:params) do{
-          :key_server => 'p-gp.m-it.edu',
-        } end
-        it "should contain apt::key" do
-          should contain_apt__key(title).with({
-            :key        => title,
-            :ensure     => 'present',
-            :key_server => 'p-gp.m-it.edu',
-          })
-        end
+    context "url with port number" do
+      let :params do
+        {
+          :key_server => 'hkp://pgp.mit.edu:80',
+        }
       end
-
-      context "domain begin with dash" do
-        let(:params) do{
-          :key_server => '-pgp.mit.edu',
-        } end
-        it 'fails' do
-          expect { subject } .to raise_error(/does not match/)
-        end
+      it 'contains the apt_key' do
+        should contain_apt_key(title).with({
+          :id        => title,
+          :server => 'hkp://pgp.mit.edu:80',
+        })
       end
+    end
+  end
 
-      context "domain begin with dot" do
-        let(:params) do{
-          :key_server => '.pgp.mit.edu',
-        } end
-        it 'fails' do
-          expect { subject } .to raise_error(/does not match/)
-        end
+  describe 'validation' do
+    context "domain begin with dash" do
+      let(:params) do{
+        :key_server => '-pgp.mit.edu',
+      } end
+      it 'fails' do
+        expect { subject } .to raise_error(/does not match/)
       end
+    end
 
-      context "domain end with dot" do
-        let(:params) do{
-          :key_server => "pgp.mit.edu.",
-        } end
-        it 'fails' do
-          expect { subject } .to raise_error(/does not match/)
-        end
+    context "domain begin with dot" do
+      let(:params) do{
+        :key_server => '.pgp.mit.edu',
+      } end
+      it 'fails' do
+        expect { subject } .to raise_error(/does not match/)
       end
+    end
 
-      context "url" do
-        let (:params) do{
-          :key_server => 'hkp://pgp.mit.edu',
-        } end
-        it "should contain apt::key" do
-         should contain_apt__key(title).with({
-           :key         => title,
-           :ensure      => 'present',
-           :key_server  => 'hkp://pgp.mit.edu',
-         })
-        end
+    context "domain end with dot" do
+      let(:params) do{
+        :key_server => "pgp.mit.edu.",
+      } end
+      it 'fails' do
+        expect { subject } .to raise_error(/does not match/)
       end
-      context "url with port number" do
-        let (:params) do{
-          :key_server => 'hkp://pgp.mit.edu:80',
-        } end
-        it "should contain apt::key" do
-         should contain_apt__key(title).with({
-            :key        => title,
-            :ensure     => 'present',
-            :key_server => 'hkp://pgp.mit.edu:80',
-         })
-        end
+    end
+    context "exceed character url" do
+      let :params do
+        {
+          :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
+        }
       end
-
-      context "incorrect port number url" do
-        let (:params) do{
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
+      end
+    end
+    context "incorrect port number url" do
+      let :params do
+        {
           :key_server => 'hkp://pgp.mit.edu:8008080'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+        }
+      end
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
-      context "incorrect protocol for  url" do
-        let (:params) do{
+    end
+    context "incorrect protocol for  url" do
+      let :params do
+        {
           :key_server => 'abc://pgp.mit.edu:80'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+        }
       end
-      context "missing port number url" do
-        let (:params) do{
-          :key_server => 'hkp://pgp.mit.edu:'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
-      context "url ending with a dot" do
-        let (:params) do{
-          :key_server => 'hkp://pgp.mit.edu.'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+    end
+    context "missing port number url" do
+      let :params do
+        {
+          :key_server => 'hkp://pgp.mit.edu:'
+        }
       end
-      context "url begin with a dash" do
-        let(:params) do{
-          :key_server => "hkp://-pgp.mit.edu",
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
-      context "url with dash" do
-        let(:params) do{
-          :key_server => 'hkp://p-gp.m-it.edu',
-        } end
-        it "should contain apt::key" do
-          should contain_apt__key(title).with({
-            :key        => title,
-            :ensure     => 'present',
-            :key_server => 'hkp://p-gp.m-it.edu',
-          })
-        end
+    end
+    context "url ending with a dot" do
+      let :params do
+        {
+          :key_server => 'hkp://pgp.mit.edu.'
+        }
       end
-      context "exceed characher url" do
-        let (:params) do{
-          :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
-        } end
-        it 'fails' do
-          expect { subject }.to raise_error(/does not match/)
-        end
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
-		end
-
-    describe 'key_options =>' do
-      let :params do {
-        :key_options => 'debug',
+    end
+    context "url begin with a dash" do
+      let(:params) do{
+        :key_server => "hkp://-pgp.mit.edu",
       } end
-
-      it 'contains the apt::key' do
-        should contain_apt__key(title).with({
-          :key          => title,
-          :ensure       => 'present',
-          :key_options  => 'debug',
-        })
-      end
-      it 'contains the apt_key' do
-        should contain_apt_key(title).with({
-          :id                => title,
-          :ensure            => 'present',
-          :source            => nil,
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => params[:key_options],
-        })
-      end
-      it 'contains the apt_key present anchor' do
-        should contain_anchor("apt_key #{title} present")
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
     end
-  end
-
-  describe 'validation' do
     context 'invalid key' do
       let :title do
         'Out of rum. Why? Why are we out of rum?'
@@ -369,44 +261,55 @@
         expect { subject }.to raise_error(/is not a string/)
       end
     end
-  end
 
-  describe 'duplication' do
-    context 'two apt::key resources for same key, different titles' do
-      let :pre_condition do
-        "apt::key { 'duplicate': key => #{title}, }"
+    context 'invalid ensure' do
+      let :params do
+        {
+          :ensure => 'foo',
+        }
       end
-
-      it 'contains two apt::key resources' do
-        should contain_apt__key('duplicate').with({
-          :key    => title,
-          :ensure => 'present',
-        })
-        should contain_apt__key(title).with({
-          :key    => title,
-          :ensure => 'present',
-        })
-      end
-
-      it 'contains only a single apt_key' do
-        should contain_apt_key('duplicate').with({
-          :id                => title,
-          :ensure            => 'present',
-          :source            => nil,
-          :server            => nil,
-          :content           => nil,
-          :keyserver_options => nil,
-        })
-        should_not contain_apt_key(title)
+      it 'fails' do
+        expect { subject }.to raise_error(/does not match/)
       end
     end
 
-    context 'two apt::key resources, different ensure' do
-      let :pre_condition do
-        "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }"
+    describe 'duplication' do
+      context 'two apt::key resources for same key, different titles' do
+        let :pre_condition do
+          "apt::key { 'duplicate': key => #{title}, }"
+        end
+
+        it 'contains two apt::key resources' do
+          should contain_apt__key('duplicate').with({
+            :key    => title,
+            :ensure => 'present',
+          })
+          should contain_apt__key(title).with({
+            :key    => title,
+            :ensure => 'present',
+          })
+        end
+
+        it 'contains only a single apt_key' do
+          should contain_apt_key('duplicate').with({
+            :id                => title,
+            :ensure            => 'present',
+            :source            => nil,
+            :server            => nil,
+            :content           => nil,
+            :keyserver_options => nil,
+          })
+          should_not contain_apt_key(title)
+        end
       end
-      it 'informs the user of the impossibility' do
-        expect { subject }.to raise_error(/already ensured as absent/)
+
+      context 'two apt::key resources, different ensure' do
+        let :pre_condition do
+          "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }"
+        end
+        it 'informs the user of the impossibility' do
+          expect { subject }.to raise_error(/already ensured as absent/)
+        end
       end
     end
   end
diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb
index d79462cd48..23ebd59b32 100644
--- a/spec/defines/pin_spec.rb
+++ b/spec/defines/pin_spec.rb
@@ -3,118 +3,165 @@
   let(:facts) { { :lsbdistid => 'Debian' } }
   let(:title) { 'my_pin' }
 
-  let :default_params do
-    {
-      :ensure   => 'present',
-      :order    => '',
-      :packages => '*',
-      :priority => '0',
-      :release  => nil
+  context 'defaults' do
+    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/preferences.d/my_pin.pref',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    })
     }
   end
 
-  [
-    { :params  => {},
-      :content => "Explanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n"
-    },
-    {
-      :params => {
-        :packages => 'apache',
-        :priority => '1'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :order    => 50,
-        :packages => 'apache',
-        :priority => '1'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :ensure   => 'absent',
-        :packages => 'apache',
-        :priority => '1'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :packages => 'apache',
-        :priority => '1',
-        :release  => 'my_newpin'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :packages => 'apache',
-        :priority => '1',
-        :version  => '2.2.16*'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :priority => '1',
-        :origin   => 'ftp.de.debian.org'
-      },
-      :content => "Explanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :packages        => 'apache',
-        :priority        => '1',
-        :release         => 'stable',
-        :codename        => 'wheezy',
-        :release_version => '3.0',
-        :component       => 'main',
-        :originator      => 'Debian',
-        :label           => 'Debian'
-      },
-      :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n"
-    },
-    {
-      :params => {
-        :packages        => ['apache', 'ntop'],
-      },
-      :content => "Explanation: : my_pin\nPackage: apache ntop\nPin: release a=my_pin\nPin-Priority: 0\n"
-    },
-  ].each do |param_set|
-    describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
-      let :param_hash do
-        default_params.merge(param_set[:params])
-      end
+  context 'set version' do
+    let :params do
+      {
+        'packages' => 'vim',
+        'version'  => '1',
+      }
+    end
+    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/preferences.d/my_pin.pref',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    })
+    }
+  end
 
-      let :params do
-        param_set[:params]
-      end
+  context 'set origin' do
+    let :params do
+      {
+        'packages' => 'vim',
+        'origin'   => 'test',
+      }
+    end
+    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/preferences.d/my_pin.pref',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    })
+    }
+  end
 
-      it { should contain_class("apt::params") }
+  context 'not defaults' do
+    let :params do
+      {
+        'explanation'     => 'foo',
+        'order'           => 99,
+        'release'         => '1',
+        'codename'        => 'bar',
+        'release_version' => '2',
+        'component'       => 'baz',
+        'originator'      => 'foobar',
+        'label'           => 'foobaz',
+        'priority'        => 10,
+      }
+    end
+    it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) }
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/preferences.d/99-my_pin.pref',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    })
+    }
+  end
 
-      it { should contain_file("#{title}.pref").with({
-          'ensure'  => param_hash[:ensure],
-          'path'    => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
-          'owner'   => 'root',
-          'group'   => 'root',
-          'mode'    => '0644',
-          'content' => param_set[:content],
-        })
+  context 'ensure absent' do
+    let :params do
+      {
+        'ensure' => 'absent'
       }
     end
+    it { is_expected.to contain_file("my_pin.pref").with({
+      'ensure' => 'absent',
+    })
+    }
+  end
+
+  context 'bad characters' do
+    let(:title) { 'such  bad && wow!' }
+    it { is_expected.to contain_file("such__bad____wow_.pref") }
   end
 
-  describe 'resource title with invalid chars' do
-    context 'spaces' do
-      let(:title) { 'oh my god this is not valid' }
-      it { should contain_file('oh_my_god_this_is_not_valid.pref') }
+  describe 'validation' do
+    context 'invalid order' do
+      let :params do
+        {
+          'order' => 'foo',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /Only integers are allowed/)
+      end
+    end
+
+    context 'packages == * and version' do
+      let :params do
+        {
+          'version' => '1',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
+      end
     end
 
-    context '#$&*$' do
-      let(:title) { 'so && many $* invalid @! things' }
-      it { should contain_file('so____many____invalid____things.pref') }
+    context 'packages == * and release and origin' do
+      let :params do
+        {
+          'origin'  => 'test',
+          'release' => 'foo',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
+      end
+    end
+
+    context 'specific form with release and origin' do
+      let :params do
+        {
+          'release'  => 'foo',
+          'origin'   => 'test',
+          'packages' => 'vim',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
+      end
+    end
+
+    context 'specific form with version and origin' do
+      let :params do
+        {
+          'version'  => '1',
+          'origin'   => 'test',
+          'packages' => 'vim',
+        }
+      end
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
+      end
     end
   end
 end
diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb
index 6944f9b2df..3a4c381f67 100644
--- a/spec/defines/ppa_spec.rb
+++ b/spec/defines/ppa_spec.rb
@@ -1,158 +1,163 @@
 require 'spec_helper'
 describe 'apt::ppa', :type => :define do
-  [
-    {
-      :lsbdistrelease  => '11.04',
-      :lsbdistcodename => 'natty',
-      :operatingsystem => 'Ubuntu',
-      :lsbdistid       => 'Ubuntu',
-      :package         => 'python-software-properties'
-    },
-    {
-      :lsbdistrelease  => '12.10',
-      :lsbdistcodename => 'quantal',
-      :operatingsystem => 'Ubuntu',
-      :lsbdistid       => 'Ubuntu',
-      :package         => 'software-properties-common'
-    },
-  ].each do |platform|
-    context "on #{platform[:lsbdistcodename]}" do
-      let :facts do
-        {
-          :lsbdistrelease  => platform[:lsbdistrelease],
-          :lsbdistcodename => platform[:lsbdistcodename],
-          :operatingsystem => platform[:operatingsystem],
-          :lsbdistid       => platform[:lsbdistid],
-          :osfamily        => 'Debian',
-        }
-      end
-      let :release do
-        "#{platform[:lsbdistcodename]}"
-      end
-      let :package do
-        "#{platform[:package]}"
-      end
-      let :options do
-        "-y"
-      end
-      ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
-        describe "with title #{t}" do
-          let :pre_condition do
-            'class { "apt": }'
-          end
-          let :title do
-            t
-          end
-          let :filename do
-            t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list"
-          end
-
-          it { should contain_package("#{package}") }
 
-          it { should contain_exec("apt_update").with(
-            'command'     => '/usr/bin/apt-get update',
-            'refreshonly' => true
-            )
-          }
+  describe 'defaults' do
+    let :pre_condition do
+      'class { "apt": }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '11.04',
+        :lsbdistcodename => 'natty',
+        :operatingsystem => 'Ubuntu',
+        :osfamily        => 'Debian',
+        :lsbdistid       => 'Ubuntu',
+      }
+    end
 
-          it { should contain_exec("add-apt-repository-#{t}").with(
-            'command' => "/usr/bin/add-apt-repository #{options} #{t}",
-            'unless'  => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
-            'require' => ["File[sources.list.d]", "Package[#{package}]"],
-            'notify'  => "Exec[apt_update]"
-            )
-          }
+    let(:title) { 'ppa:needs/such.substitution/wow' }
+    it { is_expected.to contain_package('python-software-properties') }
+    it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
+      'environment' => [],
+      'command'     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
+      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
+      'user'        => 'root',
+      'logoutput'   => 'on_failure',
+    })
+    }
 
-          it { should create_file("/etc/apt/sources.list.d/#{filename}").with(
-            'ensure'  => 'file',
-            'require' => "Exec[add-apt-repository-#{t}]"
-            )
-          }
-        end
-      end
-      describe 'without a proxy defined' do
-        let :title do
-          'rspec_ppa'
-        end
-        let :pre_condition do
-          'class { "apt":
-             proxy_host => false
-          }'
-        end
-        let :filename do
-          "#{title}-#{release}.list"
-        end
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({
+      'ensure' => 'file',
+    })
+    }
+  end
 
-        it { should contain_exec("add-apt-repository-#{title}").with(
-          'environment' => [],
-          'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
-          'unless'      => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
-          'require'     => ["File[sources.list.d]", "Package[#{package}]"],
-          'notify'      => "Exec[apt_update]"
-          )
-        }
-      end
+  describe 'apt included, no proxy' do
+    let :pre_condition do
+      'class { "apt": }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '14.04',
+        :lsbdistcodename => 'trusty',
+        :operatingsystem => 'Ubuntu',
+        :lsbdistid       => 'Ubuntu',
+        :osfamily        => 'Debian',
+      }
+    end
+    let :params do
+      {
+        'options' => '',
+      }
+    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' => [],
+      'command'     => '/usr/bin/add-apt-repository  ppa:foo',
+      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      'user'        => 'root',
+      'logoutput'   => 'on_failure',
+    })
+    }
 
-      describe 'behind a proxy' do
-        let :title do
-          'rspec_ppa'
-        end
-        let :pre_condition do
-          'class { "apt":
-            proxy_host => "user:pass@proxy",
-          }'
-        end
-          let :filename do
-            "#{title}-#{release}.list"
-          end
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({
+      'ensure' => 'file',
+    })
+    }
+  end
 
-        it { should contain_exec("add-apt-repository-#{title}").with(
-          'environment' => [
-            "http_proxy=http://user:pass@proxy:8080",
-            "https_proxy=http://user:pass@proxy:8080",
-          ],
-          'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
-          'unless'      => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
-          'require'     => ["File[sources.list.d]", "Package[#{package}]"],
-          'notify'      => "Exec[apt_update]"
-          )
-        }
-      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
 
-  [ { :lsbdistcodename => 'natty',
-      :package => 'python-software-properties' },
-    { :lsbdistcodename => 'quantal',
-      :package => 'software-properties-common'},
-  ].each do |platform|
-    context "on #{platform[:lsbdistcodename]}" do
-      describe "it should not error if package['#{platform[:package]}'] is already defined" do
-        let :pre_condition do
-           'class {"apt": }' +
-           'package { "#{platform[:package]}": }->Apt::Ppa["ppa"]'
-        end
-        let :facts do
-          {:lsbdistcodename => '#{platform[:lsbdistcodename]}',
-           :operatingsystem => 'Ubuntu',
-           :lsbdistid => 'Ubuntu',
-           :osfamily => 'Debian'}
-        end
-        let(:title) { "ppa" }
-        let(:release) { "#{platform[:lsbdistcodename]}" }
-        it { should contain_package('#{platform[:package]}') }
-      end
+  describe 'ensure absent' do
+    let :facts do
+      {
+        :lsbdistrelease  => '14.04',
+        :lsbdistcodename => 'trusty',
+        :operatingsystem => 'Ubuntu',
+        :lsbdistid       => 'Ubuntu',
+        :osfamily        => 'Debian',
+      }
+    end
+    let(:title) { 'ppa:foo' }
+    let :params do
+      {
+        'ensure' => 'absent'
+      }
     end
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({
+      'ensure' => 'absent',
+    })
+    }
   end
 
-  describe "without Class[apt] should raise a Puppet::Error" do
-    let(:release) { "natty" }
-    let(:title) { "ppa" }
-    it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) }
-  end
+  context 'validation' do
+    describe 'no release' do
+      let :facts do
+        {
+          :lsbdistrelease  => '14.04',
+          :operatingsystem => 'Ubuntu',
+          :lsbdistid       => 'Ubuntu',
+          :osfamily        => 'Debian',
+        }
+      end
+      let(:title) { 'ppa:foo' }
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
+      end
+    end
 
-  describe "without release should raise a Puppet::Error" do
-    let(:title) { "ppa:" }
-    it { expect { should contain_apt__ppa(:release) }.to raise_error(Puppet::Error) }
+    describe 'not ubuntu' do
+      let :facts do
+        {
+          :lsbdistrelease  => '14.04',
+          :lsbdistcodename => 'trusty',
+          :operatingsystem => 'Debian',
+          :lsbdistid       => 'Ubuntu',
+          :osfamily        => 'Debian',
+        }
+      end
+      let(:title) { 'ppa:foo' }
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /apt::ppa is currently supported on Ubuntu only./)
+      end
+    end
   end
 end
diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb
index 284adca27f..960bb620fc 100644
--- a/spec/defines/source_spec.rb
+++ b/spec/defines/source_spec.rb
@@ -1,179 +1,127 @@
 require 'spec_helper'
 
 describe 'apt::source', :type => :define do
-  let(:facts) { { :lsbdistid => 'Debian' } }
   GPG_KEY_ID = '4BD6EC30'
 
   let :title do
     'my_source'
   end
 
-  let :default_params do
-    {
-      :ensure             => 'present',
-      :location           => '',
-      :release            => 'karmic',
-      :repos              => 'main',
-      :include_src        => true,
-      :include_deb        => true,
-      :required_packages  => false,
-      :key                => false,
-      :key_server         => false,
-      :key_content        => false,
-      :key_source         => false,
-      :pin                => false
-    }
-  end
+  context 'mostly defaults' do
+    let :facts do
+      {
+        :lsbdistid       => 'Debian',
+        :lsbdistcodename => 'wheezy',
+      }
+    end
 
-  [{},
-   {
-      :location           => 'http://example.com',
-      :release            => 'precise',
-      :repos              => 'security',
-      :include_src        => false,
-      :required_packages  => 'apache',
-      :key                => GPG_KEY_ID,
-      :key_server         => 'keyserver.debian.com',
-      :pin                => '600',
-      :key_content        => 'ABCD1234'
-    },
-    {
-      :key                => GPG_KEY_ID,
-      :key_server         => 'keyserver.debian.com',
-    },
-    {
-      :ensure             => 'absent',
-      :location           => 'http://example.com',
-      :release            => 'precise',
-      :repos              => 'security',
-    },
-    {
-      :release            => '',
-    },
-    {
-      :release            => 'custom',
-    },
-    {
-      :architecture       => 'amd64',
+    let :params do
+      {
+        'include_deb' => false,
+      }
+    end
+
+    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/sources.list.d/my_source.list',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    }).with_content(/#file generated by puppet\n# my_source\ndeb-src  wheezy main\n/)
     }
-  ].each do |param_set|
-    describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
-      let :param_hash do
-        default_params.merge(param_set)
-      end
+  end
 
-      let :facts do
-        {:lsbdistcodename => 'karmic', :lsbdistid => 'Ubuntu'}
-      end
+  context 'no defaults' do
+    let :facts do
+      {
+        :lsbdistid       => 'Debian',
+        :lsbdistcodename => 'wheezy',
+      }
+    end
+    let :params do
+      {
+        'comment'           => 'foo',
+        'location'          => 'http://debian.mirror.iweb.ca/debian/',
+        'release'           => 'sid',
+        'repos'             => 'testing',
+        'include_src'       => false,
+        'required_packages' => 'vim',
+        'key'               => GPG_KEY_ID,
+        'key_server'        => 'pgp.mit.edu',
+        'key_content'       => 'GPG key content',
+        'key_source'        => 'http://apt.puppetlabs.com/pubkey.gpg',
+        'pin'               => '10',
+        'architecture'      => 'x86_64',
+      }
+    end
 
-      let :params do
-        param_set
-      end
+    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+      'ensure' => 'present',
+      'path'   => '/etc/apt/sources.list.d/my_source.list',
+      'owner'  => 'root',
+      'group'  => 'root',
+      'mode'   => '0644',
+    }).with_content(/#file generated by puppet\n# foo\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
+    }
 
-      let :filename do
-        "/etc/apt/sources.list.d/#{title}.list"
-      end
+    it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
+      'ensure'   => 'present',
+      'priority' => '10',
+      'origin'   => 'debian.mirror.iweb.ca',
+    })
+    }
 
-      let :content do
-        content = "#file generated by puppet\n"
-	if param_hash[:comment]
-	  content << "# #{comment}"
-	else
-	  content << "# #{title}"
-	end
-        if param_hash[:architecture]
-          arch = "[arch=#{param_hash[:architecture]}] "
-        end
-        if param_hash[:include_deb]
-	  content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
-	end
-        if param_hash[:include_src]
-          content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
-        end
-        content
-      end
+    it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Exec[apt_update]').that_subscribes_to('File[my_source.list]').with({
+      'command'     => '/usr/bin/apt-get -y install vim',
+      'logoutput'   => 'on_failure',
+      'refreshonly' => true,
+      'tries'       => '3',
+      'try_sleep'   => '1',
+    })
+    }
 
-      it { should contain_apt__params }
+    it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('File[my_source.list]').with({
+      'ensure' => 'present',
+        'key'  => GPG_KEY_ID,
+        'key_server' => 'pgp.mit.edu',
+        'key_content' => 'GPG key content',
+        'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
+    })
+    }
+  end
 
-      it { should contain_file("#{title}.list").with({
-          'ensure'    => param_hash[:ensure],
-          'path'      => filename,
-          'owner'     => 'root',
-          'group'     => 'root',
-          'mode'      => '0644',
-          'content'   => content,
-        })
+  context 'ensure => absent' do
+    let :facts do
+      {
+        :lsbdistid       => 'Debian',
+        :lsbdistcodename => 'wheezy',
       }
-
-      it {
-        if param_hash[:pin]
-          should contain_apt__pin(title).with({
-            "priority"  => param_hash[:pin],
-            "before"    => "File[#{title}.list]"
-          })
-        else
-          should_not contain_apt__pin(title).with({
-            "priority"  => param_hash[:pin],
-            "before"    => "File[#{title}.list]"
-          })
-        end
+    end
+    let :params do
+      {
+        'ensure' => 'absent',
       }
+    end
 
-      it {
-        should contain_exec("apt_update").with({
-          "command"     => "/usr/bin/apt-get update",
-          "refreshonly" => true
-        })
-      }
+    it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+      'ensure' => 'absent'
+    })
+    }
+  end
 
-      it {
-        if param_hash[:required_packages]
-          should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
-            "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
-            "subscribe"   => "File[#{title}.list]",
-            "refreshonly" => true,
-            "before"      => 'Exec[apt_update]',
-          })
-        else
-          should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
-            "command"     => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
-            "subscribe"   => "File[#{title}.list]",
-            "refreshonly" => true
-          })
-        end
-      }
+  describe 'validation' do
+    context 'no release' do
+      let :facts do
+        {
+          :lsbdistid       => 'Debian',
+        }
+      end
 
-      it {
-        key_server  = param_hash[:key_server]  || nil
-        key_content = param_hash[:key_content] || nil
-        key_source  = param_hash[:key_source]  || nil
-        if param_hash[:key]
-          should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
-            "key"         => param_hash[:key],
-            "ensure"      => :present,
-            "key_server"  => key_server,
-            "key_content" => key_content,
-            "key_source"  => key_source,
-            "before"      => "File[#{title}.list]"
-          })
-        else
-          should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
-            "key"         => param_hash[:key],
-            "ensure"      => :present,
-            "key_server"  => param_hash[:key_server],
-            "key_content" => param_hash[:key_content],
-            "key_source"  => param_hash[:key_source],
-            "before"      => "File[#{title}.list]"
-          })
-        end
-      }
+      it do
+        expect {
+          should compile
+        }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
+      end
     end
   end
-  describe "without release should raise a Puppet::Error" do
-    let(:default_params) { Hash.new }
-    let(:facts) { Hash.new }
-    it { expect { should raise_error(Puppet::Error) } }
-    let(:facts) { { :lsbdistcodename => 'lucid', :lsbdistid => 'Ubuntu' } }
-    it { should contain_apt__source(title) }
-  end
 end

From c7b88aae38af8354fc026d515be605ca37cce0da Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Tue, 12 Aug 2014 12:12:21 -0400
Subject: [PATCH 346/574] Missed test refactoring in CHANGELOG

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index fda47c5e41..4a325f42f2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
 - Allow custom comment for sources list
 - Enable auto-update for Debian squeeze LTS
 - Add facts showing available updates
+- Test refactoring
 
 ####Bugfixes
 - Allow dashes in URL or domain for key_server parameter

From c69fb2cd2411460f979e410e14dbc435ee979f0a Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Tue, 12 Aug 2014 13:39:22 -0400
Subject: [PATCH 347/574] Clean up test failures

---
 spec/acceptance/apt_key_provider_spec.rb | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb
index 497c6edb53..0f20174d06 100644
--- a/spec/acceptance/apt_key_provider_spec.rb
+++ b/spec/acceptance/apt_key_provider_spec.rb
@@ -36,7 +36,7 @@
           EOS
 
           apply_manifest(pp, :catch_failures => true)
-          expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+          apply_manifest(pp, :catch_failures => true)
           shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
         end
       end
@@ -74,7 +74,7 @@
 
         # Time to remove it using Puppet
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
 
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}",
               :acceptable_exit_codes => [1])
@@ -153,7 +153,7 @@
         EOS
 
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
     end
@@ -187,7 +187,7 @@
         EOS
 
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
     end
@@ -203,7 +203,7 @@
         EOS
 
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
     end
@@ -253,7 +253,7 @@
         EOS
 
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
 
@@ -302,7 +302,7 @@
         EOS
 
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
         shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}")
       end
 
@@ -346,7 +346,7 @@
         EOS
 
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
 
@@ -399,7 +399,7 @@
         EOS
 
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
     end
@@ -456,7 +456,7 @@
         EOS
 
         apply_manifest(pp, :catch_failures => true)
-        expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+        apply_manifest(pp, :catch_failures => true)
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
       end
 
@@ -469,6 +469,7 @@
         }
         EOS
 
+        shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}", :acceptable_exit_codes => [0,1,2])
         apply_manifest(pp, :expect_failures => true) do |r|
           expect(r.stderr).to match(/--keyserver-options this is totally/)
         end

From 442ca3087077434c9f96376b9b3e289966392839 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Tue, 12 Aug 2014 16:10:36 -0400
Subject: [PATCH 348/574] Don't hardcode /etc/puppet as the puppetpath.

---
 spec/spec_helper_acceptance.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 3352564ce7..fe3e4bf0c9 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -26,7 +26,7 @@
     # Install module and dependencies
     puppet_module_install(:source => proj_root, :module_name => 'apt')
     hosts.each do |host|
-      shell('/bin/touch /etc/puppet/hiera.yaml')
+      shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
       shell('puppet module install puppetlabs-stdlib --version 2.2.1', { :acceptable_exit_codes => [0,1] })
     end
   end

From ea9f902543e0696286bf55ce2ad8c1818ffd5a84 Mon Sep 17 00:00:00 2001
From: Hunter Haugen 
Date: Fri, 15 Aug 2014 16:22:46 -0700
Subject: [PATCH 349/574] Remove stderr from stdout

Sometimes there are lib errors on platforms with malformed packages.
This shouldn't cause the facts to completely fail.
---
 lib/facter/apt_package_updates.rb  | 2 +-
 lib/facter/apt_security_updates.rb | 2 +-
 lib/facter/apt_updates.rb          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/facter/apt_package_updates.rb b/lib/facter/apt_package_updates.rb
index 97c75c66a2..e2fc96e4b5 100644
--- a/lib/facter/apt_package_updates.rb
+++ b/lib/facter/apt_package_updates.rb
@@ -2,7 +2,7 @@
   confine :osfamily => 'Debian'
   setcode do
     if File.executable?("/usr/lib/update-notifier/apt-check")
-      packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1')
+      packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>/dev/null')
       packages = packages.split("\n")
       if Facter.version < '2.0.0'
         packages = packages.join(',')
diff --git a/lib/facter/apt_security_updates.rb b/lib/facter/apt_security_updates.rb
index 19bae7521d..77b3c0e9fc 100644
--- a/lib/facter/apt_security_updates.rb
+++ b/lib/facter/apt_security_updates.rb
@@ -2,7 +2,7 @@
   confine :osfamily => 'Debian'
   setcode do
     if File.executable?("/usr/lib/update-notifier/apt-check")
-      updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1')
+      updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>/dev/null')
       Integer(updates.strip.split(';')[1])
     end
   end
diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb
index ee177380c2..15d9473d6e 100644
--- a/lib/facter/apt_updates.rb
+++ b/lib/facter/apt_updates.rb
@@ -2,7 +2,7 @@
   confine :osfamily => 'Debian'
   setcode do
     if File.executable?("/usr/lib/update-notifier/apt-check")
-      updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1')
+      updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>/dev/null')
       Integer(updates.strip.split(';')[0])
     end
   end

From af02b9c8a77822a1a33f22d0c34bcfc1cfd473ee Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Tue, 19 Aug 2014 10:17:42 -0700
Subject: [PATCH 350/574] Remove Puppet 2.7 from travis matrix

---
 .travis.yml | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a40ae502e9..d49700981f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,10 +5,6 @@ script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake
 matrix:
   fast_finish: true
   include:
-  - rvm: 1.8.7
-    env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
-  - rvm: 1.8.7
-    env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0"
   - rvm: 1.9.3
     env: PUPPET_GEM_VERSION="~> 3.0"
   - rvm: 2.0.0

From 4dc8e8f462e38e198f2bd9f697ca1e41c1af4fbe Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Tue, 19 Aug 2014 10:50:58 -0700
Subject: [PATCH 351/574] Add testing on Ruby 1.8.7 with Puppet 3 to travis.yml

---
 .travis.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index d49700981f..66e90e38df 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,8 @@ script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake
 matrix:
   fast_finish: true
   include:
+  - rvm: 1.8.7
+    env: PUPPET_GEM_VERSION="~> 3.0"
   - rvm: 1.9.3
     env: PUPPET_GEM_VERSION="~> 3.0"
   - rvm: 2.0.0

From 018a31a0ecf3020d74928363c88b8fa160eea14a Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Tue, 19 Aug 2014 13:45:39 -0700
Subject: [PATCH 352/574] Pin puppet-lint to 0.3.2

---
 Gemfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Gemfile b/Gemfile
index e960f7c4b7..081b1a2915 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,7 +5,7 @@ group :development, :test do
   gem 'rspec-puppet',            :require => false
   gem 'puppetlabs_spec_helper',  :require => false
   gem 'serverspec',              :require => false
-  gem 'puppet-lint',             :require => false
+  gem 'puppet-lint', '0.3.2',    :require => false
   gem 'beaker',                  :require => false
   gem 'beaker-rspec',            :require => false
   gem 'pry',                     :require => false

From ae28193ce40c1820f7b43f5c7769aa46cf54b5cd Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Thu, 28 Aug 2014 11:16:09 -0400
Subject: [PATCH 353/574] Only call install_* methods once

---
 spec/spec_helper_acceptance.rb | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 3352564ce7..6627cf764b 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -2,13 +2,14 @@
 
 # Install Puppet
 unless ENV['RS_PROVISION'] == 'no'
+  # This will install the latest available package on el and deb based
+  # systems fail on windows and osx, and install via gem on other *nixes
+  foss_opts = { :default_action => 'gem_install' }
+
+  if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end
+
   hosts.each do |host|
-    if host.is_pe?
-      install_pe
-    else
-      install_puppet
-      on host, "mkdir -p #{host['distmoduledir']}"
-    end
+    on host, "mkdir -p #{host['distmoduledir']}"
   end
 end
 

From 636cacd72c8b82f3e812e7b53499afff89ccded9 Mon Sep 17 00:00:00 2001
From: Christophe Bliard 
Date: Fri, 29 Aug 2014 16:23:21 +0200
Subject: [PATCH 354/574] add support for LinuxMint operating system

---
 manifests/backports.pp         | 23 ++++++++++++++++---
 manifests/params.pp            | 36 +++++++++++++++++++++++-------
 spec/classes/backports_spec.rb | 40 ++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+), 11 deletions(-)

diff --git a/manifests/backports.pp b/manifests/backports.pp
index eafa50692e..c45bc15682 100644
--- a/manifests/backports.pp
+++ b/manifests/backports.pp
@@ -38,12 +38,29 @@
     fail('$pin_priority must be an integer')
   }
 
-  $release_real = downcase($release)
-  $key = $::lsbdistid ? {
+  if $::lsbdistid == 'LinuxMint' {
+    $distid = $::lsbdistcodename ? {
+      'debian' => 'debian',
+      default  => 'ubuntu',
+    }
+    $release_real = $::lsbdistcodename ? {
+      'debian' => 'wheezy',
+      'qiana'  => 'trusty',
+      'petra'  => 'saucy',
+      'olivia' => 'raring',
+      'nadia'  => 'quantal',
+      'maya'   => 'precise',
+    }
+  } else {
+    $distid = $::lsbdistid
+    $release_real = downcase($release)
+  }
+
+  $key = $distid ? {
     'debian' => '46925553',
     'ubuntu' => '437D05B5',
   }
-  $repos = $::lsbdistid ? {
+  $repos = $distid ? {
     'debian' => 'main contrib non-free',
     'ubuntu' => 'main universe multiverse restricted',
   }
diff --git a/manifests/params.pp b/manifests/params.pp
index d57b80110c..20ad8d8dd7 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -6,8 +6,34 @@
   $preferences_d  = "${root}/preferences.d"
 
   case $::lsbdistid {
+    'linuxmint': {
+      $distid = $::lsbdistcodename ? {
+        'debian' => 'debian',
+        default  => 'ubuntu',
+      }
+      $distcodename = $::lsbdistcodename ? {
+        'debian' => 'wheezy',
+        'qiana'  => 'trusty',
+        'petra'  => 'saucy',
+        'olivia' => 'raring',
+        'nadia'  => 'quantal',
+        'maya'   => 'precise',
+      }
+    }
+    'ubuntu', 'debian': {
+      $distid = $::lsbdistid
+      $distcodename = $::lsbdistcodename
+    }
+    '': {
+      fail('Unable to determine lsbdistid, is lsb-release installed?')
+    }
+    default: {
+      fail("Unsupported lsbdistid (${::lsbdistid})")
+    }
+  }
+  case $distid {
     'debian': {
-      case $::lsbdistcodename {
+      case $distcodename {
         'squeeze': {
           $backports_location = 'http://backports.debian.org/debian-backports'
           $legacy_origin       = true
@@ -28,7 +54,7 @@
       }
     }
     'ubuntu': {
-      case $::lsbdistcodename {
+      case $distcodename {
         'lucid': {
           $backports_location = 'http://us.archive.ubuntu.com/ubuntu'
           $ppa_options        = undef
@@ -49,11 +75,5 @@
         }
       }
     }
-    '': {
-      fail('Unable to determine lsbdistid, is lsb-release installed?')
-    }
-    default: {
-      fail("Unsupported lsbdistid (${::lsbdistid})")
-    }
   }
 }
diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb
index 2f67aa4bc0..17c86ebbba 100644
--- a/spec/classes/backports_spec.rb
+++ b/spec/classes/backports_spec.rb
@@ -71,6 +71,46 @@
     }
   end
 
+  describe "when turning on backports for linux mint debian edition" do
+
+    let :facts do
+      {
+        'lsbdistcodename' => 'debian',
+        'lsbdistid'       => 'LinuxMint',
+      }
+    end
+
+    it { should contain_apt__source('backports').with({
+        'location'   => 'http://ftp.debian.org/debian/',
+        'release'    => 'wheezy-backports',
+        'repos'      => 'main contrib non-free',
+        'key'        => '46925553',
+        'key_server' => 'pgp.mit.edu',
+        'pin'        => 200,
+      })
+    }
+  end
+
+  describe "when turning on backports for linux mint 17 (ubuntu-based)" do
+
+    let :facts do
+      {
+        'lsbdistcodename' => 'qiana',
+        'lsbdistid'       => 'LinuxMint',
+      }
+    end
+
+    it { should contain_apt__source('backports').with({
+        'location'   => 'http://us.archive.ubuntu.com/ubuntu',
+        'release'    => 'trusty-backports',
+        'repos'      => 'main universe multiverse restricted',
+        'key'        => '437D05B5',
+        'key_server' => 'pgp.mit.edu',
+        'pin'        => 200,
+      })
+    }
+  end
+
   describe "when turning on backports for debian squeeze but using your own mirror" do
 
     let :facts do

From ec3c20e288ec8af8d8955d73c0c41043c29a7684 Mon Sep 17 00:00:00 2001
From: Christophe Bliard 
Date: Fri, 29 Aug 2014 16:57:09 +0200
Subject: [PATCH 355/574] Prefer `if/else` over `?` selector with `default`

---
 manifests/backports.pp | 23 ++++++++++++-----------
 manifests/params.pp    | 29 +++++++++++++++--------------
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/manifests/backports.pp b/manifests/backports.pp
index c45bc15682..ee462094d4 100644
--- a/manifests/backports.pp
+++ b/manifests/backports.pp
@@ -39,17 +39,18 @@
   }
 
   if $::lsbdistid == 'LinuxMint' {
-    $distid = $::lsbdistcodename ? {
-      'debian' => 'debian',
-      default  => 'ubuntu',
-    }
-    $release_real = $::lsbdistcodename ? {
-      'debian' => 'wheezy',
-      'qiana'  => 'trusty',
-      'petra'  => 'saucy',
-      'olivia' => 'raring',
-      'nadia'  => 'quantal',
-      'maya'   => 'precise',
+    if $::lsbdistcodename == 'debian' {
+      $distid = 'debian'
+      $release_real = 'wheezy'
+    } else {
+      $distid = 'ubuntu'
+      $release_real = $::lsbdistcodename ? {
+        'qiana'  => 'trusty',
+        'petra'  => 'saucy',
+        'olivia' => 'raring',
+        'nadia'  => 'quantal',
+        'maya'   => 'precise',
+      }
     }
   } else {
     $distid = $::lsbdistid
diff --git a/manifests/params.pp b/manifests/params.pp
index 20ad8d8dd7..d073c3645d 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -6,24 +6,25 @@
   $preferences_d  = "${root}/preferences.d"
 
   case $::lsbdistid {
-    'linuxmint': {
-      $distid = $::lsbdistcodename ? {
-        'debian' => 'debian',
-        default  => 'ubuntu',
-      }
-      $distcodename = $::lsbdistcodename ? {
-        'debian' => 'wheezy',
-        'qiana'  => 'trusty',
-        'petra'  => 'saucy',
-        'olivia' => 'raring',
-        'nadia'  => 'quantal',
-        'maya'   => 'precise',
-      }
-    }
     'ubuntu', 'debian': {
       $distid = $::lsbdistid
       $distcodename = $::lsbdistcodename
     }
+    'linuxmint': {
+      if $::lsbdistcodename == 'debian' {
+        $distid = 'debian'
+        $distcodename = 'wheezy'
+      } else {
+        $distid = 'ubuntu'
+        $distcodename = $::lsbdistcodename ? {
+          'qiana'  => 'trusty',
+          'petra'  => 'saucy',
+          'olivia' => 'raring',
+          'nadia'  => 'quantal',
+          'maya'   => 'precise',
+        }
+      }
+    }
     '': {
       fail('Unable to determine lsbdistid, is lsb-release installed?')
     }

From 1044886150fd3f5a8488714594c38a11a7328f09 Mon Sep 17 00:00:00 2001
From: Matthias Baur 
Date: Fri, 5 Sep 2014 18:51:39 +0200
Subject: [PATCH 356/574] Fix some Puppet Lint errors

---
 manifests/init.pp   | 20 ++++++++++----------
 manifests/params.pp | 12 ++++++------
 manifests/ppa.pp    | 14 +++++++-------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/manifests/init.pp b/manifests/init.pp
index 1c318b67ca..eb8c709bab 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -89,8 +89,8 @@
 
   if $purge_preferences {
     file { 'apt-preferences':
-      ensure  => absent,
-      path    => "${root}/preferences",
+      ensure => absent,
+      path   => "${root}/preferences",
     }
   }
 
@@ -113,8 +113,8 @@
     }
     false: {
       file { '99progressbar':
-        ensure  => absent,
-        path    => "${apt_conf_d}/99progressbar",
+        ensure => absent,
+        path   => "${apt_conf_d}/99progressbar",
       }
     }
     undef: {} # do nothing
@@ -142,9 +142,9 @@
   case $proxy_host {
     false, '', undef: {
       file { '01proxy':
-        ensure  => absent,
-        path    => "${apt_conf_d}/01proxy",
-        notify  => Exec['apt_update'],
+        ensure => absent,
+        path   => "${apt_conf_d}/01proxy",
+        notify => Exec['apt_update'],
       }
     }
     default: {
@@ -161,9 +161,9 @@
   }
 
   file { 'old-proxy-file':
-    ensure  => absent,
-    path    => "${apt_conf_d}/proxy",
-    notify  => Exec['apt_update'],
+    ensure => absent,
+    path   => "${apt_conf_d}/proxy",
+    notify => Exec['apt_update'],
   }
 
   # Need anchor to provide containment for dependencies.
diff --git a/manifests/params.pp b/manifests/params.pp
index d57b80110c..a90d2b4ed6 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -11,9 +11,9 @@
         'squeeze': {
           $backports_location = 'http://backports.debian.org/debian-backports'
           $legacy_origin       = true
-          $origins             = ['${distro_id} oldstable',
-                                  '${distro_id} ${distro_codename}-security',
-                                  '${distro_id} ${distro_codename}-lts']
+          $origins             = ['${distro_id} oldstable', #lint:ignore:single_quote_string_with_variables
+                                  '${distro_id} ${distro_codename}-security', #lint:ignore:single_quote_string_with_variables
+                                  '${distro_id} ${distro_codename}-lts'] #lint:ignore:single_quote_string_with_variables
         }
         'wheezy': {
           $backports_location = 'http://ftp.debian.org/debian/'
@@ -33,19 +33,19 @@
           $backports_location = 'http://us.archive.ubuntu.com/ubuntu'
           $ppa_options        = undef
           $legacy_origin      = true
-          $origins            = ['${distro_id} ${distro_codename}-security']
+          $origins            = ['${distro_id} ${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables
         }
         'precise', 'trusty': {
           $backports_location = 'http://us.archive.ubuntu.com/ubuntu'
           $ppa_options        = '-y'
           $legacy_origin      = true
-          $origins            = ['${distro_id}:${distro_codename}-security']
+          $origins            = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables
         }
         default: {
           $backports_location = 'http://old-releases.ubuntu.com/ubuntu'
           $ppa_options        = '-y'
           $legacy_origin      = true
-          $origins            = ['${distro_id}:${distro_codename}-security']
+          $origins            = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables
         }
       }
     }
diff --git a/manifests/ppa.pp b/manifests/ppa.pp
index 5f5c6ae574..0fdcc95f3a 100644
--- a/manifests/ppa.pp
+++ b/manifests/ppa.pp
@@ -48,13 +48,13 @@
         $proxy_env = []
     }
     exec { "add-apt-repository-${name}":
-        environment  => $proxy_env,
-        command      => "/usr/bin/add-apt-repository ${options} ${name}",
-        unless       => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}",
-        user         => 'root',
-        logoutput    => 'on_failure',
-        notify       => Exec['apt_update'],
-        require      => [
+        environment => $proxy_env,
+        command     => "/usr/bin/add-apt-repository ${options} ${name}",
+        unless      => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}",
+        user        => 'root',
+        logoutput   => 'on_failure',
+        notify      => Exec['apt_update'],
+        require     => [
         File['sources.list.d'],
         Package[$package],
         ],

From d92513261b6d90d78f59269a133c1c1a07e55277 Mon Sep 17 00:00:00 2001
From: Colleen Murphy 
Date: Sun, 7 Sep 2014 11:12:28 -0700
Subject: [PATCH 357/574] Unpin puppet-lint

The issues associated with the 1.0.0 release of puppet-lint have been
resolved.
---
 Gemfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Gemfile b/Gemfile
index 081b1a2915..e960f7c4b7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,7 +5,7 @@ group :development, :test do
   gem 'rspec-puppet',            :require => false
   gem 'puppetlabs_spec_helper',  :require => false
   gem 'serverspec',              :require => false
-  gem 'puppet-lint', '0.3.2',    :require => false
+  gem 'puppet-lint',             :require => false
   gem 'beaker',                  :require => false
   gem 'beaker-rspec',            :require => false
   gem 'pry',                     :require => false

From 8fa73ac96fda8af4360e71b41c0a3e514f28080a Mon Sep 17 00:00:00 2001
From: Travis Fields 
Date: Wed, 10 Sep 2014 10:37:07 -0700
Subject: [PATCH 358/574] Fix issue with puppet_module_install, removed and
 using updated method from beaker core copy_module_to

---
 spec/spec_helper_acceptance.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index fe3e4bf0c9..7e0de22e28 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -24,8 +24,8 @@
   # Configure all nodes in nodeset
   c.before :suite do
     # Install module and dependencies
-    puppet_module_install(:source => proj_root, :module_name => 'apt')
     hosts.each do |host|
+      copy_module_to(host, :source => proj_root, :module_name => 'apt')
       shell("/bin/touch #{default['puppetpath']}/hiera.yaml")
       shell('puppet module install puppetlabs-stdlib --version 2.2.1', { :acceptable_exit_codes => [0,1] })
     end

From db556a0a5a13d07f02d73dd547fd5005a0e3f335 Mon Sep 17 00:00:00 2001
From: Matthaus Owens 
Date: Wed, 10 Sep 2014 13:21:07 -0700
Subject: [PATCH 359/574] (DOC-1230) Update all short key examples to use the
 long key id

---
 README.md | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 9f3bbbe7b7..6badc1a43f 100644
--- a/README.md
+++ b/README.md
@@ -85,7 +85,7 @@ this module.
 
     apt_key { 'puppetlabs':
       ensure => 'present',
-      id     => '4BD6EC30',
+      id     => '1054B7A24BD6EC30',
     }
 
 You can additionally set the following attributes:
@@ -105,12 +105,12 @@ uses the aforementioned `apt_key` native type. As such it no longer requires
 the wget command that the old implementation depended on.
 
     apt::key { 'puppetlabs':
-      key        => '4BD6EC30',
+      key        => '1054B7A24BD6EC30',
       key_server => 'pgp.mit.edu',
     }
 
     apt::key { 'jenkins':
-      key        => 'D50582E6',
+      key        => '9B7D32F2D50582E6',
       key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
     }
 
@@ -199,7 +199,7 @@ Adds an apt source to `/etc/apt/sources.list.d/`.
       release           => 'unstable',
       repos             => 'main contrib non-free',
       required_packages => 'debian-keyring debian-archive-keyring',
-      key               => '46925553',
+      key               => '8B48AD6246925553',
       key_server        => 'subkeys.pgp.net',
       pin               => '-10',
       include_src       => true,
@@ -211,7 +211,7 @@ If you would like to configure your system so the source is the Puppet Labs APT
     apt::source { 'puppetlabs':
       location   => 'http://apt.puppetlabs.com',
       repos      => 'main',
-      key        => '4BD6EC30',
+      key        => '1054B7A24BD6EC30',
       key_server => 'pgp.mit.edu',
     }
 
@@ -231,7 +231,7 @@ apt::sources:
       release: 'unstable'
       repos: 'main contrib non-free'
       required_packages: 'debian-keyring debian-archive-keyring'
-      key: '55BE302B'
+      key: '9AA38DCD55BE302B'
       key_server: 'subkeys.pgp.net'
       pin: '-10'
       include_src: 'true'
@@ -240,7 +240,7 @@ apt::sources:
   'puppetlabs':
       location: 'http://apt.puppetlabs.com'
       repos: 'main'
-      key: '4BD6EC30'
+      key: '1054B7A24BD6EC30'
       key_server: 'pgp.mit.edu'
 
@@ -255,7 +255,7 @@ This test will set up a Puppet Labs apt repository. Start by creating a new smok apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', repos => 'main', - key => '4BD6EC30', + key => '1054B7A24BD6EC30', key_server => 'pgp.mit.edu', } From 67f6355c2d44328dff7e4ea33cc9e8c2a754c7de Mon Sep 17 00:00:00 2001 From: jbondpdx Date: Tue, 16 Sep 2014 16:51:24 -0700 Subject: [PATCH 360/574] MODULES-1259: added info on apt::update + edits to readme.md Added apt::update information to the Readme file. Also general copy editing throughout for clarity and consistent style. --- README.md | 92 +++++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 6badc1a43f..7991404290 100644 --- a/README.md +++ b/README.md @@ -6,45 +6,45 @@ apt Overview -------- -The APT module provides a simple interface for managing APT source, key, and definitions with Puppet. +The apt module provides a simple interface for managing APT source, key, and definitions with Puppet. Module Description ------------------ -APT automates obtaining and installing software packages on \*nix systems. +The apt module automates obtaining and installing software packages on \*nix systems. -***Note:** While this module allows the use of short keys, we STRONGLY RECOMMEND that you DO NOT USE short keys, as they pose a serious security issue in that they open you up to collision attacks.* +***Note:** While this module allows the use of short keys, we **strongly** recommend that you **do not use short keys**, as they pose a serious security issue by opening you up to collision attacks. Setup ----- -**What APT affects:** +**What apt affects:** * package/service/configuration files for APT - * NOTE: Setting the `purge_preferences` or `purge_preferences_d` parameters to 'true' will destroy any existing configuration that was not declared with puppet. The default for these parameters is 'false'. + * NOTE: Setting the `purge_preferences` or `purge_preferences_d` parameters to 'true' will destroy any existing configuration that was not declared with Puppet. The default for these parameters is 'false'. * your system's `sources.list` file and `sources.list.d` directory * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'. * system repositories * authentication keys -### Beginning with APT +### Beginning with apt -To begin using the APT module with default parameters, declare the class +To begin using the apt module with default parameters, declare the class. include apt -Puppet code that uses anything from the APT module requires that the core apt class be declared. +Puppet code that uses anything from the apt module requires that the core apt class be declared. Usage ----- -Using the APT module consists predominantly in declaring classes that provide desired functionality and features. +Using the apt module consists predominantly of declaring classes that provide the desired functionality and features. ### apt -`apt` provides a number of common resources and options that are shared by the various defined types in this module, so you MUST always include this class in your manifests. +`apt` provides a number of common resources and options that are shared by the various defined types in this module, so you **must always** include this class in your manifests. -The parameters for `apt` are not required in general and are predominantly for development environment use-cases. +The parameters for `apt` are not generally required and are predominantly for development environment use cases. class { 'apt': always_apt_update => false, @@ -70,7 +70,7 @@ Installs the build depends of a specified package. ### apt::force -Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. +Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. apt::force { 'glusterfs-server': release => 'unstable', @@ -80,8 +80,7 @@ Forces a package to be installed from a specific release. This class is particu ### apt_key -A native Puppet type and provider for managing GPG keys for APT is provided by -this module. +A native Puppet type and provider for managing GPG keys for APT is provided by this module. apt_key { 'puppetlabs': ensure => 'present', @@ -96,13 +95,12 @@ You can additionally set the following attributes: * `server`: The GPG key server to use. It defaults to *keyserver.ubuntu.com*; * `keyserver_options`: Additional options to pass to `--keyserver`. -Because it is a native type it can be used in and queried for with MCollective. +Because apt_key is a native type, it can be used in and queried for with MCollective. ### apt::key -Adds a key to the list of keys used by APT to authenticate packages. This type -uses the aforementioned `apt_key` native type. As such it no longer requires -the wget command that the old implementation depended on. +Adds a key to the list of keys used by APT to authenticate packages. This type uses the aforementioned `apt_key` native type. As such, it no longer requires +the `wget` command on which the old implementation depended. apt::key { 'puppetlabs': key => '1054B7A24BD6EC30', @@ -138,38 +136,26 @@ names. ### apt::hold -When you wish to hold a package in Puppet is should be done by passing in +When you wish to hold a package in Puppet, it should be done by passing in 'held' as the ensure attribute to the package resource. However, a lot of public modules do not take this into account and generally do not work well with an ensure of 'held'. -There is an additional issue that when Puppet is told to hold a package, it -will hold it at the current version installed, there is no way to tell it in -one go to install a specific version and then hold that version without using -an exec resource that wraps `dpkg --set-selections` or `apt-mark`. +Moreover, when Puppet is told to hold a package, it holds it at the current version installed; there is no way to tell it to both install a specific version **and** hold that version, unless you use an exec resource that wraps `dpkg --set-selections` or `apt-mark`. -At first glance this could also be solved by just passing the version required -to the ensure attribute but that only means that Puppet will install that -version once it processes that package. It does not inform apt that we want -this package to be held. In other words; if another package somehow wants to -upgrade this one (because of a version requirement in a dependency), apt -should not allow it. +At first glance, it seems this issue could also be solved by passing the version required to the ensure attribute---but that only means that Puppet will install that +version after it processes the package. It does not inform apt that we want +this package to be held; that is, should another package want to upgrade this one (because of a version requirement in a dependency, for example), we want apt to refuse. -In order to solve this you can use apt::hold. It's implemented by creating -a preferences file with a priority of 1001, meaning that under normal -circumstances this preference will always win. Because the priority is > 1000 -apt will interpret this as 'this should be the version installed and I am -allowed to downgrade the current package if needed'. +To solve this issue, use apt::hold. Implement this by creating a preferences file with a priority of 1001. Under normal circumstances, this preference will always win. Because the priority is > 1000, apt will maintain the required version, downgrading the current package if necessary. -With this you can now set a package's ensure attribute to 'latest' but still -get the version specified by apt::hold. You can do it like this: +With this, you can now set a package's ensure attribute to 'latest' but get the version specified by apt::hold: apt::hold { 'vim': version => '2:7.3.547-7', } -Since you might just want to hold Vim at version 7.3 and not care about the -rest you can also pass in a version with a glob: +Alternatively, if you want to hold Vim at version 7.3.*, you can pass in a version with a glob: apt::hold { 'vim': version => '2:7.3.*', @@ -206,7 +192,7 @@ Adds an apt source to `/etc/apt/sources.list.d/`. include_deb => true } -If you would like to configure your system so the source is the Puppet Labs APT repository +If you would like to configure your system so the source is the Puppet Labs APT repository: apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', @@ -215,13 +201,19 @@ If you would like to configure your system so the source is the Puppet Labs APT key_server => 'pgp.mit.edu', } +### apt::update + +Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. + +The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs---this should happen when config files get updated or other relevant changes occur. If you set the `always_apt_update` parameter, the update will run on every Puppet run. + ### Facts -There are a few facts included within the apt module describing the state of the apt system: +There are a few facts included in the apt module describing the state of the apt system: -* `apt_updates` - the number of updates available on the system -* `apt_security_updates` - the number of updates which are security updates -* `apt_package_updates` - the package names that are available for update. On Facter 2.0 and newer this will be a list type, in earlier versions it is a comma delimitered string. +* `apt_updates` --- the number of updates available on the system +* `apt_security_updates` --- the number of updates which are security updates +* `apt_package_updates` --- the package names that are available for update. In Facter 2.0 and later, this will be a list type; in earlier versions, it is a comma-delimited string. #### Hiera example
@@ -246,11 +238,11 @@ apt::sources:
 
 ### Testing
 
-The APT module is mostly a collection of defined resource types, which provide reusable logic that can be leveraged to manage APT. It does provide smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources.
+The apt module is mostly a collection of defined resource types, which provide reusable logic that can be leveraged to manage APT. It provides smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources.
 
 #### Example Test
 
-This test will set up a Puppet Labs apt repository. Start by creating a new smoke test in the apt module's test folder. Call it puppetlabs-apt.pp. Inside, declare a single resource representing the Puppet Labs APT source and gpg key
+This test will set up a Puppet Labs APT repository. Start by creating a new smoke test, called puppetlabs-apt.pp, in the apt module's test folder. In this test, declare a single resource representing the Puppet Labs APT source and GPG key:
 
     apt::source { 'puppetlabs':
       location   => 'http://apt.puppetlabs.com',
@@ -259,20 +251,20 @@ This test will set up a Puppet Labs apt repository. Start by creating a new smok
       key_server => 'pgp.mit.edu',
     }
 
-This resource creates an apt source named puppetlabs and gives Puppet information about the repository's location and key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set it directly by adding the release type.
+This resource creates an APT source named puppetlabs and gives Puppet information about the repository's location and the key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set this directly by adding the release type.
 
-Check your smoke test for syntax errors
+Check your smoke test for syntax errors:
 
     $ puppet parser validate tests/puppetlabs-apt.pp
 
-If you receive no output from that command, it means nothing is wrong. Then apply the code
+If you receive no output from that command, it means nothing is wrong. Then, apply the code:
 
     $ puppet apply --verbose tests/puppetlabs-apt.pp
     notice: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]/ensure: defined content as '{md5}3be1da4923fb910f1102a233b77e982e'
     info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update]
     notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events>
 
-The above example used a smoke test to easily lay out a resource declaration and apply it on your system. In production, you may want to declare your APT sources inside the classes where they’re needed.
+The above example uses a smoke test to lay out a resource declaration and apply it on your system. In production, you might want to declare your APT sources inside the classes where they’re needed.
 
 Implementation
 --------------
@@ -281,7 +273,7 @@ Implementation
 
 Adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined behavior (read: universe exploding).
 
-By default this class drops a Pin-file for Backports pinning it to a priority of 200, lower than the normal Debian archive which gets a priority of 500 to ensure your packages with `ensure => latest` don't get magically upgraded from Backports without your explicit say-so.
+By default this class drops a Pin-file for Backports, pinning it to a priority of 200. This is lower than the normal Debian archive, which gets a priority of 500 to ensure that packages with `ensure => latest` don't get magically upgraded from Backports without your explicit permission.
 
 If you raise the priority through the `pin_priority` parameter to *500*, identical to the rest of the Debian mirrors, normal policy goes into effect and the newest version wins/becomes the candidate apt will want to install or upgrade to. This means that if a package is available from Backports it and its dependencies will be pulled in from Backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version.
 

From 93567aef4a376b97d2dc71a0e6eb14a96b201a6e Mon Sep 17 00:00:00 2001
From: Martin Seener 
Date: Fri, 5 Sep 2014 10:14:08 +0200
Subject: [PATCH 361/574] apt::force: Added 2 parameters for automatic
 configuration file handling; fixes #modules-1306

when updating or installing newer packages with apt::force and you have changed previous
configuration files aptitude or apt-get will prompt what to do. You can suppress that
by pre-define the action with cfg_files parameter (new, old or unchanged and its backward
compatible if not defined). With a second optional parameter cfg_missing you can force
your provider to install missing configuration files as well.

Signed-off-by: Martin Seener 

apt::force: Changed selectors used in force.pp to case statements; refs #module-1306

Signed-off-by: Martin Seener 

apt::force: rspec: fixed the failing tests and added validate_re for cfg_files and validate_bool for cfg_missing. Also removed default values for both case statements and only allow pre-defined values or true/false. Furthermore enhanced the README refs #module-1306

Was able to fix the failing rspec tests for the patch.
Thanks to Morgan Haskel.

Signed-off-by: Martin Seener 

Despite the puppetlabs-stdlib documentation says validation_re supports 3 arguments the tests failed telling that only 2 are supported. Fixed this by removing the 3 optional argument; refs #modules-1306

Signed-off-by: Martin Seener 

apt::force: updated readme refs #module-1306

Signed-off-by: Martin Seener 
---
 README.md                  | 14 +++++++--
 manifests/force.pp         | 25 +++++++++++++---
 spec/defines/force_spec.rb | 58 ++++++++++++++++++++++++++++++++++----
 3 files changed, 84 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index 7991404290..c7938a6a88 100644
--- a/README.md
+++ b/README.md
@@ -71,13 +71,21 @@ Installs the build depends of a specified package.
 ### apt::force
 
 Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu.
+The cfg_files parameter controls wether newer or older configuration files should be used or only unchanged configuration files should be updated. Cfg_missing forces the provider to install all missing configuration files. Both are optional.
 
     apt::force { 'glusterfs-server':
-      release => 'unstable',
-      version => '3.0.3',
-      require => Apt::Source['debian_unstable'],
+      release     => 'unstable',
+      version     => '3.0.3',
+      cfg_files   => 'unchanged',
+      cfg_missing => true,
+      require     => Apt::Source['debian_unstable'],
     }
 
+You can additionally set the following attributes:
+
+ * `cfg_files`: "new", "old", "unchanged" or "none" (default). "new" will overwrite all existing configuration files with newer ones, "old" will force usage of all old files and "unchanged" only updates unchanged config files whereas setting "none" will don't do anything but providing backward-compatability with existing puppet manifests.
+ * `cfg_missing`: "true" or "false". Setting cfg_missing to false will provide backward compatability whereas setting true will add an aptitude/apt-get parameter which checks and installs missing configuration files for the selected package.
+
 ### apt_key
 
 A native Puppet type and provider for managing GPG keys for APT is provided by this module.
diff --git a/manifests/force.pp b/manifests/force.pp
index 152bb67354..a73f7ab218 100644
--- a/manifests/force.pp
+++ b/manifests/force.pp
@@ -2,11 +2,16 @@
 # force a package from a specific release
 
 define apt::force(
-  $release = false,
-  $version = false,
-  $timeout = 300
+  $release     = false,
+  $version     = false,
+  $timeout     = 300,
+  $cfg_files   = 'none',
+  $cfg_missing = false,
 ) {
 
+  validate_re($cfg_files, ['^new', '^old', '^unchanged', '^none'])
+  validate_bool($cfg_missing)
+
   $provider = $apt::params::provider
 
   $version_string = $version ? {
@@ -19,6 +24,18 @@
     default => "-t ${release}",
   }
 
+  case $cfg_files {
+    'new':       { $config_files = '-o Dpkg::Options::="--force-confnew"' }
+    'old':       { $config_files = '-o Dpkg::Options::="--force-confold"' }
+    'unchanged': { $config_files = '-o Dpkg::Options::="--force-confdef"' }
+    'none':      { $config_files = '' }
+  }
+
+  case $cfg_missing {
+    true:    { $config_missing = '-o Dpkg::Options::="--force-confmiss"' }
+    false:   { $config_missing = '' }
+  }
+
   if $version == false {
     if $release == false {
       $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'"
@@ -34,7 +51,7 @@
     }
   }
 
-  exec { "${provider} -y ${release_string} install ${name}${version_string}":
+  exec { "${provider} -y ${config_files} ${config_missing} ${release_string} install ${name}${version_string}":
     unless    => $install_check,
     logoutput => 'on_failure',
     timeout   => $timeout,
diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb
index a3a215c0ca..c32c438c59 100644
--- a/spec/defines/force_spec.rb
+++ b/spec/defines/force_spec.rb
@@ -11,13 +11,15 @@
 
   let :default_params do
     {
-      :release => false,
-      :version => false
+      :release     => false,
+      :version     => false,
+      :cfg_files   => 'none',
+      :cfg_missing => false,
     }
   end
 
   describe "when using default parameters" do
-    it { should contain_exec("/usr/bin/apt-get -y  install #{title}").with(
+    it { should contain_exec("/usr/bin/apt-get -y    install #{title}").with(
       :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
       :logoutput => 'on_failure',
       :timeout   => '300'
@@ -28,7 +30,7 @@
     let :params do
       default_params.merge(:release => 'testing')
     end
-    it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with(
+    it { should contain_exec("/usr/bin/apt-get -y   -t #{params[:release]} install #{title}").with(
       :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1"
     ) }
   end
@@ -37,11 +39,41 @@
     let :params do
       default_params.merge(:version => '1')
     end
-    it { should contain_exec("/usr/bin/apt-get -y  install #{title}=#{params[:version]}").with(
+    it { should contain_exec("/usr/bin/apt-get -y    install #{title}=#{params[:version]}").with(
       :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'"
     ) }
   end
 
+  describe "when specifying cfg_files parameter" do
+    let :params do
+      default_params.merge(:cfg_files => 'unchanged')
+    end
+    it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef"   install my_package').with(
+      :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
+    ) }
+  end
+
+  describe "when specifying cfg_missing parameter" do
+    let :params do
+      default_params.merge(:cfg_missing => true)
+    end
+    it { should contain_exec('/usr/bin/apt-get -y  -o Dpkg::Options::="--force-confmiss"  install my_package').with(
+      :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
+    ) }
+  end
+
+  describe "when specifying cfg_files and cfg_missing parameter" do
+   let :params do
+     default_params.merge(
+       :cfg_files   => 'unchanged',
+       :cfg_missing => true
+     )
+   end
+   it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss"  install my_package').with(
+     :unless    => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
+   ) }
+  end
+
   describe "when specifying release and version parameters" do
     let :params do
       default_params.merge(
@@ -49,8 +81,22 @@
         :version => '1'
       )
     end
-    it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with(
+    it { should contain_exec("/usr/bin/apt-get -y   -t #{params[:release]} install #{title}=1").with(
       :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'"
     ) }
   end
+
+  describe "when specifying release, version, cfg_files and cfg_missing parameters" do
+   let :params do
+     default_params.merge(
+       :release     => 'testing',
+       :version     => '1',
+       :cfg_files   => 'unchanged',
+       :cfg_missing => true
+     )
+   end
+   it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" -t testing install my_package=1').with(
+     :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'"
+   ) }
+  end
 end

From 761a4d26c7b05f91d914033236d14a3557e6eab6 Mon Sep 17 00:00:00 2001
From: Daniele Sluijters 
Date: Wed, 24 Sep 2014 15:27:06 -0700
Subject: [PATCH 362/574] Fix a test that broke with #326.

---
 spec/defines/builddep_spec.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb
index 88cdf4fb6e..8836693779 100644
--- a/spec/defines/builddep_spec.rb
+++ b/spec/defines/builddep_spec.rb
@@ -5,7 +5,7 @@
   let(:title) { 'my_package' }
 
   describe "defaults" do
-    it { should contain_exec("apt-builddep-my_package").that_notifies('Exec[apt_update]').with({
+    it { should contain_exec("apt-builddep-my_package").that_requires('Exec[apt_update]').with({
         'command' => "/usr/bin/apt-get -y --force-yes build-dep my_package",
         'logoutput' => 'on_failure'
       })

From 7a192d7bea57990741398cb2fe120b51b7a3fd53 Mon Sep 17 00:00:00 2001
From: Wolf Noble 
Date: Mon, 18 Aug 2014 15:12:55 -0500
Subject: [PATCH 363/574] - add bits for updating apt - fix spec tests to
 include osfamily fact - add spec tests to verify current default behavior
 unimpacted. - manage the update-stamp file in puppet via content rather than
 a served file. - update custom fact to return -1 if the file doesn't exist -
 add spec test for custom fact - refactor to use a variable vs a
 collector/override - document parameters a bit more verbosely - remove empty
 unconstrained fact - Add osfamily fact to backports tests to facilitate
 functional tests on non-debian hosts

---
 README.md                                     |   9 +-
 lib/facter/apt_update_last_success.rb         |  18 +++
 manifests/init.pp                             |  28 +++++
 manifests/update.pp                           |  50 +++++++-
 spec/classes/apt_spec.rb                      |   8 ++
 spec/classes/apt_update_spec.rb               | 109 ++++++++++++++++++
 spec/classes/backports_spec.rb                |  12 +-
 spec/defines/builddep_spec.rb                 |   2 +-
 spec/defines/source_spec.rb                   |   4 +
 .../facter/apt_update_last_success_spec.rb    |  28 +++++
 10 files changed, 260 insertions(+), 8 deletions(-)
 create mode 100644 lib/facter/apt_update_last_success.rb
 create mode 100644 spec/classes/apt_update_spec.rb
 create mode 100644 spec/unit/facter/apt_update_last_success_spec.rb

diff --git a/README.md b/README.md
index c7938a6a88..b0574a7aa0 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,7 @@ The parameters for `apt` are not generally required and are predominantly for de
 
     class { 'apt':
       always_apt_update    => false,
+      apt_update_frequency => undef,
       disable_keys         => undef,
       proxy_host           => false,
       proxy_port           => '8080',
@@ -153,9 +154,9 @@ Moreover, when Puppet is told to hold a package, it holds it at the current vers
 
 At first glance, it seems this issue could also be solved by passing the version required to the ensure attribute---but that only means that Puppet will install that
 version after it processes the package. It does not inform apt that we want
-this package to be held; that is, should another package want to upgrade this one (because of a version requirement in a dependency, for example), we want apt to refuse. 
+this package to be held; that is, should another package want to upgrade this one (because of a version requirement in a dependency, for example), we want apt to refuse.
 
-To solve this issue, use apt::hold. Implement this by creating a preferences file with a priority of 1001. Under normal circumstances, this preference will always win. Because the priority is > 1000, apt will maintain the required version, downgrading the current package if necessary. 
+To solve this issue, use apt::hold. Implement this by creating a preferences file with a priority of 1001. Under normal circumstances, this preference will always win. Because the priority is > 1000, apt will maintain the required version, downgrading the current package if necessary.
 
 With this, you can now set a package's ensure attribute to 'latest' but get the version specified by apt::hold:
 
@@ -211,7 +212,7 @@ If you would like to configure your system so the source is the Puppet Labs APT
 
 ### apt::update
 
-Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. 
+Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages.
 
 The update runs on the first Puppet run after you include the class, then whenever `notify  => Exec['apt_update']` occurs---this should happen when config files get updated or other relevant changes occur. If you set the `always_apt_update` parameter, the update will run on every Puppet run.
 
@@ -222,6 +223,7 @@ There are a few facts included in the apt module describing the state of the apt
 * `apt_updates` --- the number of updates available on the system
 * `apt_security_updates` --- the number of updates which are security updates
 * `apt_package_updates` --- the package names that are available for update. In Facter 2.0 and later, this will be a list type; in earlier versions, it is a comma-delimited string.
+* `apt_update_last_success` --- The date in epochtime that `apt-get update` last ran successfully. This is determined by reading the mtime of the file `/var/lib/apt/periodic/update-success-stamp`. That file is generated by the `/etc/apt/apt.conf.d/15update-stamp` file.
 
 #### Hiera example
 
@@ -332,3 +334,4 @@ A lot of great people have contributed to this module. A somewhat current list f
 * Zach Leslie 
 * Daniele Sluijters 
 * Daniel Paulus 
+* Wolf Noble 
diff --git a/lib/facter/apt_update_last_success.rb b/lib/facter/apt_update_last_success.rb
new file mode 100644
index 0000000000..21c33d5949
--- /dev/null
+++ b/lib/facter/apt_update_last_success.rb
@@ -0,0 +1,18 @@
+require 'facter'
+
+#This is derived from the file /var/lib/apt/periodic/update-success-stamp
+# This is generated upon a successful apt-get update run natively in ubuntu.
+# the Puppetlabs-apt module deploys this same functionality for other debian-ish OSes
+Facter.add('apt_update_last_success') do
+  confine :osfamily => 'Debian'
+  setcode do
+    if File.exists?('/var/lib/apt/periodic/update-success-stamp')
+      #get epoch time
+      lastsuccess = File.mtime('/var/lib/apt/periodic/update-success-stamp').to_i
+      lastsuccess
+    else
+      lastsuccess = -1
+      lastsuccess
+    end
+  end
+end
diff --git a/manifests/init.pp b/manifests/init.pp
index eb8c709bab..89fb68471d 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -5,15 +5,32 @@
 # Parameters:
 #   The parameters listed here are not required in general and were
 #     added for use cases related to development environments.
+#
 #   disable_keys - disables the requirement for all packages to be signed
+#
 #   always_apt_update - rather apt should be updated on every run (intended
 #     for development environments where package updates are frequent)
+#
+#   apt_update_frequency - *string* Supported values:
+#     **always**: Will fire `apt-get update` at every puppet run. Intended to
+#       deprecate the `always_apt_update` parameter.
+#     **daily**: Trigger `apt-get update` if the value of the fact
+#       `apt_update_last_success` is less than current epoch time - 86400.
+#        *notifying the apt_update exec will trigger apt-get update regardless*
+#     **weekly**: Trigger `apt-get update` if the value of the fact
+#       `apt_update_last_success` is less than current epoch time - 604800.
+#        *notifying the apt_update exec will trigger apt-get update regardless*
+#     **reluctantly**: *Default* only run apt-get update if the exec resource `apt_update` is notified.
+#
 #   purge_sources_list - Accepts true or false. Defaults to false If set to
 #     true, Puppet will purge all unmanaged entries from sources.list
+#
 #   purge_sources_list_d - Accepts true or false. Defaults to false. If set
 #     to true, Puppet will purge all unmanaged entries from sources.list.d
+#
 #   update_timeout - Overrides the exec timeout in seconds for apt-get update.
 #     If not set defaults to Exec's default (300)
+#
 #   update_tries - Number of times that `apt-get update` will be tried. Use this
 #     to work around transient DNS and HTTP errors. By default, the command
 #     will only be run once.
@@ -27,6 +44,7 @@
 
 class apt(
   $always_apt_update    = false,
+  $apt_update_frequency = 'reluctantly',
   $disable_keys         = undef,
   $proxy_host           = undef,
   $proxy_port           = '8080',
@@ -44,6 +62,8 @@
     fail('This module only works on Debian or derivatives like Ubuntu')
   }
 
+  $frequency_options = ['always','daily','weekly','reluctantly']
+  validate_re($apt_update_frequency, $frequency_options)
   include apt::params
   include apt::update
 
@@ -61,6 +81,14 @@
     }
   }
 
+  file { '/etc/apt/apt.conf.d/15update-stamp':
+    ensure  => 'file',
+    content => 'APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};',
+    group   => 'root',
+    mode    => '0644',
+    owner   => 'root',
+  }
+
   $root           = $apt::params::root
   $apt_conf_d     = $apt::params::apt_conf_d
   $sources_list_d = $apt::params::sources_list_d
diff --git a/manifests/update.pp b/manifests/update.pp
index 725bb3bea6..9112c9b626 100644
--- a/manifests/update.pp
+++ b/manifests/update.pp
@@ -1,10 +1,58 @@
 class apt::update {
   include apt::params
+  #TODO: to catch if $::apt_update_last_success has the value of -1 here. If we
+  #opt to do this, a info/warn would likely be all you'd need likely to happen
+  #on the first run, but if it's not run in awhile something is likely borked
+  #with apt and we'd want to know about it.
 
+  if $::apt::always_apt_update == false {
+    #if always_apt_update is true there's no point in parsing this logic.
+
+    case $apt::apt_update_frequency {
+      'always': {
+        $_kick_apt = true
+      }
+      'daily': {
+        #compare current date with the apt_update_last_success fact to determine
+        #if we should kick apt_update.
+        $daily_threshold = (strftime('%s') - 86400)
+        if $::apt_update_last_success {
+          if $::apt_update_last_success < $daily_threshold {
+            $_kick_apt = true
+          }
+        } else {
+          #if apt-get update has not successfully run, we should kick apt_update
+          $_kick_apt = true
+        }
+      }
+      'weekly':{
+        #compare current date with the apt_update_last_success fact to determine
+        #if we should kick apt_update.
+        $weekly_threshold = (strftime('%s') - 604800)
+        if $::apt_update_last_success {
+          if ( $::apt_update_last_success < $weekly_threshold ) {
+            $_kick_apt = true
+          }
+        } else {
+          #if apt-get update has not successfully run, we should kick apt_update
+          $_kick_apt = true
+        }
+      }
+      default: {
+        #catches 'recluctantly', and any other value (which should not occur).
+        #do nothing.
+      }
+    }
+  }
+  if $_kick_apt {
+    $_refresh = false
+  } else {
+    $_refresh = true
+  }
   exec { 'apt_update':
     command     => "${apt::params::provider} update",
     logoutput   => 'on_failure',
-    refreshonly => true,
+    refreshonly => $_refresh,
     timeout     => $apt::update_timeout,
     tries       => $apt::update_tries,
     try_sleep   => 1
diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb
index 2c70e3e090..0a1c0a1bd7 100644
--- a/spec/classes/apt_spec.rb
+++ b/spec/classes/apt_spec.rb
@@ -37,6 +37,14 @@
       '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',
+        'mode'  => '0644',
+        'owner' => 'root',
+      }).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',
diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb
new file mode 100644
index 0000000000..d70efd37d1
--- /dev/null
+++ b/spec/classes/apt_update_spec.rb
@@ -0,0 +1,109 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+
+describe 'apt::update', :type => :class do
+  context 'when apt::always_apt_update is true' do
+    #This should completely disable all of this logic. These tests are to guarantee that we don't somehow magically change the behavior.
+    let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+    let (:pre_condition) { "class{'::apt': always_apt_update => true}" }
+    it 'should trigger an apt-get update run' do
+      #set the apt_update exec's refreshonly attribute to false
+      should contain_exec('apt_update').with({'refreshonly' => false })
+    end
+    ['always','daily','weekly','reluctantly'].each do |update_frequency|
+      context "when apt::apt_update_frequency has the value of #{update_frequency}" do
+        { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
+          context "and $::apt_update_last_success indicates #{desc}" do
+            let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } }
+            let (:pre_condition) { "class{'::apt': always_apt_update => true, apt_update_frequency => '#{update_frequency}' }" }
+            it 'should trigger an apt-get update run' do
+              # set the apt_update exec's refreshonly attribute to false
+              should contain_exec('apt_update').with({'refreshonly' => false})
+            end
+          end
+          context 'when $::apt_update_last_success is nil' do
+            let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+            let (:pre_condition) { "class{'::apt': always_apt_update => true, apt_update_frequency => '#{update_frequency}' }" }
+            it 'should trigger an apt-get update run' do
+              #set the apt_update exec\'s refreshonly attribute to false
+              should contain_exec('apt_update').with({'refreshonly' => false})
+            end
+          end
+        end
+      end
+    end
+  end
+
+  context 'when apt::always_apt_update is false' do
+    context "and apt::apt_update_frequency has the value of always" do
+      { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
+        context "and $::apt_update_last_success indicates #{desc}" do
+          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } }
+          let (:pre_condition) { "class{'::apt': always_apt_update => false, apt_update_frequency => 'always' }" }
+          it 'should trigger an apt-get update run' do
+            #set the apt_update exec's refreshonly attribute to false
+            should contain_exec('apt_update').with({'refreshonly' => false})
+          end
+        end
+      end
+      context 'when $::apt_update_last_success is nil' do
+        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+        let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'always' }" }
+        it 'should trigger an apt-get update run' do
+          #set the apt_update exec\'s refreshonly attribute to false
+          should contain_exec('apt_update').with({'refreshonly' => false})
+        end
+      end
+    end
+    context "and apt::apt_update_frequency has the value of reluctantly" do
+      {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
+        context "and $::apt_update_last_success indicates #{desc}" do
+          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval} }
+          let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'reluctantly' }" }
+          it 'should not trigger an apt-get update run' do
+            #don't change the apt_update exec's refreshonly attribute. (it should be true)
+            should contain_exec('apt_update').with({'refreshonly' => true})
+          end
+        end
+      end
+      context 'when $::apt_update_last_success is nil' do
+        let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+        let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'reluctantly' }" }
+        it 'should not trigger an apt-get update run' do
+          #don't change the apt_update exec's refreshonly attribute. (it should be true)
+          should contain_exec('apt_update').with({'refreshonly' => true})
+        end
+      end
+    end
+    ['daily','weekly'].each do |update_frequency|
+      context "and apt::apt_update_frequency has the value of #{update_frequency}" do
+        { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
+          context "and $::apt_update_last_success indicates #{desc}" do
+            let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } }
+            let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" }
+            it 'should trigger an apt-get update run' do
+              #set the apt_update exec\'s refreshonly attribute to false
+              should contain_exec('apt_update').with({'refreshonly' => false})
+            end
+          end
+        end
+        context 'when the $::apt_update_last_success fact has a recent value' do
+          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => Time.now.to_i } }
+          let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" }
+          it 'should not trigger an apt-get update run' do
+            #don't change the apt_update exec\'s refreshonly attribute. (it should be true)
+            should contain_exec('apt_update').with({'refreshonly' => true})
+          end
+        end
+        context 'when $::apt_update_last_success is nil' do
+          let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+          let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" }
+          it 'should trigger an apt-get update run' do
+            #set the apt_update exec\'s refreshonly attribute to false
+            should contain_exec('apt_update').with({'refreshonly' => false})
+          end
+        end
+      end
+    end
+  end
+end
diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb
index 17c86ebbba..18f6337aef 100644
--- a/spec/classes/backports_spec.rb
+++ b/spec/classes/backports_spec.rb
@@ -5,7 +5,8 @@
     let :facts do
       {
         'lsbdistcodename' => 'Karmic',
-        'lsbdistid'       => 'Ubuntu'
+        'lsbdistid'       => 'Ubuntu',
+        'osfamily'        => 'Debian'
       }
     end
 
@@ -36,7 +37,8 @@
     let :facts do
       {
         'lsbdistcodename' => 'Karmic',
-        'lsbdistid'       => 'Ubuntu'
+        'lsbdistid'       => 'Ubuntu',
+        'osfamily'        => 'Debian'
       }
     end
 
@@ -57,6 +59,7 @@
       {
         'lsbdistcodename' => 'Squeeze',
         'lsbdistid'       => 'Debian',
+        'osfamily'        => 'Debian'
       }
     end
 
@@ -77,6 +80,7 @@
       {
         'lsbdistcodename' => 'debian',
         'lsbdistid'       => 'LinuxMint',
+        'osfamily'        => 'Debian'
       }
     end
 
@@ -97,6 +101,7 @@
       {
         'lsbdistcodename' => 'qiana',
         'lsbdistid'       => 'LinuxMint',
+        'osfamily'        => 'Debian'
       }
     end
 
@@ -116,7 +121,8 @@
     let :facts do
       {
         'lsbdistcodename' => 'Squeeze',
-        'lsbdistid'       => 'Debian'
+        'lsbdistid'       => 'Debian',
+        'osfamily'        => 'Debian'
       }
     end
 
diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb
index 8836693779..41152d5c9b 100644
--- a/spec/defines/builddep_spec.rb
+++ b/spec/defines/builddep_spec.rb
@@ -1,7 +1,7 @@
 require 'spec_helper'
 describe 'apt::builddep', :type => :define do
 
-  let(:facts) { { :lsbdistid => 'Debian' } }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
   let(:title) { 'my_package' }
 
   describe "defaults" do
diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb
index 960bb620fc..8327ed2d72 100644
--- a/spec/defines/source_spec.rb
+++ b/spec/defines/source_spec.rb
@@ -12,6 +12,7 @@
       {
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
+        :osfamily        => 'Debian'
       }
     end
 
@@ -36,6 +37,7 @@
       {
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
+        :osfamily        => 'Debian'
       }
     end
     let :params do
@@ -95,6 +97,7 @@
       {
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
+        :osfamily        => 'Debian'
       }
     end
     let :params do
@@ -114,6 +117,7 @@
       let :facts do
         {
           :lsbdistid       => 'Debian',
+          :osfamily        => 'Debian'
         }
       end
 
diff --git a/spec/unit/facter/apt_update_last_success_spec.rb b/spec/unit/facter/apt_update_last_success_spec.rb
new file mode 100644
index 0000000000..08774cd012
--- /dev/null
+++ b/spec/unit/facter/apt_update_last_success_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe 'apt_update_last_success fact' do
+  subject { Facter.fact(:apt_update_last_success).value }
+  after(:each) { Facter.clear }
+
+  describe 'on Debian based distro which has not yet created the update-success-stamp file' do
+    before {
+      Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+      File.stubs(:exists?).returns false
+    }
+    it 'should have a value of -1' do
+      should == -1
+    end
+  end
+
+  describe 'on Debian based distro which has created the update-success-stamp' do
+    before {
+      Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+      File.stubs(:exists?).returns true
+      File.stubs(:mtime).returns 1407660561
+    }
+    it 'should have the value of the mtime of the file' do
+      should == 1407660561
+    end
+  end
+
+end

From 87f3f1023cad452937d3b4c0bad84c69b442ffa1 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Wed, 1 Oct 2014 12:55:41 -0500
Subject: [PATCH 364/574] Don't truncate to short keys in the type

You should be able to create/delete keys using the long key to avoid
collisions, and truncating in the type makes that not work.
---
 lib/puppet/provider/apt_key/apt_key.rb   |  7 ++++++-
 lib/puppet/type/apt_key.rb               |  6 +-----
 spec/acceptance/apt_key_provider_spec.rb | 21 +++++++++++++--------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb
index e5020fe27d..3ef9431508 100644
--- a/lib/puppet/provider/apt_key/apt_key.rb
+++ b/lib/puppet/provider/apt_key/apt_key.rb
@@ -57,7 +57,12 @@ def self.instances
   def self.prefetch(resources)
     apt_keys = instances
     resources.keys.each do |name|
-      if provider = apt_keys.find{ |key| key.name == name }
+      if name.length == 16
+        shortname=name[8..-1]
+      else
+        shortname=name
+      end
+      if provider = apt_keys.find{ |key| key.name == shortname }
         resources[name].provider = provider
       end
     end
diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb
index e2cb8d9cf9..f55247314c 100644
--- a/lib/puppet/type/apt_key.rb
+++ b/lib/puppet/type/apt_key.rb
@@ -36,11 +36,7 @@
       else
         id = value.upcase
       end
-      if id.length == 16
-        id[8..-1]
-      else
-        id
-      end
+      id
     end
   end
 
diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb
index 0f20174d06..69f7a930f6 100644
--- a/spec/acceptance/apt_key_provider_spec.rb
+++ b/spec/acceptance/apt_key_provider_spec.rb
@@ -1,14 +1,19 @@
 require 'spec_helper_acceptance'
 
-PUPPETLABS_GPG_KEY_ID   = '4BD6EC30'
-PUPPETLABS_APT_URL      = 'apt.puppetlabs.com'
-PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg'
-CENTOS_GPG_KEY_ID       = 'C105B9DE'
-CENTOS_REPO_URL         = 'ftp.cvut.cz/centos'
-CENTOS_GPG_KEY_FILE     = 'RPM-GPG-KEY-CentOS-6'
+PUPPETLABS_GPG_KEY_ID        = '4BD6EC30'
+PUPPETLABS_GPG_LONG_KEY_ID   = '1054B7A24BD6EC30'
+PUPPETLABS_APT_URL           = 'apt.puppetlabs.com'
+PUPPETLABS_GPG_KEY_FILE      = 'pubkey.gpg'
+CENTOS_GPG_KEY_ID            = 'C105B9DE'
+CENTOS_REPO_URL              = 'ftp.cvut.cz/centos'
+CENTOS_GPG_KEY_FILE          = 'RPM-GPG-KEY-CentOS-6'
 
 describe 'apt_key' do
   before(:each) do
+    # Delete twice to make sure everything is cleaned
+    # up after the short key collision
+    shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}",
+          :acceptable_exit_codes => [0,1,2])
     shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}",
           :acceptable_exit_codes => [0,1,2])
   end
@@ -36,7 +41,7 @@
           EOS
 
           apply_manifest(pp, :catch_failures => true)
-          apply_manifest(pp, :catch_failures => true)
+          apply_manifest(pp, :catch_changes => true)
           shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
         end
       end
@@ -69,7 +74,7 @@
 
         # Install the key first
         shell("apt-key adv --keyserver keyserver.ubuntu.com \
-              --recv-keys #{PUPPETLABS_GPG_KEY_ID}")
+              --recv-keys #{PUPPETLABS_GPG_LONG_KEY_ID}")
         shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
 
         # Time to remove it using Puppet

From febda27623b2033a1401c8c55e575bfba8997c85 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Wed, 1 Oct 2014 13:46:14 -0500
Subject: [PATCH 365/574] We aren't truncating in the type

So don't check for truncated IDs in the type test.
---
 spec/unit/puppet/type/apt_key_spec.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb
index c29f82b088..e661ba1bdb 100644
--- a/spec/unit/puppet/type/apt_key_spec.rb
+++ b/spec/unit/puppet/type/apt_key_spec.rb
@@ -41,7 +41,7 @@
       :id => 'FFFFFFFF4BD6EC30'
     )}
     it 'id is set' do
-      resource[:id].should eq '4BD6EC30'
+      resource[:id].should eq 'FFFFFFFF4BD6EC30'
     end
   end
 
@@ -68,7 +68,7 @@
       :id => '0xFFFFFFFF4BD6EC30'
     )}
     it 'id is set' do
-      resource[:id].should eq '4BD6EC30'
+      resource[:id].should eq 'FFFFFFFF4BD6EC30'
     end
   end
 

From a3d4822920ac0fb21f3443e0860f83f7daf04fbe Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Thu, 2 Oct 2014 17:21:46 -0500
Subject: [PATCH 366/574] apt-key doesn't add long keys in deb6

You can feed the command the long key, but it truncates it to add the
key. This causes issues due to the short-key collision with the
puppetlabs key. So, test with a different key on debian 6.
---
 spec/acceptance/apt_key_provider_spec.rb | 26 ++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb
index 69f7a930f6..3f2536c7f0 100644
--- a/spec/acceptance/apt_key_provider_spec.rb
+++ b/spec/acceptance/apt_key_provider_spec.rb
@@ -64,6 +64,32 @@
 
   describe 'ensure =>' do
     context 'absent' do
+      it 'is removed' do
+        pp = <<-EOS
+        apt_key { 'centos':
+          id     => '#{CENTOS_GPG_KEY_ID}',
+          ensure => 'absent',
+        }
+        EOS
+
+        # Install the key first
+        shell("apt-key adv --keyserver keyserver.ubuntu.com \
+              --recv-keys #{CENTOS_GPG_KEY_ID}")
+        shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}")
+
+        # Time to remove it using Puppet
+        apply_manifest(pp, :catch_failures => true)
+        apply_manifest(pp, :catch_failures => true)
+
+        shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}",
+              :acceptable_exit_codes => [1])
+
+        shell("apt-key adv --keyserver keyserver.ubuntu.com \
+              --recv-keys #{CENTOS_GPG_KEY_ID}")
+      end
+    end
+
+    context 'absent, added with long key', :unless => (fact('operatingsystem') == 'Debian' and fact('operatingsystemmajrelease') == '6') do
       it 'is removed' do
         pp = <<-EOS
         apt_key { 'puppetlabs':

From c41e71d0c2fce83627f0e3a4de242919fbb996d3 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Fri, 3 Oct 2014 19:30:33 -0400
Subject: [PATCH 367/574] Fix for future parser support

---
 manifests/update.pp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/manifests/update.pp b/manifests/update.pp
index 9112c9b626..8cb38b226a 100644
--- a/manifests/update.pp
+++ b/manifests/update.pp
@@ -19,6 +19,8 @@
         if $::apt_update_last_success {
           if $::apt_update_last_success < $daily_threshold {
             $_kick_apt = true
+          } else {
+            $_kick_apt = false
           }
         } else {
           #if apt-get update has not successfully run, we should kick apt_update
@@ -32,6 +34,8 @@
         if $::apt_update_last_success {
           if ( $::apt_update_last_success < $weekly_threshold ) {
             $_kick_apt = true
+          } else {
+            $_kick_apt = false
           }
         } else {
           #if apt-get update has not successfully run, we should kick apt_update
@@ -41,6 +45,7 @@
       default: {
         #catches 'recluctantly', and any other value (which should not occur).
         #do nothing.
+        $_kick_apt = false
       }
     }
   }

From 049e993511dfb3d9de2bd436a867917d17f2eab2 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Mon, 6 Oct 2014 16:41:14 -0400
Subject: [PATCH 368/574] Missed one case for _kick_apt needed for strict
 variables

---
 manifests/update.pp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/manifests/update.pp b/manifests/update.pp
index 8cb38b226a..d9b338d952 100644
--- a/manifests/update.pp
+++ b/manifests/update.pp
@@ -48,7 +48,10 @@
         $_kick_apt = false
       }
     }
+  } else {
+    $_kick_apt = false
   }
+
   if $_kick_apt {
     $_refresh = false
   } else {

From c5edc86c3c03c0f61b1fb1bc1497f9e26a9a6ab9 Mon Sep 17 00:00:00 2001
From: Morgan Haskel 
Date: Mon, 6 Oct 2014 19:44:19 -0400
Subject: [PATCH 369/574] add --force-yes so deb7 doesn't hang

---
 spec/acceptance/apt_spec.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb
index 3c97421ab0..3011f9dfde 100644
--- a/spec/acceptance/apt_spec.rb
+++ b/spec/acceptance/apt_spec.rb
@@ -38,7 +38,7 @@ class { 'apt':
     end
     it 'should still work' do
       shell('apt-get update')
-      shell('apt-get -y upgrade')
+      shell('apt-get -y --force-yes upgrade')
     end
   end
 

From b2c40388e5202604d90c4f13897c2ba980dccd80 Mon Sep 17 00:00:00 2001
From: jbondpdx 
Date: Wed, 8 Oct 2014 11:09:54 -0700
Subject: [PATCH 370/574] DOC-249 Revised and updated apt readme

Revised and updated apt readme. Post-merge-conflict edition.
---
 README.md | 467 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 249 insertions(+), 218 deletions(-)

diff --git a/README.md b/README.md
index b0574a7aa0..d07c7a2fbc 100644
--- a/README.md
+++ b/README.md
@@ -1,296 +1,327 @@
-apt
-===
+# apt
 
 [![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-apt.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-apt)
 
-Overview
---------
+## Overview
 
-The apt module provides a simple interface for managing APT source, key, and definitions with Puppet.
+The apt module provides a simple interface for managing Apt source, key, and definitions with Puppet.
 
-Module Description
-------------------
+## Module Description
 
 The apt module automates obtaining and installing software packages on \*nix systems.
 
-***Note:** While this module allows the use of short keys, we **strongly** recommend that you **do not use short keys**, as they pose a serious security issue by opening you up to collision attacks.
+**Note**: While this module allows the use of short keys, **we urge you NOT to use short keys**, as they pose a serious security issue by opening you up to collision attacks.
 
-Setup
------
+## Setup
 
-**What apt affects:**
+### What apt affects:
 
-* package/service/configuration files for APT
-    * NOTE: Setting the `purge_preferences` or `purge_preferences_d` parameters to 'true' will destroy any existing configuration that was not declared with Puppet. The default for these parameters is 'false'.
-* your system's `sources.list` file and `sources.list.d` directory
-    * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'.
-* system repositories
-* authentication keys
+* Package/service/configuration files for Apt
+* Your system's `sources.list` file and `sources.list.d` directory
+* System repositories
+* Authentication keys
 
-### Beginning with apt
-
-To begin using the apt module with default parameters, declare the class.
-
-    include apt
-
-Puppet code that uses anything from the apt module requires that the core apt class be declared.
-
-Usage
------
-
-Using the apt module consists predominantly of declaring classes that provide the desired functionality and features.
-
-### apt
-
-`apt` provides a number of common resources and options that are shared by the various defined types in this module, so you **must always** include this class in your manifests.
-
-The parameters for `apt` are not generally required and are predominantly for development environment use cases.
-
-    class { 'apt':
-      always_apt_update    => false,
-      apt_update_frequency => undef,
-      disable_keys         => undef,
-      proxy_host           => false,
-      proxy_port           => '8080',
-      purge_sources_list   => false,
-      purge_sources_list_d => false,
-      purge_preferences_d  => false,
-      update_timeout       => undef,
-      fancy_progress       => undef
-    }
-
-Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content.
-
-If you declare your apt class with `purge_sources_list`, `purge_sources_list_d`, `purge_preferences` and `purge_preferences_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet.
-
-### apt::builddep
-
-Installs the build depends of a specified package.
-
-    apt::builddep { 'glusterfs-server': }
-
-### apt::force
-
-Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu.
-The cfg_files parameter controls wether newer or older configuration files should be used or only unchanged configuration files should be updated. Cfg_missing forces the provider to install all missing configuration files. Both are optional.
-
-    apt::force { 'glusterfs-server':
-      release     => 'unstable',
-      version     => '3.0.3',
-      cfg_files   => 'unchanged',
-      cfg_missing => true,
-      require     => Apt::Source['debian_unstable'],
-    }
-
-You can additionally set the following attributes:
-
- * `cfg_files`: "new", "old", "unchanged" or "none" (default). "new" will overwrite all existing configuration files with newer ones, "old" will force usage of all old files and "unchanged" only updates unchanged config files whereas setting "none" will don't do anything but providing backward-compatability with existing puppet manifests.
- * `cfg_missing`: "true" or "false". Setting cfg_missing to false will provide backward compatability whereas setting true will add an aptitude/apt-get parameter which checks and installs missing configuration files for the selected package.
+**Note**: Setting the apt module's `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will **destroy** any existing content that was not declared with Puppet. The default for these parameters is 'false'.
 
-### apt_key
+### Beginning with apt
 
-A native Puppet type and provider for managing GPG keys for APT is provided by this module.
+To begin using the apt module with default parameters, declare the class with `include apt`.
 
-    apt_key { 'puppetlabs':
-      ensure => 'present',
-      id     => '1054B7A24BD6EC30',
-    }
+Any Puppet code that uses anything from the apt module requires that the core apt class be declared.
 
-You can additionally set the following attributes:
+## Usage
 
- * `source`: HTTP, HTTPS or FTP location of a GPG key or path to a file on the
-             target host;
- * `content`: Instead of pointing to a file, pass the key in as a string;
- * `server`: The GPG key server to use. It defaults to *keyserver.ubuntu.com*;
- * `keyserver_options`: Additional options to pass to `--keyserver`.
+Using the apt module consists predominantly of declaring classes and defined types that provide the desired functionality and features. This module provides common resources and options that are shared by the various defined types in the apt module, so you **must always** include this class in your manifests.
 
-Because apt_key is a native type, it can be used in and queried for with MCollective.
+```
+class { 'apt':
+  always_apt_update    => false,
+  apt_update_frequency => undef,
+  disable_keys         => undef,
+  proxy_host           => false,
+  proxy_port           => '8080',
+  purge_sources_list   => false,
+  purge_sources_list_d => false,
+  purge_preferences_d  => false,
+  update_timeout       => undef,
+  fancy_progress       => undef
+}
+```
 
-### apt::key
+## Reference
 
-Adds a key to the list of keys used by APT to authenticate packages. This type uses the aforementioned `apt_key` native type. As such, it no longer requires
-the `wget` command on which the old implementation depended.
+### Classes
 
-    apt::key { 'puppetlabs':
-      key        => '1054B7A24BD6EC30',
-      key_server => 'pgp.mit.edu',
-    }
+* `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory, but it does its best to respect existing content.
 
-    apt::key { 'jenkins':
-      key        => '9B7D32F2D50582E6',
-      key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
-    }
+  If you declare your apt class with `purge_sources_list`, `purge_sources_list_d`, `purge_preferences` and `purge_preferences_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet.
+  
+* `apt::backports`: This class adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined and potentially serious behavior.
 
-### apt::pin
+  By default, this class drops a pin-file for backports, pinning it to a priority of 200. This is lower than the normal Debian archive, which gets a priority of 500 to ensure that packages with `ensure => latest` don't get magically upgraded from backports without your explicit permission.
 
-Adds an apt pin for a certain release.
+  If you raise the priority through the `pin_priority` parameter to 500---identical to the rest of the Debian mirrors---normal policy goes into effect, and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version.
 
-    apt::pin { 'karmic': priority => 700 }
-    apt::pin { 'karmic-updates': priority => 700 }
-    apt::pin { 'karmic-security': priority => 700 }
+* `apt::params`: Sets defaults for the apt module parameters.
 
-Note you can also specifying more complex pins using distribution properties.
+* `apt::release`: Sets the default Apt release. This class is particularly useful when using repositories that are unstable in Ubuntu, such as Debian.
 
-    apt::pin { 'stable':
-      priority        => -10,
-      originator      => 'Debian',
-      release_version => '3.0',
-      component       => 'main',
-      label           => 'Debian'
-    }
+  ```
+  class { 'apt::release':
+    release_id => 'precise',
+  }
+  ```  
 
-If you wish to pin a number of packages you may specify the packages as a space
-delimited string using the `packages` attribute or pass in an array of package
-names.
+* `apt::unattended_updates`: This class manages the unattended-upgrades package and related configuration files for Ubuntu and Debian systems. You can configure the class to automatically upgrade all new package releases or just security releases.
 
-### apt::hold
+  ```
+  apt::unattended_upgrades {
+    origins             = $::apt::params::origins,
+    blacklist           = [],
+    update              = '1',
+    download            = '1',
+    upgrade             = '1',
+    autoclean           = '7',
+  }
+  ```
+  
+* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify  => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set the `always_apt_update` parameter to 'true', the update runs on every Puppet run.
 
-When you wish to hold a package in Puppet, it should be done by passing in
-'held' as the ensure attribute to the package resource. However, a lot of
-public modules do not take this into account and generally do not work well
-with an ensure of 'held'.
+### Types
 
-Moreover, when Puppet is told to hold a package, it holds it at the current version installed; there is no way to tell it to both install a specific version **and** hold that version, unless you use an exec resource that wraps `dpkg --set-selections` or `apt-mark`.
+* `apt_key`
 
-At first glance, it seems this issue could also be solved by passing the version required to the ensure attribute---but that only means that Puppet will install that
-version after it processes the package. It does not inform apt that we want
-this package to be held; that is, should another package want to upgrade this one (because of a version requirement in a dependency, for example), we want apt to refuse.
+  A native Puppet type and provider for managing GPG keys for Apt is provided by this module.
 
-To solve this issue, use apt::hold. Implement this by creating a preferences file with a priority of 1001. Under normal circumstances, this preference will always win. Because the priority is > 1000, apt will maintain the required version, downgrading the current package if necessary.
+  ```
+  apt_key { 'puppetlabs':
+    ensure => 'present',
+    id     => '1054B7A24BD6EC30',
+  }
+  ```
 
-With this, you can now set a package's ensure attribute to 'latest' but get the version specified by apt::hold:
+  You can additionally set the following attributes:
 
-    apt::hold { 'vim':
-      version => '2:7.3.547-7',
-    }
+   * `source`: HTTP, HTTPS or FTP location of a GPG key or path to a file on the target host.
+   * `content`: Instead of pointing to a file, pass the key in as a string.
+   * `server`: The GPG key server to use. It defaults to *keyserver.ubuntu.com*.
+   * `keyserver_options`: Additional options to pass to `--keyserver`.
 
-Alternatively, if you want to hold Vim at version 7.3.*, you can pass in a version with a glob:
+  Because apt_key is a native type, you can use it and query for it with MCollective. 
 
-    apt::hold { 'vim':
-      version => '2:7.3.*',
-    }
-
-### apt::ppa
-
-Adds a ppa repository using `add-apt-repository`.
+### Defined Types
 
-    apt::ppa { 'ppa:drizzle-developers/ppa': }
+* `apt::builddep`: Installs the build dependencies of a specified package.
 
-### apt::release
+  `apt::builddep { 'glusterfs-server': }`
+    
+* `apt::conf`: Specifies a custom configuration file. The priority defaults to 50, but you can set the priority parameter to load the file earlier or later. The content parameter passes specified content, if any, into the file resource.
 
-Sets the default apt release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu.
-
-    class { 'apt::release':
-      release_id => 'precise',
-    }
+* `apt::hold`: Holds a specific version of a package. You can hold a package to a full version or a partial version.
 
-### apt::source
-
-Adds an apt source to `/etc/apt/sources.list.d/`.
-
-    apt::source { 'debian_unstable':
-      comment           => 'This is the iWeb Debian unstable mirror',
-      location          => 'http://debian.mirror.iweb.ca/debian/',
-      release           => 'unstable',
-      repos             => 'main contrib non-free',
-      required_packages => 'debian-keyring debian-archive-keyring',
-      key               => '8B48AD6246925553',
-      key_server        => 'subkeys.pgp.net',
-      pin               => '-10',
-      include_src       => true,
-      include_deb       => true
-    }
+  To set a package's ensure attribute to 'latest' but get the version specified by `apt::hold`:
 
-If you would like to configure your system so the source is the Puppet Labs APT repository:
+  ```
+  apt::hold { 'vim':
+    version => '2:7.3.547-7',
+  }
+  ```
+
+  Alternatively, if you want to hold your package at a partial version, you can use a wildcard. For example, you can hold Vim at version 7.3.*:
+
+
+  ```
+  apt::hold { 'vim':
+    version => '2:7.3.*',
+  }
+  ```
+
+* `apt::force`: Forces a package to be installed from a specific release. This is particularly useful when using repositories that are unstable in Ubuntu, such as Debian.
+
+  ```
+  apt::force { 'glusterfs-server':
+    release     => 'unstable',
+    version     => '3.0.3',
+    cfg_files   => 'unchanged',
+    cfg_missing => true,
+    require => Apt::Source['debian_unstable'],
+  }
+  ```
 
-    apt::source { 'puppetlabs':
-      location   => 'http://apt.puppetlabs.com',
-      repos      => 'main',
-      key        => '1054B7A24BD6EC30',
-      key_server => 'pgp.mit.edu',
+  Valid values for `cfg_files` are:
+    * 'new': Overwrites all existing configuration files with newer ones.
+    * 'old': Forces usage of all old files.
+    * 'unchanged: Updates only unchanged config files.
+    * 'none': Provides backward-compatibility with existing Puppet manifests.
+   
+  Valid values for `cfg_missing` are 'true', 'false'. Setting this to 'false' provides backward compatability; setting it to 'true' checks for and installs missing configuration files for the selected package.
+
+* `apt::key`: Adds a key to the list of keys used by Apt to authenticate packages. This type uses the aforementioned `apt_key` native type. As such, it no longer requires the `wget` command on which the old implementation depended.
+
+  ```
+  apt::key { 'puppetlabs':
+    key        => '1054B7A24BD6EC30',
+    key_server => 'pgp.mit.edu',
+  }
+
+  apt::key { 'jenkins':
+    key        => '9B7D32F2D50582E6',
+    key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
+  }
+  ```
+
+* `apt::pin`: Defined type that adds an Apt pin for a certain release.
+
+  ```
+  apt::pin { 'karmic': priority => 700 }
+  apt::pin { 'karmic-updates': priority => 700 }
+  apt::pin { 'karmic-security': priority => 700 }
+  ```
+
+  Note that you can also specify more complex pins using distribution properties.
+
+  ```
+  apt::pin { 'stable':
+    priority        => -10,
+    originator      => 'Debian',
+    release_version => '3.0',
+    component       => 'main',
+    label           => 'Debian'
+  }
+  ```  
+
+  If you want to pin a number of packages, you can specify the packages as a space-delimited string using the `packages` attribute, or you can pass in an array of package names.
+
+* `apt::ppa`: Adds a PPA repository using `add-apt-repository`. For example, `apt::ppa { 'ppa:drizzle-developers/ppa': }`.
+
+* `apt::source`: Adds an Apt source to `/etc/apt/sources.list.d/`. For example:
+
+  ```
+  apt::source { 'debian_unstable':
+    comment           => 'This is the iWeb Debian unstable mirror',
+    location          => 'http://debian.mirror.iweb.ca/debian/',
+    release           => 'unstable',
+    repos             => 'main contrib non-free',
+    required_packages => 'debian-keyring debian-archive-keyring',
+    key               => '8B48AD6246925553',
+    key_server        => 'subkeys.pgp.net',
+    pin               => '-10',
+    include_src       => true,
+    include_deb       => true
+  }
+  ```  
+
+  For example, to configure your system so the source is the Puppet Labs Apt repository:
+
+  ```
+  apt::source { 'puppetlabs':
+    location   => 'http://apt.puppetlabs.com',
+    repos      => 'main',
+    key        => '1054B7A24BD6EC30',
+    key_server => 'pgp.mit.edu',
     }
-
-### apt::update
-
-Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages.
-
-The update runs on the first Puppet run after you include the class, then whenever `notify  => Exec['apt_update']` occurs---this should happen when config files get updated or other relevant changes occur. If you set the `always_apt_update` parameter, the update will run on every Puppet run.
+  ```
 
 ### Facts
 
-There are a few facts included in the apt module describing the state of the apt system:
+The apt module includes a few facts to describe the state of the Apt system:
 
-* `apt_updates` --- the number of updates available on the system
-* `apt_security_updates` --- the number of updates which are security updates
-* `apt_package_updates` --- the package names that are available for update. In Facter 2.0 and later, this will be a list type; in earlier versions, it is a comma-delimited string.
-* `apt_update_last_success` --- The date in epochtime that `apt-get update` last ran successfully. This is determined by reading the mtime of the file `/var/lib/apt/periodic/update-success-stamp`. That file is generated by the `/etc/apt/apt.conf.d/15update-stamp` file.
+* `apt_updates`: The number of updates available on the system
+* `apt_security_updates`: The number of updates which are security updates
+* `apt_package_updates`: The package names that are available for update. In Facter 2.0 and later, this will be a list type; in earlier versions, it is a comma-delimited string.
+* `apt_update_last_success`: The date, in epochtime, of the most recent successful `apt-get update` run. This is determined by reading the mtime of  /var/lib/apt/periodic/update-success-stamp.
 
 #### Hiera example
+
+```
 
 apt::sources:
   'debian_unstable':
-      location: 'http://debian.mirror.iweb.ca/debian/'
-      release: 'unstable'
-      repos: 'main contrib non-free'
-      required_packages: 'debian-keyring debian-archive-keyring'
-      key: '9AA38DCD55BE302B'
-      key_server: 'subkeys.pgp.net'
-      pin: '-10'
-      include_src: 'true'
-      include_deb: 'true'
+    location: 'http://debian.mirror.iweb.ca/debian/'
+    release: 'unstable'
+    repos: 'main contrib non-free'
+    required_packages: 'debian-keyring debian-archive-keyring'
+    key: '9AA38DCD55BE302B'
+    key_server: 'subkeys.pgp.net'
+    pin: '-10'
+    include_src: 'true'
+    include_deb: 'true'
 
   'puppetlabs':
-      location: 'http://apt.puppetlabs.com'
-      repos: 'main'
-      key: '1054B7A24BD6EC30'
-      key_server: 'pgp.mit.edu'
+    location: 'http://apt.puppetlabs.com'
+    repos: 'main'
+    key: '1054B7A24BD6EC30'
+    key_server: 'pgp.mit.edu'
 
+``` + +### Parameters + +#### apt + +* `always_apt_update`: Set to 'true' to update Apt on every run. This setting is intended for development environments where package updates are frequent. Defaults to 'false'. +* `apt_update_frequency`: Sets the run frequency for `apt-get update`. Defaults to 'reluctantly'. Accepts the following values: + * 'always': Runs update at every Puppet run. + * 'daily': Runs update daily; that is, `apt-get update` runs if the value of `apt_update_last_success` is less than current epoch time - 86400. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. + * 'weekly': Runs update weekly; that is, `apt-get update` runs if the value of `apt_update_last_success` is less than current epoch time - 604800. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. + * 'reluctantly': Only runs `apt-get update` if the exec resource `apt_update` is notified. This is the default setting. +* `disable_keys`: Disables the requirement for all packages to be signed. +* `proxy_host`: Configures a proxy host and stores the configuration in /etc/apt/apt.conf.d/01proxy. +* `proxy_port`: Configures a proxy port and stores the configuration in /etc/apt/apt.conf.d/01proxy. +* `purge_sources_list`: If set to 'true', Puppet purges all unmanaged entries from sources.list. Accepts 'true' or 'false'. Defaults to 'false'. +* `purge_sources_list_d`: If set to 'true', Puppet purges all unmanaged entries from sources.list.d. Accepts 'true' or 'false'. Defaults to 'false'. +* `update_timeout`: Overrides the exec timeout in seconds for `apt-get update`. Defaults to exec default (300). +* `update_tries`: Sets how many times to attempt running `apt-get update`. Use this to work around transient DNS and HTTP errors. By default, the command runs only once. +* `sources`: Passes a hash to create_resource to make new `apt::source` resources. +* `fancy_progress`: Enables fancy progress bars for apt. Accepts 'true', 'false'. Defaults to 'false'. + +####apt::unattended_upgrades + +* `origins`: The repositories from which to automatically upgrade included packages. +* `blacklist`: A list of packages to **not** automatically upgrade. +* `update`: How often, in days, to run `apt-get update`. +* `download`: How often, in days, to run `apt-get upgrade --download-only`. +* `upgrade`: How often, in days, to upgrade packages included in the origins list. +* `autoclean`: How often, in days, to run `apt-get autoclean`. ### Testing -The apt module is mostly a collection of defined resource types, which provide reusable logic that can be leveraged to manage APT. It provides smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. +The apt module is mostly a collection of defined resource types, which provide reusable logic for managing Apt. It provides smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. #### Example Test -This test will set up a Puppet Labs APT repository. Start by creating a new smoke test, called puppetlabs-apt.pp, in the apt module's test folder. In this test, declare a single resource representing the Puppet Labs APT source and GPG key: +This test sets up a Puppet Labs Apt repository. Start by creating a new smoke test, called puppetlabs-apt.pp, in the apt module's test folder. In this test, declare a single resource representing the Puppet Labs Apt source and GPG key: - apt::source { 'puppetlabs': - location => 'http://apt.puppetlabs.com', - repos => 'main', - key => '1054B7A24BD6EC30', - key_server => 'pgp.mit.edu', - } +``` +apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '1054B7A24BD6EC30', + key_server => 'pgp.mit.edu', +} +``` -This resource creates an APT source named puppetlabs and gives Puppet information about the repository's location and the key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set this directly by adding the release type. +This resource creates an Apt source named puppetlabs and gives Puppet information about the repository's location and the key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set this directly by adding the release type. Check your smoke test for syntax errors: - $ puppet parser validate tests/puppetlabs-apt.pp +`$ puppet parser validate tests/puppetlabs-apt.pp` If you receive no output from that command, it means nothing is wrong. Then, apply the code: - $ puppet apply --verbose tests/puppetlabs-apt.pp - notice: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]/ensure: defined content as '{md5}3be1da4923fb910f1102a233b77e982e' - info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update] - notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events> - -The above example uses a smoke test to lay out a resource declaration and apply it on your system. In production, you might want to declare your APT sources inside the classes where they’re needed. - -Implementation --------------- - -### apt::backports - -Adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined behavior (read: universe exploding). - -By default this class drops a Pin-file for Backports, pinning it to a priority of 200. This is lower than the normal Debian archive, which gets a priority of 500 to ensure that packages with `ensure => latest` don't get magically upgraded from Backports without your explicit permission. +``` +$ puppet apply --verbose tests/puppetlabs-apt.pp +notice: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]/ensure: defined content as '{md5}3be1da4923fb910f1102a233b77e982e' +info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update] +notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events> +``` -If you raise the priority through the `pin_priority` parameter to *500*, identical to the rest of the Debian mirrors, normal policy goes into effect and the newest version wins/becomes the candidate apt will want to install or upgrade to. This means that if a package is available from Backports it and its dependencies will be pulled in from Backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. +The above example uses a smoke test to lay out a resource declaration and apply it on your system. In production, you might want to declare your Apt sources inside the classes where they’re needed. Limitations ----------- -This module should work across all versions of Debian/Ubuntu and support all major APT repository management features. +This module should work across all versions of Debian/Ubuntu and support all major Apt repository management features. Development ------------ From b10415be63071ba9a8d387c314f9576eb4e0350e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 8 Oct 2014 18:18:39 -0400 Subject: [PATCH 371/574] Update pe compatibility --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index f6ea55e160..1403e1406d 100644 --- a/metadata.json +++ b/metadata.json @@ -27,7 +27,7 @@ "requirements": [ { "name": "pe", - "version_requirement": ">= 3.2.0 < 3.4.0" + "version_requirement": "3.x" }, { "name": "puppet", From a6b560c9b40608f55d7cd2fd28261ec131ec2b33 Mon Sep 17 00:00:00 2001 From: "Bryan M. Schlief" Date: Mon, 13 Oct 2014 11:44:56 -0700 Subject: [PATCH 372/574] Add support for RandomSleep to 10periodic --- README.md | 1 + manifests/unattended_upgrades.pp | 7 +++++++ spec/classes/unattended_upgrades_spec.rb | 11 +++++++++++ templates/10periodic.erb | 3 +++ 4 files changed, 22 insertions(+) diff --git a/README.md b/README.md index d07c7a2fbc..99481a3744 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,7 @@ apt::sources: * `download`: How often, in days, to run `apt-get upgrade --download-only`. * `upgrade`: How often, in days, to upgrade packages included in the origins list. * `autoclean`: How often, in days, to run `apt-get autoclean`. +* `randomsleep`: How long, in seconds, to randomly wait before applying upgrades. ### Testing diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index 2f75d5dd19..069c3593dd 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -28,6 +28,7 @@ $remove_unused = true, $auto_reboot = false, $dl_limit = 'NONE', + $randomsleep = undef, $enable = '1', $backup_interval = '0', $backup_level = '3', @@ -48,6 +49,12 @@ ) validate_array($origins) + if $randomsleep { + unless is_numeric($randomsleep) { + fail('randomsleep must be numeric') + } + } + package { 'unattended-upgrades': ensure => present, } diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 291719b009..57df21cbdf 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -94,6 +94,14 @@ it { expect { should raise_error(Puppet::Error) } } end + context 'bad randomsleep' do + let :params do + { + 'randomsleep' => '4ever' + } + end + it { expect { should raise_error(Puppet::Error) } } + end end context 'defaults' do @@ -123,6 +131,7 @@ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "1";}} it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "7";}} it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "0";}} + it { is_expected.to_not contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep}} end context 'anything but defaults' do @@ -157,6 +166,7 @@ 'remove_unused' => false, 'auto_reboot' => true, 'dl_limit' => '70', + 'randomsleep' => '1799', } end @@ -183,6 +193,7 @@ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "0";}} it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "0";}} it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "1";}} + it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep "1799";}} end end diff --git a/templates/10periodic.erb b/templates/10periodic.erb index 5737c9ac29..43caed9ea1 100644 --- a/templates/10periodic.erb +++ b/templates/10periodic.erb @@ -10,3 +10,6 @@ APT::Periodic::Download-Upgradeable-Packages-Debdelta "<%= @download_delta %>"; APT::Periodic::Unattended-Upgrade "<%= @upgrade %>"; APT::Periodic::AutocleanInterval "<%= @autoclean %>"; APT::Periodic::Verbose "<%= @verbose %>"; +<%- unless @randomsleep.nil? -%> +APT::Periodic::RandomSleep "<%= @randomsleep %>"; +<%- end -%> From be3abffb0eaee90407661ad8b91fc9bf80f8b9da Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Tue, 14 Oct 2014 13:42:59 +0200 Subject: [PATCH 373/574] README: the facts depend on update-notifier --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 99481a3744..991e961dcf 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,8 @@ The apt module includes a few facts to describe the state of the Apt system: * `apt_package_updates`: The package names that are available for update. In Facter 2.0 and later, this will be a list type; in earlier versions, it is a comma-delimited string. * `apt_update_last_success`: The date, in epochtime, of the most recent successful `apt-get update` run. This is determined by reading the mtime of /var/lib/apt/periodic/update-success-stamp. +**Note:** The facts depend on 'update-notifier' being installed on your system. Though this is a GNOME daemon only the support files are needed so the package 'update-notifier-common' is enough to enable this functionality. + #### Hiera example ``` From d090ae4ebb9041bc46e161f698732a6bc9d28399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 15 Oct 2014 15:44:50 +0200 Subject: [PATCH 374/574] Refactor facts to improve performance: * Add an apt_has_updates boolean fact * Make other facts depend on it --- lib/facter/apt_package_updates.rb | 13 ------- lib/facter/apt_security_updates.rb | 9 ----- lib/facter/apt_updates.rb | 36 ++++++++++++++++--- spec/unit/facter/apt_has_updates_spec.rb | 34 ++++++++++++++++++ spec/unit/facter/apt_package_updates_spec.rb | 36 ++++++++++--------- spec/unit/facter/apt_security_updates_spec.rb | 23 ++++++------ spec/unit/facter/apt_updates_spec.rb | 23 ++++++------ 7 files changed, 109 insertions(+), 65 deletions(-) delete mode 100644 lib/facter/apt_package_updates.rb delete mode 100644 lib/facter/apt_security_updates.rb create mode 100644 spec/unit/facter/apt_has_updates_spec.rb diff --git a/lib/facter/apt_package_updates.rb b/lib/facter/apt_package_updates.rb deleted file mode 100644 index 97c75c66a2..0000000000 --- a/lib/facter/apt_package_updates.rb +++ /dev/null @@ -1,13 +0,0 @@ -Facter.add("apt_package_updates") do - confine :osfamily => 'Debian' - setcode do - if File.executable?("/usr/lib/update-notifier/apt-check") - packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1') - packages = packages.split("\n") - if Facter.version < '2.0.0' - packages = packages.join(',') - end - packages - end - end -end diff --git a/lib/facter/apt_security_updates.rb b/lib/facter/apt_security_updates.rb deleted file mode 100644 index 19bae7521d..0000000000 --- a/lib/facter/apt_security_updates.rb +++ /dev/null @@ -1,9 +0,0 @@ -Facter.add("apt_security_updates") do - confine :osfamily => 'Debian' - setcode do - if File.executable?("/usr/lib/update-notifier/apt-check") - updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1') - Integer(updates.strip.split(';')[1]) - end - end -end diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index ee177380c2..75670bc397 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -1,9 +1,37 @@ -Facter.add("apt_updates") do +apt_package_updates = nil +Facter.add("apt_has_updates") do confine :osfamily => 'Debian' + if File.executable?("/usr/lib/update-notifier/apt-check") + apt_package_updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1').split(';') + end + + setcode do + apt_package_updates != ['0', '0'] unless apt_package_updates.nil? + end +end + +Facter.add("apt_package_updates") do + confine :apt_has_updates => true setcode do - if File.executable?("/usr/lib/update-notifier/apt-check") - updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1') - Integer(updates.strip.split(';')[0]) + packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1').split("\n") + if Facter.version < '2.0.0' + packages.join(',') + else + packages end end end + +Facter.add("apt_updates") do + confine :apt_has_updates => true + setcode do + Integer(apt_package_updates[0]) + end +end + +Facter.add("apt_security_updates") do + confine :apt_has_updates => true + setcode do + Integer(apt_package_updates[1]) + end +end diff --git a/spec/unit/facter/apt_has_updates_spec.rb b/spec/unit/facter/apt_has_updates_spec.rb new file mode 100644 index 0000000000..9a444db5b4 --- /dev/null +++ b/spec/unit/facter/apt_has_updates_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe 'apt_has_updates fact' do + subject { Facter.fact(:apt_has_updates).value } + after(:each) { Facter.clear } + + describe 'on non-Debian distro' do + before { + Facter.fact(:osfamily).expects(:value).returns 'RedHat' + } + it { should be_nil } + end + + describe 'on Debian based distro missing update-notifier-common' do + before { + Facter.fact(:osfamily).expects(:value).returns 'Debian' + File.stubs(:executable?) # Stub all other calls + File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns false + } + it { should be_nil } + end + + describe 'on Debian based distro' do + before { + Facter.fact(:osfamily).expects(:value).returns 'Debian' + File.stubs(:executable?) # Stub all other calls + Facter::Util::Resolution.stubs(:exec) # Catch all other calls + File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "4;3" + } + it { should be true } + end +end + diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb index dfa09270eb..5c7a624f4d 100644 --- a/spec/unit/facter/apt_package_updates_spec.rb +++ b/spec/unit/facter/apt_package_updates_spec.rb @@ -4,26 +4,28 @@ subject { Facter.fact(:apt_package_updates).value } after(:each) { Facter.clear } - describe 'on Debian based distro missing update-notifier-common' do + describe 'when apt has no updates' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?).returns false - } - it { should == nil } + Facter.fact(:apt_has_updates).stubs(:value).returns false + } + it { should be nil } end - describe 'on Debian based distro' do + describe 'when apt has updates' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?).returns true - Facter::Util::Resolution.stubs(:exec).returns "puppet-common\nlinux-generic\nlinux-image-generic" - } - it { - if Facter.version < '2.0.0' - should == 'puppet-common,linux-generic,linux-image-generic' - else - should == ['puppet-common', 'linux-generic', 'linux-image-generic'] - end - } + Facter.fact(:osfamily).stubs(:value).returns 'Debian' + File.stubs(:executable?) # Stub all other calls + Facter::Util::Resolution.stubs(:exec) # Catch all other calls + File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "1;2" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check -p 2>&1').returns "puppet-common\nlinux-generic\nlinux-image-generic" + } + it { + if Facter.version < '2.0.0' + should == 'puppet-common,linux-generic,linux-image-generic' + else + should == ['puppet-common', 'linux-generic', 'linux-image-generic'] + end + } end end diff --git a/spec/unit/facter/apt_security_updates_spec.rb b/spec/unit/facter/apt_security_updates_spec.rb index 999603b612..4bc760f789 100644 --- a/spec/unit/facter/apt_security_updates_spec.rb +++ b/spec/unit/facter/apt_security_updates_spec.rb @@ -4,21 +4,22 @@ subject { Facter.fact(:apt_security_updates).value } after(:each) { Facter.clear } - describe 'on Debian based distro missing update-notifier-common' do + describe 'when apt has no updates' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?).returns false - } - it { should == nil } + Facter.fact(:apt_has_updates).stubs(:value).returns false + } + it { should be nil } end - describe 'on Debian based distro' do + describe 'when apt has security updates' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?).returns true - Facter::Util::Resolution.stubs(:exec).returns '14;7' - } - it { should == 7 } + Facter.fact(:osfamily).stubs(:value).returns 'Debian' + File.stubs(:executable?) # Stub all other calls + Facter::Util::Resolution.stubs(:exec) # Catch all other calls + File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" + } + it { should == 7 } end end diff --git a/spec/unit/facter/apt_updates_spec.rb b/spec/unit/facter/apt_updates_spec.rb index 2f343bd8a1..7e9b77f84f 100644 --- a/spec/unit/facter/apt_updates_spec.rb +++ b/spec/unit/facter/apt_updates_spec.rb @@ -4,21 +4,22 @@ subject { Facter.fact(:apt_updates).value } after(:each) { Facter.clear } - describe 'on Debian based distro missing update-notifier-common' do + describe 'when apt has no updates' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?).returns false - } - it { should == nil } + Facter.fact(:apt_has_updates).stubs(:value).returns false + } + it { should be nil } end - describe 'on Debian based distro' do + describe 'when apt has updates' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:executable?).returns true - Facter::Util::Resolution.stubs(:exec).returns '14;7' - } - it { should == 14 } + Facter.fact(:osfamily).stubs(:value).returns 'Debian' + File.stubs(:executable?) # Stub all other calls + Facter::Util::Resolution.stubs(:exec) # Catch all other calls + File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" + } + it { should == 14 } end end From 7f3acf40f99a618b714c629ff695770e91e12d6f Mon Sep 17 00:00:00 2001 From: Raoul Bhatia Date: Fri, 24 Oct 2014 12:29:48 +0200 Subject: [PATCH 375/574] Add "oldstable" to the default update origins for wheezy Add "oldstable" to the default update origins to ensure the updates keep working after wheezy+1 gets released See unattended-upgrades 0.79.5+wheezy1 and https://bugs.debian.org/711826 --- manifests/params.pp | 3 ++- spec/classes/unattended_upgrades_spec.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index d33a401fe6..06925a341b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -45,7 +45,8 @@ 'wheezy': { $backports_location = 'http://ftp.debian.org/debian/' $legacy_origin = false - $origins = ['origin=Debian,archive=stable,label=Debian-Security'] + $origins = ['origin=Debian,archive=stable,label=Debian-Security', + 'origin=Debian,archive=oldstable,label=Debian-Security'] } default: { $backports_location = 'http://http.debian.net/debian/' diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 57df21cbdf..3742bf1c2a 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -134,6 +134,17 @@ it { is_expected.to_not contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep}} end + context 'wheezy' do + let :facts do + { + 'lsbdistid' => 'debian', + 'lsbdistcodename' => 'wheezy', + } + end + + it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"origin=Debian,archive=stable,label=Debian-Security";\n\t"origin=Debian,archive=oldstable,label=Debian-Security";\n\};} } + end + context 'anything but defaults' do let :facts do { From fb9b9185e4754f120046fc43a184a2b2c43d60dc Mon Sep 17 00:00:00 2001 From: Raoul Bhatia Date: Fri, 24 Oct 2014 12:37:46 +0200 Subject: [PATCH 376/574] Fix "WARNING: indentation of => is not properly aligned on line 9" --- manifests/builddep.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/builddep.pp b/manifests/builddep.pp index 3beadeb373..3a059c273d 100644 --- a/manifests/builddep.pp +++ b/manifests/builddep.pp @@ -6,7 +6,7 @@ exec { "apt-builddep-${name}": command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", logoutput => 'on_failure', - require => Exec['apt_update'], + require => Exec['apt_update'], } # Need anchor to provide containment for dependencies. From 15fad7ec118d93edab7f2eb8beaa641b9485f266 Mon Sep 17 00:00:00 2001 From: Raoul Bhatia Date: Fri, 24 Oct 2014 12:59:15 +0200 Subject: [PATCH 377/574] Fix "WARNING: case statement without a default case on line ..." --- manifests/force.pp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index a73f7ab218..7524981da2 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -25,15 +25,15 @@ } case $cfg_files { - 'new': { $config_files = '-o Dpkg::Options::="--force-confnew"' } - 'old': { $config_files = '-o Dpkg::Options::="--force-confold"' } - 'unchanged': { $config_files = '-o Dpkg::Options::="--force-confdef"' } - 'none': { $config_files = '' } + 'new': { $config_files = '-o Dpkg::Options::="--force-confnew"' } + 'old': { $config_files = '-o Dpkg::Options::="--force-confold"' } + 'unchanged': { $config_files = '-o Dpkg::Options::="--force-confdef"' } + 'none', default: { $config_files = '' } } case $cfg_missing { - true: { $config_missing = '-o Dpkg::Options::="--force-confmiss"' } - false: { $config_missing = '' } + true: { $config_missing = '-o Dpkg::Options::="--force-confmiss"' } + false, default: { $config_missing = '' } } if $version == false { From 97556124daf5d49a755fd55e545b5023f057f49e Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 15 Aug 2014 16:22:46 -0700 Subject: [PATCH 378/574] Remove stderr from stdout Sometimes there are lib errors on platforms with malformed packages. This shouldn't cause the facts to completely fail. --- lib/facter/apt_package_updates.rb | 2 +- lib/facter/apt_security_updates.rb | 2 +- lib/facter/apt_updates.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/facter/apt_package_updates.rb b/lib/facter/apt_package_updates.rb index 97c75c66a2..e2fc96e4b5 100644 --- a/lib/facter/apt_package_updates.rb +++ b/lib/facter/apt_package_updates.rb @@ -2,7 +2,7 @@ confine :osfamily => 'Debian' setcode do if File.executable?("/usr/lib/update-notifier/apt-check") - packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1') + packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>/dev/null') packages = packages.split("\n") if Facter.version < '2.0.0' packages = packages.join(',') diff --git a/lib/facter/apt_security_updates.rb b/lib/facter/apt_security_updates.rb index 19bae7521d..77b3c0e9fc 100644 --- a/lib/facter/apt_security_updates.rb +++ b/lib/facter/apt_security_updates.rb @@ -2,7 +2,7 @@ confine :osfamily => 'Debian' setcode do if File.executable?("/usr/lib/update-notifier/apt-check") - updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1') + updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>/dev/null') Integer(updates.strip.split(';')[1]) end end diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index ee177380c2..15d9473d6e 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -2,7 +2,7 @@ confine :osfamily => 'Debian' setcode do if File.executable?("/usr/lib/update-notifier/apt-check") - updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1') + updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>/dev/null') Integer(updates.strip.split(';')[0]) end end From bc7601dfed3fdd9d22eb1527a394112ada447c9d Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Wed, 10 Sep 2014 10:37:07 -0700 Subject: [PATCH 379/574] Fix issue with puppet_module_install, removed and using updated method from beaker core copy_module_to --- spec/spec_helper_acceptance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index fd1f2c56b9..a523bb8321 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -25,8 +25,8 @@ # Configure all nodes in nodeset c.before :suite do # Install module and dependencies - puppet_module_install(:source => proj_root, :module_name => 'apt') hosts.each do |host| + copy_module_to(host, :source => proj_root, :module_name => 'apt') shell("/bin/touch #{default['puppetpath']}/hiera.yaml") shell('puppet module install puppetlabs-stdlib --version 2.2.1', { :acceptable_exit_codes => [0,1] }) end From 2fdad79f74c4af95557f0522b4c90fa6d14084d9 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 27 Oct 2014 10:10:52 -0400 Subject: [PATCH 380/574] Fix tests to reflect behavior fixed on 1.7.x The facts don't really work with 2>&1 in the case of an error, so you want 2>/dev/null instead. --- spec/unit/facter/apt_has_updates_spec.rb | 2 +- spec/unit/facter/apt_package_updates_spec.rb | 4 ++-- spec/unit/facter/apt_security_updates_spec.rb | 2 +- spec/unit/facter/apt_updates_spec.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/unit/facter/apt_has_updates_spec.rb b/spec/unit/facter/apt_has_updates_spec.rb index 9a444db5b4..691fb32280 100644 --- a/spec/unit/facter/apt_has_updates_spec.rb +++ b/spec/unit/facter/apt_has_updates_spec.rb @@ -26,7 +26,7 @@ File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "4;3" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>/dev/null').returns "4;3" } it { should be true } end diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb index 5c7a624f4d..c0f54f23af 100644 --- a/spec/unit/facter/apt_package_updates_spec.rb +++ b/spec/unit/facter/apt_package_updates_spec.rb @@ -17,8 +17,8 @@ File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "1;2" - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check -p 2>&1').returns "puppet-common\nlinux-generic\nlinux-image-generic" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>/dev/null').returns "1;2" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check -p 2>/dev/null').returns "puppet-common\nlinux-generic\nlinux-image-generic" } it { if Facter.version < '2.0.0' diff --git a/spec/unit/facter/apt_security_updates_spec.rb b/spec/unit/facter/apt_security_updates_spec.rb index 4bc760f789..a5d26c76cf 100644 --- a/spec/unit/facter/apt_security_updates_spec.rb +++ b/spec/unit/facter/apt_security_updates_spec.rb @@ -17,7 +17,7 @@ File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>/dev/null').returns "14;7" } it { should == 7 } end diff --git a/spec/unit/facter/apt_updates_spec.rb b/spec/unit/facter/apt_updates_spec.rb index 7e9b77f84f..538466f999 100644 --- a/spec/unit/facter/apt_updates_spec.rb +++ b/spec/unit/facter/apt_updates_spec.rb @@ -17,7 +17,7 @@ File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>/dev/null').returns "14;7" } it { should == 14 } end From dfdcfa025554f06c64de1c06b36b8bd96487a22c Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 27 Oct 2014 15:29:47 -0400 Subject: [PATCH 381/574] 1.7.0 prep --- CHANGELOG.md | 22 ++++++++++++++++++++++ metadata.json | 9 +++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a325f42f2..736c0177a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +##2014-10-28 - Supported Release 1.7.0 +###Summary + +This release includes several new features, documentation and test improvements, and a few bug fixes. + +####Features +- Updated unit and acceptance tests +- Update module to work with Linux Mint +- Documentation updates +- Future parser / strict variables support +- Improved support for long GPG keys +- New parameters! + - Added `apt_update_frequency` to apt + - Added `cfg_files` and `cfg_missing` parameters to apt::force + - Added `randomsleep` to apt::unattended_upgrades +- Added `apt_update_last_success` fact +- Refactored facts for performance improvements + +####Bugfixes +- Update apt::builddep to require Exec['apt_update'] instead of notifying it +- Clean up lint errors + ##2014-08-20 - Supported Release 1.6.0 ###Summary diff --git a/metadata.json b/metadata.json index 1403e1406d..a92b8a7bf6 100644 --- a/metadata.json +++ b/metadata.json @@ -1,12 +1,12 @@ { "name": "puppetlabs-apt", - "version": "1.6.0", + "version": "1.7.0", "author": "Puppet Labs", "summary": "Puppet Labs Apt Module", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-apt", "project_page": "https://github.com/puppetlabs/puppetlabs-apt", - "issues_url": "https://github.com/puppetlabs/puppetlabs-apt/issues", + "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "operatingsystem_support": [ { "operatingsystem": "Debian", @@ -35,9 +35,6 @@ } ], "dependencies": [ - { - "name": "puppetlabs/stdlib", - "version_requirement": ">= 2.2.1" - } + {"name":"puppetlabs/stdlib","version_requirement":">= 2.2.1"} ] } From 1a7d1f3d4367db92612a04e0d3039b00229d8943 Mon Sep 17 00:00:00 2001 From: Patrick Hervieux Date: Fri, 14 Nov 2014 14:48:09 +0100 Subject: [PATCH 382/574] Add utopic support --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 06925a341b..b337965e6c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -63,7 +63,7 @@ $legacy_origin = true $origins = ['${distro_id} ${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } - 'precise', 'trusty': { + 'precise', 'trusty', 'utopic': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = '-y' $legacy_origin = true From ee69c657c974cc705b381f7b5c8b5fae08f86379 Mon Sep 17 00:00:00 2001 From: jbondpdx Date: Thu, 20 Nov 2014 15:28:07 -0800 Subject: [PATCH 383/574] FM-1523: Added module summary to metadata.json --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index a92b8a7bf6..4c0e3d8c6a 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "name": "puppetlabs-apt", "version": "1.7.0", "author": "Puppet Labs", - "summary": "Puppet Labs Apt Module", + "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-apt", "project_page": "https://github.com/puppetlabs/puppetlabs-apt", From 559787268aa19c7c3f01d9597392bddfe5162a97 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Thu, 13 Nov 2014 20:25:46 -0800 Subject: [PATCH 384/574] MODULES-1119 Fixed to now have username and passwords passed in again --- lib/puppet/provider/apt_key/apt_key.rb | 6 ++++-- spec/unit/puppet/type/apt_key_spec.rb | 11 +++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index e5020fe27d..075fb6fca5 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -108,12 +108,13 @@ def self.key_line_regexp end def source_to_file(value) - if URI::parse(value).scheme.nil? + parsedValue = URI::parse(value) + if parsedValue.scheme.nil? fail("The file #{value} does not exist") unless File.exists?(value) value else begin - key = open(value, :ftp_active_mode => false).read + key = parsedValue.read rescue OpenURI::HTTPError, Net::FTPPermError => e fail("#{e.message} for #{resource[:source]}") rescue SocketError @@ -158,6 +159,7 @@ def create end def destroy + #Currently del only removes the first key, we need to recursively list and ensure all with id are absent. apt_key('del', resource[:id]) @property_hash.clear end diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index c29f82b088..0e9aaa2fd5 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -82,7 +82,7 @@ resource[:source].should eq 'http://apt.puppetlabs.com/pubkey.gpg' end end - + context 'with content' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', @@ -93,7 +93,7 @@ resource[:content].should eq 'http://apt.puppetlabs.com/pubkey.gpg' end end - + context 'with keyserver' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', @@ -143,6 +143,13 @@ )}.to_not raise_error end + it 'allows the https URI with username and password' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'https://testme:Password2@pgp.mit.edu' + )}.to_not raise_error + end + it 'allows the ftp URI scheme in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', From 50cd38d1d6ba1c411068b8398a18b35be3347ab5 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Sun, 7 Dec 2014 13:26:08 -0800 Subject: [PATCH 385/574] Define travis matrix in .sync.yml Since the other modules need to wait for a major release before deprecating Puppet 2.7 support, this module's travis.yml is out of sync and will need to stay that way for a while. --- .sync.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.sync.yml b/.sync.yml index ed97d539c0..08e91a74a0 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1 +1,9 @@ --- +.travis.yml: + includes: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0" From abb830885b0f2b0f16d30f528a8be500b7b2566d Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 8 Dec 2014 10:23:17 -0800 Subject: [PATCH 386/574] Update .travis.yml, Gemfile, Rakefile, and CONTRIBUTING.md --- .travis.yml | 2 +- CONTRIBUTING.md | 22 ++++------------------ Gemfile | 12 +++++++----- Rakefile | 2 +- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66e90e38df..ec6f08dc6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ --- language: ruby -bundler_args: --without development +bundler_args: --without system_tests script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: fast_finish: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e1288478a2..f1cbde4bbf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,11 +41,9 @@ Checklist (and a short version for the impatient) * Pre-requisites: - - Sign the [Contributor License Agreement](https://cla.puppetlabs.com/) - - Make sure you have a [GitHub account](https://github.com/join) - - [Create a ticket](http://projects.puppetlabs.com/projects/modules/issues/new), or [watch the ticket](http://projects.puppetlabs.com/projects/modules/issues) you are patching for. + - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. * Preferred method: @@ -94,17 +92,7 @@ The long version whitespace or other "whitespace errors". You can do this by running "git diff --check" on your changes before you commit. - 2. Sign the Contributor License Agreement - - Before we can accept your changes, we do need a signed Puppet - Labs Contributor License Agreement (CLA). - - You can access the CLA via the [Contributor License Agreement link](https://cla.puppetlabs.com/) - - If you have any questions about the CLA, please feel free to - contact Puppet Labs via email at cla-submissions@puppetlabs.com. - - 3. Sending your patches + 2. Sending your patches To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of @@ -124,7 +112,7 @@ The long version in order to open a pull request. - 4. Update the related GitHub issue. + 3. Update the related GitHub issue. If there is a GitHub issue associated with the change you submitted, then you should update the ticket to include the @@ -220,14 +208,12 @@ review. Additional Resources ==================== -* [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help) +* [Getting additional help](http://puppetlabs.com/community/get-help) * [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) * [Patchwork](https://patchwork.puppetlabs.com) -* [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) - * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) diff --git a/Gemfile b/Gemfile index e960f7c4b7..0684f19238 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,17 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" -group :development, :test do +group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'serverspec', :require => false gem 'puppet-lint', :require => false - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false - gem 'pry', :require => false gem 'simplecov', :require => false + gem 'puppet_facts', :require => false +end + +group :system_tests do + gem 'beaker-rspec', :require => false + gem 'serverspec', :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index 5868545f20..e3be95b0b8 100644 --- a/Rakefile +++ b/Rakefile @@ -2,9 +2,9 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.send('relative') PuppetLint.configuration.send('disable_80chars') PuppetLint.configuration.send('disable_class_inherits_from_params_class') -PuppetLint.configuration.send('disable_class_parameter_defaults') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] From 18eac98d881f01de61aa53963d5c8435f5b4acb8 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 8 Dec 2014 22:52:06 -0800 Subject: [PATCH 387/574] Add json gem The puppet_facts gem implicitly depends on the json gem. On Ruby 1.8.7, json is not built in. On Puppet 2.7, it is not explicitly pulled in by the hiera gem. So we add it here explicitly. --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 0684f19238..12fd363eac 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ group :development, :unit_tests do gem 'puppet-lint', :require => false gem 'simplecov', :require => false gem 'puppet_facts', :require => false + gem 'json', :require => false end group :system_tests do From 29dbe051db1d533b078290cc68abd3313c7056f9 Mon Sep 17 00:00:00 2001 From: Mahyuddin Susanto Date: Thu, 11 Dec 2014 11:22:48 +0700 Subject: [PATCH 388/574] Add Ubuntu vivid (15.04) release Signed-off-by: Mahyuddin Susanto --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index b337965e6c..1c6cc99de7 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -63,7 +63,7 @@ $legacy_origin = true $origins = ['${distro_id} ${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } - 'precise', 'trusty', 'utopic': { + 'precise', 'trusty', 'utopic', 'vivid': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = '-y' $legacy_origin = true From 342b90f4cc2d57202d2fdb1f7136e1bb062c6130 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 12 Dec 2014 12:53:18 -0800 Subject: [PATCH 389/574] Use puppet() instead of shell() to install module dependencies --- spec/spec_helper_acceptance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index a523bb8321..6b2aa5d845 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -28,7 +28,7 @@ hosts.each do |host| copy_module_to(host, :source => proj_root, :module_name => 'apt') shell("/bin/touch #{default['puppetpath']}/hiera.yaml") - shell('puppet module install puppetlabs-stdlib --version 2.2.1', { :acceptable_exit_codes => [0,1] }) + on host, puppet('module install puppetlabs-stdlib --version 2.2.1'), { :acceptable_exit_codes => [0,1] } end end end From b737557e314f23d0cb5098f60b35525241372dd9 Mon Sep 17 00:00:00 2001 From: juniorsysadmin Date: Thu, 11 Dec 2014 13:41:01 +1100 Subject: [PATCH 390/574] (MODULES-1231) Fix apt::force locale issues The current $install_check variable greps for 'Installed' or 'Candidate', which means that it will give the wrong result when a non-English locale is used. This patch ensures that the check will work properly for non-English locales by setting the environment parameters for the exec to LC_ALL=C LANG=C --- manifests/force.pp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index 7524981da2..8ceeb17060 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -52,8 +52,9 @@ } exec { "${provider} -y ${config_files} ${config_missing} ${release_string} install ${name}${version_string}": - unless => $install_check, - logoutput => 'on_failure', - timeout => $timeout, + unless => $install_check, + environment => ['LC_ALL=C', 'LANG=C'], + logoutput => 'on_failure', + timeout => $timeout, } } From 8729af231444ede1ed040f65b328c6eb84ba5610 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 29 Dec 2014 10:40:53 -0800 Subject: [PATCH 391/574] Add IntelliJ files to the ignore list --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b5b7a00d67..b5db85e051 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ spec/fixtures/ .vagrant/ .bundle/ coverage/ +.idea/ +*.iml From b0e0024730d3463153afe5af03fd66e4244bea81 Mon Sep 17 00:00:00 2001 From: Simon Kohlmeyer Date: Fri, 26 Dec 2014 05:10:52 +0100 Subject: [PATCH 392/574] Allow ports that consist of 5 decimals --- lib/puppet/type/apt_key.rb | 2 +- manifests/key.pp | 2 +- spec/unit/puppet/type/apt_key_spec.rb | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index f55247314c..8aa408193c 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -59,7 +59,7 @@ desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' defaultto :'keyserver.ubuntu.com' - newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,4})?$/) + newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/) end newparam(:keyserver_options) do diff --git a/manifests/key.pp b/manifests/key.pp index 8d3bcf045c..c51f4bfa56 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -69,7 +69,7 @@ } if $key_server { - validate_re($key_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,4})?$']) + validate_re($key_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$']) } if $key_options { diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index 57aeb863f8..e8a5462c6f 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -163,5 +163,19 @@ :source => '/path/to/a/file' )}.to_not raise_error end + + it 'allows 5-digit ports' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'http://pgp.mit.edu:12345/key' + )}.to_not raise_error + end + + it 'allows 5-digit ports when using key servers' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :server => 'http://pgp.mit.edu:12345' + )}.to_not raise_error + end end end From b3c61ce0bca99f9d6363ebb9dd34017ed1368297 Mon Sep 17 00:00:00 2001 From: Peter Souter Date: Fri, 9 Jan 2015 13:17:51 -0800 Subject: [PATCH 393/574] Format documentation a little Makes it a little easier to read and parse with scripts --- manifests/init.pp | 63 +++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 89fb68471d..d64b013acc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,47 +1,56 @@ -# Class: apt +# == Class: apt # # This module manages the initial configuration of apt. # -# Parameters: -# The parameters listed here are not required in general and were -# added for use cases related to development environments. +# The parameters listed here are not required in general and were +# added for use cases related to development environments. # -# disable_keys - disables the requirement for all packages to be signed +# === Parameters # -# always_apt_update - rather apt should be updated on every run (intended -# for development environments where package updates are frequent) +# [*disable_keys*] +# Disables the requirement for all packages to be signed # -# apt_update_frequency - *string* Supported values: -# **always**: Will fire `apt-get update` at every puppet run. Intended to +# [*always_apt_update*] +# Rather apt should be updated on every run (intended +# for development environments where package updates are frequent) +# +# [*apt_update_frequency*] +# String: Supported values: +# **always**: Will fire `apt-get update` at every puppet run. Intended to # deprecate the `always_apt_update` parameter. -# **daily**: Trigger `apt-get update` if the value of the fact +# *daily**: Trigger `apt-get update` if the value of the fact # `apt_update_last_success` is less than current epoch time - 86400. # *notifying the apt_update exec will trigger apt-get update regardless* -# **weekly**: Trigger `apt-get update` if the value of the fact +# *weekly**: Trigger `apt-get update` if the value of the fact # `apt_update_last_success` is less than current epoch time - 604800. # *notifying the apt_update exec will trigger apt-get update regardless* -# **reluctantly**: *Default* only run apt-get update if the exec resource `apt_update` is notified. +# *reluctantly**: *Default* only run apt-get update if the exec resource `apt_update` is notified. # -# purge_sources_list - Accepts true or false. Defaults to false If set to -# true, Puppet will purge all unmanaged entries from sources.list +# [*purge_sources_list*] +# Accepts true or false. Defaults to false If set to +# true, Puppet will purge all unmanaged entries from sources.list # -# purge_sources_list_d - Accepts true or false. Defaults to false. If set -# to true, Puppet will purge all unmanaged entries from sources.list.d +# [*purge_sources_list_d*] +# Accepts true or false. Defaults to false. If set +# to true, Puppet will purge all unmanaged entries from sources.list.d # -# update_timeout - Overrides the exec timeout in seconds for apt-get update. -# If not set defaults to Exec's default (300) +# [*update_timeout*] +# Overrides the exec timeout in seconds for apt-get update. +# If not set defaults to Exec's default (300) # -# update_tries - Number of times that `apt-get update` will be tried. Use this -# to work around transient DNS and HTTP errors. By default, the command -# will only be run once. +# [*update_tries*] +# Number of times that `apt-get update` will be tried. Use this +# to work around transient DNS and HTTP errors. By default, the command +# will only be run once. # -# Actions: +# === Examples +# +# class { 'apt': } +# +# === Requires +# +# puppetlabs/stdlib >= 2.2.1 # -# Requires: -# puppetlabs/stdlib -# Sample Usage: -# class { 'apt': } - class apt( $always_apt_update = false, $apt_update_frequency = 'reluctantly', From 445ad0b6fe49ec8d87c0e03cfc7dc588a7097f6c Mon Sep 17 00:00:00 2001 From: rfkrocktk Date: Wed, 3 Sep 2014 19:00:57 -0700 Subject: [PATCH 394/574] Allow full length GPG key fingerprints. Also add support for ECC and ECDSA key_types --- lib/puppet/provider/apt_key/apt_key.rb | 130 ++++++++++++----------- lib/puppet/type/apt_key.rb | 30 +++++- manifests/key.pp | 10 +- spec/acceptance/apt_key_provider_spec.rb | 103 ++++++++++-------- spec/defines/key_spec.rb | 2 +- spec/defines/source_spec.rb | 3 +- 6 files changed, 159 insertions(+), 119 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 1a7f17cc16..c80f41f0dc 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -13,27 +13,35 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do - KEY_LINE = { - :date => '[0-9]{4}-[0-9]{2}-[0-9]{2}', - :key_type => '(R|D)', - :key_size => '\d{4}', - :key_id => '[0-9a-fA-F]+', - :expires => 'expire(d|s)', - } - confine :osfamily => :debian defaultfor :osfamily => :debian commands :apt_key => 'apt-key' def self.instances + cli_args = ['adv','--list-keys', '--with-colons', '--fingerprint'] + if RUBY_VERSION > '1.8.7' - key_output = apt_key('list').encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '') + key_output = apt_key(cli_args).encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '') else - key_output = apt_key('list') + key_output = apt_key(cli_args) end + + pub_line, fpr_line = nil + key_array = key_output.split("\n").collect do |line| - line_hash = key_line_hash(line) - next unless line_hash + if line.start_with?('pub') + pub_line = line + elsif line.start_with?('fpr') + fpr_line = line + end + + next unless (pub_line and fpr_line) + + line_hash = key_line_hash(pub_line, fpr_line) + + # reset everything + pub_line, fpr_line = nil + expired = false if line_hash[:key_expiry] @@ -41,14 +49,17 @@ def self.instances end new( - :name => line_hash[:key_id], - :id => line_hash[:key_id], - :ensure => :present, - :expired => expired, - :expiry => line_hash[:key_expiry], - :size => line_hash[:key_size], - :type => line_hash[:key_type] == 'R' ? :rsa : :dsa, - :created => line_hash[:key_created] + :name => line_hash[:key_fingerprint], + :id => line_hash[:key_fingerprint], + :fingerprint => line_hash[:key_fingerprint], + :short => line_hash[:key_short], + :long => line_hash[:key_long], + :ensure => :present, + :expired => expired, + :expiry => line_hash[:key_expiry], + :size => line_hash[:key_size], + :type => line_hash[:key_type], + :created => line_hash[:key_created] ) end key_array.compact! @@ -57,59 +68,50 @@ def self.instances def self.prefetch(resources) apt_keys = instances resources.keys.each do |name| - if name.length == 16 - shortname=name[8..-1] - else - shortname=name - end - if provider = apt_keys.find{ |key| key.name == shortname } - resources[name].provider = provider + if name.length == 40 + if provider = apt_keys.find{ |key| key.fingerprint == name } + resources[name].provider = provider + end + elsif name.length == 16 + if provider = apt_keys.find{ |key| key.long == name } + resources[name].provider = provider + end + elsif name.length == 8 + if provider = apt_keys.find{ |key| key.short == name } + resources[name].provider = provider + end end end end - def self.key_line_hash(line) - line_array = line.match(key_line_regexp).to_a - return nil if line_array.length < 5 + def self.key_line_hash(pub_line, fpr_line) + pub_split = pub_line.split(':') + fpr_split = fpr_line.split(':') + fingerprint = fpr_split.last return_hash = { - :key_id => line_array[3], - :key_size => line_array[1], - :key_type => line_array[2], - :key_created => line_array[4], - :key_expiry => nil, + :key_fingerprint => fingerprint, + :key_long => fingerprint[-16..-1], # last 16 characters of fingerprint + :key_short => fingerprint[-8..-1], # last 8 characters of fingerprint + :key_size => pub_split[2], + :key_type => nil, + :key_created => pub_split[5], + :key_expiry => pub_split[6].empty? ? nil : pub_split[6], } - return_hash[:key_expiry] = line_array[7] if line_array.length == 8 - return return_hash - end + # set key type based on types defined in /usr/share/doc/gnupg/DETAILS.gz + case pub_split[3] + when "1" + return_hash[:key_type] = :rsa + when "17" + return_hash[:key_type] = :dsa + when "18" + return_hash[:key_type] = :ecc + when "19" + return_hash[:key_type] = :ecdsa + end - def self.key_line_regexp - # This regexp is trying to match the following output - # pub 4096R/4BD6EC30 2010-07-10 [expires: 2016-07-08] - # pub 1024D/CD2EFD2A 2009-12-15 - regexp = /\A - pub # match only the public key, not signatures - \s+ # bunch of spaces after that - (#{KEY_LINE[:key_size]}) # size of the key, usually a multiple of 1024 - #{KEY_LINE[:key_type]} # type of the key, usually R or D - \/ # separator between key_type and key_id - (#{KEY_LINE[:key_id]}) # hex id of the key - \s+ # bunch of spaces after that - (#{KEY_LINE[:date]}) # date the key was added to the keyring - # following an optional block which indicates if the key has an expiration - # date and if it has expired yet - ( - \s+ # again with thes paces - \[ # we open with a square bracket - #{KEY_LINE[:expires]} # expires or expired - \: # a colon - \s+ # more spaces - (#{KEY_LINE[:date]}) # date indicating key expiry - \] # we close with a square bracket - )? # end of the optional block - \Z/x - regexp + return return_hash end def source_to_file(value) diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 8aa408193c..70825ac218 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -28,8 +28,8 @@ newparam(:id, :namevar => true) do desc 'The ID of the key you want to manage.' # GPG key ID's should be either 32-bit (short) or 64-bit (long) key ID's - # and may start with the optional 0x - newvalues(/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/) + # and may start with the optional 0x, or they can be 40-digit key fingerprints + newvalues(/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/) munge do |value| if value.start_with?('0x') id = value.partition('0x').last.upcase @@ -66,6 +66,30 @@ desc 'Additional options to pass to apt-key\'s --keyserver-options.' end + newproperty(:fingerprint) do + desc <<-EOS + The 40-digit hexadecimal fingerprint of the specified GPG key. + + This property is read-only. + EOS + end + + newproperty(:long) do + desc <<-EOS + The 16-digit hexadecimal id of the specified GPG key. + + This property is read-only. + EOS + end + + newproperty(:short) do + desc <<-EOS + The 8-digit hexadecimal id of the specified GPG key. + + This property is read-only. + EOS + end + newproperty(:expired) do desc <<-EOS Indicates if the key has expired. @@ -92,7 +116,7 @@ newproperty(:type) do desc <<-EOS - The key type, either RSA or DSA. + The key type, one of: rsa, dsa, ecc, ecdsa This property is read-only. EOS diff --git a/manifests/key.pp b/manifests/key.pp index c51f4bfa56..ce5fc2514c 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -10,9 +10,11 @@ # [*key*] # _default_: +$title+, the title/name of the resource # -# Is a GPG key ID. This key ID is validated with a regex enforcing it -# to only contain valid hexadecimal characters, be precisely 8 or 16 -# characters long and optionally prefixed with 0x. +# Is a GPG key ID or full key fingerprint. This value is validated with +# a regex enforcing it to only contain valid hexadecimal characters, be +# precisely 8 or 16 hexadecimal characters long and optionally prefixed +# with 0x for key IDs, or 40 hexadecimal characters long for key +# fingerprints. # # [*ensure*] # _default_: +present+ @@ -57,7 +59,7 @@ $key_options = undef, ) { - validate_re($key, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z']) + validate_re($key, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z']) validate_re($ensure, ['\Aabsent|present\Z',]) if $key_content { diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 3f2536c7f0..aa1e5a425e 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -1,20 +1,27 @@ require 'spec_helper_acceptance' -PUPPETLABS_GPG_KEY_ID = '4BD6EC30' -PUPPETLABS_GPG_LONG_KEY_ID = '1054B7A24BD6EC30' -PUPPETLABS_APT_URL = 'apt.puppetlabs.com' -PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg' -CENTOS_GPG_KEY_ID = 'C105B9DE' -CENTOS_REPO_URL = 'ftp.cvut.cz/centos' -CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' +PUPPETLABS_GPG_KEY_SHORT_ID = '4BD6EC30' +PUPPETLABS_GPG_KEY_LONG_ID = '1054B7A24BD6EC30' +PUPPETLABS_GPG_KEY_FINGERPRINT = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' +PUPPETLABS_APT_URL = 'apt.puppetlabs.com' +PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg' +CENTOS_GPG_KEY_SHORT_ID = 'C105B9DE' +CENTOS_GPG_KEY_LONG_ID = '0946FCA2C105B9DE' +CENTOS_GPG_KEY_FINGERPRINT = 'C1DAC52D1664E8A4386DBA430946FCA2C105B9DE' +CENTOS_REPO_URL = 'ftp.cvut.cz/centos' +CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' + +KEY_CHECK_COMMAND = "apt-key adv --list-keys --with-colons --fingerprint | grep " +PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}" +CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}" describe 'apt_key' do before(:each) do # Delete twice to make sure everything is cleaned # up after the short key collision - shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}", + shell("apt-key del #{PUPPETLABS_GPG_KEY_SHORT_ID}", :acceptable_exit_codes => [0,1,2]) - shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}", + shell("apt-key del #{PUPPETLABS_GPG_KEY_SHORT_ID}", :acceptable_exit_codes => [0,1,2]) end @@ -22,12 +29,16 @@ key_versions = { '32bit key id' => '4BD6EC30', '64bit key id' => '1054B7A24BD6EC30', + '160bit key fingerprint' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', '32bit lowercase key id' => '4bd6ec30', '64bit lowercase key id' => '1054b7a24bd6ec30', + '160bit lowercase key fingerprint' => '47b320eb4c7c375aa9dae1a01054b7a24bd6ec30', '0x formatted 32bit key id' => '0x4BD6EC30', '0x formatted 64bit key id' => '0x1054B7A24BD6EC30', + '0x formatted 160bit key fingerprint' => '0x47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', '0x formatted 32bit lowercase key id' => '0x4bd6ec30', '0x formatted 64bit lowercase key id' => '0x1054b7a24bd6ec30', + '0x formatted 160bit lowercase key fingerprint' => '0x47b320eb4c7c375aa9dae1a01054b7a24bd6ec30', } key_versions.each do |key, value| @@ -42,7 +53,7 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) end end end @@ -67,25 +78,25 @@ it 'is removed' do pp = <<-EOS apt_key { 'centos': - id => '#{CENTOS_GPG_KEY_ID}', + id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'absent', } EOS # Install the key first shell("apt-key adv --keyserver keyserver.ubuntu.com \ - --recv-keys #{CENTOS_GPG_KEY_ID}") - shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}") + --recv-keys #{CENTOS_GPG_KEY_FINGERPRINT}") + shell(CENTOS_KEY_CHECK_COMMAND) # Time to remove it using Puppet apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}", + shell(CENTOS_KEY_CHECK_COMMAND, :acceptable_exit_codes => [1]) shell("apt-key adv --keyserver keyserver.ubuntu.com \ - --recv-keys #{CENTOS_GPG_KEY_ID}") + --recv-keys #{CENTOS_GPG_KEY_FINGERPRINT}") end end @@ -93,21 +104,21 @@ it 'is removed' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'absent', } EOS # Install the key first shell("apt-key adv --keyserver keyserver.ubuntu.com \ - --recv-keys #{PUPPETLABS_GPG_LONG_KEY_ID}") - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + --recv-keys #{PUPPETLABS_GPG_KEY_LONG_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) # Time to remove it using Puppet apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}", + shell(PUPPETLABS_KEY_CHECK_COMMAND, :acceptable_exit_codes => [1]) end end @@ -118,7 +129,7 @@ it 'works' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', content => "-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.4.12 (GNU/Linux) @@ -185,7 +196,7 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) end end @@ -193,7 +204,7 @@ it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', content => 'For posterity: such content, much bogus, wow', } @@ -211,7 +222,7 @@ it 'works' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => 'pgp.mit.edu', } @@ -219,7 +230,7 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) end end @@ -227,7 +238,7 @@ it 'works' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', ensure => 'present', server => 'hkp://pgp.mit.edu:80', } @@ -235,7 +246,7 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) end end @@ -243,7 +254,7 @@ it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => 'nonexistant.key.server', } @@ -259,7 +270,7 @@ it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', server => '.pgp.key.server', } @@ -277,7 +288,7 @@ it 'works' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } @@ -285,13 +296,13 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'fails with a 404' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', } @@ -305,7 +316,7 @@ it 'fails with a socket error' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'http://apt.puppetlabss.com/herpderp.gpg', } @@ -319,14 +330,14 @@ context 'ftp://' do before(:each) do - shell("apt-key del #{CENTOS_GPG_KEY_ID}", + shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}", :acceptable_exit_codes => [0,1,2]) end it 'works' do pp = <<-EOS apt_key { 'CentOS 6': - id => '#{CENTOS_GPG_KEY_ID}', + id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', } @@ -334,13 +345,13 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}") + shell(CENTOS_KEY_CHECK_COMMAND) end it 'fails with a 550' do pp = <<-EOS apt_key { 'CentOS 6': - id => '#{CENTOS_GPG_KEY_ID}', + id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', } @@ -354,7 +365,7 @@ it 'fails with a socket error' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'ftp://apt.puppetlabss.com/herpderp.gpg', } @@ -370,7 +381,7 @@ it 'works' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } @@ -378,7 +389,7 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'fails with a 404' do @@ -431,7 +442,7 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) end end @@ -439,7 +450,7 @@ it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => '/tmp/totally_bogus.file', } @@ -462,7 +473,7 @@ it 'fails' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', source => '/tmp/fake-key.gpg', } @@ -480,7 +491,7 @@ it 'works' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', keyserver_options => 'debug', } @@ -488,19 +499,19 @@ apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_failures => true) - shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}") + shell(PUPPETLABS_KEY_CHECK_COMMAND) end it 'fails on invalid options' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_ID}', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', ensure => 'present', keyserver_options => 'this is totally bonkers', } EOS - shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}", :acceptable_exit_codes => [0,1,2]) + shell("apt-key del #{PUPPETLABS_GPG_KEY_FINGERPRINT}", :acceptable_exit_codes => [0,1,2]) apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(/--keyserver-options this is totally/) end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index dbb67c4c57..b09dc5bf50 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -2,7 +2,7 @@ describe 'apt::key', :type => :define do let(:facts) { { :lsbdistid => 'Debian' } } - GPG_KEY_ID = '4BD6EC30' + GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' let :title do GPG_KEY_ID diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 8327ed2d72..b553fa8dfe 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -1,7 +1,8 @@ require 'spec_helper' describe 'apt::source', :type => :define do - GPG_KEY_ID = '4BD6EC30' + GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' + let :title do 'my_source' From 38582d02cd36274ecd79932aef30b5c1330d16f4 Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Tue, 13 Jan 2015 17:27:03 +0200 Subject: [PATCH 395/574] Add support for parameter trusted * Add support for paramater trusted, valid options are 'true' and false. defaults to false. True sets the value to trusted=yes. trusted=yes can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. * Update documentation --- README.md | 18 +++++++++++++ manifests/source.pp | 6 ++++- spec/defines/source_spec.rb | 53 ++++++++++++++++++++++++++++++++++++- templates/source.list.erb | 8 ++++-- 4 files changed, 81 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 991e961dcf..554561d6ba 100644 --- a/README.md +++ b/README.md @@ -287,6 +287,24 @@ apt::sources: * `autoclean`: How often, in days, to run `apt-get autoclean`. * `randomsleep`: How long, in seconds, to randomly wait before applying upgrades. +####apt::source + +* `comment`: Add a comment to the apt source file. +* `ensure`: Allows you to remove the apt source file. Can be 'present' or 'absent'. +* `location`: The URL of the apt repository. +* `release`: The distribution of the apt repository. Defaults to fact 'lsbdistcodename'. +* `repos`: The component of the apt repository. This defaults to 'main'. +* `include_deb`: References a Debian distribution's binary package. +* `include_src`: Enable the deb-src type, references a Debian distribution's source code in the same form as the include_deb type. A deb-src line is required to fetch source indexes. +* `required_packages`: todo +* `key`: See apt::key +* `key_server`: See apt::key +* `key_content`: See apt::key +* `key_source`: See apt::key +* `pin`: See apt::pin +* `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to 'undef' which means all. Example values can be 'i386' or 'i386,alpha,powerpc' +* `trusted` can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to false. Can be 'true' or 'false'. + ### Testing The apt module is mostly a collection of defined resource types, which provide reusable logic for managing Apt. It provides smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. diff --git a/manifests/source.pp b/manifests/source.pp index 259d0ebb98..04c367119a 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -15,12 +15,16 @@ $key_content = undef, $key_source = undef, $pin = false, - $architecture = undef + $architecture = undef, + $trusted = false, ) { include apt::params include apt::update + validate_string($architecture) + validate_bool($trusted) + $sources_list_d = $apt::params::sources_list_d $provider = $apt::params::provider diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 8327ed2d72..e5db5c58d4 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -54,6 +54,7 @@ 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg', 'pin' => '10', 'architecture' => 'x86_64', + 'trusted' => true, } end @@ -63,7 +64,7 @@ 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - }).with_content(/#file generated by puppet\n# foo\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) + }).with_content(/#file generated by puppet\n# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({ @@ -92,6 +93,56 @@ } end + context 'trusted true' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + let :params do + { + 'include_src' => false, + 'trusted' => true, + } + end + + it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({ + 'ensure' => 'present', + 'path' => '/etc/apt/sources.list.d/my_source.list', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + }).with_content(/#file generated by puppet\n# my_source\ndeb \[trusted=yes\] wheezy main\n/) + } + end + + context 'architecture equals x86_64' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + let :params do + { + 'include_deb' => false, + 'architecture' => 'x86_64', + } + end + + it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({ + 'ensure' => 'present', + 'path' => '/etc/apt/sources.list.d/my_source.list', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + }).with_content(/#file generated by puppet\n# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) + } + end + context 'ensure => absent' do let :facts do { diff --git a/templates/source.list.erb b/templates/source.list.erb index 01b2176a6e..f9a878e509 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,8 +1,12 @@ #file generated by puppet # <%= @comment %> <%- if @include_deb then -%> -deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> +deb <%- if @architecture or @trusted -%> +[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted %>trusted=yes<% end -%> +] <%- end %><%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> <%- if @include_src then -%> -deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> +deb-src <%- if @architecture or @trusted -%> +[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted %>trusted=yes<% end -%> +] <%- end %><%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> From f1ca76dec569d7829603a249c96c1767c14113a9 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Tue, 13 Jan 2015 15:54:10 -0800 Subject: [PATCH 396/574] MODULES-1661 Fix issue with apt_key destroy, also added mutliple deletes --- lib/puppet/provider/apt_key/apt_key.rb | 8 +++++--- spec/acceptance/apt_key_provider_spec.rb | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index c80f41f0dc..201c022d99 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -50,7 +50,7 @@ def self.instances new( :name => line_hash[:key_fingerprint], - :id => line_hash[:key_fingerprint], + :id => line_hash[:key_long], :fingerprint => line_hash[:key_fingerprint], :short => line_hash[:key_short], :long => line_hash[:key_long], @@ -166,8 +166,10 @@ def create end def destroy - #Currently del only removes the first key, we need to recursively list and ensure all with id are absent. - apt_key('del', resource[:id]) + begin + apt_key('del', resource.provider.long) + r = execute(["#{command(:apt_key)} list | grep #{resource.provider.long}"], :failonfail => false) + end while r.exitstatus == 0 @property_hash.clear end diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index aa1e5a425e..24277d237a 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -11,6 +11,8 @@ CENTOS_REPO_URL = 'ftp.cvut.cz/centos' CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6' +SHOULD_NEVER_EXIST_ID = '4BD6EC30' + KEY_CHECK_COMMAND = "apt-key adv --list-keys --with-colons --fingerprint | grep " PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}" CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}" @@ -351,7 +353,7 @@ it 'fails with a 550' do pp = <<-EOS apt_key { 'CentOS 6': - id => '#{CENTOS_GPG_KEY_LONG_ID}', + id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', } @@ -395,7 +397,7 @@ it 'fails with a 404' do pp = <<-EOS apt_key { 'puppetlabs': - id => '4BD6EC30', + id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', } @@ -409,7 +411,7 @@ it 'fails with a socket error' do pp = <<-EOS apt_key { 'puppetlabs': - id => '4BD6EC30', + id => '#{SHOULD_NEVER_EXIST_ID}', ensure => 'present', source => 'https://apt.puppetlabss.com/herpderp.gpg', } From 18fae0a5162a8341c9db74ac677c5b07aec71e26 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Tue, 13 Jan 2015 23:43:13 -0800 Subject: [PATCH 397/574] MODULES-1661 Fix to do delete with short key not long --- lib/puppet/provider/apt_key/apt_key.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 201c022d99..67a8aa0643 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -167,8 +167,8 @@ def create def destroy begin - apt_key('del', resource.provider.long) - r = execute(["#{command(:apt_key)} list | grep #{resource.provider.long}"], :failonfail => false) + apt_key('del', resource.provider.short) + r = execute(["#{command(:apt_key)} list | grep '/#{resource.provider.short}\s'"], :failonfail => false) end while r.exitstatus == 0 @property_hash.clear end From e7fee16589fc478f4d73ea0782df975b03e4478b Mon Sep 17 00:00:00 2001 From: WolverineFan Date: Thu, 8 Jan 2015 00:45:43 -0500 Subject: [PATCH 398/574] Fix apt_has_updates fact not parsing apt-check output correctly The /usr/lib/update-notifier/apt-check script returns its output to STDERR but a recent change to the script redirects STDERR to /dev/null. This will cause the array to always be empty. Combined with that problem, while we were checking for the result being nil, we never checked for an invalid array. As a result, the apt_has_updates was always true and the apt_updates and apt_security_updates facts were trying to read from an empty array and failing. --- lib/facter/apt_updates.rb | 11 +++++-- spec/unit/facter/apt_has_updates_spec.rb | 30 ++++++++++++++++--- spec/unit/facter/apt_package_updates_spec.rb | 4 +-- spec/unit/facter/apt_security_updates_spec.rb | 2 +- spec/unit/facter/apt_updates_spec.rb | 2 +- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index 77e667e6d7..014782eab2 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -2,18 +2,23 @@ Facter.add("apt_has_updates") do confine :osfamily => 'Debian' if File.executable?("/usr/lib/update-notifier/apt-check") - apt_package_updates = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>/dev/null').split(';') + apt_check_result = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check 2>&1') + if not apt_check_result.nil? and apt_check_result =~ /^\d+;\d+$/ + apt_package_updates = apt_check_result.split(';') + end end setcode do - apt_package_updates != ['0', '0'] unless apt_package_updates.nil? + if not apt_package_updates.nil? and apt_package_updates.length == 2 + apt_package_updates != ['0', '0'] + end end end Facter.add("apt_package_updates") do confine :apt_has_updates => true setcode do - packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>/dev/null').split("\n") + packages = Facter::Util::Resolution.exec('/usr/lib/update-notifier/apt-check -p 2>&1').split("\n") if Facter.version < '2.0.0' packages.join(',') else diff --git a/spec/unit/facter/apt_has_updates_spec.rb b/spec/unit/facter/apt_has_updates_spec.rb index 691fb32280..f8a3f20a13 100644 --- a/spec/unit/facter/apt_has_updates_spec.rb +++ b/spec/unit/facter/apt_has_updates_spec.rb @@ -6,27 +6,49 @@ describe 'on non-Debian distro' do before { - Facter.fact(:osfamily).expects(:value).returns 'RedHat' + Facter.fact(:osfamily).expects(:value).at_least(1).returns 'RedHat' } it { should be_nil } end describe 'on Debian based distro missing update-notifier-common' do before { - Facter.fact(:osfamily).expects(:value).returns 'Debian' + Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:executable?) # Stub all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns false } it { should be_nil } end + describe 'on Debian based distro with broken packages' do + before { + Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' + File.stubs(:executable?) # Stub all other calls + Facter::Util::Resolution.stubs(:exec) # Catch all other calls + File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "E: Error: BrokenCount > 0" + } + it { should be_nil } + end + + describe 'on Debian based distro with unknown error with semicolons' do + before { + Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' + File.stubs(:executable?) # Stub all other calls + Facter::Util::Resolution.stubs(:exec) # Catch all other calls + File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "E: Unknown Error: 'This error contains something that could be parsed like 4;3' (10)" + } + it { should be_nil } + end + describe 'on Debian based distro' do before { - Facter.fact(:osfamily).expects(:value).returns 'Debian' + Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>/dev/null').returns "4;3" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "4;3" } it { should be true } end diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb index c0f54f23af..5c7a624f4d 100644 --- a/spec/unit/facter/apt_package_updates_spec.rb +++ b/spec/unit/facter/apt_package_updates_spec.rb @@ -17,8 +17,8 @@ File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>/dev/null').returns "1;2" - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check -p 2>/dev/null').returns "puppet-common\nlinux-generic\nlinux-image-generic" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "1;2" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check -p 2>&1').returns "puppet-common\nlinux-generic\nlinux-image-generic" } it { if Facter.version < '2.0.0' diff --git a/spec/unit/facter/apt_security_updates_spec.rb b/spec/unit/facter/apt_security_updates_spec.rb index a5d26c76cf..4bc760f789 100644 --- a/spec/unit/facter/apt_security_updates_spec.rb +++ b/spec/unit/facter/apt_security_updates_spec.rb @@ -17,7 +17,7 @@ File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>/dev/null').returns "14;7" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" } it { should == 7 } end diff --git a/spec/unit/facter/apt_updates_spec.rb b/spec/unit/facter/apt_updates_spec.rb index 538466f999..7e9b77f84f 100644 --- a/spec/unit/facter/apt_updates_spec.rb +++ b/spec/unit/facter/apt_updates_spec.rb @@ -17,7 +17,7 @@ File.stubs(:executable?) # Stub all other calls Facter::Util::Resolution.stubs(:exec) # Catch all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true - Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>/dev/null').returns "14;7" + Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" } it { should == 14 } end From 3d25c08ec1745466dea99b121cfef72f8255cfe3 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 21 Jan 2015 10:54:37 -0800 Subject: [PATCH 399/574] Trusted will be a reserved word in Puppet 4 Rename the new `trusted` parameter to `trusted_source`. --- README.md | 2 +- manifests/source.pp | 4 ++-- spec/defines/source_spec.rb | 8 ++++---- templates/source.list.erb | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 554561d6ba..04bb3392dd 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,7 @@ apt::sources: * `key_source`: See apt::key * `pin`: See apt::pin * `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to 'undef' which means all. Example values can be 'i386' or 'i386,alpha,powerpc' -* `trusted` can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to false. Can be 'true' or 'false'. +* `trusted_source` can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to false. Can be 'true' or 'false'. ### Testing diff --git a/manifests/source.pp b/manifests/source.pp index 04c367119a..c5ed3a6402 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -16,14 +16,14 @@ $key_source = undef, $pin = false, $architecture = undef, - $trusted = false, + $trusted_source = false, ) { include apt::params include apt::update validate_string($architecture) - validate_bool($trusted) + validate_bool($trusted_source) $sources_list_d = $apt::params::sources_list_d $provider = $apt::params::provider diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index ae47ccf91e..b4d379902d 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -55,7 +55,7 @@ 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg', 'pin' => '10', 'architecture' => 'x86_64', - 'trusted' => true, + 'trusted_source' => true, } end @@ -94,7 +94,7 @@ } end - context 'trusted true' do + context 'trusted_source true' do let :facts do { :lsbdistid => 'Debian', @@ -104,8 +104,8 @@ end let :params do { - 'include_src' => false, - 'trusted' => true, + 'include_src' => false, + 'trusted_source' => true, } end diff --git a/templates/source.list.erb b/templates/source.list.erb index f9a878e509..75147667b5 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,12 +1,12 @@ #file generated by puppet # <%= @comment %> <%- if @include_deb then -%> -deb <%- if @architecture or @trusted -%> -[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted %>trusted=yes<% end -%> +deb <%- if @architecture or @trusted_source -%> +[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> ] <%- end %><%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> <%- if @include_src then -%> -deb-src <%- if @architecture or @trusted -%> -[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted %>trusted=yes<% end -%> +deb-src <%- if @architecture or @trusted_source -%> +[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> ] <%- end %><%= @location %> <%= @release_real %> <%= @repos %> <%- end -%> From 64f9c76a49cd73deb730cf468f54a9eda50a780b Mon Sep 17 00:00:00 2001 From: Richard Connon Date: Sun, 14 Dec 2014 21:54:17 +0000 Subject: [PATCH 400/574] Separate apt::pin for apt::backports to allow pin by release instead of origin Updated tests for backports --- manifests/backports.pp | 7 +++++- spec/classes/backports_spec.rb | 42 +++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index ee462094d4..a3ddb76e00 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -66,12 +66,17 @@ 'ubuntu' => 'main universe multiverse restricted', } + apt::pin { 'backports': + before => Apt::Source['backports'], + release => "${release_real}-backports", + priority => $pin_priority, + } + apt::source { 'backports': location => $location, release => "${release_real}-backports", repos => $repos, key => $key, key_server => 'pgp.mit.edu', - pin => $pin_priority, } } diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb index 18f6337aef..3c1f438561 100644 --- a/spec/classes/backports_spec.rb +++ b/spec/classes/backports_spec.rb @@ -19,7 +19,12 @@ 'repos' => 'main universe multiverse restricted', 'key' => '437D05B5', 'key_server' => 'pgp.mit.edu', - 'pin' => 500, + }) + } + + it { should contain_apt__pin('backports').with({ + 'release' => 'karmic-backports', + 'priority' => 500, }) } end @@ -48,7 +53,12 @@ 'repos' => 'main universe multiverse restricted', 'key' => '437D05B5', 'key_server' => 'pgp.mit.edu', - 'pin' => 200, + }) + } + + it { should contain_apt__pin('backports').with({ + 'release' => 'karmic-backports', + 'priority' => 200, }) } end @@ -69,7 +79,12 @@ 'repos' => 'main contrib non-free', 'key' => '46925553', 'key_server' => 'pgp.mit.edu', - 'pin' => 200, + }) + } + + it { should contain_apt__pin('backports').with({ + 'release' => 'squeeze-backports', + 'priority' => 200, }) } end @@ -90,7 +105,12 @@ 'repos' => 'main contrib non-free', 'key' => '46925553', 'key_server' => 'pgp.mit.edu', - 'pin' => 200, + }) + } + + it { should contain_apt__pin('backports').with({ + 'release' => 'wheezy-backports', + 'priority' => 200, }) } end @@ -111,7 +131,12 @@ 'repos' => 'main universe multiverse restricted', 'key' => '437D05B5', 'key_server' => 'pgp.mit.edu', - 'pin' => 200, + }) + } + + it { should contain_apt__pin('backports').with({ + 'release' => 'trusty-backports', + 'priority' => 200, }) } end @@ -140,7 +165,12 @@ 'repos' => 'main contrib non-free', 'key' => '46925553', 'key_server' => 'pgp.mit.edu', - 'pin' => 200, + }) + } + + it { should contain_apt__pin('backports').with({ + 'release' => 'squeeze-backports', + 'priority' => 200, }) } end From 9545a85b06ad9374b56388a1b55a981923612809 Mon Sep 17 00:00:00 2001 From: Patric Hafner Date: Thu, 29 Jan 2015 14:48:47 +0100 Subject: [PATCH 401/574] Documentation: Fix typo and syntax for example of apt::unattended_upgrades --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 04bb3392dd..a3e432e078 100644 --- a/README.md +++ b/README.md @@ -72,16 +72,16 @@ class { 'apt': } ``` -* `apt::unattended_updates`: This class manages the unattended-upgrades package and related configuration files for Ubuntu and Debian systems. You can configure the class to automatically upgrade all new package releases or just security releases. +* `apt::unattended_upgrades`: This class manages the unattended-upgrades package and related configuration files for Ubuntu and Debian systems. You can configure the class to automatically upgrade all new package releases or just security releases. ``` - apt::unattended_upgrades { - origins = $::apt::params::origins, - blacklist = [], - update = '1', - download = '1', - upgrade = '1', - autoclean = '7', + class { 'apt::unattended_upgrades': + origins => $::apt::params::origins, + blacklist => [], + update => '1', + download => '1', + upgrade => '1', + autoclean => '7', } ``` From e8bef852edb3451d07fb3ff7f865aa7329a25c42 Mon Sep 17 00:00:00 2001 From: Merritt Krakowitzer Date: Tue, 3 Feb 2015 18:59:54 +0200 Subject: [PATCH 402/574] (doc) Add documentation for apt::key parameters and apt::pin parameters Add documentation for apt::key parameters and apt::pin parameters. Fix minor spelling error --- README.md | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a3e432e078..9feb900cfe 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ class { 'apt': * 'unchanged: Updates only unchanged config files. * 'none': Provides backward-compatibility with existing Puppet manifests. - Valid values for `cfg_missing` are 'true', 'false'. Setting this to 'false' provides backward compatability; setting it to 'true' checks for and installs missing configuration files for the selected package. + Valid values for `cfg_missing` are 'true', 'false'. Setting this to 'false' provides backward compatibility; setting it to 'true' checks for and installs missing configuration files for the selected package. * `apt::key`: Adds a key to the list of keys used by Apt to authenticate packages. This type uses the aforementioned `apt_key` native type. As such, it no longer requires the `wget` command on which the old implementation depended. @@ -296,15 +296,44 @@ apt::sources: * `repos`: The component of the apt repository. This defaults to 'main'. * `include_deb`: References a Debian distribution's binary package. * `include_src`: Enable the deb-src type, references a Debian distribution's source code in the same form as the include_deb type. A deb-src line is required to fetch source indexes. -* `required_packages`: todo +* `required_packages`: install required packages via an exec. defaults to 'false'. * `key`: See apt::key * `key_server`: See apt::key * `key_content`: See apt::key * `key_source`: See apt::key * `pin`: See apt::pin -* `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to 'undef' which means all. Example values can be 'i386' or 'i386,alpha,powerpc' +* `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to 'undef' which means all. Example values can be 'i386' or 'i386,alpha,powerpc'. * `trusted_source` can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to false. Can be 'true' or 'false'. +####apt::key + +* `ensure`: The state we want this key in. Can be 'present' or 'absent'. +* `key`: Is a GPG key ID or full key fingerprint. This value is validated with a regex enforcing it to only contain valid hexadecimal characters, be precisely 8 or 16 hexadecimal characters long and optionally prefixed with 0x for key IDs, or 40 hexadecimal characters long for key fingerprints. +* `key_content`: This parameter can be used to pass in a GPG key as a string in case it cannot be fetched from a remote location and using a file resource is for other reasons inconvenient. +* `key_source`: This parameter can be used to pass in the location of a GPG key. This URI can take the form of a `URL` (ftp, http or https) and a `path` (absolute path to a file on the target system). +* `key_server`: The keyserver from where to fetch our GPG key. It can either be a domain name or URL. It defaults to undef which results in apt_key's default keyserver being used, currently `keyserver.ubuntu.com`. +* `key_options`: Additional options to pass on to `apt-key adv --keyserver-options`. + +####apt::pin + +* `ensure`: The state we want this pin in. Can be 'present' or 'absent'. +* `explanation`: Add a comment. Defaults to `${caller_module_name}: ${name}`. +* `order`: The order of the file name. Defaults to '', otherwise must be an integer. +* `packages`: The list of packages to pin. Defaults to '\*'. Can be an array or string. +* `priority`: Several versions of a package may be available for installation when the sources.list(5) file contains references to more than one distribution (for example, stable and testing). APT assigns a priority to each version that is available. Subject to dependency constraints, apt-get selects the version with the highest priority for installation. +* `release`: The Debian release. Defaults to ''. Typical values can be 'stable', 'testing' and 'unstable'. +* `origin`: Can be used to match a hostname. The following record will assign a high priority to all versions available from the server identified by the hostname. Defaults to ''. +* `version`: The specific form assigns a priority (a "Pin-Priority") to one or more specified packages with a specified version or version range. +* `codename`: The distribution (lsbdistcodename) of the apt repository. Defaults to ''. +* `release_version`: Names the release version. For example, the packages in the tree might belong to Debian release version 7. Defaults to ''. +* `component`: Names the licensing component associated with the packages in the directory tree of the Release file. defaults to ''. Typical values can be 'main', 'dependencies' and 'restricted' +* `originator`: Names the originator of the packages in the directory tree of the Release file. Defaults to ''. Most commonly, this is Debian. +* `label`: Names the label of the packages in the directory tree of the Release file. Defaults to ''. Most commonly, this is Debian. + +**Note**: Parameters release, origin, and version are mutually exclusive. + +It is recommended to read the manpage 'apt_preferences(5)' + ### Testing The apt module is mostly a collection of defined resource types, which provide reusable logic for managing Apt. It provides smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. From 553e3004ba3468a0a9fd316bd2141a8cc452e897 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 4 Feb 2015 17:02:03 +0100 Subject: [PATCH 403/574] Pin rspec gems --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 12fd363eac..62c5693973 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,8 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false - gem 'rspec-puppet', :require => false + gem 'rspec-core', '3.1.7', :require => false + gem 'rspec-puppet', '~> 1.0', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false gem 'simplecov', :require => false From 443db5a7c24fc7186ed10d9dc5af5b8eaef88ede Mon Sep 17 00:00:00 2001 From: Stefan Dietrich Date: Sun, 31 Aug 2014 15:46:57 +0200 Subject: [PATCH 404/574] (MODULES-1200) Fix inconsistent header across files --- manifests/conf.pp | 2 +- manifests/init.pp | 8 ++++---- manifests/pin.pp | 2 +- manifests/release.pp | 2 +- manifests/source.pp | 2 +- manifests/unattended_upgrades.pp | 4 ++-- spec/classes/apt_spec.rb | 8 ++++---- spec/classes/release_spec.rb | 2 +- spec/defines/conf_spec.rb | 4 ++-- spec/defines/source_spec.rb | 8 ++++---- templates/15update-stamp.erb | 1 + templates/_header.erb | 1 + templates/conf.erb | 1 + templates/progressbar.erb | 1 + templates/proxy.erb | 1 + templates/release.erb | 1 + templates/source.list.erb | 1 - templates/unauth.erb | 1 + 18 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 templates/15update-stamp.erb create mode 100644 templates/_header.erb create mode 100644 templates/conf.erb create mode 100644 templates/progressbar.erb create mode 100644 templates/proxy.erb create mode 100644 templates/release.erb create mode 100644 templates/unauth.erb diff --git a/manifests/conf.pp b/manifests/conf.pp index 3c4cb1975c..318422e293 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -10,7 +10,7 @@ file { "${apt_conf_d}/${priority}${name}": ensure => $ensure, - content => $content, + content => template('apt/_header.erb', 'apt/conf.erb'), owner => root, group => root, mode => '0644', diff --git a/manifests/init.pp b/manifests/init.pp index d64b013acc..5f33fdba70 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -92,7 +92,7 @@ file { '/etc/apt/apt.conf.d/15update-stamp': ensure => 'file', - content => 'APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};', + content => template('apt/_header.erb', 'apt/15update-stamp.erb'), group => 'root', mode => '0644', owner => 'root', @@ -144,7 +144,7 @@ true: { file { '99progressbar': ensure => present, - content => 'Dpkg::Progress-Fancy "1";', + content => template('apt/_header.erb', 'apt/progressbar.erb'), path => "${apt_conf_d}/99progressbar", } } @@ -162,7 +162,7 @@ true: { file { '99unauth': ensure => present, - content => "APT::Get::AllowUnauthenticated 1;\n", + content => template('apt/_header.erb', 'apt/unauth.erb'), path => "${apt_conf_d}/99unauth", } } @@ -188,7 +188,7 @@ file { '01proxy': ensure => present, path => "${apt_conf_d}/01proxy", - content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n", + content => template('apt/_header.erb', 'apt/proxy.erb'), notify => Exec['apt_update'], mode => '0644', owner => root, diff --git a/manifests/pin.pp b/manifests/pin.pp index 54961ec8dd..935dc226e5 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -76,6 +76,6 @@ owner => root, group => root, mode => '0644', - content => template('apt/pin.pref.erb'), + content => template('apt/_header.erb', 'apt/pin.pref.erb'), } } diff --git a/manifests/release.pp b/manifests/release.pp index 6e0a38f73f..ae12dd4fb2 100644 --- a/manifests/release.pp +++ b/manifests/release.pp @@ -12,6 +12,6 @@ owner => root, group => root, mode => '0644', - content => "APT::Default-Release \"${release_id}\";" + content => template('apt/_header.erb', 'apt/release.erb'), } } diff --git a/manifests/source.pp b/manifests/source.pp index c5ed3a6402..f6647dfe76 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -44,7 +44,7 @@ owner => root, group => root, mode => '0644', - content => template("${module_name}/source.list.erb"), + content => template('apt/_header.erb', 'apt/source.list.erb'), notify => Exec['apt_update'], } diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index 069c3593dd..b835b9a6a5 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -64,7 +64,7 @@ owner => 'root', group => 'root', mode => '0644', - content => template('apt/50unattended-upgrades.erb'), + content => template('apt/_header.erb', 'apt/50unattended-upgrades.erb'), require => Package['unattended-upgrades'], } @@ -73,7 +73,7 @@ owner => 'root', group => 'root', mode => '0644', - content => template('apt/10periodic.erb'), + content => template('apt/_header.erb', 'apt/10periodic.erb'), require => Package['unattended-upgrades'], } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 0a1c0a1bd7..f65ed03093 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -42,7 +42,7 @@ 'group' => 'root', 'mode' => '0644', 'owner' => 'root', - }).with_content('APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};') + }).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({ @@ -94,20 +94,20 @@ it { should contain_file('99progressbar').only_with({ 'ensure' => 'present', - 'content' => 'Dpkg::Progress-Fancy "1";', + '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;\n", + '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\";\n", + 'content' => /Acquire::http::Proxy "http:\/\/foo:9876";/, 'notify' => 'Exec[apt_update]', 'mode' => '0644', 'owner' => 'root', diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb index e43f449d62..f8c6512840 100644 --- a/spec/classes/release_spec.rb +++ b/spec/classes/release_spec.rb @@ -16,7 +16,7 @@ "mode" => "0644", "owner" => "root", "group" => "root", - "content" => "APT::Default-Release \"#{param_set[:release_id]}\";" + "content" => /APT::Default-Release "#{param_set[:release_id]}";/ }) } end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index ec4e229c44..2c1752f074 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -19,7 +19,7 @@ it { should contain_file(filename).with({ 'ensure' => 'present', - 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, 'owner' => 'root', 'group' => 'root', 'mode' => '0644', @@ -42,7 +42,7 @@ it { should contain_file(filename).with({ 'ensure' => 'absent', - 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, 'owner' => 'root', 'group' => 'root', 'mode' => '0644', diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index b4d379902d..8ca7f8e203 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -29,7 +29,7 @@ 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - }).with_content(/#file generated by puppet\n# my_source\ndeb-src wheezy main\n/) + }).with_content(/# my_source\ndeb-src wheezy main\n/) } end @@ -65,7 +65,7 @@ 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - }).with_content(/#file generated by puppet\n# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) + }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({ @@ -115,7 +115,7 @@ 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - }).with_content(/#file generated by puppet\n# my_source\ndeb \[trusted=yes\] wheezy main\n/) + }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/) } end @@ -140,7 +140,7 @@ 'owner' => 'root', 'group' => 'root', 'mode' => '0644', - }).with_content(/#file generated by puppet\n# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) + }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) } end diff --git a/templates/15update-stamp.erb b/templates/15update-stamp.erb new file mode 100644 index 0000000000..14ead83763 --- /dev/null +++ b/templates/15update-stamp.erb @@ -0,0 +1 @@ +APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";}; diff --git a/templates/_header.erb b/templates/_header.erb new file mode 100644 index 0000000000..487e581c7b --- /dev/null +++ b/templates/_header.erb @@ -0,0 +1 @@ +# This file is managed by Puppet. DO NOT EDIT. diff --git a/templates/conf.erb b/templates/conf.erb new file mode 100644 index 0000000000..a35d1d4f84 --- /dev/null +++ b/templates/conf.erb @@ -0,0 +1 @@ +<%= @content -%> diff --git a/templates/progressbar.erb b/templates/progressbar.erb new file mode 100644 index 0000000000..d3d9278c0d --- /dev/null +++ b/templates/progressbar.erb @@ -0,0 +1 @@ +Dpkg::Progress-Fancy "1"; diff --git a/templates/proxy.erb b/templates/proxy.erb new file mode 100644 index 0000000000..accb0ccee8 --- /dev/null +++ b/templates/proxy.erb @@ -0,0 +1 @@ +Acquire::http::Proxy "http://<%= @proxy_host %>:<%= @proxy_port %>"; diff --git a/templates/release.erb b/templates/release.erb new file mode 100644 index 0000000000..08760af70a --- /dev/null +++ b/templates/release.erb @@ -0,0 +1 @@ +APT::Default-Release "<%= @release_id %>"; diff --git a/templates/source.list.erb b/templates/source.list.erb index 75147667b5..b50be8d1fd 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,4 +1,3 @@ -#file generated by puppet # <%= @comment %> <%- if @include_deb then -%> deb <%- if @architecture or @trusted_source -%> diff --git a/templates/unauth.erb b/templates/unauth.erb new file mode 100644 index 0000000000..77edd289f6 --- /dev/null +++ b/templates/unauth.erb @@ -0,0 +1 @@ +APT::Get::AllowUnauthenticated 1; From e05810d03263759e7f831a8d7b2efe8492038b62 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 11 Feb 2015 16:38:32 -0800 Subject: [PATCH 405/574] Update spec tests for future parser Strings must be quoted in the future parser. --- spec/defines/key_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index b09dc5bf50..7ac1d28130 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -276,7 +276,7 @@ describe 'duplication' do context 'two apt::key resources for same key, different titles' do let :pre_condition do - "apt::key { 'duplicate': key => #{title}, }" + "apt::key { 'duplicate': key => '#{title}', }" end it 'contains two apt::key resources' do @@ -305,7 +305,7 @@ context 'two apt::key resources, different ensure' do let :pre_condition do - "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }" + "apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }" end it 'informs the user of the impossibility' do expect { subject }.to raise_error(/already ensured as absent/) From 4d39089ac2af1a7827e108b033852d2551413642 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 11 Feb 2015 16:43:14 -0800 Subject: [PATCH 406/574] Ensure linter fails on lint warnings --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index e3be95b0b8..181157e6e0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' -PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.send('relative') PuppetLint.configuration.send('disable_80chars') PuppetLint.configuration.send('disable_class_inherits_from_params_class') From 6cdbe562ab6dc6a75ae57bacbc2d5f44dcedcd10 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 09:09:47 -0800 Subject: [PATCH 407/574] Starting to clean up init.pp --- manifests/init.pp | 125 ++------------------------------------------ templates/proxy.erb | 1 - 2 files changed, 3 insertions(+), 123 deletions(-) delete mode 100644 templates/proxy.erb diff --git a/manifests/init.pp b/manifests/init.pp index 5f33fdba70..faaecc7413 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,62 +1,7 @@ -# == Class: apt -# -# This module manages the initial configuration of apt. -# -# The parameters listed here are not required in general and were -# added for use cases related to development environments. -# -# === Parameters -# -# [*disable_keys*] -# Disables the requirement for all packages to be signed -# -# [*always_apt_update*] -# Rather apt should be updated on every run (intended -# for development environments where package updates are frequent) -# -# [*apt_update_frequency*] -# String: Supported values: -# **always**: Will fire `apt-get update` at every puppet run. Intended to -# deprecate the `always_apt_update` parameter. -# *daily**: Trigger `apt-get update` if the value of the fact -# `apt_update_last_success` is less than current epoch time - 86400. -# *notifying the apt_update exec will trigger apt-get update regardless* -# *weekly**: Trigger `apt-get update` if the value of the fact -# `apt_update_last_success` is less than current epoch time - 604800. -# *notifying the apt_update exec will trigger apt-get update regardless* -# *reluctantly**: *Default* only run apt-get update if the exec resource `apt_update` is notified. -# -# [*purge_sources_list*] -# Accepts true or false. Defaults to false If set to -# true, Puppet will purge all unmanaged entries from sources.list -# -# [*purge_sources_list_d*] -# Accepts true or false. Defaults to false. If set -# to true, Puppet will purge all unmanaged entries from sources.list.d -# -# [*update_timeout*] -# Overrides the exec timeout in seconds for apt-get update. -# If not set defaults to Exec's default (300) -# -# [*update_tries*] -# Number of times that `apt-get update` will be tried. Use this -# to work around transient DNS and HTTP errors. By default, the command -# will only be run once. -# -# === Examples -# -# class { 'apt': } -# -# === Requires -# -# puppetlabs/stdlib >= 2.2.1 # class apt( $always_apt_update = false, $apt_update_frequency = 'reluctantly', - $disable_keys = undef, - $proxy_host = undef, - $proxy_port = '8080', $purge_sources_list = false, $purge_sources_list_d = false, $purge_preferences = false, @@ -64,17 +9,16 @@ $update_timeout = undef, $update_tries = undef, $sources = undef, - $fancy_progress = 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'] validate_re($apt_update_frequency, $frequency_options) - include apt::params - include apt::update validate_bool($purge_sources_list, $purge_sources_list_d, $purge_preferences, $purge_preferences_d) @@ -140,69 +84,6 @@ recurse => $purge_preferences_d, } - case $fancy_progress { - true: { - file { '99progressbar': - ensure => present, - content => template('apt/_header.erb', 'apt/progressbar.erb'), - path => "${apt_conf_d}/99progressbar", - } - } - false: { - file { '99progressbar': - ensure => absent, - path => "${apt_conf_d}/99progressbar", - } - } - undef: {} # do nothing - default: { fail('Valid values for fancy_progress are true or false') } - } - - case $disable_keys { - true: { - file { '99unauth': - ensure => present, - content => template('apt/_header.erb', 'apt/unauth.erb'), - path => "${apt_conf_d}/99unauth", - } - } - false: { - file { '99unauth': - ensure => absent, - path => "${apt_conf_d}/99unauth", - } - } - undef: { } # do nothing - default: { fail('Valid values for disable_keys are true or false') } - } - - case $proxy_host { - false, '', undef: { - file { '01proxy': - ensure => absent, - path => "${apt_conf_d}/01proxy", - notify => Exec['apt_update'], - } - } - default: { - file { '01proxy': - ensure => present, - path => "${apt_conf_d}/01proxy", - content => template('apt/_header.erb', 'apt/proxy.erb'), - notify => Exec['apt_update'], - mode => '0644', - owner => root, - group => root, - } - } - } - - file { 'old-proxy-file': - ensure => absent, - path => "${apt_conf_d}/proxy", - notify => Exec['apt_update'], - } - # Need anchor to provide containment for dependencies. anchor { 'apt::update': require => Class['apt::update'], diff --git a/templates/proxy.erb b/templates/proxy.erb deleted file mode 100644 index accb0ccee8..0000000000 --- a/templates/proxy.erb +++ /dev/null @@ -1 +0,0 @@ -Acquire::http::Proxy "http://<%= @proxy_host %>:<%= @proxy_port %>"; From 61080fb6760e3d28b04158a3a2e1f3a055a2854e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 09:39:17 -0800 Subject: [PATCH 408/574] Unbreak broken tests --- manifests/init.pp | 4 -- manifests/params.pp | 4 ++ spec/classes/apt_spec.rb | 58 ------------------------ spec/classes/params_spec.rb | 4 +- spec/classes/release_spec.rb | 2 +- spec/classes/unattended_upgrades_spec.rb | 6 ++- spec/defines/conf_spec.rb | 2 +- spec/defines/force_spec.rb | 2 +- spec/defines/key_spec.rb | 2 +- spec/defines/pin_spec.rb | 2 +- spec/defines/ppa_spec.rb | 35 -------------- 11 files changed, 16 insertions(+), 105 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index faaecc7413..a9d35403d1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,10 +11,6 @@ $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 1c6cc99de7..b97a8a25bf 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,6 +5,10 @@ $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 f65ed03093..5095904ac4 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -31,12 +31,6 @@ '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 @@ }).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 @@ 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 @@ '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 @@ 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 d85e849d5a..9a75ade4db 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -14,7 +14,7 @@ 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 @@ 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 f8c6512840..e33a9be4bb 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 3742bf1c2a..e0a6ebf722 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -2,7 +2,7 @@ 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 @@ { 'lsbdistid' => 'debian', 'lsbdistcodename' => 'squeeze', + 'osfamily' => 'Debian', } end context 'bad auto_fix' do @@ -109,6 +110,7 @@ { 'lsbdistid' => 'debian', 'lsbdistcodename' => 'squeeze', + 'osfamily' => 'Debian', } end @@ -139,6 +141,7 @@ { 'lsbdistid' => 'debian', 'lsbdistcodename' => 'wheezy', + 'osfamily' => 'Debian', } end @@ -150,6 +153,7 @@ { 'lsbdistid' => 'debian', 'lsbdistcodename' => 'wheezy', + 'osfamily' => 'Debian', } end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 2c1752f074..91b6d4e62f 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 c32c438c59..5c48ec64c3 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 7ac1d28130..d622ecbcbc 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 23ebd59b32..206dbf1e01 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 3a4c381f67..e10481ef8d 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -67,41 +67,6 @@ } 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 { From 6b5e4d1790022b3389702ebc3d4b63fe9e186888 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 09:41:20 -0800 Subject: [PATCH 409/574] and an acceptance test --- spec/acceptance/apt_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 3011f9dfde..e409a9098f 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -13,7 +13,6 @@ pp = <<-EOS class { 'apt': always_apt_update => true, - disable_keys => true, purge_sources_list => true, purge_sources_list_d => true, purge_preferences => true, @@ -29,7 +28,6 @@ class { 'apt': 'key_server' => 'pgp.mit.edu', } }, - fancy_progress => true, } EOS From 87b087e9c0d61cb9c09fbc59d09f56cf43fa5cdc Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 09:46:04 -0800 Subject: [PATCH 410/574] Get rid of unattended upgrades and cleanup unused templates --- manifests/unattended_upgrades.pp | 79 --------- spec/classes/unattended_upgrades_spec.rb | 214 ----------------------- templates/10periodic.erb | 15 -- templates/50unattended-upgrades.erb | 57 ------ templates/progressbar.erb | 1 - templates/unauth.erb | 1 - tests/unattended_upgrades.pp | 1 - 7 files changed, 368 deletions(-) delete mode 100644 manifests/unattended_upgrades.pp delete mode 100644 spec/classes/unattended_upgrades_spec.rb delete mode 100644 templates/10periodic.erb delete mode 100644 templates/50unattended-upgrades.erb delete mode 100644 templates/progressbar.erb delete mode 100644 templates/unauth.erb delete mode 100644 tests/unattended_upgrades.pp diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp deleted file mode 100644 index b835b9a6a5..0000000000 --- a/manifests/unattended_upgrades.pp +++ /dev/null @@ -1,79 +0,0 @@ -# Class: apt::unattended_upgrades -# -# This class manages the unattended-upgrades package and related configuration -# files for ubuntu -# -# origins are the repositories to automatically upgrade included packages -# blacklist is a list of packages to not automatically upgrade -# update is how often to run "apt-get update" in days -# download is how often to run "apt-get upgrade --download-only" in days -# upgrade is how often to upgrade packages included in the origins list in days -# autoclean is how often to run "apt-get autoclean" in days -# -# information on the other options can be found in the 50unattended-upgrades -# file and in /etc/cron.daily/apt -# -class apt::unattended_upgrades ( - $origins = $::apt::params::origins, - $blacklist = [], - $update = '1', - $download = '1', - $upgrade = '1', - $autoclean = '7', - $auto_fix = true, - $minimal_steps = false, - $install_on_shutdown = false, - $mail_to = 'NONE', - $mail_only_on_error = false, - $remove_unused = true, - $auto_reboot = false, - $dl_limit = 'NONE', - $randomsleep = undef, - $enable = '1', - $backup_interval = '0', - $backup_level = '3', - $max_age = '0', - $min_age = '0', - $max_size = '0', - $download_delta = '0', - $verbose = '0', -) inherits ::apt::params { - - validate_bool( - $auto_fix, - $minimal_steps, - $install_on_shutdown, - $mail_only_on_error, - $remove_unused, - $auto_reboot - ) - validate_array($origins) - - if $randomsleep { - unless is_numeric($randomsleep) { - fail('randomsleep must be numeric') - } - } - - package { 'unattended-upgrades': - ensure => present, - } - - file { '/etc/apt/apt.conf.d/50unattended-upgrades': - ensure => file, - owner => 'root', - group => 'root', - mode => '0644', - content => template('apt/_header.erb', 'apt/50unattended-upgrades.erb'), - require => Package['unattended-upgrades'], - } - - file { '/etc/apt/apt.conf.d/10periodic': - ensure => file, - owner => 'root', - group => 'root', - mode => '0644', - content => template('apt/_header.erb', 'apt/10periodic.erb'), - require => Package['unattended-upgrades'], - } -} diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb deleted file mode 100644 index e0a6ebf722..0000000000 --- a/spec/classes/unattended_upgrades_spec.rb +++ /dev/null @@ -1,214 +0,0 @@ -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', :osfamily => 'Debian' } } - - it { should contain_package("unattended-upgrades") } - - it { - should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({ - "owner" => "root", - "group" => "root", - "mode" => "0644", - "require" => "Package[unattended-upgrades]", - }) - } - - it { - should create_file("/etc/apt/apt.conf.d/10periodic").with({ - "owner" => "root", - "group" => "root", - "mode" => "0644", - "require" => "Package[unattended-upgrades]", - }) - } - - describe 'failing' do - let :facts do - { - 'lsbdistid' => 'debian', - 'lsbdistcodename' => 'squeeze', - 'osfamily' => 'Debian', - } - end - context 'bad auto_fix' do - let :params do - { - 'auto_fix' => 'foo', - } - end - it { expect { should raise_error(Puppet::Error) } } - end - - context 'bad minimal_steps' do - let :params do - { - 'minimal_steps' => 'foo', - } - end - it { expect { should raise_error(Puppet::Error) } } - end - - context 'bad install_on_shutdown' do - let :params do - { - 'install_on_shutdown' => 'foo', - } - end - it { expect { should raise_error(Puppet::Error) } } - end - - context 'bad mail_only_on_error' do - let :params do - { - 'mail_only_on_error' => 'foo', - } - end - it { expect { should raise_error(Puppet::Error) } } - end - - context 'bad remove_unused' do - let :params do - { - 'remove_unused' => 'foo', - } - end - it { expect { should raise_error(Puppet::Error) } } - end - - context 'bad auto_reboot' do - let :params do - { - 'auto_reboot' => 'foo', - } - end - it { expect { should raise_error(Puppet::Error) } } - end - - context 'bad origins' do - let :params do - { - 'origins' => 'foo' - } - end - it { expect { should raise_error(Puppet::Error) } } - end - - context 'bad randomsleep' do - let :params do - { - 'randomsleep' => '4ever' - } - end - it { expect { should raise_error(Puppet::Error) } } - end - end - - context 'defaults' do - let :facts do - { - 'lsbdistid' => 'debian', - 'lsbdistcodename' => 'squeeze', - 'osfamily' => 'Debian', - } - end - - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id} oldstable";\n\t"\${distro_id} \${distro_codename}-security";\n\t"\${distro_id} \${distro_codename}-lts";\n\};} } - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "true";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "false";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "false";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "true";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "false";}} - - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "1";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "3";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "1";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "1";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "1";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "7";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "0";}} - it { is_expected.to_not contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep}} - end - - context 'wheezy' do - let :facts do - { - 'lsbdistid' => 'debian', - 'lsbdistcodename' => 'wheezy', - 'osfamily' => 'Debian', - } - end - - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"origin=Debian,archive=stable,label=Debian-Security";\n\t"origin=Debian,archive=oldstable,label=Debian-Security";\n\};} } - end - - context 'anything but defaults' do - let :facts do - { - 'lsbdistid' => 'debian', - 'lsbdistcodename' => 'wheezy', - 'osfamily' => 'Debian', - } - end - - let :params do - { - 'enable' => '0', - 'backup_interval' => '3', - 'backup_level' => '1', - 'max_age' => '7', - 'min_age' => '1', - 'max_size' => '100', - 'update' => '0', - 'download' => '0', - 'download_delta' => '1', - 'upgrade' => '0', - 'autoclean' => '0', - 'verbose' => '1', - 'origins' => ['bananas'], - 'blacklist' => ['foo', 'bar'], - 'auto_fix' => false, - 'minimal_steps' => true, - 'install_on_shutdown' => true, - 'mail_to' => 'root@localhost', - 'mail_only_on_error' => true, - 'remove_unused' => false, - 'auto_reboot' => true, - 'dl_limit' => '70', - 'randomsleep' => '1799', - } - end - - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"bananas";\n\};} } - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Package-Blacklist \{\n\t"foo";\n\t"bar";\n\};} } - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "false";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "true";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "true";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Mail "root@localhost";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MailOnlyOnError "true";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "false";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "true";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Acquire::http::Dl-Limit "70";}} - - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "3";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "1";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "7";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "1";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "100";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "1";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "0";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "1";}} - it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep "1799";}} - - end -end diff --git a/templates/10periodic.erb b/templates/10periodic.erb deleted file mode 100644 index 43caed9ea1..0000000000 --- a/templates/10periodic.erb +++ /dev/null @@ -1,15 +0,0 @@ -APT::Periodic::Enable "<%= @enable %>"; -APT::Periodic::BackUpArchiveInterval "<%= @backup_interval %>"; -APT::Periodic::BackUpLevel "<%= @backup_level %>"; -APT::Periodic::MaxAge "<%= @max_age %>"; -APT::Periodic::MinAge "<%= @min_age %>"; -APT::Periodic::MaxSize "<%= @max_size %>"; -APT::Periodic::Update-Package-Lists "<%= @update %>"; -APT::Periodic::Download-Upgradeable-Packages "<%= @download %>"; -APT::Periodic::Download-Upgradeable-Packages-Debdelta "<%= @download_delta %>"; -APT::Periodic::Unattended-Upgrade "<%= @upgrade %>"; -APT::Periodic::AutocleanInterval "<%= @autoclean %>"; -APT::Periodic::Verbose "<%= @verbose %>"; -<%- unless @randomsleep.nil? -%> -APT::Periodic::RandomSleep "<%= @randomsleep %>"; -<%- end -%> diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb deleted file mode 100644 index 1177922de0..0000000000 --- a/templates/50unattended-upgrades.erb +++ /dev/null @@ -1,57 +0,0 @@ -// Automatically upgrade packages from these (origin:archive) pairs -<%- if @legacy_origin -%> -Unattended-Upgrade::Allowed-Origins { -<%- else -%> -Unattended-Upgrade::Origins-Pattern { -<%- end -%> -<% @origins.each do |origin| -%> - "<%= origin %>"; -<% end -%> -}; - -// List of packages to not update -Unattended-Upgrade::Package-Blacklist { -<% @blacklist.each do |package| -%> - "<%= package %>"; -<% end -%> -}; - -// This option allows you to control if on a unclean dpkg exit -// unattended-upgrades will automatically run -// dpkg --force-confold --configure -a -// The default is true, to ensure updates keep getting installed -Unattended-Upgrade::AutoFixInterruptedDpkg "<%= @auto_fix %>"; - -// Split the upgrade into the smallest possible chunks so that -// they can be interrupted with SIGUSR1. This makes the upgrade -// a bit slower but it has the benefit that shutdown while a upgrade -// is running is possible (with a small delay) -Unattended-Upgrade::MinimalSteps "<%= @minimal_steps %>"; - -// Install all unattended-upgrades when the machine is shuting down -// instead of doing it in the background while the machine is running -// This will (obviously) make shutdown slower -Unattended-Upgrade::InstallOnShutdown "<%= @install_on_shutdown %>"; - -// Send email to this address for problems or packages upgrades -// If empty or unset then no email is sent, make sure that you -// have a working mail setup on your system. A package that provides -// 'mailx' must be installed. -<% if @mail_to != "NONE" %>Unattended-Upgrade::Mail "<%= @mail_to %>";<% end %> - -// Set this value to "true" to get emails only on errors. Default -// is to always send a mail if Unattended-Upgrade::Mail is set -<% if @mail_to != "NONE" %>Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>";<% end %> - -// Do automatic removal of new unused dependencies after the upgrade -// (equivalent to apt-get autoremove) -Unattended-Upgrade::Remove-Unused-Dependencies "<%= @remove_unused %>"; - -// Automatically reboot *WITHOUT CONFIRMATION* if a -// the file /var/run/reboot-required is found after the upgrade -Unattended-Upgrade::Automatic-Reboot "<%= @auto_reboot %>"; - - -// Use apt bandwidth limit feature, this example limits the download -// speed to 70kb/sec -<% if @dl_limit != "NONE" %>Acquire::http::Dl-Limit "<%= @dl_limit %>";<% end %> diff --git a/templates/progressbar.erb b/templates/progressbar.erb deleted file mode 100644 index d3d9278c0d..0000000000 --- a/templates/progressbar.erb +++ /dev/null @@ -1 +0,0 @@ -Dpkg::Progress-Fancy "1"; diff --git a/templates/unauth.erb b/templates/unauth.erb deleted file mode 100644 index 77edd289f6..0000000000 --- a/templates/unauth.erb +++ /dev/null @@ -1 +0,0 @@ -APT::Get::AllowUnauthenticated 1; diff --git a/tests/unattended_upgrades.pp b/tests/unattended_upgrades.pp deleted file mode 100644 index 3b9b49eb72..0000000000 --- a/tests/unattended_upgrades.pp +++ /dev/null @@ -1 +0,0 @@ -include apt::unattended_upgrades From b09a699b8c0454cabcfbd85efd7e1294a3c0f891 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 09:48:10 -0800 Subject: [PATCH 411/574] move tests to examples --- {tests => examples}/builddep.pp | 0 {tests => examples}/debian/testing.pp | 0 {tests => examples}/debian/unstable.pp | 0 {tests => examples}/force.pp | 0 {tests => examples}/init.pp | 0 {tests => examples}/key.pp | 0 {tests => examples}/params.pp | 0 {tests => examples}/pin.pp | 0 {tests => examples}/ppa.pp | 0 {tests => examples}/release.pp | 0 {tests => examples}/source.pp | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename {tests => examples}/builddep.pp (100%) rename {tests => examples}/debian/testing.pp (100%) rename {tests => examples}/debian/unstable.pp (100%) rename {tests => examples}/force.pp (100%) rename {tests => examples}/init.pp (100%) rename {tests => examples}/key.pp (100%) rename {tests => examples}/params.pp (100%) rename {tests => examples}/pin.pp (100%) rename {tests => examples}/ppa.pp (100%) rename {tests => examples}/release.pp (100%) rename {tests => examples}/source.pp (100%) diff --git a/tests/builddep.pp b/examples/builddep.pp similarity index 100% rename from tests/builddep.pp rename to examples/builddep.pp diff --git a/tests/debian/testing.pp b/examples/debian/testing.pp similarity index 100% rename from tests/debian/testing.pp rename to examples/debian/testing.pp diff --git a/tests/debian/unstable.pp b/examples/debian/unstable.pp similarity index 100% rename from tests/debian/unstable.pp rename to examples/debian/unstable.pp diff --git a/tests/force.pp b/examples/force.pp similarity index 100% rename from tests/force.pp rename to examples/force.pp diff --git a/tests/init.pp b/examples/init.pp similarity index 100% rename from tests/init.pp rename to examples/init.pp diff --git a/tests/key.pp b/examples/key.pp similarity index 100% rename from tests/key.pp rename to examples/key.pp diff --git a/tests/params.pp b/examples/params.pp similarity index 100% rename from tests/params.pp rename to examples/params.pp diff --git a/tests/pin.pp b/examples/pin.pp similarity index 100% rename from tests/pin.pp rename to examples/pin.pp diff --git a/tests/ppa.pp b/examples/ppa.pp similarity index 100% rename from tests/ppa.pp rename to examples/ppa.pp diff --git a/tests/release.pp b/examples/release.pp similarity index 100% rename from tests/release.pp rename to examples/release.pp diff --git a/tests/source.pp b/examples/source.pp similarity index 100% rename from tests/source.pp rename to examples/source.pp From 9debb1a909e27452c4704930b5b0026a73f0f142 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 10:22:37 -0800 Subject: [PATCH 412/574] Remove backports and debian --- manifests/backports.pp | 82 --------------- manifests/debian/testing.pp | 21 ---- manifests/debian/unstable.pp | 21 ---- manifests/params.pp | 6 -- spec/classes/backports_spec.rb | 177 --------------------------------- 5 files changed, 307 deletions(-) delete mode 100644 manifests/backports.pp delete mode 100644 manifests/debian/testing.pp delete mode 100644 manifests/debian/unstable.pp delete mode 100644 spec/classes/backports_spec.rb diff --git a/manifests/backports.pp b/manifests/backports.pp deleted file mode 100644 index a3ddb76e00..0000000000 --- a/manifests/backports.pp +++ /dev/null @@ -1,82 +0,0 @@ -# This adds the necessary components to get backports for ubuntu and debian -# -# == Parameters -# -# [*release*] -# The ubuntu/debian release name. Defaults to $lsbdistcodename. Setting this -# manually can cause undefined behavior. (Read: universe exploding) -# -# [*pin_priority*] -# _default_: 200 -# -# The priority that should be awarded by default to all packages coming from -# the Debian Backports project. -# -# == Examples -# -# include apt::backports -# -# class { 'apt::backports': -# release => 'natty', -# } -# -# == Authors -# -# Ben Hughes, I think. At least blame him if this goes wrong. -# I just added puppet doc. -# -# == Copyright -# -# Copyright 2011 Puppet Labs Inc, unless otherwise noted. -class apt::backports( - $release = $::lsbdistcodename, - $location = $::apt::params::backports_location, - $pin_priority = 200, -) inherits apt::params { - - if ! is_integer($pin_priority) { - fail('$pin_priority must be an integer') - } - - if $::lsbdistid == 'LinuxMint' { - if $::lsbdistcodename == 'debian' { - $distid = 'debian' - $release_real = 'wheezy' - } else { - $distid = 'ubuntu' - $release_real = $::lsbdistcodename ? { - 'qiana' => 'trusty', - 'petra' => 'saucy', - 'olivia' => 'raring', - 'nadia' => 'quantal', - 'maya' => 'precise', - } - } - } else { - $distid = $::lsbdistid - $release_real = downcase($release) - } - - $key = $distid ? { - 'debian' => '46925553', - 'ubuntu' => '437D05B5', - } - $repos = $distid ? { - 'debian' => 'main contrib non-free', - 'ubuntu' => 'main universe multiverse restricted', - } - - apt::pin { 'backports': - before => Apt::Source['backports'], - release => "${release_real}-backports", - priority => $pin_priority, - } - - apt::source { 'backports': - location => $location, - release => "${release_real}-backports", - repos => $repos, - key => $key, - key_server => 'pgp.mit.edu', - } -} diff --git a/manifests/debian/testing.pp b/manifests/debian/testing.pp deleted file mode 100644 index 3a82b4f7fd..0000000000 --- a/manifests/debian/testing.pp +++ /dev/null @@ -1,21 +0,0 @@ -# testing.pp - -class apt::debian::testing { - include apt - - # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free - # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free - # Key: 46925553 Server: subkeys.pgp.net - # debian-keyring - # debian-archive-keyring - - apt::source { 'debian_testing': - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'testing', - repos => 'main contrib non-free', - required_packages => 'debian-keyring debian-archive-keyring', - key => '46925553', - key_server => 'subkeys.pgp.net', - pin => '-10', - } -} diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp deleted file mode 100644 index 77df94b0af..0000000000 --- a/manifests/debian/unstable.pp +++ /dev/null @@ -1,21 +0,0 @@ -# unstable.pp - -class apt::debian::unstable { - include apt - - # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free - # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free - # Key: 46925553 Server: subkeys.pgp.net - # debian-keyring - # debian-archive-keyring - - apt::source { 'debian_unstable': - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'unstable', - repos => 'main contrib non-free', - required_packages => 'debian-keyring debian-archive-keyring', - key => '46925553', - key_server => 'subkeys.pgp.net', - pin => '-10', - } -} diff --git a/manifests/params.pp b/manifests/params.pp index b97a8a25bf..ce8a6dfe0d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -40,20 +40,17 @@ 'debian': { case $distcodename { 'squeeze': { - $backports_location = 'http://backports.debian.org/debian-backports' $legacy_origin = true $origins = ['${distro_id} oldstable', #lint:ignore:single_quote_string_with_variables '${distro_id} ${distro_codename}-security', #lint:ignore:single_quote_string_with_variables '${distro_id} ${distro_codename}-lts'] #lint:ignore:single_quote_string_with_variables } 'wheezy': { - $backports_location = 'http://ftp.debian.org/debian/' $legacy_origin = false $origins = ['origin=Debian,archive=stable,label=Debian-Security', 'origin=Debian,archive=oldstable,label=Debian-Security'] } default: { - $backports_location = 'http://http.debian.net/debian/' $legacy_origin = false $origins = ['origin=Debian,archive=stable,label=Debian-Security'] } @@ -62,19 +59,16 @@ 'ubuntu': { case $distcodename { 'lucid': { - $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = undef $legacy_origin = true $origins = ['${distro_id} ${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } 'precise', 'trusty', 'utopic', 'vivid': { - $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = '-y' $legacy_origin = true $origins = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } default: { - $backports_location = 'http://old-releases.ubuntu.com/ubuntu' $ppa_options = '-y' $legacy_origin = true $origins = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb deleted file mode 100644 index 3c1f438561..0000000000 --- a/spec/classes/backports_spec.rb +++ /dev/null @@ -1,177 +0,0 @@ -require 'spec_helper' -describe 'apt::backports', :type => :class do - - describe 'when asigning a custom priority to backports' do - let :facts do - { - 'lsbdistcodename' => 'Karmic', - 'lsbdistid' => 'Ubuntu', - 'osfamily' => 'Debian' - } - end - - context 'integer priority' do - let :params do { :pin_priority => 500 } end - - it { should contain_apt__source('backports').with({ - 'location' => 'http://old-releases.ubuntu.com/ubuntu', - 'release' => 'karmic-backports', - 'repos' => 'main universe multiverse restricted', - 'key' => '437D05B5', - 'key_server' => 'pgp.mit.edu', - }) - } - - it { should contain_apt__pin('backports').with({ - 'release' => 'karmic-backports', - 'priority' => 500, - }) - } - end - - context 'invalid priority' do - let :params do { :pin_priority => 'banana' } end - it 'should fail' do - expect { subject }.to raise_error(/must be an integer/) - end - end - end - - describe 'when turning on backports for ubuntu karmic' do - - let :facts do - { - 'lsbdistcodename' => 'Karmic', - 'lsbdistid' => 'Ubuntu', - 'osfamily' => 'Debian' - } - end - - it { should contain_apt__source('backports').with({ - 'location' => 'http://old-releases.ubuntu.com/ubuntu', - 'release' => 'karmic-backports', - 'repos' => 'main universe multiverse restricted', - 'key' => '437D05B5', - 'key_server' => 'pgp.mit.edu', - }) - } - - it { should contain_apt__pin('backports').with({ - 'release' => 'karmic-backports', - 'priority' => 200, - }) - } - end - - describe "when turning on backports for debian squeeze" do - - let :facts do - { - 'lsbdistcodename' => 'Squeeze', - 'lsbdistid' => 'Debian', - 'osfamily' => 'Debian' - } - end - - it { should contain_apt__source('backports').with({ - 'location' => 'http://backports.debian.org/debian-backports', - 'release' => 'squeeze-backports', - 'repos' => 'main contrib non-free', - 'key' => '46925553', - 'key_server' => 'pgp.mit.edu', - }) - } - - it { should contain_apt__pin('backports').with({ - 'release' => 'squeeze-backports', - 'priority' => 200, - }) - } - end - - describe "when turning on backports for linux mint debian edition" do - - let :facts do - { - 'lsbdistcodename' => 'debian', - 'lsbdistid' => 'LinuxMint', - 'osfamily' => 'Debian' - } - end - - it { should contain_apt__source('backports').with({ - 'location' => 'http://ftp.debian.org/debian/', - 'release' => 'wheezy-backports', - 'repos' => 'main contrib non-free', - 'key' => '46925553', - 'key_server' => 'pgp.mit.edu', - }) - } - - it { should contain_apt__pin('backports').with({ - 'release' => 'wheezy-backports', - 'priority' => 200, - }) - } - end - - describe "when turning on backports for linux mint 17 (ubuntu-based)" do - - let :facts do - { - 'lsbdistcodename' => 'qiana', - 'lsbdistid' => 'LinuxMint', - 'osfamily' => 'Debian' - } - end - - it { should contain_apt__source('backports').with({ - 'location' => 'http://us.archive.ubuntu.com/ubuntu', - 'release' => 'trusty-backports', - 'repos' => 'main universe multiverse restricted', - 'key' => '437D05B5', - 'key_server' => 'pgp.mit.edu', - }) - } - - it { should contain_apt__pin('backports').with({ - 'release' => 'trusty-backports', - 'priority' => 200, - }) - } - end - - describe "when turning on backports for debian squeeze but using your own mirror" do - - let :facts do - { - 'lsbdistcodename' => 'Squeeze', - 'lsbdistid' => 'Debian', - 'osfamily' => 'Debian' - } - end - - let :location do - 'http://mirrors.example.com/debian-backports' - end - - let :params do - { 'location' => location } - end - - it { should contain_apt__source('backports').with({ - 'location' => location, - 'release' => 'squeeze-backports', - 'repos' => 'main contrib non-free', - 'key' => '46925553', - 'key_server' => 'pgp.mit.edu', - }) - } - - it { should contain_apt__pin('backports').with({ - 'release' => 'squeeze-backports', - 'priority' => 200, - }) - } - end -end From 501a1b5627687b13c0809b82db03f9df168fbd7a Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 10:25:36 -0800 Subject: [PATCH 413/574] stop including params everywhere --- manifests/conf.pp | 2 -- manifests/pin.pp | 2 -- manifests/ppa.pp | 1 - manifests/release.pp | 3 --- manifests/source.pp | 2 -- manifests/update.pp | 1 - 6 files changed, 11 deletions(-) diff --git a/manifests/conf.pp b/manifests/conf.pp index 318422e293..c37cf6b804 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -4,8 +4,6 @@ $priority = '50' ) { - include apt::params - $apt_conf_d = $apt::params::apt_conf_d file { "${apt_conf_d}/${priority}${name}": diff --git a/manifests/pin.pp b/manifests/pin.pp index 935dc226e5..a6e3cf8e29 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -16,8 +16,6 @@ $originator = '', # o= $label = '' # l= ) { - include apt::params - $preferences_d = $apt::params::preferences_d if $order != '' and !is_integer($order) { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 0fdcc95f3a..f6c7373d8d 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -5,7 +5,6 @@ $release = $::lsbdistcodename, $options = $apt::params::ppa_options, ) { - include apt::params include apt::update $sources_list_d = $apt::params::sources_list_d diff --git a/manifests/release.pp b/manifests/release.pp index ae12dd4fb2..d4760180f7 100644 --- a/manifests/release.pp +++ b/manifests/release.pp @@ -3,9 +3,6 @@ class apt::release ( $release_id ) { - - include apt::params - $root = $apt::params::root file { "${root}/apt.conf.d/01release": diff --git a/manifests/source.pp b/manifests/source.pp index f6647dfe76..3e9414f11d 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -18,8 +18,6 @@ $architecture = undef, $trusted_source = false, ) { - - include apt::params include apt::update validate_string($architecture) diff --git a/manifests/update.pp b/manifests/update.pp index d9b338d952..26790ceafa 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -1,5 +1,4 @@ class apt::update { - include apt::params #TODO: to catch if $::apt_update_last_success has the value of -1 here. If we #opt to do this, a info/warn would likely be all you'd need likely to happen #on the first run, but if it's not run in awhile something is likely borked From 4def3987e0cdfba7bd76824fc97ffee9a00949f5 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sun, 15 Feb 2015 19:40:42 +0100 Subject: [PATCH 414/574] Remove some vars for unattended_upgrades. --- manifests/params.pp | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index ce8a6dfe0d..aa90a7dd32 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -37,41 +37,16 @@ } } case $distid { - 'debian': { - case $distcodename { - 'squeeze': { - $legacy_origin = true - $origins = ['${distro_id} oldstable', #lint:ignore:single_quote_string_with_variables - '${distro_id} ${distro_codename}-security', #lint:ignore:single_quote_string_with_variables - '${distro_id} ${distro_codename}-lts'] #lint:ignore:single_quote_string_with_variables - } - 'wheezy': { - $legacy_origin = false - $origins = ['origin=Debian,archive=stable,label=Debian-Security', - 'origin=Debian,archive=oldstable,label=Debian-Security'] - } - default: { - $legacy_origin = false - $origins = ['origin=Debian,archive=stable,label=Debian-Security'] - } - } - } 'ubuntu': { case $distcodename { 'lucid': { $ppa_options = undef - $legacy_origin = true - $origins = ['${distro_id} ${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } 'precise', 'trusty', 'utopic', 'vivid': { $ppa_options = '-y' - $legacy_origin = true - $origins = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } default: { $ppa_options = '-y' - $legacy_origin = true - $origins = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } } } From 90cc951753edeb3380b0ee6193c4d6febdc84a18 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 10:45:25 -0800 Subject: [PATCH 415/574] get rid of builddep --- examples/builddep.pp | 5 +++-- manifests/builddep.pp | 16 ---------------- metadata.json | 2 +- spec/defines/builddep_spec.rb | 19 ------------------- 4 files changed, 4 insertions(+), 38 deletions(-) delete mode 100644 manifests/builddep.pp delete mode 100644 spec/defines/builddep_spec.rb diff --git a/examples/builddep.pp b/examples/builddep.pp index 8b4f796408..67cc86b4d3 100644 --- a/examples/builddep.pp +++ b/examples/builddep.pp @@ -1,2 +1,3 @@ -class { 'apt': } -apt::builddep{ 'glusterfs-server': } +package{ 'glusterfs-server': + install_options => 'build-dep', +} diff --git a/manifests/builddep.pp b/manifests/builddep.pp deleted file mode 100644 index 3a059c273d..0000000000 --- a/manifests/builddep.pp +++ /dev/null @@ -1,16 +0,0 @@ -# builddep.pp - -define apt::builddep() { - include apt::update - - exec { "apt-builddep-${name}": - command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", - logoutput => 'on_failure', - require => Exec['apt_update'], - } - - # Need anchor to provide containment for dependencies. - anchor { "apt::builddep::${name}": - require => Class['apt::update'], - } -} diff --git a/metadata.json b/metadata.json index 4c0e3d8c6a..6135d62a46 100644 --- a/metadata.json +++ b/metadata.json @@ -35,6 +35,6 @@ } ], "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 2.2.1"} + {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0"} ] } diff --git a/spec/defines/builddep_spec.rb b/spec/defines/builddep_spec.rb deleted file mode 100644 index 41152d5c9b..0000000000 --- a/spec/defines/builddep_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper' -describe 'apt::builddep', :type => :define do - - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let(:title) { 'my_package' } - - describe "defaults" do - it { should contain_exec("apt-builddep-my_package").that_requires('Exec[apt_update]').with({ - 'command' => "/usr/bin/apt-get -y --force-yes build-dep my_package", - 'logoutput' => 'on_failure' - }) - } - it { should contain_anchor("apt::builddep::my_package").with({ - 'require' => 'Class[Apt::Update]', - }) - } - end - -end From 8cc7d40dd9930b34abfdbebd8a27acefc449d69c Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 10:52:57 -0800 Subject: [PATCH 416/574] Get rid of force --- manifests/force.pp | 60 ---------------------- spec/defines/force_spec.rb | 102 ------------------------------------- 2 files changed, 162 deletions(-) delete mode 100644 manifests/force.pp delete mode 100644 spec/defines/force_spec.rb diff --git a/manifests/force.pp b/manifests/force.pp deleted file mode 100644 index 8ceeb17060..0000000000 --- a/manifests/force.pp +++ /dev/null @@ -1,60 +0,0 @@ -# force.pp -# force a package from a specific release - -define apt::force( - $release = false, - $version = false, - $timeout = 300, - $cfg_files = 'none', - $cfg_missing = false, -) { - - validate_re($cfg_files, ['^new', '^old', '^unchanged', '^none']) - validate_bool($cfg_missing) - - $provider = $apt::params::provider - - $version_string = $version ? { - false => undef, - default => "=${version}", - } - - $release_string = $release ? { - false => undef, - default => "-t ${release}", - } - - case $cfg_files { - 'new': { $config_files = '-o Dpkg::Options::="--force-confnew"' } - 'old': { $config_files = '-o Dpkg::Options::="--force-confold"' } - 'unchanged': { $config_files = '-o Dpkg::Options::="--force-confdef"' } - 'none', default: { $config_files = '' } - } - - case $cfg_missing { - true: { $config_missing = '-o Dpkg::Options::="--force-confmiss"' } - false, default: { $config_missing = '' } - } - - if $version == false { - if $release == false { - $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'" - } else { - # If installed version and candidate version differ, this check returns 1 (false). - $install_check = "/usr/bin/test \$(/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" - } - } else { - if $release == false { - $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" - } else { - $install_check = "/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -q 'Installed: ${version}'" - } - } - - exec { "${provider} -y ${config_files} ${config_missing} ${release_string} install ${name}${version_string}": - unless => $install_check, - environment => ['LC_ALL=C', 'LANG=C'], - logoutput => 'on_failure', - timeout => $timeout, - } -} diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb deleted file mode 100644 index 5c48ec64c3..0000000000 --- a/spec/defines/force_spec.rb +++ /dev/null @@ -1,102 +0,0 @@ -require 'spec_helper' -describe 'apt::force', :type => :define do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let :pre_condition do - 'include apt::params' - end - - let :title do - 'my_package' - end - - let :default_params do - { - :release => false, - :version => false, - :cfg_files => 'none', - :cfg_missing => false, - } - end - - describe "when using default parameters" do - it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'", - :logoutput => 'on_failure', - :timeout => '300' - ) } - end - - describe "when specifying release parameter" do - let :params do - default_params.merge(:release => 'testing') - end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( - :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" - ) } - end - - describe "when specifying version parameter" do - let :params do - default_params.merge(:version => '1') - end - it { should contain_exec("/usr/bin/apt-get -y install #{title}=#{params[:version]}").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" - ) } - end - - describe "when specifying cfg_files parameter" do - let :params do - default_params.merge(:cfg_files => 'unchanged') - end - it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" install my_package').with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" - ) } - end - - describe "when specifying cfg_missing parameter" do - let :params do - default_params.merge(:cfg_missing => true) - end - it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confmiss" install my_package').with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" - ) } - end - - describe "when specifying cfg_files and cfg_missing parameter" do - let :params do - default_params.merge( - :cfg_files => 'unchanged', - :cfg_missing => true - ) - end - it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" install my_package').with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" - ) } - end - - describe "when specifying release and version parameters" do - let :params do - default_params.merge( - :release => 'testing', - :version => '1' - ) - end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with( - :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" - ) } - end - - describe "when specifying release, version, cfg_files and cfg_missing parameters" do - let :params do - default_params.merge( - :release => 'testing', - :version => '1', - :cfg_files => 'unchanged', - :cfg_missing => true - ) - end - it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" -t testing install my_package=1').with( - :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" - ) } - end -end From 080977400605936e5ad092b0bbeb4d68b11fc6c8 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 10:54:33 -0800 Subject: [PATCH 417/574] Get rid of release --- manifests/release.pp | 14 -------------- spec/classes/release_spec.rb | 23 ----------------------- templates/release.erb | 1 - 3 files changed, 38 deletions(-) delete mode 100644 manifests/release.pp delete mode 100644 spec/classes/release_spec.rb delete mode 100644 templates/release.erb diff --git a/manifests/release.pp b/manifests/release.pp deleted file mode 100644 index d4760180f7..0000000000 --- a/manifests/release.pp +++ /dev/null @@ -1,14 +0,0 @@ -# release.pp - -class apt::release ( - $release_id -) { - $root = $apt::params::root - - file { "${root}/apt.conf.d/01release": - owner => root, - group => root, - mode => '0644', - content => template('apt/_header.erb', 'apt/release.erb'), - } -} diff --git a/spec/classes/release_spec.rb b/spec/classes/release_spec.rb deleted file mode 100644 index e33a9be4bb..0000000000 --- a/spec/classes/release_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' -describe 'apt::release', :type => :class do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let (:title) { 'my_package' } - - let :param_set do - { :release_id => 'precise' } - end - - let (:params) { param_set } - - it { should contain_class("apt::params") } - - it { - should contain_file("/etc/apt/apt.conf.d/01release").with({ - "mode" => "0644", - "owner" => "root", - "group" => "root", - "content" => /APT::Default-Release "#{param_set[:release_id]}";/ - }) - } -end - diff --git a/templates/release.erb b/templates/release.erb deleted file mode 100644 index 08760af70a..0000000000 --- a/templates/release.erb +++ /dev/null @@ -1 +0,0 @@ -APT::Default-Release "<%= @release_id %>"; From 8ef58a456d2217caade1cb1dc04d5302066d1c6b Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 10:59:00 -0800 Subject: [PATCH 418/574] Get rid of hold --- examples/hold.pp | 5 ++ manifests/hold.pp | 54 ---------------------- spec/defines/hold_spec.rb | 97 --------------------------------------- 3 files changed, 5 insertions(+), 151 deletions(-) create mode 100644 examples/hold.pp delete mode 100644 manifests/hold.pp delete mode 100644 spec/defines/hold_spec.rb diff --git a/examples/hold.pp b/examples/hold.pp new file mode 100644 index 0000000000..00f760c4e0 --- /dev/null +++ b/examples/hold.pp @@ -0,0 +1,5 @@ +apt::pin { 'hold-vim': + packages => 'vim', + version => '2:7.4.488-5', + priority => 1001, +} diff --git a/manifests/hold.pp b/manifests/hold.pp deleted file mode 100644 index 61e8afcb3b..0000000000 --- a/manifests/hold.pp +++ /dev/null @@ -1,54 +0,0 @@ -# == Define apt::hold -# -# This defined type allows you to hold a package based on the version you -# require. It's implemented by dropping an apt preferences file pinning the -# package to the version you require. -# -# === Parameters -# -# [*version*] -# The version at which you wish to pin a package. -# -# This can either be the full version, such as 4:2.11.8.1-5, or -# a partial version, such as 4:2.11.* -# -# [*package*] -# _default_: +$title+, the title/name of the resource. -# -# Name of the package that apt is to hold. -# -# [*priority*] -# _default_: +1001+ -# -# The default priority of 1001 causes this preference to always win. By -# setting the priority to a number greater than 1000 apt will always install -# this version even if it means downgrading the currently installed version. -define apt::hold( - $version, - $ensure = 'present', - $package = $title, - $priority = 1001, -){ - - validate_string($title) - validate_re($ensure, ['^present|absent',]) - validate_string($package) - validate_string($version) - - if ! is_integer($priority) { - fail('$priority must be an integer') - } - - if $ensure == 'present' { - ::apt::pin { "hold_${package}": - packages => $package, - version => $version, - priority => $priority, - } - } else { - ::apt::pin { "hold_${package}": - ensure => 'absent', - } - } - -} diff --git a/spec/defines/hold_spec.rb b/spec/defines/hold_spec.rb deleted file mode 100644 index 60b991f194..0000000000 --- a/spec/defines/hold_spec.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'spec_helper' -describe 'apt::hold' do - let :facts do { - :osfamily => 'Debian', - :lsbdistid => 'Debian', - :lsbrelease => 'wheezy', - } end - - let :title do - 'vim' - end - - let :default_params do { - :version => '1.1.1', - } end - - describe 'default params' do - let :params do default_params end - - it 'creates an apt preferences file' do - should contain_apt__pin("hold_#{title}").with({ - :ensure => 'present', - :packages => title, - :version => params[:version], - :priority => 1001, - }) - end - end - - describe 'ensure => absent' do - let :params do default_params.merge({:ensure => 'absent',}) end - - it 'creates an apt preferences file' do - - should contain_apt__pin("hold_#{title}").with({ - :ensure => params[:ensure], - }) - end - end - - describe 'priority => 990' do - let :params do default_params.merge({:priority => 990,}) end - - it 'creates an apt preferences file' do - should contain_apt__pin("hold_#{title}").with({ - :ensure => 'present', - :packages => title, - :version => params[:version], - :priority => params[:priority], - }) - end - end - - describe 'package => foo' do - let :params do default_params.merge({:package => 'foo'}) end - - it 'creates an apt preferences file' do - should contain_apt__pin("hold_foo").with({ - :ensure => 'present', - :packages => 'foo', - :version => params[:version], - :priority => 1001, - }) - end - end - - - describe 'validation' do - context 'version => {}' do - let :params do { :version => {}, } end - it 'should fail' do - expect { subject }.to raise_error(/is not a string/) - end - end - - context 'ensure => bananana' do - let :params do default_params.merge({:ensure => 'bananana',}) end - it 'should fail' do - expect { subject }.to raise_error(/does not match/) - end - end - - context 'package => []' do - let :params do default_params.merge({:package => [],}) end - it 'should fail' do - expect { subject }.to raise_error(/is not a string/) - end - end - - context 'priority => bananana' do - let :params do default_params.merge({:priority => 'bananana',}) end - it 'should fail' do - expect { subject }.to raise_error(/must be an integer/) - end - end - end -end From e965fe450d5ec69d24c023096c3f73b4e43f34b2 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 11:11:58 -0800 Subject: [PATCH 419/574] Update examples --- examples/debian/testing.pp | 2 -- examples/debian/unstable.pp | 2 -- examples/force.pp | 17 +---------------- examples/init.pp | 1 - examples/params.pp | 1 - examples/release.pp | 6 +++--- 6 files changed, 4 insertions(+), 25 deletions(-) delete mode 100644 examples/debian/testing.pp delete mode 100644 examples/debian/unstable.pp delete mode 100644 examples/init.pp delete mode 100644 examples/params.pp diff --git a/examples/debian/testing.pp b/examples/debian/testing.pp deleted file mode 100644 index 8245b3a337..0000000000 --- a/examples/debian/testing.pp +++ /dev/null @@ -1,2 +0,0 @@ -class { 'apt': } -class { 'apt::debian::testing': } diff --git a/examples/debian/unstable.pp b/examples/debian/unstable.pp deleted file mode 100644 index 8605179295..0000000000 --- a/examples/debian/unstable.pp +++ /dev/null @@ -1,2 +0,0 @@ -class { 'apt': } -class { 'apt::debian::unstable': } diff --git a/examples/force.pp b/examples/force.pp index 59ad8f1b57..36d23f8546 100644 --- a/examples/force.pp +++ b/examples/force.pp @@ -1,17 +1,2 @@ # force.pp - -# force a package from a specific release -apt::force { 'package1': - release => 'backports', -} - -# force a package to be a specific version -apt::force { 'package2': - version => '1.0.0-1', -} - -# force a package from a specific release to be a specific version -apt::force { 'package3': - release => 'sid', - version => '2.0.0-1', -} +# TODO: Update diff --git a/examples/init.pp b/examples/init.pp deleted file mode 100644 index abc75afa25..0000000000 --- a/examples/init.pp +++ /dev/null @@ -1 +0,0 @@ -class { 'apt': } diff --git a/examples/params.pp b/examples/params.pp deleted file mode 100644 index 5ddf3c6551..0000000000 --- a/examples/params.pp +++ /dev/null @@ -1 +0,0 @@ -include apt::params diff --git a/examples/release.pp b/examples/release.pp index 823f5861fa..46d6893b0d 100644 --- a/examples/release.pp +++ b/examples/release.pp @@ -1,4 +1,4 @@ -class { 'apt': } -class { 'apt::release': - release_id => 'karmic' +apt::conf { 'release': + content => 'APT::Default-Release "karmic";', + priority => '01', } From e626423b57f0d4913ee2446df82ca88c19fad649 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sun, 15 Feb 2015 11:17:12 -0800 Subject: [PATCH 420/574] Placeholders for needed examples --- examples/backports.pp | 1 + examples/unattended_upgrades.pp | 1 + 2 files changed, 2 insertions(+) create mode 100644 examples/backports.pp create mode 100644 examples/unattended_upgrades.pp diff --git a/examples/backports.pp b/examples/backports.pp new file mode 100644 index 0000000000..464090415c --- /dev/null +++ b/examples/backports.pp @@ -0,0 +1 @@ +# TODO diff --git a/examples/unattended_upgrades.pp b/examples/unattended_upgrades.pp new file mode 100644 index 0000000000..464090415c --- /dev/null +++ b/examples/unattended_upgrades.pp @@ -0,0 +1 @@ +# TODO From 1534042c932a484ccb2e150968d4e98832436157 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 18 Feb 2015 11:43:50 -0800 Subject: [PATCH 421/574] Fix broken unit tests --- spec/classes/debian_testing_spec.rb | 15 --------------- spec/classes/debian_unstable_spec.rb | 15 --------------- spec/defines/conf_spec.rb | 3 +++ spec/defines/pin_spec.rb | 3 +++ spec/defines/ppa_spec.rb | 3 +++ spec/defines/source_spec.rb | 3 +++ 6 files changed, 12 insertions(+), 30 deletions(-) delete mode 100644 spec/classes/debian_testing_spec.rb delete mode 100644 spec/classes/debian_unstable_spec.rb diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb deleted file mode 100644 index 6e0332652f..0000000000 --- a/spec/classes/debian_testing_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' -describe 'apt::debian::testing', :type => :class do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - it { - should contain_apt__source("debian_testing").with({ - "location" => "http://debian.mirror.iweb.ca/debian/", - "release" => "testing", - "repos" => "main contrib non-free", - "required_packages" => "debian-keyring debian-archive-keyring", - "key" => "46925553", - "key_server" => "subkeys.pgp.net", - "pin" => "-10" - }) - } -end diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb deleted file mode 100644 index 8477a39e58..0000000000 --- a/spec/classes/debian_unstable_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' -describe 'apt::debian::unstable', :type => :class do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - it { - should contain_apt__source("debian_unstable").with({ - "location" => "http://debian.mirror.iweb.ca/debian/", - "release" => "unstable", - "repos" => "main contrib non-free", - "required_packages" => "debian-keyring debian-archive-keyring", - "key" => "46925553", - "key_server" => "subkeys.pgp.net", - "pin" => "-10" - }) - } -end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 91b6d4e62f..208f209a27 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -1,5 +1,8 @@ require 'spec_helper' describe 'apt::conf', :type => :define do + let :pre_condition do + 'class { "apt": }' + end let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let :title do 'norecommends' diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 206dbf1e01..b4443cc241 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -1,5 +1,8 @@ require 'spec_helper' describe 'apt::pin', :type => :define do + let :pre_condition do + 'class { "apt": }' + end let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let(:title) { 'my_pin' } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index e10481ef8d..f078204ed8 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -68,6 +68,9 @@ end describe 'ensure absent' do + let :pre_condition do + 'class { "apt": }' + end let :facts do { :lsbdistrelease => '14.04', diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 8ca7f8e203..684a6f0656 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -3,6 +3,9 @@ describe 'apt::source', :type => :define do GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' + let :pre_condition do + 'class { "apt": }' + end let :title do 'my_source' From 9f758e8b5fbad23caa820f4e038e4f5bb63e3f5f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 18 Feb 2015 13:42:43 -0800 Subject: [PATCH 422/574] Fix acceptance tests --- .fixtures.yml | 2 +- spec/spec_helper_acceptance.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index 2bb941de23..578437cb9f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,6 +2,6 @@ fixtures: repositories: "stdlib": "repo": "git://github.com/puppetlabs/puppetlabs-stdlib.git" - "ref": "v2.2.1" + "ref": "4.5.0" symlinks: "apt": "#{source_dir}" diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 6b2aa5d845..56b8dadc62 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -28,7 +28,7 @@ hosts.each do |host| copy_module_to(host, :source => proj_root, :module_name => 'apt') shell("/bin/touch #{default['puppetpath']}/hiera.yaml") - on host, puppet('module install puppetlabs-stdlib --version 2.2.1'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module install puppetlabs-stdlib --version 4.5.0'), { :acceptable_exit_codes => [0,1] } end end end From 59782daea166b210a468af6cb09ca956ddc01921 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 19 Feb 2015 08:26:30 -0800 Subject: [PATCH 423/574] Fix lint issue in examples --- examples/builddep.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/builddep.pp b/examples/builddep.pp index 67cc86b4d3..deaaef8c8f 100644 --- a/examples/builddep.pp +++ b/examples/builddep.pp @@ -1,3 +1,3 @@ -package{ 'glusterfs-server': +package{ 'glusterfs-server': install_options => 'build-dep', } From 794740813dde0ca76e62b88f82b4d1222e3c111e Mon Sep 17 00:00:00 2001 From: Spencer Krum Date: Thu, 19 Feb 2015 13:55:24 -0800 Subject: [PATCH 424/574] Remove travis badge --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 9feb900cfe..e46efc135f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # apt -[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-apt.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-apt) - ## Overview The apt module provides a simple interface for managing Apt source, key, and definitions with Puppet. From bb3a1f0af06febbae96effd048448f03e4c87d7e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 19 Feb 2015 15:39:14 -0800 Subject: [PATCH 425/574] Remove required packages I'm not entirely clear on the history behind this feature, and this feels sort of hack-y. If you could explain why this is needed that would be awesome, or if it isn't just merge this :) --- manifests/source.pp | 13 ------------- spec/classes/apt_spec.rb | 1 - spec/defines/source_spec.rb | 10 ---------- 3 files changed, 24 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 3e9414f11d..b06d6101b1 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -9,7 +9,6 @@ $repos = 'main', $include_src = true, $include_deb = true, - $required_packages = false, $key = undef, $key_server = 'keyserver.ubuntu.com', $key_content = undef, @@ -60,18 +59,6 @@ } } - if ($required_packages != false) and ($ensure == 'present') { - exec { "Required packages: '${required_packages}' for ${name}": - command => "${provider} -y install ${required_packages}", - logoutput => 'on_failure', - refreshonly => true, - tries => 3, - try_sleep => 1, - subscribe => File["${name}.list"], - before => Exec['apt_update'], - } - } - # We do not want to remove keys when the source is absent. if $key and ($ensure == 'present') { apt::key { "Add key: ${key} from Apt::Source ${title}": diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 5095904ac4..b92f7ddabc 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -96,7 +96,6 @@ 'location' => 'http://debian.mirror.iweb.ca/debian/', 'release' => 'unstable', 'repos' => 'main contrib non-free', - 'required_packages' => 'debian-keyring debian-archive-keyring', 'key' => '55BE302B', 'key_server' => 'subkeys.pgp.net', 'pin' => '-10', diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 684a6f0656..7a1cac321a 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -51,7 +51,6 @@ 'release' => 'sid', 'repos' => 'testing', 'include_src' => false, - 'required_packages' => 'vim', 'key' => GPG_KEY_ID, 'key_server' => 'pgp.mit.edu', 'key_content' => 'GPG key content', @@ -78,15 +77,6 @@ }) } - it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Exec[apt_update]').that_subscribes_to('File[my_source.list]').with({ - 'command' => '/usr/bin/apt-get -y install vim', - 'logoutput' => 'on_failure', - 'refreshonly' => true, - 'tries' => '3', - 'try_sleep' => '1', - }) - } - it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('File[my_source.list]').with({ 'ensure' => 'present', 'key' => GPG_KEY_ID, From 3e407d70e09d1271958b82fe27a4e3a26915f707 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 20 Feb 2015 00:09:44 +0100 Subject: [PATCH 426/574] apt::params: Add two missing entries, use them. --- manifests/conf.pp | 4 +--- manifests/init.pp | 14 ++++---------- manifests/params.pp | 4 +++- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/manifests/conf.pp b/manifests/conf.pp index c37cf6b804..40f9c40307 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -4,9 +4,7 @@ $priority = '50' ) { - $apt_conf_d = $apt::params::apt_conf_d - - file { "${apt_conf_d}/${priority}${name}": + file { "${$apt::conf_d}/${priority}${name}": ensure => $ensure, content => template('apt/_header.erb', 'apt/conf.erb'), owner => root, diff --git a/manifests/init.pp b/manifests/init.pp index a9d35403d1..b82bd27e0e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -38,15 +38,9 @@ owner => 'root', } - $root = $apt::params::root - $apt_conf_d = $apt::params::apt_conf_d - $sources_list_d = $apt::params::sources_list_d - $preferences_d = $apt::params::preferences_d - $provider = $apt::params::provider - file { 'sources.list': ensure => present, - path => "${root}/sources.list", + path => $::apt::sources_list, owner => root, group => root, mode => '0644', @@ -56,7 +50,7 @@ file { 'sources.list.d': ensure => directory, - path => $sources_list_d, + path => $::apt::sources_list_d, owner => root, group => root, purge => $purge_sources_list_d, @@ -67,13 +61,13 @@ if $purge_preferences { file { 'apt-preferences': ensure => absent, - path => "${root}/preferences", + path => $::apt::preferences, } } file { 'preferences.d': ensure => directory, - path => $preferences_d, + path => $::apt::preferences_d, owner => root, group => root, purge => $purge_preferences_d, diff --git a/manifests/params.pp b/manifests/params.pp index aa90a7dd32..e7310aa55a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,8 +1,10 @@ class apt::params { $root = '/etc/apt' $provider = '/usr/bin/apt-get' + $sources_list = "${root}/sources.list" $sources_list_d = "${root}/sources.list.d" - $apt_conf_d = "${root}/apt.conf.d" + $conf_d = "${root}/apt.conf.d" + $preferences = "${root}/preferences" $preferences_d = "${root}/preferences.d" if $::osfamily != 'Debian' { From 0d9bab38cc252edb1af333e7cd6cee11a2c71f65 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 20 Feb 2015 10:47:35 -0800 Subject: [PATCH 427/574] Remove 'include apt::update' It is included in `class apt`, and there are no promises about anything working without that. --- manifests/ppa.pp | 3 --- manifests/source.pp | 2 -- 2 files changed, 5 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index f6c7373d8d..788262f09f 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,12 +1,9 @@ # ppa.pp - define apt::ppa( $ensure = 'present', $release = $::lsbdistcodename, $options = $apt::params::ppa_options, ) { - include apt::update - $sources_list_d = $apt::params::sources_list_d if ! $release { diff --git a/manifests/source.pp b/manifests/source.pp index b06d6101b1..d145918223 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -17,8 +17,6 @@ $architecture = undef, $trusted_source = false, ) { - include apt::update - validate_string($architecture) validate_bool($trusted_source) From 12a358912aba1aeb25f359bcf6900ae76a65d5b4 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 20 Feb 2015 10:55:47 -0800 Subject: [PATCH 428/574] Fix typo from #426 Too many `$`s --- manifests/conf.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/conf.pp b/manifests/conf.pp index 40f9c40307..08159379e7 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -4,7 +4,7 @@ $priority = '50' ) { - file { "${$apt::conf_d}/${priority}${name}": + file { "${apt::conf_d}/${priority}${name}": ensure => $ensure, content => template('apt/_header.erb', 'apt/conf.erb'), owner => root, From 76c88af041743ac4eeab8a9662cb3e46e535e055 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 20 Feb 2015 13:00:17 +0100 Subject: [PATCH 429/574] apt: Add apt::setting defined type. This is a 'base' type. It's a simple wrapper around a file which takes `type`, `ensure`, `content`, `source` and `file_perms`. It is intended for usage by `apt::conf`, `apt::source` and an upcoming `apt::pref`. --- manifests/params.pp | 21 ++++++ manifests/setting.pp | 52 ++++++++++++++ spec/defines/setting_spec.rb | 133 +++++++++++++++++++++++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 manifests/setting.pp create mode 100644 spec/defines/setting_spec.rb diff --git a/manifests/params.pp b/manifests/params.pp index e7310aa55a..3aba99e311 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,6 +11,27 @@ fail('This module only works on Debian or derivatives like Ubuntu') } + $config_files = { + 'conf' => { + 'path' => $conf_d, + 'ext' => '', + }, + 'pref' => { + 'path' => $preferences_d, + 'ext' => '', + }, + 'list' => { + 'path' => $sources_list_d, + 'ext' => '.list', + } + } + + $file_defaults = { + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + } + case $::lsbdistid { 'ubuntu', 'debian': { $distid = $::lsbdistid diff --git a/manifests/setting.pp b/manifests/setting.pp new file mode 100644 index 0000000000..99549e6769 --- /dev/null +++ b/manifests/setting.pp @@ -0,0 +1,52 @@ +define apt::setting ( + $type, + $priority = 50, + $ensure = file, + $source = undef, + $content = undef, + $file_perms = {}, +) { + + $_file = merge($::apt::file_defaults, $file_perms) + + if $content and $source { + fail('apt::setting cannot have both content and source') + } + + if !$content and !$source { + fail('apt::setting needs either of content or source') + } + + validate_re($type, ['conf', 'pref', 'list']) + validate_re($ensure, ['file', 'present', 'absent']) + + unless is_integer($priority) { + fail('apt::setting priority must be an integer') + } + + if $source { + validate_string($source) + } + + if $content { + validate_string($content) + } + + if $type == 'list' { + $_priority = '' + } else { + $_priority = $priority + } + + $_path = $::apt::config_files[$type]['path'] + $_ext = $::apt::config_files[$type]['ext'] + + file { "${_path}/${_priority}${title}${_ext}": + ensure => $ensure, + owner => $_file['owner'], + group => $_file['group'], + mode => $_file['mode'], + content => $content, + source => $source, + } +} diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb new file mode 100644 index 0000000000..7368ec3a16 --- /dev/null +++ b/spec/defines/setting_spec.rb @@ -0,0 +1,133 @@ +require 'spec_helper' + +describe 'apt::setting' do + let(:pre_condition) { 'class { "apt": }' } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:title) { 'teddybear' } + + let(:default_params) { { :type => 'conf', :content => 'di' } } + + describe 'when using the defaults' do + context 'without type' do + it do + expect { should compile }.to raise_error(Puppet::Error, /Must pass type /) + end + end + + context 'without source or content' do + let(:params) { { :type => 'conf' } } + it do + expect { should compile }.to raise_error(Puppet::Error, /needs either of /) + end + end + + context 'with type=conf' do + let(:params) { default_params } + it { should contain_file('/etc/apt/apt.conf.d/50teddybear') } + end + + context 'with type=pref' do + let(:params) { { :type => 'pref', :content => 'di' } } + it { should contain_file('/etc/apt/preferences.d/50teddybear') } + end + + context 'with type=list' do + let(:params) { { :type => 'list', :content => 'di' } } + it { should contain_file('/etc/apt/sources.list.d/teddybear.list') } + end + + context 'with source' do + let(:params) { { :type => 'conf', :source => 'puppet:///la/die/dah' } } + it { + should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + :ensure => 'file', + :owner => 'root', + :group => 'root', + :mode => '0644', + :source => "#{params[:source]}", + })} + end + + context 'with content' do + let(:params) { default_params } + it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + :ensure => 'file', + :owner => 'root', + :group => 'root', + :mode => '0644', + :content => "#{params[:content]}", + })} + end + end + + describe 'when trying to pull one over' do + context 'with source and content' do + let(:params) { default_params.merge({ :source => 'la' }) } + it do + expect { should compile }.to raise_error(Puppet::Error, /cannot have both /) + end + end + + context 'with type=ext' do + let(:params) { default_params.merge({ :type => 'ext' }) } + it do + expect { should compile }.to raise_error(Puppet::Error, /"ext" does not /) + end + end + + context 'with ensure=banana' do + let(:params) { default_params.merge({ :ensure => 'banana' }) } + it do + expect { should compile }.to raise_error(Puppet::Error, /"banana" does not /) + end + end + + context 'with priority=1.2' do + let(:params) { default_params.merge({ :priority => 1.2 }) } + it do + expect { should compile }.to raise_error(Puppet::Error, /be an integer /) + end + end + end + + describe 'with priority=100' do + let(:params) { default_params.merge({ :priority => 100 }) } + it { should contain_file('/etc/apt/apt.conf.d/100teddybear') } + end + + describe 'with ensure=absent' do + let(:params) { default_params.merge({ :ensure => 'absent' }) } + it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + :ensure => 'absent', + })} + end + + describe 'with file_perms' do + context "{'owner' => 'roosevelt'}" do + let(:params) { default_params.merge({ :file_perms => {'owner' => 'roosevelt'} }) } + it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + :owner => 'roosevelt', + :group => 'root', + :mode => '0644', + })} + end + + context "'group' => 'roosevelt'}" do + let(:params) { default_params.merge({ :file_perms => {'group' => 'roosevelt'} }) } + it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + :owner => 'root', + :group => 'roosevelt', + :mode => '0644', + })} + end + + context "'owner' => 'roosevelt'}" do + let(:params) { default_params.merge({ :file_perms => {'mode' => '0600'} }) } + it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + :owner => 'root', + :group => 'root', + :mode => '0600', + })} + end + end +end From 4f4d8aeafdb413e9407359d19ddcb7a0de08e9fe Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sat, 21 Feb 2015 11:50:00 -0800 Subject: [PATCH 430/574] Type is a reserved word in puppet 4 So replace `type` with `setting_type` in apt::setting --- manifests/setting.pp | 10 +++++----- spec/defines/setting_spec.rb | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/manifests/setting.pp b/manifests/setting.pp index 99549e6769..8d876faee0 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -1,5 +1,5 @@ define apt::setting ( - $type, + $setting_type, $priority = 50, $ensure = file, $source = undef, @@ -17,7 +17,7 @@ fail('apt::setting needs either of content or source') } - validate_re($type, ['conf', 'pref', 'list']) + validate_re($setting_type, ['conf', 'pref', 'list']) validate_re($ensure, ['file', 'present', 'absent']) unless is_integer($priority) { @@ -32,14 +32,14 @@ validate_string($content) } - if $type == 'list' { + if $setting_type == 'list' { $_priority = '' } else { $_priority = $priority } - $_path = $::apt::config_files[$type]['path'] - $_ext = $::apt::config_files[$type]['ext'] + $_path = $::apt::config_files[$setting_type]['path'] + $_ext = $::apt::config_files[$setting_type]['ext'] file { "${_path}/${_priority}${title}${_ext}": ensure => $ensure, diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 7368ec3a16..3736dc9641 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -5,39 +5,39 @@ let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let(:title) { 'teddybear' } - let(:default_params) { { :type => 'conf', :content => 'di' } } + let(:default_params) { { :setting_type => 'conf', :content => 'di' } } describe 'when using the defaults' do - context 'without type' do + context 'without setting_type' do it do - expect { should compile }.to raise_error(Puppet::Error, /Must pass type /) + expect { should compile }.to raise_error(Puppet::Error, /Must pass setting_type /) end end context 'without source or content' do - let(:params) { { :type => 'conf' } } + let(:params) { { :setting_type => 'conf' } } it do expect { should compile }.to raise_error(Puppet::Error, /needs either of /) end end - context 'with type=conf' do + context 'with setting_type=conf' do let(:params) { default_params } it { should contain_file('/etc/apt/apt.conf.d/50teddybear') } end - context 'with type=pref' do - let(:params) { { :type => 'pref', :content => 'di' } } + context 'with setting_type=pref' do + let(:params) { { :setting_type => 'pref', :content => 'di' } } it { should contain_file('/etc/apt/preferences.d/50teddybear') } end - context 'with type=list' do - let(:params) { { :type => 'list', :content => 'di' } } + context 'with setting_type=list' do + let(:params) { { :setting_type => 'list', :content => 'di' } } it { should contain_file('/etc/apt/sources.list.d/teddybear.list') } end context 'with source' do - let(:params) { { :type => 'conf', :source => 'puppet:///la/die/dah' } } + let(:params) { { :setting_type => 'conf', :source => 'puppet:///la/die/dah' } } it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ :ensure => 'file', @@ -68,8 +68,8 @@ end end - context 'with type=ext' do - let(:params) { default_params.merge({ :type => 'ext' }) } + context 'with setting_type=ext' do + let(:params) { default_params.merge({ :setting_type => 'ext' }) } it do expect { should compile }.to raise_error(Puppet::Error, /"ext" does not /) end From 7c5a62f13ef4c05dc2176d5879e80be618ff81e2 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 20 Feb 2015 11:15:23 -0800 Subject: [PATCH 431/574] Stop redeclaring variables from params It really seems unnecessary. --- manifests/pin.pp | 6 ++---- manifests/ppa.pp | 9 ++++----- manifests/source.pp | 5 +---- manifests/update.pp | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/manifests/pin.pp b/manifests/pin.pp index a6e3cf8e29..c4eb1f8dcf 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -16,8 +16,6 @@ $originator = '', # o= $label = '' # l= ) { - $preferences_d = $apt::params::preferences_d - if $order != '' and !is_integer($order) { fail('Only integers are allowed in the apt::pin order param') } @@ -65,8 +63,8 @@ $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') $path = $order ? { - '' => "${preferences_d}/${file_name}.pref", - default => "${preferences_d}/${order}-${file_name}.pref", + '' => "${::apt::preferences_d}/${file_name}.pref", + default => "${::apt::preferences_d}/${order}-${file_name}.pref", } file { "${file_name}.pref": ensure => $ensure, diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 788262f09f..3a11ede779 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -2,9 +2,8 @@ define apt::ppa( $ensure = 'present', $release = $::lsbdistcodename, - $options = $apt::params::ppa_options, + $options = $::apt::ppa_options, ) { - $sources_list_d = $apt::params::sources_list_d if ! $release { fail('lsbdistcodename fact not available: release parameter required') @@ -46,7 +45,7 @@ exec { "add-apt-repository-${name}": environment => $proxy_env, command => "/usr/bin/add-apt-repository ${options} ${name}", - unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", + unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}", user => 'root', logoutput => 'on_failure', notify => Exec['apt_update'], @@ -56,14 +55,14 @@ ], } - file { "${sources_list_d}/${sources_list_d_filename}": + file { "${::apt::sources_list_d}/${sources_list_d_filename}": ensure => file, require => Exec["add-apt-repository-${name}"], } } else { - file { "${sources_list_d}/${sources_list_d_filename}": + file { "${::apt::sources_list_d}/${sources_list_d_filename}": ensure => 'absent', notify => Exec['apt_update'], } diff --git a/manifests/source.pp b/manifests/source.pp index d145918223..78b861f29c 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -20,9 +20,6 @@ validate_string($architecture) validate_bool($trusted_source) - $sources_list_d = $apt::params::sources_list_d - $provider = $apt::params::provider - if $release == 'UNDEF' { if $::lsbdistcodename == undef { fail('lsbdistcodename fact not available: release parameter required') @@ -35,7 +32,7 @@ file { "${name}.list": ensure => $ensure, - path => "${sources_list_d}/${name}.list", + path => "${::apt::sources_list_d}/${name}.list", owner => root, group => root, mode => '0644', diff --git a/manifests/update.pp b/manifests/update.pp index 26790ceafa..6f338f043c 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -57,7 +57,7 @@ $_refresh = true } exec { 'apt_update': - command => "${apt::params::provider} update", + command => "${::apt::provider} update", logoutput => 'on_failure', refreshonly => $_refresh, timeout => $apt::update_timeout, From 0a178c338261e8b48121426e881be8c335d9ad72 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 19 Feb 2015 15:35:47 -0800 Subject: [PATCH 432/574] Cleanup for `apt::source` * Update `release` to default to `$::lsbdistcodename` * Default `include_src` to false * Validate more things! * Stop redefining variables from `apt::params` --- manifests/source.pp | 19 ++++++------------- spec/classes/apt_spec.rb | 1 - spec/defines/source_spec.rb | 2 ++ templates/source.list.erb | 4 ++-- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 78b861f29c..0ca5212319 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -1,13 +1,12 @@ # source.pp # add an apt source - define apt::source( $comment = $name, $ensure = present, $location = '', - $release = 'UNDEF', + $release = $::lsbdistcodename, $repos = 'main', - $include_src = true, + $include_src = false, $include_deb = true, $key = undef, $key_server = 'keyserver.ubuntu.com', @@ -17,17 +16,11 @@ $architecture = undef, $trusted_source = false, ) { - validate_string($architecture) - validate_bool($trusted_source) + validate_string($architecture, $comment, $location, $release, $repos, $key_server) + validate_bool($trusted_source, $include_src, $include_deb) - if $release == 'UNDEF' { - if $::lsbdistcodename == undef { - fail('lsbdistcodename fact not available: release parameter required') - } else { - $release_real = $::lsbdistcodename - } - } else { - $release_real = $release + if ! $release { + fail('lsbdistcodename fact not available: release parameter required') } file { "${name}.list": diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index b92f7ddabc..d4be96419b 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -135,7 +135,6 @@ } it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } - it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) } end describe 'failing tests' do diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 7a1cac321a..ff236bd5d0 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -23,6 +23,7 @@ let :params do { 'include_deb' => false, + 'include_src' => true, } end @@ -123,6 +124,7 @@ let :params do { 'include_deb' => false, + 'include_src' => true, 'architecture' => 'x86_64', } end diff --git a/templates/source.list.erb b/templates/source.list.erb index b50be8d1fd..fb0a38612e 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -2,10 +2,10 @@ <%- if @include_deb then -%> deb <%- if @architecture or @trusted_source -%> [<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> -] <%- end %><%= @location %> <%= @release_real %> <%= @repos %> +] <%- end %><%= @location %> <%= @release %> <%= @repos %> <%- end -%> <%- if @include_src then -%> deb-src <%- if @architecture or @trusted_source -%> [<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> -] <%- end %><%= @location %> <%= @release_real %> <%= @repos %> +] <%- end %><%= @location %> <%= @release %> <%= @repos %> <%- end -%> From 10f313cfb4138b34481e219e231251c15acc84da Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Sat, 21 Feb 2015 12:11:57 -0800 Subject: [PATCH 433/574] Convert apt::source to use apt::setting May as well use the define since we added it --- manifests/source.pp | 18 +++++++----------- spec/classes/apt_spec.rb | 18 +++++------------- spec/defines/source_spec.rb | 30 +++++++----------------------- 3 files changed, 19 insertions(+), 47 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 0ca5212319..bbd504e374 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -23,17 +23,13 @@ fail('lsbdistcodename fact not available: release parameter required') } - file { "${name}.list": - ensure => $ensure, - path => "${::apt::sources_list_d}/${name}.list", - owner => root, - group => root, - mode => '0644', - content => template('apt/_header.erb', 'apt/source.list.erb'), - notify => Exec['apt_update'], + apt::setting { $name: + ensure => $ensure, + setting_type => 'list', + content => template('apt/_header.erb', 'apt/source.list.erb'), + notify => Exec['apt_update'], } - if ($pin != false) { # Get the host portion out of the url so we can pin to origin $url_split = split($location, '/') @@ -42,7 +38,7 @@ apt::pin { $name: ensure => $ensure, priority => $pin, - before => File["${name}.list"], + before => Apt::Setting[$name], origin => $host, } } @@ -55,7 +51,7 @@ key_server => $key_server, key_content => $key_content, key_source => $key_source, - before => File["${name}.list"], + before => Apt::Setting[$name], } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index d4be96419b..f8e8c17380 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -110,31 +110,23 @@ } } } it { - should contain_file('debian_unstable.list').with({ + should contain_apt__setting('debian_unstable').with({ 'ensure' => 'present', - 'path' => '/etc/apt/sources.list.d/debian_unstable.list', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', 'notify' => 'Exec[apt_update]', }) } - it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } - it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } + it { should contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } + it { should contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } it { - should contain_file('puppetlabs.list').with({ + should contain_apt__setting('puppetlabs').with({ 'ensure' => 'present', - 'path' => '/etc/apt/sources.list.d/puppetlabs.list', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', 'notify' => 'Exec[apt_update]', }) } - it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } + it { should contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } end describe 'failing tests' do diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index ff236bd5d0..85a6d76043 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -27,12 +27,8 @@ } end - it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'present', - 'path' => '/etc/apt/sources.list.d/my_source.list', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', }).with_content(/# my_source\ndeb-src wheezy main\n/) } end @@ -62,23 +58,19 @@ } end - it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'present', - 'path' => '/etc/apt/sources.list.d/my_source.list', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } - it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({ + it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[my_source]').with({ 'ensure' => 'present', 'priority' => '10', 'origin' => 'debian.mirror.iweb.ca', }) } - it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('File[my_source.list]').with({ + it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[my_source]').with({ 'ensure' => 'present', 'key' => GPG_KEY_ID, 'key_server' => 'pgp.mit.edu', @@ -103,12 +95,8 @@ } end - it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'present', - 'path' => '/etc/apt/sources.list.d/my_source.list', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/) } end @@ -129,12 +117,8 @@ } end - it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'present', - 'path' => '/etc/apt/sources.list.d/my_source.list', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) } end @@ -153,7 +137,7 @@ } end - it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'absent' }) } From 1b6e046bea87b388f957edf946af363279769c21 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 20 Feb 2015 14:25:53 -0800 Subject: [PATCH 434/574] PPA Cleanup, pt 1 Make the code much cleaner, but don't make a t&p. --- manifests/params.pp | 9 +++++- manifests/ppa.pp | 67 +++++++++++++++++----------------------- spec/defines/ppa_spec.rb | 13 ++------ 3 files changed, 39 insertions(+), 50 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 3aba99e311..765677f314 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -64,12 +64,19 @@ case $distcodename { 'lucid': { $ppa_options = undef + $ppa_package = 'python-software-properties' } - 'precise', 'trusty', 'utopic', 'vivid': { + 'precise': { $ppa_options = '-y' + $ppa_package = 'python-software-properties' + } + 'trusty', 'utopic', 'vivid': { + $ppa_options = '-y' + $ppa_package = 'software-properties-common' } default: { $ppa_options = '-y' + $ppa_package = 'software-properties-common' } } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 3a11ede779..4181b5811d 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,10 +1,11 @@ # ppa.pp define apt::ppa( - $ensure = 'present', - $release = $::lsbdistcodename, - $options = $::apt::ppa_options, + $ensure = 'present', + $release = $::lsbdistcodename, + $options = $::apt::ppa_options, + $package_name = $::apt::ppa_package, + $package_manage = false, ) { - if ! $release { fail('lsbdistcodename fact not available: release parameter required') } @@ -19,52 +20,42 @@ $sources_list_d_filename = "${filename_without_ppa}-${release}.list" if $ensure == 'present' { - $package = $::lsbdistrelease ? { - /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties', - default => 'software-properties-common', - } + if $package_manage { + package { $package_name: } - if ! defined(Package[$package]) { - package { $package: } + $_require = [File['sources.list.d'], Package[$package_name]] + } else { + $_require = File['sources.list.d'] } - if defined(Class[apt]) { - $proxy_host = $apt::proxy_host - $proxy_port = $apt::proxy_port - case $proxy_host { - false, '', undef: { - $proxy_env = [] - } - default: { - $proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"] - } - } - } else { - $proxy_env = [] + case $::apt::proxy_host { + false, '', undef: { + $_proxy_env = [] + } + default: { + $_proxy_env = ["http_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}", "https_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}"] + } } + exec { "add-apt-repository-${name}": - environment => $proxy_env, - command => "/usr/bin/add-apt-repository ${options} ${name}", - unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}", - user => 'root', - logoutput => 'on_failure', - notify => Exec['apt_update'], - require => [ - File['sources.list.d'], - Package[$package], - ], + environment => $_proxy_env, + command => "/usr/bin/add-apt-repository ${options} ${name}", + unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}", + user => 'root', + logoutput => 'on_failure', + notify => Exec['apt_update'], + require => $_require, } file { "${::apt::sources_list_d}/${sources_list_d_filename}": - ensure => file, - require => Exec["add-apt-repository-${name}"], + ensure => file, + require => Exec["add-apt-repository-${name}"], } } else { - file { "${::apt::sources_list_d}/${sources_list_d_filename}": - ensure => 'absent', - notify => Exec['apt_update'], + ensure => 'absent', + notify => Exec['apt_update'], } } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index f078204ed8..d57c1a5895 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -16,7 +16,7 @@ end let(:title) { 'ppa:needs/such.substitution/wow' } - it { is_expected.to contain_package('python-software-properties') } + it { is_expected.to_not contain_package('python-software-properties') } it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ 'environment' => [], 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', @@ -25,11 +25,6 @@ 'logoutput' => 'on_failure', }) } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ - 'ensure' => 'file', - }) - } end describe 'apt included, no proxy' do @@ -48,6 +43,7 @@ let :params do { 'options' => '', + 'package_manage' => true, } end let(:title) { 'ppa:foo' } @@ -60,11 +56,6 @@ 'logoutput' => 'on_failure', }) } - - it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({ - 'ensure' => 'file', - }) - } end describe 'ensure absent' do From 08192b3927c39089526b322f9d7450300bc6ceb2 Mon Sep 17 00:00:00 2001 From: Frank Wall Date: Tue, 24 Feb 2015 14:38:43 +0100 Subject: [PATCH 435/574] fix hiera example in documentation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e46efc135f..1c06e1760c 100644 --- a/README.md +++ b/README.md @@ -244,8 +244,8 @@ apt::sources: key: '9AA38DCD55BE302B' key_server: 'subkeys.pgp.net' pin: '-10' - include_src: 'true' - include_deb: 'true' + include_src: true + include_deb: true 'puppetlabs': location: 'http://apt.puppetlabs.com' From 3b5145bf51c0a887233b7d97208b9329aefc2d64 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Tue, 24 Feb 2015 21:43:36 +0100 Subject: [PATCH 436/574] apt::params: Make the class private. Prevent direct access to apt::params. This will ensure that any other module cannot blindly access apt::params and get settings that have been potentially overridden at the apt level. Our own module still can since any class in apt has a module_name of 'apt' but that's up to us to prevent from happening. Every setting must now be accessed by a qualified lookup into the apt namespace. --- manifests/params.pp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/manifests/params.pp b/manifests/params.pp index 765677f314..8f9d7e85f4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,4 +1,9 @@ class apt::params { + + if $caller_module_name and $caller_module_name != $module_name { + fail('apt::params is a private class and cannot be accessed directly') + } + $root = '/etc/apt' $provider = '/usr/bin/apt-get' $sources_list = "${root}/sources.list" From 1139f801eb7c603c4ee10ef165f03a710ef8bf38 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 24 Feb 2015 13:20:29 -0800 Subject: [PATCH 437/574] Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 3.0.8 with the following command: transpec spec/classes spec/defines spec/unit * 87 conversions from: it { should ... } to: it { is_expected.to ... } * 14 conversions from: obj.should to: expect(obj).to * 7 conversions from: == expected to: eq(expected) * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions --- spec/classes/apt_spec.rb | 40 +++++++++---------- spec/classes/apt_update_spec.rb | 20 +++++----- spec/classes/params_spec.rb | 8 ++-- spec/defines/conf_spec.rb | 4 +- spec/defines/key_spec.rb | 30 +++++++------- spec/defines/pin_spec.rb | 10 ++--- spec/defines/ppa_spec.rb | 4 +- spec/defines/setting_spec.rb | 32 +++++++-------- spec/defines/source_spec.rb | 2 +- spec/unit/facter/apt_has_updates_spec.rb | 10 ++--- spec/unit/facter/apt_package_updates_spec.rb | 6 +-- spec/unit/facter/apt_security_updates_spec.rb | 4 +- .../facter/apt_update_last_success_spec.rb | 4 +- spec/unit/facter/apt_updates_spec.rb | 4 +- spec/unit/puppet/type/apt_key_spec.rb | 26 ++++++------ 15 files changed, 102 insertions(+), 102 deletions(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index f8e8c17380..26119bfb15 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -3,7 +3,7 @@ let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } context 'defaults' do - it { should contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({ + it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({ 'ensure' => 'present', 'path' => '/etc/apt/sources.list', 'owner' => 'root', @@ -12,7 +12,7 @@ 'notify' => 'Exec[apt_update]', })} - it { should contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({ + it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({ 'ensure' => 'directory', 'path' => '/etc/apt/sources.list.d', 'owner' => 'root', @@ -22,7 +22,7 @@ 'notify' => 'Exec[apt_update]', })} - it { should contain_file('preferences.d').only_with({ + it { is_expected.to contain_file('preferences.d').only_with({ 'ensure' => 'directory', 'path' => '/etc/apt/preferences.d', 'owner' => 'root', @@ -32,14 +32,14 @@ })} it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do - should contain_file('/etc/apt/apt.conf.d/15update-stamp').with({ + is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({ 'group' => 'root', 'mode' => '0644', 'owner' => 'root', }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/) end - it { should contain_exec('apt_update').with({ + it { is_expected.to contain_exec('apt_update').with({ 'refreshonly' => 'true', })} end @@ -57,26 +57,26 @@ } end - it { should contain_file('sources.list').with({ + it { is_expected.to contain_file('sources.list').with({ 'content' => "# Repos managed by puppet.\n" })} - it { should contain_file('sources.list.d').with({ + it { is_expected.to contain_file('sources.list.d').with({ 'purge' => 'true', 'recurse' => 'true', })} - it { should contain_file('apt-preferences').only_with({ + it { is_expected.to contain_file('apt-preferences').only_with({ 'ensure' => 'absent', 'path' => '/etc/apt/preferences', })} - it { should contain_file('preferences.d').with({ + it { is_expected.to contain_file('preferences.d').with({ 'purge' => 'true', 'recurse' => 'true', })} - it { should contain_exec('apt_update').with({ + it { is_expected.to contain_exec('apt_update').with({ 'refreshonly' => 'false', 'timeout' => '1', 'tries' => '3', @@ -110,23 +110,23 @@ } } } it { - should contain_apt__setting('debian_unstable').with({ + is_expected.to contain_apt__setting('debian_unstable').with({ 'ensure' => 'present', 'notify' => 'Exec[apt_update]', }) } - it { should contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } - it { should contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } + it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } + it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } it { - should contain_apt__setting('puppetlabs').with({ + is_expected.to contain_apt__setting('puppetlabs').with({ 'ensure' => 'present', 'notify' => 'Exec[apt_update]', }) } - it { should contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } + it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } end describe 'failing tests' do @@ -138,7 +138,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error) end end @@ -151,7 +151,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error) end end @@ -164,7 +164,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error) end end @@ -177,7 +177,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error) end end @@ -189,7 +189,7 @@ it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/) end end diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index d70efd37d1..d0bfae2675 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -8,7 +8,7 @@ let (:pre_condition) { "class{'::apt': always_apt_update => true}" } it 'should trigger an apt-get update run' do #set the apt_update exec's refreshonly attribute to false - should contain_exec('apt_update').with({'refreshonly' => false }) + is_expected.to contain_exec('apt_update').with({'refreshonly' => false }) end ['always','daily','weekly','reluctantly'].each do |update_frequency| context "when apt::apt_update_frequency has the value of #{update_frequency}" do @@ -18,7 +18,7 @@ let (:pre_condition) { "class{'::apt': always_apt_update => true, apt_update_frequency => '#{update_frequency}' }" } it 'should trigger an apt-get update run' do # set the apt_update exec's refreshonly attribute to false - should contain_exec('apt_update').with({'refreshonly' => false}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end context 'when $::apt_update_last_success is nil' do @@ -26,7 +26,7 @@ let (:pre_condition) { "class{'::apt': always_apt_update => true, apt_update_frequency => '#{update_frequency}' }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false - should contain_exec('apt_update').with({'refreshonly' => false}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end @@ -42,7 +42,7 @@ let (:pre_condition) { "class{'::apt': always_apt_update => false, apt_update_frequency => 'always' }" } it 'should trigger an apt-get update run' do #set the apt_update exec's refreshonly attribute to false - should contain_exec('apt_update').with({'refreshonly' => false}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end @@ -51,7 +51,7 @@ let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'always' }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false - should contain_exec('apt_update').with({'refreshonly' => false}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end @@ -62,7 +62,7 @@ let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'reluctantly' }" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) - should contain_exec('apt_update').with({'refreshonly' => true}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) end end end @@ -71,7 +71,7 @@ let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'reluctantly' }" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) - should contain_exec('apt_update').with({'refreshonly' => true}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) end end end @@ -83,7 +83,7 @@ let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false - should contain_exec('apt_update').with({'refreshonly' => false}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end @@ -92,7 +92,7 @@ let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec\'s refreshonly attribute. (it should be true) - should contain_exec('apt_update').with({'refreshonly' => true}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) end end context 'when $::apt_update_last_success is nil' do @@ -100,7 +100,7 @@ let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false - should contain_exec('apt_update').with({'refreshonly' => false}) + is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index 9a75ade4db..65759fad1d 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -3,13 +3,13 @@ let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let (:title) { 'my_package' } - it { should contain_apt__params } + it { is_expected.to contain_apt__params } # There are 4 resources in this class currently # there should not be any more resources because it is a params class # The resources are class[apt::params], class[main], class[settings], stage[main] it "Should not contain any resources" do - subject.resources.size.should == 4 + expect(subject.resources.size).to eq(4) end describe "With unknown lsbdistid" do @@ -19,7 +19,7 @@ it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /Unsupported lsbdistid/) end @@ -31,7 +31,7 @@ it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, is lsb-release installed/) end end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 208f209a27..4e5b46b824 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -20,7 +20,7 @@ "/etc/apt/apt.conf.d/00norecommends" end - it { should contain_file(filename).with({ + it { is_expected.to contain_file(filename).with({ 'ensure' => 'present', 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, 'owner' => 'root', @@ -43,7 +43,7 @@ "/etc/apt/apt.conf.d/00norecommends" end - it { should contain_file(filename).with({ + it { is_expected.to contain_file(filename).with({ 'ensure' => 'absent', 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, 'owner' => 'root', diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index d622ecbcbc..c6f3752e80 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -11,7 +11,7 @@ describe 'normal operation' do describe 'default options' do it 'contains the apt_key' do - should contain_apt_key(title).with({ + is_expected.to contain_apt_key(title).with({ :id => title, :ensure => 'present', :source => nil, @@ -21,7 +21,7 @@ }) end it 'contains the apt_key present anchor' do - should contain_anchor("apt_key #{title} present") + is_expected.to contain_anchor("apt_key #{title} present") end end @@ -35,7 +35,7 @@ } end it 'contains the apt_key' do - should contain_apt_key(title).with({ + is_expected.to contain_apt_key(title).with({ :id => GPG_KEY_ID, :ensure => 'present', :source => nil, @@ -45,7 +45,7 @@ }) end it 'contains the apt_key present anchor' do - should contain_anchor("apt_key #{GPG_KEY_ID} present") + is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") end end @@ -55,7 +55,7 @@ } end it 'contains the apt_key' do - should contain_apt_key(title).with({ + is_expected.to contain_apt_key(title).with({ :id => title, :ensure => 'absent', :source => nil, @@ -65,7 +65,7 @@ }) end it 'contains the apt_key absent anchor' do - should contain_anchor("apt_key #{title} absent") + is_expected.to contain_anchor("apt_key #{title} absent") end end @@ -78,7 +78,7 @@ } end it 'contains the apt_key' do - should contain_apt_key(title).with({ + is_expected.to contain_apt_key(title).with({ :id => title, :ensure => 'present', :source => 'http://apt.puppetlabs.com/pubkey.gpg', @@ -88,7 +88,7 @@ }) end it 'contains the apt_key present anchor' do - should contain_anchor("apt_key #{title} present") + is_expected.to contain_anchor("apt_key #{title} present") end end @@ -97,7 +97,7 @@ :key_server => 'p-gp.m-it.edu', } end it 'contains the apt_key' do - should contain_apt_key(title).with({ + is_expected.to contain_apt_key(title).with({ :id => title, :server => 'p-gp.m-it.edu', }) @@ -111,7 +111,7 @@ } end it 'contains the apt_key' do - should contain_apt_key(title).with({ + is_expected.to contain_apt_key(title).with({ :id => title, :server => 'hkp://pgp.mit.edu', }) @@ -124,7 +124,7 @@ } end it 'contains the apt_key' do - should contain_apt_key(title).with({ + is_expected.to contain_apt_key(title).with({ :id => title, :server => 'hkp://pgp.mit.edu:80', }) @@ -280,18 +280,18 @@ end it 'contains two apt::key resources' do - should contain_apt__key('duplicate').with({ + is_expected.to contain_apt__key('duplicate').with({ :key => title, :ensure => 'present', }) - should contain_apt__key(title).with({ + is_expected.to contain_apt__key(title).with({ :key => title, :ensure => 'present', }) end it 'contains only a single apt_key' do - should contain_apt_key('duplicate').with({ + is_expected.to contain_apt_key('duplicate').with({ :id => title, :ensure => 'present', :source => nil, @@ -299,7 +299,7 @@ :content => nil, :keyserver_options => nil, }) - should_not contain_apt_key(title) + is_expected.not_to contain_apt_key(title) end end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index b4443cc241..4b05cd1551 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -105,7 +105,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /Only integers are allowed/) end end @@ -118,7 +118,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/) end end @@ -132,7 +132,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/) end end @@ -147,7 +147,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) end end @@ -162,7 +162,7 @@ end it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) end end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index d57c1a5895..f3c76a3bde 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -96,7 +96,7 @@ let(:title) { 'ppa:foo' } it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end @@ -114,7 +114,7 @@ let(:title) { 'ppa:foo' } it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /apt::ppa is currently supported on Ubuntu only./) end end diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 3736dc9641..0abcead5d4 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -10,36 +10,36 @@ describe 'when using the defaults' do context 'without setting_type' do it do - expect { should compile }.to raise_error(Puppet::Error, /Must pass setting_type /) + expect { is_expected.to compile }.to raise_error(Puppet::Error, /Must pass setting_type /) end end context 'without source or content' do let(:params) { { :setting_type => 'conf' } } it do - expect { should compile }.to raise_error(Puppet::Error, /needs either of /) + expect { is_expected.to compile }.to raise_error(Puppet::Error, /needs either of /) end end context 'with setting_type=conf' do let(:params) { default_params } - it { should contain_file('/etc/apt/apt.conf.d/50teddybear') } + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') } end context 'with setting_type=pref' do let(:params) { { :setting_type => 'pref', :content => 'di' } } - it { should contain_file('/etc/apt/preferences.d/50teddybear') } + it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear') } end context 'with setting_type=list' do let(:params) { { :setting_type => 'list', :content => 'di' } } - it { should contain_file('/etc/apt/sources.list.d/teddybear.list') } + it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list') } end context 'with source' do let(:params) { { :setting_type => 'conf', :source => 'puppet:///la/die/dah' } } it { - should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ :ensure => 'file', :owner => 'root', :group => 'root', @@ -50,7 +50,7 @@ context 'with content' do let(:params) { default_params } - it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ :ensure => 'file', :owner => 'root', :group => 'root', @@ -64,40 +64,40 @@ context 'with source and content' do let(:params) { default_params.merge({ :source => 'la' }) } it do - expect { should compile }.to raise_error(Puppet::Error, /cannot have both /) + expect { is_expected.to compile }.to raise_error(Puppet::Error, /cannot have both /) end end context 'with setting_type=ext' do let(:params) { default_params.merge({ :setting_type => 'ext' }) } it do - expect { should compile }.to raise_error(Puppet::Error, /"ext" does not /) + expect { is_expected.to compile }.to raise_error(Puppet::Error, /"ext" does not /) end end context 'with ensure=banana' do let(:params) { default_params.merge({ :ensure => 'banana' }) } it do - expect { should compile }.to raise_error(Puppet::Error, /"banana" does not /) + expect { is_expected.to compile }.to raise_error(Puppet::Error, /"banana" does not /) end end context 'with priority=1.2' do let(:params) { default_params.merge({ :priority => 1.2 }) } it do - expect { should compile }.to raise_error(Puppet::Error, /be an integer /) + expect { is_expected.to compile }.to raise_error(Puppet::Error, /be an integer /) end end end describe 'with priority=100' do let(:params) { default_params.merge({ :priority => 100 }) } - it { should contain_file('/etc/apt/apt.conf.d/100teddybear') } + it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear') } end describe 'with ensure=absent' do let(:params) { default_params.merge({ :ensure => 'absent' }) } - it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ :ensure => 'absent', })} end @@ -105,7 +105,7 @@ describe 'with file_perms' do context "{'owner' => 'roosevelt'}" do let(:params) { default_params.merge({ :file_perms => {'owner' => 'roosevelt'} }) } - it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ :owner => 'roosevelt', :group => 'root', :mode => '0644', @@ -114,7 +114,7 @@ context "'group' => 'roosevelt'}" do let(:params) { default_params.merge({ :file_perms => {'group' => 'roosevelt'} }) } - it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ :owner => 'root', :group => 'roosevelt', :mode => '0644', @@ -123,7 +123,7 @@ context "'owner' => 'roosevelt'}" do let(:params) { default_params.merge({ :file_perms => {'mode' => '0600'} }) } - it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ :owner => 'root', :group => 'root', :mode => '0600', diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 85a6d76043..3d8410f097 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -154,7 +154,7 @@ it do expect { - should compile + is_expected.to compile }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end diff --git a/spec/unit/facter/apt_has_updates_spec.rb b/spec/unit/facter/apt_has_updates_spec.rb index f8a3f20a13..b6eee265f7 100644 --- a/spec/unit/facter/apt_has_updates_spec.rb +++ b/spec/unit/facter/apt_has_updates_spec.rb @@ -8,7 +8,7 @@ before { Facter.fact(:osfamily).expects(:value).at_least(1).returns 'RedHat' } - it { should be_nil } + it { is_expected.to be_nil } end describe 'on Debian based distro missing update-notifier-common' do @@ -17,7 +17,7 @@ File.stubs(:executable?) # Stub all other calls File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns false } - it { should be_nil } + it { is_expected.to be_nil } end describe 'on Debian based distro with broken packages' do @@ -28,7 +28,7 @@ File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "E: Error: BrokenCount > 0" } - it { should be_nil } + it { is_expected.to be_nil } end describe 'on Debian based distro with unknown error with semicolons' do @@ -39,7 +39,7 @@ File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "E: Unknown Error: 'This error contains something that could be parsed like 4;3' (10)" } - it { should be_nil } + it { is_expected.to be_nil } end describe 'on Debian based distro' do @@ -50,7 +50,7 @@ File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "4;3" } - it { should be true } + it { is_expected.to be true } end end diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb index 5c7a624f4d..08bfb42a34 100644 --- a/spec/unit/facter/apt_package_updates_spec.rb +++ b/spec/unit/facter/apt_package_updates_spec.rb @@ -8,7 +8,7 @@ before { Facter.fact(:apt_has_updates).stubs(:value).returns false } - it { should be nil } + it { is_expected.to be nil } end describe 'when apt has updates' do @@ -22,9 +22,9 @@ } it { if Facter.version < '2.0.0' - should == 'puppet-common,linux-generic,linux-image-generic' + is_expected.to eq('puppet-common,linux-generic,linux-image-generic') else - should == ['puppet-common', 'linux-generic', 'linux-image-generic'] + is_expected.to eq(['puppet-common', 'linux-generic', 'linux-image-generic']) end } end diff --git a/spec/unit/facter/apt_security_updates_spec.rb b/spec/unit/facter/apt_security_updates_spec.rb index 4bc760f789..83aa6ff620 100644 --- a/spec/unit/facter/apt_security_updates_spec.rb +++ b/spec/unit/facter/apt_security_updates_spec.rb @@ -8,7 +8,7 @@ before { Facter.fact(:apt_has_updates).stubs(:value).returns false } - it { should be nil } + it { is_expected.to be nil } end describe 'when apt has security updates' do @@ -19,7 +19,7 @@ File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" } - it { should == 7 } + it { is_expected.to eq(7) } end end diff --git a/spec/unit/facter/apt_update_last_success_spec.rb b/spec/unit/facter/apt_update_last_success_spec.rb index 08774cd012..cb32a5ef02 100644 --- a/spec/unit/facter/apt_update_last_success_spec.rb +++ b/spec/unit/facter/apt_update_last_success_spec.rb @@ -10,7 +10,7 @@ File.stubs(:exists?).returns false } it 'should have a value of -1' do - should == -1 + is_expected.to eq(-1) end end @@ -21,7 +21,7 @@ File.stubs(:mtime).returns 1407660561 } it 'should have the value of the mtime of the file' do - should == 1407660561 + is_expected.to eq(1407660561) end end diff --git a/spec/unit/facter/apt_updates_spec.rb b/spec/unit/facter/apt_updates_spec.rb index 7e9b77f84f..781ffd6972 100644 --- a/spec/unit/facter/apt_updates_spec.rb +++ b/spec/unit/facter/apt_updates_spec.rb @@ -8,7 +8,7 @@ before { Facter.fact(:apt_has_updates).stubs(:value).returns false } - it { should be nil } + it { is_expected.to be nil } end describe 'when apt has updates' do @@ -19,7 +19,7 @@ File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7" } - it { should == 14 } + it { is_expected.to eq(14) } end end diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index e8a5462c6f..e412b50664 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -7,23 +7,23 @@ :id => '4BD6EC30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq '4BD6EC30' end it 'name is set to id' do - resource[:name].should eq '4BD6EC30' + expect(resource[:name]).to eq '4BD6EC30' end it 'keyserver is default' do - resource[:server].should eq :'keyserver.ubuntu.com' + expect(resource[:server]).to eq :'keyserver.ubuntu.com' end it 'source is not set' do - resource[:source].should eq nil + expect(resource[:source]).to eq nil end it 'content is not set' do - resource[:content].should eq nil + expect(resource[:content]).to eq nil end end @@ -32,7 +32,7 @@ :id => '4bd6ec30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq '4BD6EC30' end end @@ -41,7 +41,7 @@ :id => 'FFFFFFFF4BD6EC30' )} it 'id is set' do - resource[:id].should eq 'FFFFFFFF4BD6EC30' + expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30' end end @@ -50,7 +50,7 @@ :id => '0x4BD6EC30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq '4BD6EC30' end end @@ -59,7 +59,7 @@ :id => '0x4bd6ec30' )} it 'id is set' do - resource[:id].should eq '4BD6EC30' + expect(resource[:id]).to eq '4BD6EC30' end end @@ -68,7 +68,7 @@ :id => '0xFFFFFFFF4BD6EC30' )} it 'id is set' do - resource[:id].should eq 'FFFFFFFF4BD6EC30' + expect(resource[:id]).to eq 'FFFFFFFF4BD6EC30' end end @@ -79,7 +79,7 @@ )} it 'source is set to the URL' do - resource[:source].should eq 'http://apt.puppetlabs.com/pubkey.gpg' + expect(resource[:source]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' end end @@ -90,7 +90,7 @@ )} it 'content is set to the string' do - resource[:content].should eq 'http://apt.puppetlabs.com/pubkey.gpg' + expect(resource[:content]).to eq 'http://apt.puppetlabs.com/pubkey.gpg' end end @@ -101,7 +101,7 @@ )} it 'keyserver is set to Debian' do - resource[:server].should eq 'http://keyring.debian.org' + expect(resource[:server]).to eq 'http://keyring.debian.org' end end From e0f058cc209e89451e36ed631161c1bc82d62383 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 24 Feb 2015 13:53:25 -0800 Subject: [PATCH 438/574] Allow priorities to be zero-padded --- manifests/setting.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/setting.pp b/manifests/setting.pp index 8d876faee0..7740fd6e24 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -21,7 +21,8 @@ validate_re($ensure, ['file', 'present', 'absent']) unless is_integer($priority) { - fail('apt::setting priority must be an integer') + # need this to allow zero-padded priority. + validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer.') } if $source { From 1236ecff2cb2d761f17ae459c6d04f0ba2c8a082 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 24 Feb 2015 15:51:41 -0800 Subject: [PATCH 439/574] Add base_name parameter to apt::setting This allows you to work around duplicate resource issues when you have settings of different types with the same name. When the files are built it is path/${priority}${base_name}${extension}. --- manifests/setting.pp | 4 +++- spec/defines/setting_spec.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/manifests/setting.pp b/manifests/setting.pp index 8d876faee0..8e46ed966d 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -1,5 +1,6 @@ define apt::setting ( $setting_type, + $base_name = $title, $priority = 50, $ensure = file, $source = undef, @@ -19,6 +20,7 @@ validate_re($setting_type, ['conf', 'pref', 'list']) validate_re($ensure, ['file', 'present', 'absent']) + validate_string($base_name) unless is_integer($priority) { fail('apt::setting priority must be an integer') @@ -41,7 +43,7 @@ $_path = $::apt::config_files[$setting_type]['path'] $_ext = $::apt::config_files[$setting_type]['ext'] - file { "${_path}/${_priority}${title}${_ext}": + file { "${_path}/${_priority}${base_name}${_ext}": ensure => $ensure, owner => $_file['owner'], group => $_file['group'], diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 3736dc9641..a597cb8663 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -95,6 +95,18 @@ it { should contain_file('/etc/apt/apt.conf.d/100teddybear') } end + describe 'with base_name=puppy' do + let(:params) { default_params.merge({ :base_name => 'puppy' }) } + it { should contain_file('/etc/apt/apt.conf.d/50puppy') } + end + + describe 'with base_name=true' do + let(:params) { default_params.merge({ :base_name => true }) } + it do + expect { should compile }.to raise_error(Puppet::Error, /not a string/) + end + end + describe 'with ensure=absent' do let(:params) { default_params.merge({ :ensure => 'absent' }) } it { should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ From 3e44b685d2a0457774401f2f200e3ed82abeda4f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 24 Feb 2015 17:03:50 -0800 Subject: [PATCH 440/574] proxy_* params were removed from class apt Add them to PPA since they were being used there, and add a placeholder example for setting up the proxy files. --- examples/proxy.pp | 1 + manifests/params.pp | 5 ++++ manifests/ppa.pp | 7 +++-- spec/defines/ppa_spec.rb | 64 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 examples/proxy.pp diff --git a/examples/proxy.pp b/examples/proxy.pp new file mode 100644 index 0000000000..464090415c --- /dev/null +++ b/examples/proxy.pp @@ -0,0 +1 @@ +# TODO diff --git a/manifests/params.pp b/manifests/params.pp index 8f9d7e85f4..3c169e3fcf 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -31,6 +31,11 @@ } } + $proxy = { + 'host' => undef, + 'port' => 8080, + } + $file_defaults = { 'owner' => 'root', 'group' => 'root', diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 4181b5811d..1dc8e26fce 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -5,6 +5,7 @@ $options = $::apt::ppa_options, $package_name = $::apt::ppa_package, $package_manage = false, + $proxy = {}, ) { if ! $release { fail('lsbdistcodename fact not available: release parameter required') @@ -19,6 +20,8 @@ $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') $sources_list_d_filename = "${filename_without_ppa}-${release}.list" + $_proxy = merge($apt::proxy, $proxy) + if $ensure == 'present' { if $package_manage { package { $package_name: } @@ -28,12 +31,12 @@ $_require = File['sources.list.d'] } - case $::apt::proxy_host { + case $_proxy['host'] { false, '', undef: { $_proxy_env = [] } default: { - $_proxy_env = ["http_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}", "https_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}"] + $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=http://${_proxy['host']}:${_proxy['port']}"] } } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index f3c76a3bde..6ca008b4ba 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -58,6 +58,70 @@ } end + describe 'apt included, proxy host' do + let :pre_condition do + 'class { "apt": }' + end + let :facts do + { + :lsbdistrelease => '14.04', + :lsbdistcodename => 'trusty', + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu', + :osfamily => 'Debian', + } + end + let :params do + { + 'options' => '', + 'package_manage' => true, + 'proxy' => { 'host' => 'localhost', } + } + 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://localhost:8080', 'https_proxy=http://localhost:8080'], + 'command' => '/usr/bin/add-apt-repository ppa:foo', + 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + 'user' => 'root', + 'logoutput' => 'on_failure', + }) + } + end + + describe 'apt included, proxy host and port' do + let :pre_condition do + 'class { "apt": }' + end + let :facts do + { + :lsbdistrelease => '14.04', + :lsbdistcodename => 'trusty', + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu', + :osfamily => 'Debian', + } + end + let :params do + { + 'options' => '', + 'package_manage' => true, + 'proxy' => { 'host' => 'localhost', 'port' => 8180, } + } + 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://localhost:8180', 'https_proxy=http://localhost:8180'], + 'command' => '/usr/bin/add-apt-repository ppa:foo', + 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + 'user' => 'root', + 'logoutput' => 'on_failure', + }) + } + end + describe 'ensure absent' do let :pre_condition do 'class { "apt": }' From 351c8d5941f6bd02304df6b4185dea8c8104aefa Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 24 Feb 2015 14:57:31 -0800 Subject: [PATCH 441/574] Convert to use apt::setting instead of file resources This adds consistency across the module --- manifests/conf.pp | 15 ++++++------ manifests/init.pp | 11 ++++----- manifests/pin.pp | 22 ++++++----------- manifests/source.pp | 7 +++--- spec/classes/apt_spec.rb | 4 +-- spec/defines/pin_spec.rb | 49 ++++++++++++++----------------------- spec/defines/source_spec.rb | 14 +++++------ 7 files changed, 52 insertions(+), 70 deletions(-) diff --git a/manifests/conf.pp b/manifests/conf.pp index 08159379e7..49e32abaaa 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -1,14 +1,13 @@ define apt::conf ( $content, $ensure = present, - $priority = '50' + $priority = '50', ) { - - file { "${apt::conf_d}/${priority}${name}": - ensure => $ensure, - content => template('apt/_header.erb', 'apt/conf.erb'), - owner => root, - group => root, - mode => '0644', + apt::setting { "conf-${name}": + ensure => $ensure, + base_name => $name, + setting_type => 'conf', + priority => $priority, + content => template('apt/_header.erb', 'apt/conf.erb'), } } diff --git a/manifests/init.pp b/manifests/init.pp index b82bd27e0e..59a7fe4e3a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -30,12 +30,11 @@ } } - file { '/etc/apt/apt.conf.d/15update-stamp': - ensure => 'file', - content => template('apt/_header.erb', 'apt/15update-stamp.erb'), - group => 'root', - mode => '0644', - owner => 'root', + apt::setting { 'conf-update-stamp': + base_name => 'update-stamp', + setting_type => 'conf', + priority => 15, + content => template('apt/_header.erb', 'apt/15update-stamp.erb'), } file { 'sources.list': diff --git a/manifests/pin.pp b/manifests/pin.pp index c4eb1f8dcf..214fa997e8 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -4,7 +4,7 @@ define apt::pin( $ensure = present, $explanation = "${caller_module_name}: ${name}", - $order = '', + $order = undef, $packages = '*', $priority = 0, $release = '', # a= @@ -16,7 +16,7 @@ $originator = '', # o= $label = '' # l= ) { - if $order != '' and !is_integer($order) { + if $order and !is_integer($order) { fail('Only integers are allowed in the apt::pin order param') } @@ -52,7 +52,6 @@ } } - # According to man 5 apt_preferences: # The files have either no or "pref" as filename extension # and only contain alphanumeric, hyphen (-), underscore (_) and period @@ -62,16 +61,11 @@ # be silently ignored. $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') - $path = $order ? { - '' => "${::apt::preferences_d}/${file_name}.pref", - default => "${::apt::preferences_d}/${order}-${file_name}.pref", - } - file { "${file_name}.pref": - ensure => $ensure, - path => $path, - owner => root, - group => root, - mode => '0644', - content => template('apt/_header.erb', 'apt/pin.pref.erb'), + apt::setting { "pref-${file_name}": + ensure => $ensure, + base_name => $file_name, + setting_type => 'pref', + priority => $order, + content => template('apt/_header.erb', 'apt/pin.pref.erb'), } } diff --git a/manifests/source.pp b/manifests/source.pp index bbd504e374..e4e4aa3dea 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -23,8 +23,9 @@ fail('lsbdistcodename fact not available: release parameter required') } - apt::setting { $name: + apt::setting { "list-${name}": ensure => $ensure, + base_name => $name, setting_type => 'list', content => template('apt/_header.erb', 'apt/source.list.erb'), notify => Exec['apt_update'], @@ -38,7 +39,7 @@ apt::pin { $name: ensure => $ensure, priority => $pin, - before => Apt::Setting[$name], + before => Apt::Setting["list-${name}"], origin => $host, } } @@ -51,7 +52,7 @@ key_server => $key_server, key_content => $key_content, key_source => $key_source, - before => Apt::Setting[$name], + before => Apt::Setting["list-${name}"], } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 26119bfb15..f66bf54049 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -110,7 +110,7 @@ } } } it { - is_expected.to contain_apt__setting('debian_unstable').with({ + is_expected.to contain_apt__setting('list-debian_unstable').with({ 'ensure' => 'present', 'notify' => 'Exec[apt_update]', }) @@ -120,7 +120,7 @@ it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) } it { - is_expected.to contain_apt__setting('puppetlabs').with({ + is_expected.to contain_apt__setting('list-puppetlabs').with({ 'ensure' => 'present', 'notify' => 'Exec[apt_update]', }) diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 4b05cd1551..1421d68fbd 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -7,13 +7,10 @@ let(:title) { 'my_pin' } context 'defaults' do - it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)} - it { is_expected.to contain_file("my_pin.pref").with({ - 'ensure' => 'present', - 'path' => '/etc/apt/preferences.d/my_pin.pref', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', + it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)} + it { is_expected.to contain_apt__setting("pref-my_pin").with({ + 'setting_type' => 'pref', + 'base_name' => 'my_pin', }) } end @@ -25,13 +22,10 @@ 'version' => '1', } end - it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)} - it { is_expected.to contain_file("my_pin.pref").with({ - 'ensure' => 'present', - 'path' => '/etc/apt/preferences.d/my_pin.pref', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', + it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)} + it { is_expected.to contain_apt__setting("pref-my_pin").with({ + 'setting_type' => 'pref', + 'base_name' => 'my_pin', }) } end @@ -43,13 +37,10 @@ 'origin' => 'test', } end - it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)} - it { is_expected.to contain_file("my_pin.pref").with({ - 'ensure' => 'present', - 'path' => '/etc/apt/preferences.d/my_pin.pref', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', + it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)} + it { is_expected.to contain_apt__setting("pref-my_pin").with({ + 'setting_type' => 'pref', + 'base_name' => 'my_pin', }) } end @@ -68,13 +59,11 @@ 'priority' => 10, } end - it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) } - it { is_expected.to contain_file("my_pin.pref").with({ - 'ensure' => 'present', - 'path' => '/etc/apt/preferences.d/99-my_pin.pref', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', + it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) } + it { is_expected.to contain_apt__setting("pref-my_pin").with({ + 'setting_type' => 'pref', + 'base_name' => 'my_pin', + 'priority' => 99, }) } end @@ -85,7 +74,7 @@ 'ensure' => 'absent' } end - it { is_expected.to contain_file("my_pin.pref").with({ + it { is_expected.to contain_apt__setting("pref-my_pin").with({ 'ensure' => 'absent', }) } @@ -93,7 +82,7 @@ context 'bad characters' do let(:title) { 'such bad && wow!' } - it { is_expected.to contain_file("such__bad____wow_.pref") } + it { is_expected.to contain_apt__setting("pref-such__bad____wow_") } end describe 'validation' do diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 3d8410f097..ad986e9684 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -27,7 +27,7 @@ } end - it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'present', }).with_content(/# my_source\ndeb-src wheezy main\n/) } @@ -58,19 +58,19 @@ } end - it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'present', }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } - it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[my_source]').with({ + it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ 'ensure' => 'present', 'priority' => '10', 'origin' => 'debian.mirror.iweb.ca', }) } - it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[my_source]').with({ + it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ 'ensure' => 'present', 'key' => GPG_KEY_ID, 'key_server' => 'pgp.mit.edu', @@ -95,7 +95,7 @@ } end - it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'present', }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/) } @@ -117,7 +117,7 @@ } end - it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'present', }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) } @@ -137,7 +137,7 @@ } end - it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ 'ensure' => 'absent' }) } From d261d8f11b85407c149924a8b03b0e681777f65a Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 26 Feb 2015 19:12:53 +0100 Subject: [PATCH 442/574] apt::setting: Parse type and name from title. Instead of having two additional parameters, `base_name` and `setting_type` simply parse it from `title`. We need to prefix most resources with `list-`, `conf-`, or `pref-` any way to avoid duplicate resources so we might as well leverage that. --- manifests/conf.pp | 8 +++---- manifests/init.pp | 6 ++--- manifests/pin.pp | 8 +++---- manifests/setting.pp | 12 ++++++---- manifests/source.pp | 8 +++---- spec/defines/pin_spec.rb | 20 +++------------- spec/defines/setting_spec.rb | 44 ++++++++++++------------------------ 7 files changed, 35 insertions(+), 71 deletions(-) diff --git a/manifests/conf.pp b/manifests/conf.pp index 49e32abaaa..2850205281 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -4,10 +4,8 @@ $priority = '50', ) { apt::setting { "conf-${name}": - ensure => $ensure, - base_name => $name, - setting_type => 'conf', - priority => $priority, - content => template('apt/_header.erb', 'apt/conf.erb'), + ensure => $ensure, + priority => $priority, + content => template('apt/_header.erb', 'apt/conf.erb'), } } diff --git a/manifests/init.pp b/manifests/init.pp index 59a7fe4e3a..0b4a0bc626 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -31,10 +31,8 @@ } apt::setting { 'conf-update-stamp': - base_name => 'update-stamp', - setting_type => 'conf', - priority => 15, - content => template('apt/_header.erb', 'apt/15update-stamp.erb'), + priority => 15, + content => template('apt/_header.erb', 'apt/15update-stamp.erb'), } file { 'sources.list': diff --git a/manifests/pin.pp b/manifests/pin.pp index 214fa997e8..b27ed8ea2a 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -62,10 +62,8 @@ $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') apt::setting { "pref-${file_name}": - ensure => $ensure, - base_name => $file_name, - setting_type => 'pref', - priority => $order, - content => template('apt/_header.erb', 'apt/pin.pref.erb'), + ensure => $ensure, + priority => $order, + content => template('apt/_header.erb', 'apt/pin.pref.erb'), } } diff --git a/manifests/setting.pp b/manifests/setting.pp index 78f007fdbc..f6f0bc0c22 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -1,6 +1,4 @@ define apt::setting ( - $setting_type, - $base_name = $title, $priority = 50, $ensure = file, $source = undef, @@ -18,13 +16,17 @@ fail('apt::setting needs either of content or source') } - validate_re($setting_type, ['conf', 'pref', 'list']) validate_re($ensure, ['file', 'present', 'absent']) - validate_string($base_name) + + $title_array = split($title, '-') + $setting_type = $title_array[0] + $base_name = join(delete_at($title_array, 0), '-') + + validate_re($setting_type, ['\Aconf\z', '\Apref\z', '\Alist\z'], "apt::setting resource name/title must start with either 'conf-', 'pref-' or 'list-'") unless is_integer($priority) { # need this to allow zero-padded priority. - validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer.') + validate_re($priority, '^\d+$', 'apt::setting priority must be an integer or a zero-padded integer') } if $source { diff --git a/manifests/source.pp b/manifests/source.pp index e4e4aa3dea..9a3a7912aa 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -24,11 +24,9 @@ } apt::setting { "list-${name}": - ensure => $ensure, - base_name => $name, - setting_type => 'list', - content => template('apt/_header.erb', 'apt/source.list.erb'), - notify => Exec['apt_update'], + ensure => $ensure, + content => template('apt/_header.erb', 'apt/source.list.erb'), + notify => Exec['apt_update'], } if ($pin != false) { diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 1421d68fbd..e4d5d0ae1a 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -8,11 +8,7 @@ context 'defaults' do it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)} - it { is_expected.to contain_apt__setting("pref-my_pin").with({ - 'setting_type' => 'pref', - 'base_name' => 'my_pin', - }) - } + it { is_expected.to contain_apt__setting("pref-my_pin") } end context 'set version' do @@ -23,11 +19,7 @@ } end it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)} - it { is_expected.to contain_apt__setting("pref-my_pin").with({ - 'setting_type' => 'pref', - 'base_name' => 'my_pin', - }) - } + it { is_expected.to contain_apt__setting("pref-my_pin") } end context 'set origin' do @@ -38,11 +30,7 @@ } end it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)} - it { is_expected.to contain_apt__setting("pref-my_pin").with({ - 'setting_type' => 'pref', - 'base_name' => 'my_pin', - }) - } + it { is_expected.to contain_apt__setting("pref-my_pin") } end context 'not defaults' do @@ -61,8 +49,6 @@ end it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) } it { is_expected.to contain_apt__setting("pref-my_pin").with({ - 'setting_type' => 'pref', - 'base_name' => 'my_pin', 'priority' => 99, }) } diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 7b7c54efc4..5e88eea16e 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -3,41 +3,36 @@ describe 'apt::setting' do let(:pre_condition) { 'class { "apt": }' } let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let(:title) { 'teddybear' } + let(:title) { 'conf-teddybear' } - let(:default_params) { { :setting_type => 'conf', :content => 'di' } } + let(:default_params) { { :content => 'di' } } describe 'when using the defaults' do - context 'without setting_type' do - it do - expect { is_expected.to compile }.to raise_error(Puppet::Error, /Must pass setting_type /) - end - end - context 'without source or content' do - let(:params) { { :setting_type => 'conf' } } it do expect { is_expected.to compile }.to raise_error(Puppet::Error, /needs either of /) end end - context 'with setting_type=conf' do + context 'with title=conf-teddybear ' do let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') } end - context 'with setting_type=pref' do - let(:params) { { :setting_type => 'pref', :content => 'di' } } + context 'with title=pref-teddybear' do + let(:title) { 'pref-teddybear' } + let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear') } end - context 'with setting_type=list' do - let(:params) { { :setting_type => 'list', :content => 'di' } } + context 'with title=list-teddybear' do + let(:title) { 'list-teddybear' } + let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list') } end context 'with source' do - let(:params) { { :setting_type => 'conf', :source => 'puppet:///la/die/dah' } } + let(:params) { { :source => 'puppet:///la/die/dah' } } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ :ensure => 'file', @@ -68,10 +63,11 @@ end end - context 'with setting_type=ext' do - let(:params) { default_params.merge({ :setting_type => 'ext' }) } + context 'with title=ext-teddybear' do + let(:title) { 'ext-teddybear' } + let(:params) { default_params } it do - expect { is_expected.to compile }.to raise_error(Puppet::Error, /"ext" does not /) + expect { is_expected.to compile }.to raise_error(Puppet::Error, /must start with /) end end @@ -95,18 +91,6 @@ it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear') } end - describe 'with base_name=puppy' do - let(:params) { default_params.merge({ :base_name => 'puppy' }) } - it { should contain_file('/etc/apt/apt.conf.d/50puppy') } - end - - describe 'with base_name=true' do - let(:params) { default_params.merge({ :base_name => true }) } - it do - expect { should compile }.to raise_error(Puppet::Error, /not a string/) - end - end - describe 'with ensure=absent' do let(:params) { default_params.merge({ :ensure => 'absent' }) } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ From 0475e50be8e4994e4c1c22ce103e903f52c2c599 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 26 Feb 2015 12:44:06 -0800 Subject: [PATCH 443/574] Make apt::setting notify Exec['apt_update'] by default Can be disabled by setting `notify_update => false` --- manifests/setting.pp | 25 ++++++++++++++++++++----- manifests/source.pp | 6 ------ spec/classes/apt_spec.rb | 2 -- spec/defines/setting_spec.rb | 27 +++++++++++++++++---------- spec/defines/source_spec.rb | 10 +++++----- 5 files changed, 42 insertions(+), 28 deletions(-) diff --git a/manifests/setting.pp b/manifests/setting.pp index f6f0bc0c22..c288b35d7e 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -1,9 +1,10 @@ define apt::setting ( - $priority = 50, - $ensure = file, - $source = undef, - $content = undef, - $file_perms = {}, + $priority = 50, + $ensure = file, + $source = undef, + $content = undef, + $file_perms = {}, + $notify_update = true, ) { $_file = merge($::apt::file_defaults, $file_perms) @@ -17,6 +18,7 @@ } validate_re($ensure, ['file', 'present', 'absent']) + validate_bool($notify_update) $title_array = split($title, '-') $setting_type = $title_array[0] @@ -46,6 +48,12 @@ $_path = $::apt::config_files[$setting_type]['path'] $_ext = $::apt::config_files[$setting_type]['ext'] + if $notify_update { + $_notify = Exec['apt_update'] + } else { + $_notify = undef + } + file { "${_path}/${_priority}${base_name}${_ext}": ensure => $ensure, owner => $_file['owner'], @@ -53,5 +61,12 @@ mode => $_file['mode'], content => $content, source => $source, + notify => $_notify, + } + + if $notify_update { + anchor { "apt::setting::${name}": + require => Class['apt::update'] + } } } diff --git a/manifests/source.pp b/manifests/source.pp index 9a3a7912aa..b7d150c223 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -26,7 +26,6 @@ apt::setting { "list-${name}": ensure => $ensure, content => template('apt/_header.erb', 'apt/source.list.erb'), - notify => Exec['apt_update'], } if ($pin != false) { @@ -53,9 +52,4 @@ before => Apt::Setting["list-${name}"], } } - - # Need anchor to provide containment for dependencies. - anchor { "apt::source::${name}": - require => Class['apt::update'], - } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index f66bf54049..b8ff37ea31 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -112,7 +112,6 @@ it { is_expected.to contain_apt__setting('list-debian_unstable').with({ 'ensure' => 'present', - 'notify' => 'Exec[apt_update]', }) } @@ -122,7 +121,6 @@ it { is_expected.to contain_apt__setting('list-puppetlabs').with({ 'ensure' => 'present', - 'notify' => 'Exec[apt_update]', }) } diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 5e88eea16e..e01fdbfe44 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -16,25 +16,25 @@ context 'with title=conf-teddybear ' do let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') } + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') } end context 'with title=pref-teddybear' do let(:title) { 'pref-teddybear' } let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear') } + it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Exec[apt_update]') } end context 'with title=list-teddybear' do let(:title) { 'list-teddybear' } let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list') } + it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Exec[apt_update]') } end context 'with source' do let(:params) { { :source => 'puppet:///la/die/dah' } } it { - is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ :ensure => 'file', :owner => 'root', :group => 'root', @@ -45,7 +45,7 @@ context 'with content' do let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ :ensure => 'file', :owner => 'root', :group => 'root', @@ -88,12 +88,12 @@ describe 'with priority=100' do let(:params) { default_params.merge({ :priority => 100 }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear') } + it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Exec[apt_update]') } end describe 'with ensure=absent' do let(:params) { default_params.merge({ :ensure => 'absent' }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ :ensure => 'absent', })} end @@ -101,7 +101,7 @@ describe 'with file_perms' do context "{'owner' => 'roosevelt'}" do let(:params) { default_params.merge({ :file_perms => {'owner' => 'roosevelt'} }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ :owner => 'roosevelt', :group => 'root', :mode => '0644', @@ -110,7 +110,7 @@ context "'group' => 'roosevelt'}" do let(:params) { default_params.merge({ :file_perms => {'group' => 'roosevelt'} }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ :owner => 'root', :group => 'roosevelt', :mode => '0644', @@ -119,11 +119,18 @@ context "'owner' => 'roosevelt'}" do let(:params) { default_params.merge({ :file_perms => {'mode' => '0600'} }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ :owner => 'root', :group => 'root', :mode => '0600', })} end + + context "'notify_update' => false}" do + let(:params) { default_params.merge({ :notify_update => false }) } + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') } + it { is_expected.not_to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') } + end + end end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index ad986e9684..5e2728b251 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -27,7 +27,7 @@ } end - it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').with({ 'ensure' => 'present', }).with_content(/# my_source\ndeb-src wheezy main\n/) } @@ -58,7 +58,7 @@ } end - it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').with({ 'ensure' => 'present', }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) } @@ -95,7 +95,7 @@ } end - it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').with({ 'ensure' => 'present', }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/) } @@ -117,7 +117,7 @@ } end - it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').with({ 'ensure' => 'present', }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) } @@ -137,7 +137,7 @@ } end - it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_apt__setting('list-my_source').with({ 'ensure' => 'absent' }) } From b53ea1b90c8e050b1ce3008995ebfcb0ca0baf62 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 27 Feb 2015 12:07:56 +0100 Subject: [PATCH 444/574] spec/(apt|ppa): Enough with all the strings. Most options can and should be named through symbols, makes it much easier to read too with syntax highlighting. --- spec/classes/apt_spec.rb | 82 ++++++++++++++++++++-------------------- spec/defines/ppa_spec.rb | 56 +++++++++++++-------------- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index b8ff37ea31..b07e0d6a76 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,46 +1,46 @@ require 'spec_helper' -describe 'apt', :type => :class do +describe 'apt' do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } context 'defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({ - 'ensure' => 'present', - 'path' => '/etc/apt/sources.list', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - 'notify' => 'Exec[apt_update]', + :ensure => 'present', + :path => '/etc/apt/sources.list', + :owner => 'root', + :group => 'root', + :mode => '0644', + :notify => 'Exec[apt_update]', })} it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({ - 'ensure' => 'directory', - 'path' => '/etc/apt/sources.list.d', - 'owner' => 'root', - 'group' => 'root', - 'purge' => false, - 'recurse' => false, - 'notify' => 'Exec[apt_update]', + :ensure => 'directory', + :path => '/etc/apt/sources.list.d', + :owner => 'root', + :group => 'root', + :purge => false, + :recurse => false, + :notify => 'Exec[apt_update]', })} it { is_expected.to contain_file('preferences.d').only_with({ - 'ensure' => 'directory', - 'path' => '/etc/apt/preferences.d', - 'owner' => 'root', - 'group' => 'root', - 'purge' => false, - 'recurse' => false, + :ensure => 'directory', + :path => '/etc/apt/preferences.d', + :owner => 'root', + :group => 'root', + :purge => false, + :recurse => false, })} it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({ - 'group' => 'root', - 'mode' => '0644', - 'owner' => 'root', + :group => 'root', + :mode => '0644', + :owner => 'root', }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/) end it { is_expected.to contain_exec('apt_update').with({ - 'refreshonly' => 'true', + :refreshonly => 'true', })} end @@ -58,28 +58,28 @@ end it { is_expected.to contain_file('sources.list').with({ - 'content' => "# Repos managed by puppet.\n" + :content => "# Repos managed by puppet.\n" })} it { is_expected.to contain_file('sources.list.d').with({ - 'purge' => 'true', - 'recurse' => 'true', + :purge => 'true', + :recurse => 'true', })} it { is_expected.to contain_file('apt-preferences').only_with({ - 'ensure' => 'absent', - 'path' => '/etc/apt/preferences', + :ensure => 'absent', + :path => '/etc/apt/preferences', })} it { is_expected.to contain_file('preferences.d').with({ - 'purge' => 'true', - 'recurse' => 'true', + :purge => 'true', + :recurse => 'true', })} it { is_expected.to contain_exec('apt_update').with({ - 'refreshonly' => 'false', - 'timeout' => '1', - 'tries' => '3', + :refreshonly => 'false', + :timeout => '1', + :tries => '3', })} end @@ -99,7 +99,7 @@ 'key' => '55BE302B', 'key_server' => 'subkeys.pgp.net', 'pin' => '-10', - 'include_src' => true + 'include_src' => true, }, 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', @@ -111,7 +111,7 @@ it { is_expected.to contain_apt__setting('list-debian_unstable').with({ - 'ensure' => 'present', + :ensure => 'present', }) } @@ -120,7 +120,7 @@ it { is_expected.to contain_apt__setting('list-puppetlabs').with({ - 'ensure' => 'present', + :ensure => 'present', }) } @@ -131,7 +131,7 @@ context 'bad purge_sources_list' do let :params do { - 'purge_sources_list' => 'foo' + :purge_sources_list => 'foo' } end it do @@ -144,7 +144,7 @@ context 'bad purge_sources_list_d' do let :params do { - 'purge_sources_list_d' => 'foo' + :purge_sources_list_d => 'foo' } end it do @@ -157,7 +157,7 @@ context 'bad purge_preferences' do let :params do { - 'purge_preferences' => 'foo' + :purge_preferences => 'foo' } end it do @@ -170,7 +170,7 @@ context 'bad purge_preferences_d' do let :params do { - 'purge_preferences_d' => 'foo' + :purge_preferences_d => 'foo' } end it do diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 6ca008b4ba..dde015abad 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe 'apt::ppa', :type => :define do +describe 'apt::ppa' do describe 'defaults' do let :pre_condition do @@ -18,11 +18,11 @@ let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.to_not contain_package('python-software-properties') } it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ - 'environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', - 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', - 'user' => 'root', - 'logoutput' => 'on_failure', + :environment => [], + :command => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', + :user => 'root', + :logoutput => 'on_failure', }) } end @@ -42,18 +42,18 @@ end let :params do { - 'options' => '', - 'package_manage' => true, + :options => '', + :package_manage => true, } 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' => [], - 'command' => '/usr/bin/add-apt-repository ppa:foo', - 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', - 'user' => 'root', - 'logoutput' => 'on_failure', + :environment => [], + :command => '/usr/bin/add-apt-repository ppa:foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :user => 'root', + :logoutput => 'on_failure', }) } end @@ -81,11 +81,11 @@ 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://localhost:8080', 'https_proxy=http://localhost:8080'], - 'command' => '/usr/bin/add-apt-repository ppa:foo', - 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', - 'user' => 'root', - 'logoutput' => 'on_failure', + :environment => ['http_proxy=http://localhost:8080', 'https_proxy=http://localhost:8080'], + :command => '/usr/bin/add-apt-repository ppa:foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :user => 'root', + :logoutput => 'on_failure', }) } end @@ -105,19 +105,19 @@ end let :params do { - 'options' => '', - 'package_manage' => true, - 'proxy' => { 'host' => 'localhost', 'port' => 8180, } + :options => '', + :package_manage => true, + :proxy => { 'host' => 'localhost', 'port' => 8180, } } 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://localhost:8180', 'https_proxy=http://localhost:8180'], - 'command' => '/usr/bin/add-apt-repository ppa:foo', - 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', - 'user' => 'root', - 'logoutput' => 'on_failure', + :environment => ['http_proxy=http://localhost:8180', 'https_proxy=http://localhost:8180'], + :command => '/usr/bin/add-apt-repository ppa:foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :user => 'root', + :logoutput => 'on_failure', }) } end @@ -138,11 +138,11 @@ let(:title) { 'ppa:foo' } let :params do { - 'ensure' => 'absent' + :ensure => 'absent' } end it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({ - 'ensure' => 'absent', + :ensure => 'absent', }) } end From d81c3d9476b14892882620723a02617c344f703c Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 27 Feb 2015 12:34:05 +0100 Subject: [PATCH 445/574] apt: Add proxy support on the class. Re-introduce proxy support at the class level. Needing to configure a proxy is such a common scenario that having it on the class is a reasonable thing. It also affects `apt::ppa`. Change `apt::ppa` to no longer have its own `proxy` parameter but use the proxy as configured on the main `apt` class. --- manifests/init.pp | 23 ++++++++++++++++++++ manifests/params.pp | 7 +++--- manifests/ppa.pp | 17 +++++++-------- spec/classes/apt_spec.rb | 36 ++++++++++++++++++++++++++++++ spec/defines/ppa_spec.rb | 47 +++++++++++++++++++++++++++++++++++----- templates/proxy.erb | 4 ++++ 6 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 templates/proxy.erb diff --git a/manifests/init.pp b/manifests/init.pp index 0b4a0bc626..86e49c8f4e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,5 +1,6 @@ # class apt( + $proxy = {}, $always_apt_update = false, $apt_update_frequency = 'reluctantly', $purge_sources_list = false, @@ -19,6 +20,28 @@ validate_bool($purge_sources_list, $purge_sources_list_d, $purge_preferences, $purge_preferences_d) + validate_hash($proxy) + if $proxy['host'] { + validate_string($proxy['host']) + } + if $proxy['port'] { + unless is_integer($proxy['port']) { + fail('$proxy port must be an integer') + } + } + if $proxy['https'] { + validate_bool($proxy['https']) + } + + $_proxy = merge($apt::proxy_defaults, $proxy) + + if $proxy['host'] { + apt::setting { 'conf-proxy': + priority => '01', + content => template('apt/_header.erb', 'apt/proxy.erb'), + } + } + $sources_list_content = $purge_sources_list ? { false => undef, true => "# Repos managed by puppet.\n", diff --git a/manifests/params.pp b/manifests/params.pp index 3c169e3fcf..eda6adc93b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -31,9 +31,10 @@ } } - $proxy = { - 'host' => undef, - 'port' => 8080, + $proxy_defaults = { + 'host' => undef, + 'port' => 8080, + 'https' => false, } $file_defaults = { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 1dc8e26fce..4a08dce6fd 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -5,7 +5,6 @@ $options = $::apt::ppa_options, $package_name = $::apt::ppa_package, $package_manage = false, - $proxy = {}, ) { if ! $release { fail('lsbdistcodename fact not available: release parameter required') @@ -20,8 +19,6 @@ $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') $sources_list_d_filename = "${filename_without_ppa}-${release}.list" - $_proxy = merge($apt::proxy, $proxy) - if $ensure == 'present' { if $package_manage { package { $package_name: } @@ -31,13 +28,15 @@ $_require = File['sources.list.d'] } - case $_proxy['host'] { - false, '', undef: { - $_proxy_env = [] - } - default: { - $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=http://${_proxy['host']}:${_proxy['port']}"] + $_proxy = $::apt::_proxy + if $_proxy['host'] { + if $_proxy['https'] { + $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=https://${_proxy['host']}:${_proxy['port']}"] + } else { + $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}"] } + } else { + $_proxy_env = [] } exec { "add-apt-repository-${name}": diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index b07e0d6a76..c53e2a7dc6 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -42,8 +42,44 @@ it { is_expected.to contain_exec('apt_update').with({ :refreshonly => 'true', })} + + it { is_expected.not_to contain_apt__setting('conf-proxy') } end + describe 'proxy=' do + context 'host=localhost' do + let(:params) { { :proxy => { 'host' => 'localhost'} } } + it { is_expected.to contain_apt__setting('conf-proxy').with({ + :priority => '01', + }).with_content( + /Acquire::http::proxy "http:\/\/localhost:8080\/";/ + ).without_content( + /Acquire::https::proxy/ + )} + end + + context 'host=localhost and port=8180' do + let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } } + it { is_expected.to contain_apt__setting('conf-proxy').with({ + :priority => '01', + }).with_content( + /Acquire::http::proxy "http:\/\/localhost:8180\/";/ + ).without_content( + /Acquire::https::proxy/ + )} + end + + context 'host=localhost and https=true' do + let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } } + it { is_expected.to contain_apt__setting('conf-proxy').with({ + :priority => '01', + }).with_content( + /Acquire::http::proxy "http:\/\/localhost:8080\/";/ + ).with_content( + /Acquire::https::proxy "https:\/\/localhost:8080\/";/ + )} + end + end context 'lots of non-defaults' do let :params do { diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index dde015abad..14a5139c3b 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -60,7 +60,9 @@ describe 'apt included, proxy host' do let :pre_condition do - 'class { "apt": }' + 'class { "apt": + proxy => { "host" => "localhost" }, + }' end let :facts do { @@ -75,13 +77,12 @@ { 'options' => '', 'package_manage' => true, - 'proxy' => { 'host' => 'localhost', } } 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://localhost:8080', 'https_proxy=http://localhost:8080'], + :environment => ['http_proxy=http://localhost:8080'], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', :user => 'root', @@ -92,7 +93,42 @@ describe 'apt included, proxy host and port' do let :pre_condition do - 'class { "apt": }' + 'class { "apt": + proxy => { "host" => "localhost", "port" => 8180 }, + }' + end + let :facts do + { + :lsbdistrelease => '14.04', + :lsbdistcodename => 'trusty', + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu', + :osfamily => 'Debian', + } + end + let :params do + { + :options => '', + :package_manage => true, + } + 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://localhost:8180'], + :command => '/usr/bin/add-apt-repository ppa:foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :user => 'root', + :logoutput => 'on_failure', + }) + } + end + + describe 'apt included, proxy host and port and https' do + let :pre_condition do + 'class { "apt": + proxy => { "host" => "localhost", "port" => 8180, "https" => true }, + }' end let :facts do { @@ -107,13 +143,12 @@ { :options => '', :package_manage => true, - :proxy => { 'host' => 'localhost', 'port' => 8180, } } 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://localhost:8180', 'https_proxy=http://localhost:8180'], + :environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', :user => 'root', diff --git a/templates/proxy.erb b/templates/proxy.erb new file mode 100644 index 0000000000..670e3a7e87 --- /dev/null +++ b/templates/proxy.erb @@ -0,0 +1,4 @@ +Acquire::http::proxy "http://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/"; +<%- if @_proxy['https'] %> +Acquire::https::proxy "https://<%= @_proxy['host'] %>:<%= @_proxy['port'] %>/"; +<%- end -%> From a1ce8bdea47165bd6a26310ab6de90c85c7c8436 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sat, 28 Feb 2015 16:12:47 +0100 Subject: [PATCH 446/574] apt: Change how purging is managed. * Instead of having 4 options controlling purging we now have a single hash with four possible keys. * We purge everything by default. * `/etc/apt/preferences` is now always managed. * Add missing `mode` to some of the files. --- manifests/init.pp | 54 ++++++++++++++++-------- manifests/params.pp | 7 ++++ spec/classes/apt_spec.rb | 90 +++++++++++++++++++--------------------- 3 files changed, 86 insertions(+), 65 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 86e49c8f4e..cc4a3308ab 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,12 +1,9 @@ # class apt( + $purge = {}, $proxy = {}, $always_apt_update = false, $apt_update_frequency = 'reluctantly', - $purge_sources_list = false, - $purge_sources_list_d = false, - $purge_preferences = false, - $purge_preferences_d = false, $update_timeout = undef, $update_tries = undef, $sources = undef, @@ -17,8 +14,21 @@ $frequency_options = ['always','daily','weekly','reluctantly'] validate_re($apt_update_frequency, $frequency_options) - validate_bool($purge_sources_list, $purge_sources_list_d, - $purge_preferences, $purge_preferences_d) + validate_hash($purge) + if $purge['sources.list'] { + validate_bool($purge['sources.list']) + } + if $purge['sources.list.d'] { + validate_bool($purge['sources.list.d']) + } + if $purge['preferences'] { + validate_bool($purge['preferences']) + } + if $purge['preferences.d'] { + validate_bool($purge['preferences.d']) + } + + $_purge = merge($::apt::purge_defaults, $purge) validate_hash($proxy) if $proxy['host'] { @@ -42,11 +52,16 @@ } } - $sources_list_content = $purge_sources_list ? { + $sources_list_content = $_purge['sources.list'] ? { false => undef, true => "# Repos managed by puppet.\n", } + $preferences_ensure = $_purge['preferences'] ? { + false => file, + true => absent, + } + if $always_apt_update == true { Exec <| title=='apt_update' |> { refreshonly => false, @@ -59,7 +74,7 @@ } file { 'sources.list': - ensure => present, + ensure => file, path => $::apt::sources_list, owner => root, group => root, @@ -73,16 +88,19 @@ path => $::apt::sources_list_d, owner => root, group => root, - purge => $purge_sources_list_d, - recurse => $purge_sources_list_d, + mode => '0644', + purge => $_purge['sources.list.d'], + recurse => $_purge['sources.list.d'], notify => Exec['apt_update'], } - if $purge_preferences { - file { 'apt-preferences': - ensure => absent, - path => $::apt::preferences, - } + file { 'preferences': + ensure => $preferences_ensure, + path => $::apt::preferences, + owner => root, + group => root, + mode => '0644', + notify => Exec['apt_update'], } file { 'preferences.d': @@ -90,8 +108,10 @@ path => $::apt::preferences_d, owner => root, group => root, - purge => $purge_preferences_d, - recurse => $purge_preferences_d, + mode => '0644', + purge => $_purge['preferences.d'], + recurse => $_purge['preferences.d'], + notify => Exec['apt_update'], } # Need anchor to provide containment for dependencies. diff --git a/manifests/params.pp b/manifests/params.pp index eda6adc93b..51b6aea579 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -37,6 +37,13 @@ 'https' => false, } + $purge_defaults = { + 'sources.list' => true, + 'sources.list.d' => true, + 'preferences' => true, + 'preferences.d' => true, + } + $file_defaults = { 'owner' => 'root', 'group' => 'root', diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index c53e2a7dc6..a021993394 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -4,12 +4,13 @@ context 'defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({ - :ensure => 'present', - :path => '/etc/apt/sources.list', - :owner => 'root', - :group => 'root', - :mode => '0644', - :notify => 'Exec[apt_update]', + :ensure => 'file', + :path => '/etc/apt/sources.list', + :owner => 'root', + :group => 'root', + :mode => '0644', + :content => "# Repos managed by puppet.\n", + :notify => 'Exec[apt_update]', })} it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({ @@ -17,18 +18,30 @@ :path => '/etc/apt/sources.list.d', :owner => 'root', :group => 'root', - :purge => false, - :recurse => false, + :mode => '0644', + :purge => true, + :recurse => true, :notify => 'Exec[apt_update]', })} - it { is_expected.to contain_file('preferences.d').only_with({ + it { is_expected.to contain_file('preferences').that_notifies('Exec[apt_update]').only_with({ + :ensure => 'absent', + :path => '/etc/apt/preferences', + :owner => 'root', + :group => 'root', + :mode => '0644', + :notify => 'Exec[apt_update]', + })} + + it { is_expected.to contain_file('preferences.d').that_notifies('Exec[apt_update]').only_with({ :ensure => 'directory', :path => '/etc/apt/preferences.d', :owner => 'root', :group => 'root', - :purge => false, - :recurse => false, + :mode => '0644', + :purge => true, + :recurse => true, + :notify => 'Exec[apt_update]', })} it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do @@ -84,32 +97,29 @@ let :params do { :always_apt_update => true, - :purge_sources_list => true, - :purge_sources_list_d => true, - :purge_preferences => true, - :purge_preferences_d => true, + :purge => { 'sources.list' => false, 'sources.list.d' => false, + 'preferences' => false, 'preferences.d' => false, }, :update_timeout => '1', :update_tries => '3', } end - it { is_expected.to contain_file('sources.list').with({ - :content => "# Repos managed by puppet.\n" + it { is_expected.to contain_file('sources.list').without({ + :content => "# Repos managed by puppet.\n", })} it { is_expected.to contain_file('sources.list.d').with({ - :purge => 'true', - :recurse => 'true', + :purge => false, + :recurse => false, })} - it { is_expected.to contain_file('apt-preferences').only_with({ - :ensure => 'absent', - :path => '/etc/apt/preferences', + it { is_expected.to contain_file('preferences').with({ + :ensure => 'file', })} it { is_expected.to contain_file('preferences.d').with({ - :purge => 'true', - :recurse => 'true', + :purge => false, + :recurse => false, })} it { is_expected.to contain_exec('apt_update').with({ @@ -164,12 +174,8 @@ end describe 'failing tests' do - context 'bad purge_sources_list' do - let :params do - { - :purge_sources_list => 'foo' - } - end + context "purge['sources.list']=>'banana'" do + let(:params) { { :purge => { 'sources.list' => 'banana' }, } } it do expect { is_expected.to compile @@ -177,12 +183,8 @@ end end - context 'bad purge_sources_list_d' do - let :params do - { - :purge_sources_list_d => 'foo' - } - end + context "purge['sources.list.d']=>'banana'" do + let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } } it do expect { is_expected.to compile @@ -190,12 +192,8 @@ end end - context 'bad purge_preferences' do - let :params do - { - :purge_preferences => 'foo' - } - end + context "purge['preferences']=>'banana'" do + let(:params) { { :purge => { 'preferences' => 'banana' }, } } it do expect { is_expected.to compile @@ -203,12 +201,8 @@ end end - context 'bad purge_preferences_d' do - let :params do - { - :purge_preferences_d => 'foo' - } - end + context "purge['preferences.d']=>'banana'" do + let(:params) { { :purge => { 'preferences.d' => 'banana' }, } } it do expect { is_expected.to compile From fe228435b1c9219b7fe61e6faafe810b117fd5e4 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sat, 28 Feb 2015 16:48:48 +0100 Subject: [PATCH 447/574] apt: Change how update is managed. * Instead of having 4 options controlling purging we now have a single hash with four possible keys. * Include `apt::update` only _after_ we've assembled the `$_update` hash. --- manifests/init.pp | 29 ++++++++++++++++++++++------- manifests/params.pp | 7 +++++++ manifests/update.pp | 8 ++++---- spec/classes/apt_spec.rb | 14 ++++++-------- spec/classes/apt_update_spec.rb | 32 ++++++++++++++++---------------- 5 files changed, 55 insertions(+), 35 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index cc4a3308ab..ea546dc55e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,18 +1,33 @@ # class apt( + $update = {}, $purge = {}, $proxy = {}, - $always_apt_update = false, - $apt_update_frequency = 'reluctantly', - $update_timeout = undef, - $update_tries = undef, $sources = undef, ) inherits ::apt::params { - include apt::update $frequency_options = ['always','daily','weekly','reluctantly'] - validate_re($apt_update_frequency, $frequency_options) + validate_hash($update) + if $update['frequency'] { + validate_re($update['frequency'], $frequency_options) + } + if $update['always'] { + validate_bool($update['always']) + } + if $update['timeout'] { + unless is_integer($update['timeout']) { + fail('timeout value for update must be an integer') + } + } + if $update['tries'] { + unless is_integer($update['tries']) { + fail('tries value for update must be an integer') + } + } + + $_update = merge($::apt::update_defaults, $update) + include apt::update validate_hash($purge) if $purge['sources.list'] { @@ -62,7 +77,7 @@ true => absent, } - if $always_apt_update == true { + if $_update['always'] { Exec <| title=='apt_update' |> { refreshonly => false, } diff --git a/manifests/params.pp b/manifests/params.pp index 51b6aea579..2a29b6d1be 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -31,6 +31,13 @@ } } + $update_defaults = { + 'always' => false, + 'frequency' => 'reluctantly', + 'timeout' => undef, + 'tries' => undef, + } + $proxy_defaults = { 'host' => undef, 'port' => 8080, diff --git a/manifests/update.pp b/manifests/update.pp index 6f338f043c..a19e90aacd 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -4,10 +4,10 @@ #on the first run, but if it's not run in awhile something is likely borked #with apt and we'd want to know about it. - if $::apt::always_apt_update == false { + if $::apt::_update['always'] == false { #if always_apt_update is true there's no point in parsing this logic. - case $apt::apt_update_frequency { + case $::apt::_update['frequency'] { 'always': { $_kick_apt = true } @@ -60,8 +60,8 @@ command => "${::apt::provider} update", logoutput => 'on_failure', refreshonly => $_refresh, - timeout => $apt::update_timeout, - tries => $apt::update_tries, + timeout => $::apt::_update['timeout'], + tries => $::apt::_update['tries'], try_sleep => 1 } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index a021993394..d3559e4cef 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -96,11 +96,9 @@ context 'lots of non-defaults' do let :params do { - :always_apt_update => true, - :purge => { 'sources.list' => false, 'sources.list.d' => false, - 'preferences' => false, 'preferences.d' => false, }, - :update_timeout => '1', - :update_tries => '3', + :update => { 'always' => true, 'timeout' => 1, 'tries' => 3 }, + :purge => { 'sources.list' => false, 'sources.list.d' => false, + 'preferences' => false, 'preferences.d' => false, }, } end @@ -123,9 +121,9 @@ })} it { is_expected.to contain_exec('apt_update').with({ - :refreshonly => 'false', - :timeout => '1', - :tries => '3', + :refreshonly => false, + :timeout => 1, + :tries => 3, })} end diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index d0bfae2675..6ae9e8f9a5 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -2,20 +2,20 @@ require 'spec_helper' describe 'apt::update', :type => :class do - context 'when apt::always_apt_update is true' do + context "when update['always']=true" do #This should completely disable all of this logic. These tests are to guarantee that we don't somehow magically change the behavior. let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let (:pre_condition) { "class{'::apt': always_apt_update => true}" } + let (:pre_condition) { "class{'::apt': update => {'always' => true},}" } it 'should trigger an apt-get update run' do #set the apt_update exec's refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false }) end ['always','daily','weekly','reluctantly'].each do |update_frequency| - context "when apt::apt_update_frequency has the value of #{update_frequency}" do + context "when apt::update['frequency'] has the value of #{update_frequency}" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } } - let (:pre_condition) { "class{'::apt': always_apt_update => true, apt_update_frequency => '#{update_frequency}' }" } + let (:pre_condition) { "class{'::apt': update => {'always' => true, 'frequency' => '#{update_frequency}'}, }" } it 'should trigger an apt-get update run' do # set the apt_update exec's refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) @@ -23,7 +23,7 @@ end context 'when $::apt_update_last_success is nil' do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let (:pre_condition) { "class{'::apt': always_apt_update => true, apt_update_frequency => '#{update_frequency}' }" } + let (:pre_condition) { "class{'::apt': update => {'always' => true, 'frequency' => '#{update_frequency}'}, }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) @@ -34,12 +34,12 @@ end end - context 'when apt::always_apt_update is false' do - context "and apt::apt_update_frequency has the value of always" do + context "when apt::update['always']=false" do + context "and apt::update['frequency']='always'" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } } - let (:pre_condition) { "class{'::apt': always_apt_update => false, apt_update_frequency => 'always' }" } + let (:pre_condition) { "class{'::apt': update => {'always' => false, 'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do #set the apt_update exec's refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) @@ -48,18 +48,18 @@ end context 'when $::apt_update_last_success is nil' do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'always' }" } + let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end - context "and apt::apt_update_frequency has the value of reluctantly" do + context "and apt::update['frequency']='reluctantly'" do {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval} } - let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'reluctantly' }" } + let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) @@ -68,7 +68,7 @@ end context 'when $::apt_update_last_success is nil' do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => 'reluctantly' }" } + let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) @@ -76,11 +76,11 @@ end end ['daily','weekly'].each do |update_frequency| - context "and apt::apt_update_frequency has the value of #{update_frequency}" do + context "and apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } } - let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" } + let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) @@ -89,7 +89,7 @@ end context 'when the $::apt_update_last_success fact has a recent value' do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => Time.now.to_i } } - let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" } + let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec\'s refreshonly attribute. (it should be true) is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) @@ -97,7 +97,7 @@ end context 'when $::apt_update_last_success is nil' do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } - let (:pre_condition) { "class{ '::apt': always_apt_update => false, apt_update_frequency => '#{update_frequency}' }" } + let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) From 95ae9ab48ffd76f765d7a7bf7bf5baf2c1299a41 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sat, 28 Feb 2015 17:04:47 +0100 Subject: [PATCH 448/574] apt: Add settings, keys and ppas. * Allow any configuration of apt to be done through data bindings by passing in hashes representing the resources. * Switch apt::ppa to use `distid` as set in `apt::params. This makes `apt::ppa` also work for LinuxMint. --- manifests/init.pp | 32 +++++++++++++++++----- manifests/ppa.pp | 4 +-- spec/classes/apt_spec.rb | 57 ++++++++++++++++++++++++++++++++++++++++ spec/defines/ppa_spec.rb | 2 +- 4 files changed, 85 insertions(+), 10 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index ea546dc55e..dbf0332958 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,12 +1,14 @@ # 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'] { @@ -60,6 +62,11 @@ $_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', @@ -135,8 +142,19 @@ } # 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) + } } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 4a08dce6fd..33cd60d586 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -10,8 +10,8 @@ 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') diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index d3559e4cef..8e8a6c6613 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -171,6 +171,63 @@ 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' }, } } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 14a5139c3b..f29a8dfee5 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -214,7 +214,7 @@ it do expect { is_expected.to compile - }.to raise_error(Puppet::Error, /apt::ppa is currently supported on Ubuntu only./) + }.to raise_error(Puppet::Error, /supported on Ubuntu and LinuxMint only/) end end end From 0f3bdcdf5a44315197ded803401b52dfcce38ebe Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sat, 28 Feb 2015 17:35:25 +0100 Subject: [PATCH 449/574] apt(::key|_key) Remove the `key.*_` prefixes. Remove a lot of the redundant `key_` prefixes on `apt::key` and the `keyserver_` prefix on `apt_key`. --- lib/puppet/type/apt_key.rb | 2 +- manifests/key.pp | 60 ++++++++++----------- manifests/source.pp | 12 ++--- spec/classes/apt_spec.rb | 8 +-- spec/defines/key_spec.rb | 104 ++++++++++++++++++------------------ spec/defines/source_spec.rb | 14 ++--- 6 files changed, 100 insertions(+), 100 deletions(-) diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 70825ac218..8aae686816 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -62,7 +62,7 @@ newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/) end - newparam(:keyserver_options) do + newparam(:options) do desc 'Additional options to pass to apt-key\'s --keyserver-options.' end diff --git a/manifests/key.pp b/manifests/key.pp index ce5fc2514c..0f0572ed5f 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -23,14 +23,14 @@ # * +present+ # * +absent+ # -# [*key_content*] +# [*content*] # _default_: +undef+ # # This parameter can be used to pass in a GPG key as a # string in case it cannot be fetched from a remote location # and using a file resource is for other reasons inconvenient. # -# [*key_source*] +# [*source*] # _default_: +undef+ # # This parameter can be used to pass in the location of a GPG @@ -38,7 +38,7 @@ # * +URL+: ftp, http or https # * +path+: absolute path to a file on the target system. # -# [*key_server*] +# [*server*] # _default_: +undef+ # # The keyserver from where to fetch our GPG key. It can either be a domain @@ -46,36 +46,36 @@ # undef which results in apt_key's default keyserver being used, # currently +keyserver.ubuntu.com+. # -# [*key_options*] +# [*options*] # _default_: +undef+ # # Additional options to pass on to `apt-key adv --keyserver-options`. define apt::key ( - $key = $title, - $ensure = present, - $key_content = undef, - $key_source = undef, - $key_server = undef, - $key_options = undef, + $key = $title, + $ensure = present, + $content = undef, + $source = undef, + $server = undef, + $options = undef, ) { validate_re($key, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z']) validate_re($ensure, ['\Aabsent|present\Z',]) - if $key_content { - validate_string($key_content) + if $content { + validate_string($content) } - if $key_source { - validate_re($key_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+']) + if $source { + validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+']) } - if $key_server { - validate_re($key_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$']) + if $server { + validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$']) } - if $key_options { - validate_string($key_options) + if $options { + validate_string($options) } case $ensure { @@ -86,12 +86,12 @@ if !defined(Anchor["apt_key ${key} present"]) { apt_key { $title: - ensure => $ensure, - id => $key, - source => $key_source, - content => $key_content, - server => $key_server, - keyserver_options => $key_options, + ensure => $ensure, + id => $key, + source => $source, + content => $content, + server => $server, + options => $options, } -> anchor { "apt_key ${key} present": } } @@ -104,12 +104,12 @@ if !defined(Anchor["apt_key ${key} absent"]){ apt_key { $title: - ensure => $ensure, - id => $key, - source => $key_source, - content => $key_content, - server => $key_server, - keyserver_options => $key_options, + ensure => $ensure, + id => $key, + source => $source, + content => $content, + server => $server, + options => $options, } -> anchor { "apt_key ${key} absent": } } diff --git a/manifests/source.pp b/manifests/source.pp index b7d150c223..215e4c407e 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -44,12 +44,12 @@ # We do not want to remove keys when the source is absent. if $key and ($ensure == 'present') { apt::key { "Add key: ${key} from Apt::Source ${title}": - ensure => present, - key => $key, - key_server => $key_server, - key_content => $key_content, - key_source => $key_source, - before => Apt::Setting["list-${name}"], + ensure => present, + key => $key, + server => $key_server, + content => $key_content, + source => $key_source, + before => Apt::Setting["list-${name}"], } } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 8e8a6c6613..2de1965061 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -180,19 +180,19 @@ end let(:params) { { :keys => { '55BE302B' => { - 'key_server' => 'subkeys.pgp.net', + 'server' => 'subkeys.pgp.net', }, '4BD6EC30' => { - 'key_server' => 'pgp.mit.edu', + 'server' => 'pgp.mit.edu', } } } } it { is_expected.to contain_apt__key('55BE302B').with({ - :key_server => 'subkeys.pgp.net', + :server => 'subkeys.pgp.net', })} it { is_expected.to contain_apt__key('4BD6EC30').with({ - :key_server => 'pgp.mit.edu', + :server => 'pgp.mit.edu', })} end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index c6f3752e80..3d82df0e4f 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'apt::key', :type => :define do +describe 'apt::key' do let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' @@ -12,12 +12,12 @@ describe 'default options' do it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'present', - :source => nil, - :server => nil, - :content => nil, - :keyserver_options => nil, + :id => title, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :options => nil, }) end it 'contains the apt_key present anchor' do @@ -36,12 +36,12 @@ it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ - :id => GPG_KEY_ID, - :ensure => 'present', - :source => nil, - :server => nil, - :content => nil, - :keyserver_options => nil, + :id => GPG_KEY_ID, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :options => nil, }) end it 'contains the apt_key present anchor' do @@ -56,12 +56,12 @@ it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'absent', - :source => nil, - :server => nil, - :content => nil, - :keyserver_options => nil, + :id => title, + :ensure => 'absent', + :source => nil, + :server => nil, + :content => nil, + :keyserver => nil, }) end it 'contains the apt_key absent anchor' do @@ -71,20 +71,20 @@ describe 'set a bunch of things!' do let :params do { - :key_content => 'GPG key content', - :key_source => 'http://apt.puppetlabs.com/pubkey.gpg', - :key_server => 'pgp.mit.edu', - :key_options => 'debug', + :content => 'GPG key content', + :source => 'http://apt.puppetlabs.com/pubkey.gpg', + :server => 'pgp.mit.edu', + :options => 'debug', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ - :id => title, - :ensure => 'present', - :source => 'http://apt.puppetlabs.com/pubkey.gpg', - :server => 'pgp.mit.edu', - :content => params[:key_content], - :keyserver_options => 'debug', + :id => title, + :ensure => 'present', + :source => 'http://apt.puppetlabs.com/pubkey.gpg', + :server => 'pgp.mit.edu', + :content => params[:content], + :options => 'debug', }) end it 'contains the apt_key present anchor' do @@ -94,7 +94,7 @@ context "domain with dash" do let(:params) do{ - :key_server => 'p-gp.m-it.edu', + :server => 'p-gp.m-it.edu', } end it 'contains the apt_key' do is_expected.to contain_apt_key(title).with({ @@ -107,7 +107,7 @@ context "url" do let :params do { - :key_server => 'hkp://pgp.mit.edu', + :server => 'hkp://pgp.mit.edu', } end it 'contains the apt_key' do @@ -120,7 +120,7 @@ context "url with port number" do let :params do { - :key_server => 'hkp://pgp.mit.edu:80', + :server => 'hkp://pgp.mit.edu:80', } end it 'contains the apt_key' do @@ -135,7 +135,7 @@ describe 'validation' do context "domain begin with dash" do let(:params) do{ - :key_server => '-pgp.mit.edu', + :server => '-pgp.mit.edu', } end it 'fails' do expect { subject } .to raise_error(/does not match/) @@ -144,7 +144,7 @@ context "domain begin with dot" do let(:params) do{ - :key_server => '.pgp.mit.edu', + :server => '.pgp.mit.edu', } end it 'fails' do expect { subject } .to raise_error(/does not match/) @@ -153,7 +153,7 @@ context "domain end with dot" do let(:params) do{ - :key_server => "pgp.mit.edu.", + :server => "pgp.mit.edu.", } end it 'fails' do expect { subject } .to raise_error(/does not match/) @@ -162,7 +162,7 @@ context "exceed character url" do let :params do { - :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' + :server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' } end it 'fails' do @@ -172,7 +172,7 @@ context "incorrect port number url" do let :params do { - :key_server => 'hkp://pgp.mit.edu:8008080' + :server => 'hkp://pgp.mit.edu:8008080' } end it 'fails' do @@ -182,7 +182,7 @@ context "incorrect protocol for url" do let :params do { - :key_server => 'abc://pgp.mit.edu:80' + :server => 'abc://pgp.mit.edu:80' } end it 'fails' do @@ -192,7 +192,7 @@ context "missing port number url" do let :params do { - :key_server => 'hkp://pgp.mit.edu:' + :server => 'hkp://pgp.mit.edu:' } end it 'fails' do @@ -202,7 +202,7 @@ context "url ending with a dot" do let :params do { - :key_server => 'hkp://pgp.mit.edu.' + :server => 'hkp://pgp.mit.edu.' } end it 'fails' do @@ -211,7 +211,7 @@ end context "url begin with a dash" do let(:params) do{ - :key_server => "hkp://-pgp.mit.edu", + :server => "hkp://-pgp.mit.edu", } end it 'fails' do expect { subject }.to raise_error(/does not match/) @@ -228,7 +228,7 @@ context 'invalid source' do let :params do { - :key_source => 'afp://puppetlabs.com/key.gpg', + :source => 'afp://puppetlabs.com/key.gpg', } end it 'fails' do expect { subject }.to raise_error(/does not match/) @@ -237,7 +237,7 @@ context 'invalid content' do let :params do { - :key_content => [], + :content => [], } end it 'fails' do expect { subject }.to raise_error(/is not a string/) @@ -246,16 +246,16 @@ context 'invalid server' do let :params do { - :key_server => 'two bottles of rum', + :server => 'two bottles of rum', } end it 'fails' do expect { subject }.to raise_error(/does not match/) end end - context 'invalid keyserver_options' do + context 'invalid options' do let :params do { - :key_options => {}, + :options => {}, } end it 'fails' do expect { subject }.to raise_error(/is not a string/) @@ -292,12 +292,12 @@ it 'contains only a single apt_key' do is_expected.to contain_apt_key('duplicate').with({ - :id => title, - :ensure => 'present', - :source => nil, - :server => nil, - :content => nil, - :keyserver_options => nil, + :id => title, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :options => nil, }) is_expected.not_to contain_apt_key(title) end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 5e2728b251..f55921b615 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'apt::source', :type => :define do +describe 'apt::source' do GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' let :pre_condition do @@ -71,11 +71,11 @@ } it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ - 'ensure' => 'present', - 'key' => GPG_KEY_ID, - 'key_server' => 'pgp.mit.edu', - 'key_content' => 'GPG key content', - 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg', + 'ensure' => 'present', + 'key' => GPG_KEY_ID, + 'server' => 'pgp.mit.edu', + 'content' => 'GPG key content', + 'source' => 'http://apt.puppetlabs.com/pubkey.gpg', }) } end @@ -122,7 +122,7 @@ }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) } end - + context 'ensure => absent' do let :facts do { From ea4f615735d5fb6bb6b0fcbd735da76e0bb45c06 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sat, 28 Feb 2015 18:02:23 +0100 Subject: [PATCH 450/574] apt::source: Allow passing in a complex key. Turn `$key` into something that accepts a string or a hash of four keys representing the different options that can be passed on to `apt::key`. --- manifests/params.pp | 7 ++ manifests/source.pp | 43 +++++++--- spec/classes/apt_spec.rb | 6 +- spec/defines/source_spec.rb | 160 ++++++++++++++++++++++++++---------- 4 files changed, 155 insertions(+), 61 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 2a29b6d1be..8799f7b98e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -51,6 +51,13 @@ 'preferences.d' => true, } + $source_key_defaults = { + 'server' => $default_keyserver, + 'options' => undef, + 'content' => undef, + 'source' => undef, + } + $file_defaults = { 'owner' => 'root', 'group' => 'root', diff --git a/manifests/source.pp b/manifests/source.pp index 215e4c407e..ea24cbfe44 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -9,20 +9,30 @@ $include_src = false, $include_deb = true, $key = undef, - $key_server = 'keyserver.ubuntu.com', - $key_content = undef, - $key_source = undef, $pin = false, $architecture = undef, $trusted_source = false, ) { - validate_string($architecture, $comment, $location, $release, $repos, $key_server) + validate_string($architecture, $comment, $location, $release, $repos) validate_bool($trusted_source, $include_src, $include_deb) if ! $release { fail('lsbdistcodename fact not available: release parameter required') } + $_before = Apt::Setting["list-${title}"] + + if $key { + if is_hash($key) { + unless $key['id'] { + fail('key hash must contain at least an id entry') + } + $_key = merge($::apt::source_key_defaults, $key) + } else { + validate_string($key) + } + } + apt::setting { "list-${name}": ensure => $ensure, content => template('apt/_header.erb', 'apt/source.list.erb'), @@ -36,20 +46,29 @@ apt::pin { $name: ensure => $ensure, priority => $pin, - before => Apt::Setting["list-${name}"], + before => $_before, origin => $host, } } # We do not want to remove keys when the source is absent. if $key and ($ensure == 'present') { - apt::key { "Add key: ${key} from Apt::Source ${title}": - ensure => present, - key => $key, - server => $key_server, - content => $key_content, - source => $key_source, - before => Apt::Setting["list-${name}"], + if is_hash($_key) { + apt::key { "Add key: ${_key['id']} from Apt::Source ${title}": + ensure => present, + id => $_key['id'], + server => $_key['server'], + content => $_key['content'], + source => $_key['source'], + options => $_key['options'], + before => $_before, + } + } else { + apt::key { "Add key: ${key} from Apt::Source ${title}": + ensure => present, + id => $key, + before => $_before, + } } } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 2de1965061..9e0598565f 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -140,16 +140,14 @@ 'location' => 'http://debian.mirror.iweb.ca/debian/', 'release' => 'unstable', 'repos' => 'main contrib non-free', - 'key' => '55BE302B', - 'key_server' => 'subkeys.pgp.net', + 'key' => { 'id' => '55BE302B', 'server' => 'subkeys.pgp.net' }, 'pin' => '-10', 'include_src' => true, }, 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', - 'key' => '4BD6EC30', - 'key_server' => 'pgp.mit.edu', + 'key' => { 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' }, } } } } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index f55921b615..06363e608c 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -22,18 +22,19 @@ let :params do { - 'include_deb' => false, - 'include_src' => true, + :include_deb => false, + :include_src => true, } end it { is_expected.to contain_apt__setting('list-my_source').with({ - 'ensure' => 'present', + :ensure => 'present', }).with_content(/# my_source\ndeb-src wheezy main\n/) + } end - context 'no defaults' do + describe 'no defaults' do let :facts do { :lsbdistid => 'Debian', @@ -41,43 +42,112 @@ :osfamily => 'Debian' } end - let :params do - { - 'comment' => 'foo', - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'release' => 'sid', - 'repos' => 'testing', - 'include_src' => false, - 'key' => GPG_KEY_ID, - 'key_server' => 'pgp.mit.edu', - 'key_content' => 'GPG key content', - 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg', - 'pin' => '10', - 'architecture' => 'x86_64', - 'trusted_source' => true, + context 'with simple key' do + let :params do + { + :comment => 'foo', + :location => 'http://debian.mirror.iweb.ca/debian/', + :release => 'sid', + :repos => 'testing', + :include_src => false, + :key => GPG_KEY_ID, + :pin => '10', + :architecture => 'x86_64', + :trusted_source => true, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) + } + + it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ + :ensure => 'present', + :priority => '10', + :origin => 'debian.mirror.iweb.ca', + }) + } + + it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ + :ensure => 'present', + :key => GPG_KEY_ID, + }) } end - it { is_expected.to contain_apt__setting('list-my_source').with({ - 'ensure' => 'present', - }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) - } + context 'with complex key' do + let :params do + { + :comment => 'foo', + :location => 'http://debian.mirror.iweb.ca/debian/', + :release => 'sid', + :repos => 'testing', + :include_src => false, + :key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu', + 'content' => 'GPG key content', + 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',}, + :pin => '10', + :architecture => 'x86_64', + :trusted_source => true, + } + end - it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ - 'ensure' => 'present', - 'priority' => '10', - 'origin' => 'debian.mirror.iweb.ca', - }) - } + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) + } - it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ - 'ensure' => 'present', - 'key' => GPG_KEY_ID, - 'server' => 'pgp.mit.edu', - 'content' => 'GPG key content', - 'source' => 'http://apt.puppetlabs.com/pubkey.gpg', - }) - } + it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ + :ensure => 'present', + :priority => '10', + :origin => 'debian.mirror.iweb.ca', + }) + } + + it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ + :ensure => 'present', + :key => GPG_KEY_ID, + :server => 'pgp.mit.edu', + :content => 'GPG key content', + :source => 'http://apt.puppetlabs.com/pubkey.gpg', + }) + } + end + + context 'with simple key' do + let :params do + { + :comment => 'foo', + :location => 'http://debian.mirror.iweb.ca/debian/', + :release => 'sid', + :repos => 'testing', + :include_src => false, + :key => GPG_KEY_ID, + :pin => '10', + :architecture => 'x86_64', + :trusted_source => true, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) + } + + it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ + :ensure => 'present', + :priority => '10', + :origin => 'debian.mirror.iweb.ca', + }) + } + + it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ + :ensure => 'present', + :id => GPG_KEY_ID, + }) + } + end end context 'trusted_source true' do @@ -90,13 +160,13 @@ end let :params do { - 'include_src' => false, - 'trusted_source' => true, + :include_src => false, + :trusted_source => true, } end it { is_expected.to contain_apt__setting('list-my_source').with({ - 'ensure' => 'present', + :ensure => 'present', }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/) } end @@ -111,14 +181,14 @@ end let :params do { - 'include_deb' => false, - 'include_src' => true, - 'architecture' => 'x86_64', + :include_deb => false, + :include_src => true, + :architecture => 'x86_64', } end it { is_expected.to contain_apt__setting('list-my_source').with({ - 'ensure' => 'present', + :ensure => 'present', }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) } end @@ -133,12 +203,12 @@ end let :params do { - 'ensure' => 'absent', + :ensure => 'absent', } end it { is_expected.to contain_apt__setting('list-my_source').with({ - 'ensure' => 'absent' + :ensure => 'absent' }) } end From 061bc49463f66b3c9d7fb07386d662e50b7fe29a Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sun, 1 Mar 2015 14:18:48 +0100 Subject: [PATCH 451/574] apt::key: Rename $key to $id to match apt_key. --- manifests/key.pp | 26 +++++++++++++------------- spec/defines/key_spec.rb | 10 +++++----- spec/defines/source_spec.rb | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index 0f0572ed5f..05bda975b0 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -7,7 +7,7 @@ # # === Parameters # -# [*key*] +# [*id*] # _default_: +$title+, the title/name of the resource # # Is a GPG key ID or full key fingerprint. This value is validated with @@ -51,7 +51,7 @@ # # Additional options to pass on to `apt-key adv --keyserver-options`. define apt::key ( - $key = $title, + $id = $title, $ensure = present, $content = undef, $source = undef, @@ -59,7 +59,7 @@ $options = undef, ) { - validate_re($key, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z']) + validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z']) validate_re($ensure, ['\Aabsent|present\Z',]) if $content { @@ -80,38 +80,38 @@ case $ensure { present: { - if defined(Anchor["apt_key ${key} absent"]){ - fail("key with id ${key} already ensured as absent") + if defined(Anchor["apt_key ${id} absent"]){ + fail("key with id ${id} already ensured as absent") } - if !defined(Anchor["apt_key ${key} present"]) { + if !defined(Anchor["apt_key ${id} present"]) { apt_key { $title: ensure => $ensure, - id => $key, + id => $id, source => $source, content => $content, server => $server, options => $options, } -> - anchor { "apt_key ${key} present": } + anchor { "apt_key ${id} present": } } } absent: { - if defined(Anchor["apt_key ${key} present"]){ - fail("key with id ${key} already ensured as present") + if defined(Anchor["apt_key ${id} present"]){ + fail("key with id ${id} already ensured as present") } - if !defined(Anchor["apt_key ${key} absent"]){ + if !defined(Anchor["apt_key ${id} absent"]){ apt_key { $title: ensure => $ensure, - id => $key, + id => $id, source => $source, content => $content, server => $server, options => $options, } -> - anchor { "apt_key ${key} absent": } + anchor { "apt_key ${id} absent": } } } diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 3d82df0e4f..31248cc78a 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -31,7 +31,7 @@ end let :params do { - :key => GPG_KEY_ID, + :id => GPG_KEY_ID, } end it 'contains the apt_key' do @@ -276,16 +276,16 @@ describe 'duplication' do context 'two apt::key resources for same key, different titles' do let :pre_condition do - "apt::key { 'duplicate': key => '#{title}', }" + "apt::key { 'duplicate': id => '#{title}', }" end it 'contains two apt::key resources' do is_expected.to contain_apt__key('duplicate').with({ - :key => title, + :id => title, :ensure => 'present', }) is_expected.to contain_apt__key(title).with({ - :key => title, + :id => title, :ensure => 'present', }) end @@ -305,7 +305,7 @@ context 'two apt::key resources, different ensure' do let :pre_condition do - "apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }" + "apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }" end it 'informs the user of the impossibility' do expect { subject }.to raise_error(/already ensured as absent/) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 06363e608c..7dc03e4593 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -71,7 +71,7 @@ it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ :ensure => 'present', - :key => GPG_KEY_ID, + :id => GPG_KEY_ID, }) } end @@ -107,7 +107,7 @@ it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ :ensure => 'present', - :key => GPG_KEY_ID, + :id => GPG_KEY_ID, :server => 'pgp.mit.edu', :content => 'GPG key content', :source => 'http://apt.puppetlabs.com/pubkey.gpg', From 0cb48b0c470c81b369a54336409789b28bb09f16 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Sun, 1 Mar 2015 14:42:39 +0100 Subject: [PATCH 452/574] apt::key: Be explicit about the keyserver. The behaviour of passing down undef through multiple layers gets fuzzy so for now be explicit about the keyserver. Once Puppet 4 is out and this behaviour has been crystallised and tested we can revisit it. --- manifests/key.pp | 6 ++---- manifests/params.pp | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/manifests/key.pp b/manifests/key.pp index 05bda975b0..6761e6912d 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -42,9 +42,7 @@ # _default_: +undef+ # # The keyserver from where to fetch our GPG key. It can either be a domain -# name or url. It defaults to -# undef which results in apt_key's default keyserver being used, -# currently +keyserver.ubuntu.com+. +# name or url. It defaults to +keyserver.ubuntu.com+. # # [*options*] # _default_: +undef+ @@ -55,7 +53,7 @@ $ensure = present, $content = undef, $source = undef, - $server = undef, + $server = $::apt::keyserver, $options = undef, ) { diff --git a/manifests/params.pp b/manifests/params.pp index 8799f7b98e..14401c6c93 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,6 +11,7 @@ $conf_d = "${root}/apt.conf.d" $preferences = "${root}/preferences" $preferences_d = "${root}/preferences.d" + $keyserver = 'keyserver.ubuntu.com' if $::osfamily != 'Debian' { fail('This module only works on Debian or derivatives like Ubuntu') @@ -52,7 +53,7 @@ } $source_key_defaults = { - 'server' => $default_keyserver, + 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef, From 7a35ea03554fe172ac7e1753efbabd7fed1c7805 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Mon, 2 Mar 2015 20:37:01 +0100 Subject: [PATCH 453/574] apt::setting: Remove file_perms. This was a great idea but is pretty pointless. It's also not being used by anything and not exposed as a switch on the main class so it would almost never affect any behaviour. --- manifests/setting.pp | 9 +++------ spec/defines/setting_spec.rb | 36 ------------------------------------ 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/manifests/setting.pp b/manifests/setting.pp index c288b35d7e..bc0e15a8d5 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -3,12 +3,9 @@ $ensure = file, $source = undef, $content = undef, - $file_perms = {}, $notify_update = true, ) { - $_file = merge($::apt::file_defaults, $file_perms) - if $content and $source { fail('apt::setting cannot have both content and source') } @@ -56,9 +53,9 @@ file { "${_path}/${_priority}${base_name}${_ext}": ensure => $ensure, - owner => $_file['owner'], - group => $_file['group'], - mode => $_file['mode'], + owner => 'root', + group => 'root', + mode => '0644', content => $content, source => $source, notify => $_notify, diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index e01fdbfe44..19794115dd 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -97,40 +97,4 @@ :ensure => 'absent', })} end - - describe 'with file_perms' do - context "{'owner' => 'roosevelt'}" do - let(:params) { default_params.merge({ :file_perms => {'owner' => 'roosevelt'} }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ - :owner => 'roosevelt', - :group => 'root', - :mode => '0644', - })} - end - - context "'group' => 'roosevelt'}" do - let(:params) { default_params.merge({ :file_perms => {'group' => 'roosevelt'} }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ - :owner => 'root', - :group => 'roosevelt', - :mode => '0644', - })} - end - - context "'owner' => 'roosevelt'}" do - let(:params) { default_params.merge({ :file_perms => {'mode' => '0600'} }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ - :owner => 'root', - :group => 'root', - :mode => '0600', - })} - end - - context "'notify_update' => false}" do - let(:params) { default_params.merge({ :notify_update => false }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') } - it { is_expected.not_to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') } - end - - end end From c57d2dd5ddafe26bd17727ab184b00fb8a166a2a Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Mon, 2 Mar 2015 22:40:06 +0100 Subject: [PATCH 454/574] apt: Fix all strict variable cases. A few of these fixes are absolutely horrendous but we have no choice as we need to stay current- and future-parser compatible for now. Once we can go Puppet 4 only we can use the `$facts` hash lookup instead which will return undef/nil for things that aren't set instead of them not being defined at all. --- manifests/params.pp | 23 +++++++++++++++++------ manifests/pin.pp | 12 +++++++++++- manifests/ppa.pp | 4 ++-- manifests/source.pp | 31 ++++++++++++++++--------------- spec/classes/apt_spec.rb | 2 +- spec/classes/apt_update_spec.rb | 20 ++++++++++---------- spec/classes/params_spec.rb | 2 +- spec/defines/conf_spec.rb | 2 +- spec/defines/key_spec.rb | 21 ++++++++++++++------- spec/defines/pin_spec.rb | 2 +- spec/defines/ppa_spec.rb | 13 +++++++------ spec/defines/setting_spec.rb | 2 +- templates/pin.pref.erb | 2 +- 13 files changed, 83 insertions(+), 53 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 14401c6c93..8edd2e7840 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,9 +1,20 @@ class apt::params { - if $caller_module_name and $caller_module_name != $module_name { + if defined('$caller_module_name') and $caller_module_name and $caller_module_name != $module_name { fail('apt::params is a private class and cannot be accessed directly') } + if $::osfamily != 'Debian' { + fail('This module only works on Debian or derivatives like Ubuntu') + } + + $xfacts = { + 'lsbdistcodename' => defined('$lsbdistcodename') ? { + true => $::lsbdistcodename, + default => undef + }, + } + $root = '/etc/apt' $provider = '/usr/bin/apt-get' $sources_list = "${root}/sources.list" @@ -13,10 +24,6 @@ $preferences_d = "${root}/preferences.d" $keyserver = 'keyserver.ubuntu.com' - if $::osfamily != 'Debian' { - fail('This module only works on Debian or derivatives like Ubuntu') - } - $config_files = { 'conf' => { 'path' => $conf_d, @@ -68,7 +75,7 @@ case $::lsbdistid { 'ubuntu', 'debian': { $distid = $::lsbdistid - $distcodename = $::lsbdistcodename + $distcodename = $xfacts['lsbdistcodename'] } 'linuxmint': { if $::lsbdistcodename == 'debian' { @@ -113,5 +120,9 @@ } } } + '', default: { + $ppa_options = undef + $ppa_package = undef + } } } diff --git a/manifests/pin.pp b/manifests/pin.pp index b27ed8ea2a..bcccf28b7c 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -3,7 +3,7 @@ define apt::pin( $ensure = present, - $explanation = "${caller_module_name}: ${name}", + $explanation = undef, $order = undef, $packages = '*', $priority = 0, @@ -20,6 +20,16 @@ fail('Only integers are allowed in the apt::pin order param') } + if $explanation { + $_explanation = $explanation + } else { + if defined('$caller_module_name') { # strict vars check + $_explanation = "${caller_module_name}: ${name}" + } else { + $_explanation = ": ${name}" + } + } + $pin_release_array = [ $release, $codename, diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 33cd60d586..5fc7f3c503 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,12 +1,12 @@ # ppa.pp define apt::ppa( $ensure = 'present', - $release = $::lsbdistcodename, $options = $::apt::ppa_options, + $release = $::apt::xfacts['lsbdistcodename'], $package_name = $::apt::ppa_package, $package_manage = false, ) { - if ! $release { + unless $release { fail('lsbdistcodename fact not available: release parameter required') } diff --git a/manifests/source.pp b/manifests/source.pp index ea24cbfe44..9b3405797a 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -1,22 +1,22 @@ # source.pp # add an apt source define apt::source( - $comment = $name, - $ensure = present, - $location = '', - $release = $::lsbdistcodename, - $repos = 'main', - $include_src = false, - $include_deb = true, - $key = undef, - $pin = false, - $architecture = undef, - $trusted_source = false, + $comment = $name, + $ensure = present, + $location = '', + $release = $::apt::xfacts['lsbdistcodename'], + $repos = 'main', + $include_src = false, + $include_deb = true, + $key = undef, + $pin = false, + $architecture = undef, + $trusted_source = false, ) { - validate_string($architecture, $comment, $location, $release, $repos) + validate_string($architecture, $comment, $location, $repos) validate_bool($trusted_source, $include_src, $include_deb) - if ! $release { + unless $release { fail('lsbdistcodename fact not available: release parameter required') } @@ -30,6 +30,7 @@ $_key = merge($::apt::source_key_defaults, $key) } else { validate_string($key) + $_key = $key } } @@ -64,9 +65,9 @@ before => $_before, } } else { - apt::key { "Add key: ${key} from Apt::Source ${title}": + apt::key { "Add key: ${_key} from Apt::Source ${title}": ensure => present, - id => $key, + id => $_key, before => $_before, } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 9e0598565f..e668996f5b 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy'} } context 'defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({ diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 6ae9e8f9a5..06f76de0e0 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -4,7 +4,7 @@ describe 'apt::update', :type => :class do context "when update['always']=true" do #This should completely disable all of this logic. These tests are to guarantee that we don't somehow magically change the behavior. - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let (:pre_condition) { "class{'::apt': update => {'always' => true},}" } it 'should trigger an apt-get update run' do #set the apt_update exec's refreshonly attribute to false @@ -14,7 +14,7 @@ context "when apt::update['frequency'] has the value of #{update_frequency}" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } let (:pre_condition) { "class{'::apt': update => {'always' => true, 'frequency' => '#{update_frequency}'}, }" } it 'should trigger an apt-get update run' do # set the apt_update exec's refreshonly attribute to false @@ -22,7 +22,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let (:pre_condition) { "class{'::apt': update => {'always' => true, 'frequency' => '#{update_frequency}'}, }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false @@ -38,7 +38,7 @@ context "and apt::update['frequency']='always'" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } let (:pre_condition) { "class{'::apt': update => {'always' => false, 'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do #set the apt_update exec's refreshonly attribute to false @@ -47,7 +47,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false @@ -58,7 +58,7 @@ context "and apt::update['frequency']='reluctantly'" do {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval} } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy'} } let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) @@ -67,7 +67,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) @@ -79,7 +79,7 @@ context "and apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false @@ -88,7 +88,7 @@ end end context 'when the $::apt_update_last_success fact has a recent value' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => Time.now.to_i } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i } } let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec\'s refreshonly attribute. (it should be true) @@ -96,7 +96,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil } } let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index 65759fad1d..f8ca89f2a3 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::params', :type => :class do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let (:title) { 'my_package' } it { is_expected.to contain_apt__params } diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 4e5b46b824..a7db4e61e3 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -3,7 +3,7 @@ let :pre_condition do 'class { "apt": }' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let :title do 'norecommends' end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 31248cc78a..b9bcea845a 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -1,7 +1,12 @@ require 'spec_helper' describe 'apt::key' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let :pre_condition do + 'class { "apt": }' + end + + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' let :title do @@ -15,7 +20,7 @@ :id => title, :ensure => 'present', :source => nil, - :server => nil, + :server => 'keyserver.ubuntu.com', :content => nil, :options => nil, }) @@ -39,7 +44,7 @@ :id => GPG_KEY_ID, :ensure => 'present', :source => nil, - :server => nil, + :server => 'keyserver.ubuntu.com', :content => nil, :options => nil, }) @@ -59,7 +64,7 @@ :id => title, :ensure => 'absent', :source => nil, - :server => nil, + :server => 'keyserver.ubuntu.com', :content => nil, :keyserver => nil, }) @@ -276,7 +281,8 @@ describe 'duplication' do context 'two apt::key resources for same key, different titles' do let :pre_condition do - "apt::key { 'duplicate': id => '#{title}', }" + "class { 'apt': } + apt::key { 'duplicate': id => '#{title}', }" end it 'contains two apt::key resources' do @@ -295,7 +301,7 @@ :id => title, :ensure => 'present', :source => nil, - :server => nil, + :server => 'keyserver.ubuntu.com', :content => nil, :options => nil, }) @@ -305,7 +311,8 @@ context 'two apt::key resources, different ensure' do let :pre_condition do - "apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }" + "class { 'apt': } + apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }" end it 'informs the user of the impossibility' do expect { subject }.to raise_error(/already ensured as absent/) diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index e4d5d0ae1a..a11c3b5c25 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -3,7 +3,7 @@ let :pre_condition do 'class { "apt": }' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let(:title) { 'my_pin' } context 'defaults' do diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index f29a8dfee5..7c0d072c08 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' describe 'apt::ppa' do + let :pre_condition do + 'class { "apt": }' + end describe 'defaults' do - let :pre_condition do - 'class { "apt": }' - end let :facts do { :lsbdistrelease => '11.04', @@ -190,6 +190,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :lsbdistcodeanme => nil, } end let(:title) { 'ppa:foo' } @@ -203,10 +204,10 @@ describe 'not ubuntu' do let :facts do { - :lsbdistrelease => '14.04', - :lsbdistcodename => 'trusty', + :lsbdistrelease => '6.0.7', + :lsbdistcodename => 'wheezy', :operatingsystem => 'Debian', - :lsbdistid => 'Ubuntu', + :lsbdistid => 'debian', :osfamily => 'Debian', } end diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index e01fdbfe44..f39717627e 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -2,7 +2,7 @@ describe 'apt::setting' do let(:pre_condition) { 'class { "apt": }' } - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } let(:title) { 'conf-teddybear' } let(:default_params) { { :content => 'di' } } diff --git a/templates/pin.pref.erb b/templates/pin.pref.erb index 26b2516c47..76936d7ca4 100644 --- a/templates/pin.pref.erb +++ b/templates/pin.pref.erb @@ -15,7 +15,7 @@ elsif @origin.length > 0 @pin = "origin #{@origin}" end -%> -Explanation: <%= @explanation %> +Explanation: <%= @_explanation %> Package: <%= @packages_string %> Pin: <%= @pin %> Pin-Priority: <%= @priority %> From 1c707c7d323f80502e09008351c5007b385a1c97 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Tue, 3 Mar 2015 18:07:48 +0100 Subject: [PATCH 455/574] apt::params: Complete $xfacts. `$xfacts` now contains and guards all `lsb*` facts. Looking up any `lsb*`-related fact should now always be done through `$::apt::xfacts` to ensure that the values are always set to either the value of the fact or undef. This avoids all sorts of kerfuffles with strict variables. --- manifests/params.pp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 8edd2e7840..42dd6b0129 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -8,10 +8,31 @@ fail('This module only works on Debian or derivatives like Ubuntu') } + # Strict variables facts lookup compatibility $xfacts = { 'lsbdistcodename' => defined('$lsbdistcodename') ? { true => $::lsbdistcodename, - default => undef + default => undef, + }, + 'lsbdistrelease' => defined('$lsbdistrelease') ? { + true => $::lsbdistrelease, + default => undef, + }, + 'lsbmajdistrelease' => defined('$lsbmajdistrelease') ? { + true => $::lsbmajdistrelease, + default => undef, + }, + 'lsbdistdescription' => defined('$lsbdistdescription') ? { + true => $::lsbdistdescription, + default => undef, + }, + 'lsbminordistrelease' => defined('$lsbminordistrelease') ? { + true => $::lsbminordistrelease, + default => undef, + }, + 'lsbdistid' => defined('$lsbdistid') ? { + true => $::lsbdistid, + default => undef, }, } @@ -66,24 +87,18 @@ 'source' => undef, } - $file_defaults = { - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644', - } - - case $::lsbdistid { + case $xfacts['lsbdistid'] { 'ubuntu', 'debian': { - $distid = $::lsbdistid + $distid = $xfacts['lsbdistid'] $distcodename = $xfacts['lsbdistcodename'] } 'linuxmint': { - if $::lsbdistcodename == 'debian' { + if $xfacts['lsbdistcodename'] == 'debian' { $distid = 'debian' $distcodename = 'wheezy' } else { $distid = 'ubuntu' - $distcodename = $::lsbdistcodename ? { + $distcodename = $xfacts['lsbdistcodename'] ? { 'qiana' => 'trusty', 'petra' => 'saucy', 'olivia' => 'raring', @@ -92,7 +107,7 @@ } } } - '': { + undef: { fail('Unable to determine lsbdistid, is lsb-release installed?') } default: { From a220dcf08c84208d08d6f96b8aee7c7f70ae83a1 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 5 Mar 2015 17:37:51 +0100 Subject: [PATCH 456/574] apt::source: Merge `include_*` options into hash. This makes its behaviour similar to the `update`, `proxy` and `purge` hashes on the main classes bringing its API more in line with the rest of the module. --- manifests/params.pp | 5 +++++ manifests/source.pp | 7 ++++--- spec/classes/apt_spec.rb | 2 +- spec/defines/source_spec.rb | 21 ++++----------------- templates/source.list.erb | 4 ++-- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 42dd6b0129..e3cc8252f9 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -87,6 +87,11 @@ 'source' => undef, } + $include_defaults = { + 'deb' => true, + 'src' => false, + } + case $xfacts['lsbdistid'] { 'ubuntu', 'debian': { $distid = $xfacts['lsbdistid'] diff --git a/manifests/source.pp b/manifests/source.pp index 9b3405797a..1ceaba96ce 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -6,21 +6,22 @@ $location = '', $release = $::apt::xfacts['lsbdistcodename'], $repos = 'main', - $include_src = false, - $include_deb = true, + $include = {}, $key = undef, $pin = false, $architecture = undef, $trusted_source = false, ) { validate_string($architecture, $comment, $location, $repos) - validate_bool($trusted_source, $include_src, $include_deb) + validate_bool($trusted_source) + validate_hash($include) unless $release { fail('lsbdistcodename fact not available: release parameter required') } $_before = Apt::Setting["list-${title}"] + $_include = merge($::apt::include_defaults, $include) if $key { if is_hash($key) { diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index e668996f5b..856007bf50 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -142,7 +142,7 @@ 'repos' => 'main contrib non-free', 'key' => { 'id' => '55BE302B', 'server' => 'subkeys.pgp.net' }, 'pin' => '-10', - 'include_src' => true, + 'include' => {'src' => true,}, }, 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 7dc03e4593..e2ae69a161 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -11,7 +11,7 @@ 'my_source' end - context 'mostly defaults' do + context 'defaults' do let :facts do { :lsbdistid => 'Debian', @@ -20,17 +20,9 @@ } end - let :params do - { - :include_deb => false, - :include_src => true, - } - end - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).with_content(/# my_source\ndeb-src wheezy main\n/) - + :ensure => 'present', + }).without_content(/# my_source\ndeb-src wheezy main\n/) } end @@ -49,7 +41,6 @@ :location => 'http://debian.mirror.iweb.ca/debian/', :release => 'sid', :repos => 'testing', - :include_src => false, :key => GPG_KEY_ID, :pin => '10', :architecture => 'x86_64', @@ -83,7 +74,6 @@ :location => 'http://debian.mirror.iweb.ca/debian/', :release => 'sid', :repos => 'testing', - :include_src => false, :key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu', 'content' => 'GPG key content', 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',}, @@ -122,7 +112,6 @@ :location => 'http://debian.mirror.iweb.ca/debian/', :release => 'sid', :repos => 'testing', - :include_src => false, :key => GPG_KEY_ID, :pin => '10', :architecture => 'x86_64', @@ -160,7 +149,6 @@ end let :params do { - :include_src => false, :trusted_source => true, } end @@ -181,8 +169,7 @@ end let :params do { - :include_deb => false, - :include_src => true, + :include => {'deb' => false, 'src' => true,}, :architecture => 'x86_64', } end diff --git a/templates/source.list.erb b/templates/source.list.erb index fb0a38612e..00457de64a 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,10 +1,10 @@ # <%= @comment %> -<%- if @include_deb then -%> +<%- if @_include['deb'] then -%> deb <%- if @architecture or @trusted_source -%> [<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> ] <%- end %><%= @location %> <%= @release %> <%= @repos %> <%- end -%> -<%- if @include_src then -%> +<%- if @_include['src'] then -%> deb-src <%- if @architecture or @trusted_source -%> [<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> ] <%- end %><%= @location %> <%= @release %> <%= @repos %> From 90bade9561bb505b164c97cd5956697dd9b1f4d6 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 5 Mar 2015 20:23:38 +0100 Subject: [PATCH 457/574] apt::source: Rename `trusted_source`. It is weird that `trusted_source` would default to `false` as that would imply that we normally don't trust our sources. This is opposite to the truth, by default we trust them but only if the Releases file can be verified (meaning it is signed by a GPG key known to apt). What we were telling apt is that it should trust this source even if the Releases file and the repository is unsigned. This is better captured with `allow_unsigned` and better highlights the danger of what you're doing, installing packages from a source we cannot authenticate. --- manifests/source.pp | 4 ++-- spec/defines/source_spec.rb | 10 +++++----- templates/source.list.erb | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 1ceaba96ce..96c174c05e 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -10,10 +10,10 @@ $key = undef, $pin = false, $architecture = undef, - $trusted_source = false, + $allow_unsigned = false, ) { validate_string($architecture, $comment, $location, $repos) - validate_bool($trusted_source) + validate_bool($allow_unsigned) validate_hash($include) unless $release { diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index e2ae69a161..d5e146a2f4 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -44,7 +44,7 @@ :key => GPG_KEY_ID, :pin => '10', :architecture => 'x86_64', - :trusted_source => true, + :allow_unsigned => true, } end @@ -79,7 +79,7 @@ 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',}, :pin => '10', :architecture => 'x86_64', - :trusted_source => true, + :allow_unsigned => true, } end @@ -115,7 +115,7 @@ :key => GPG_KEY_ID, :pin => '10', :architecture => 'x86_64', - :trusted_source => true, + :allow_unsigned => true, } end @@ -139,7 +139,7 @@ end end - context 'trusted_source true' do + context 'allow_unsigned true' do let :facts do { :lsbdistid => 'Debian', @@ -149,7 +149,7 @@ end let :params do { - :trusted_source => true, + :allow_unsigned => true, } end diff --git a/templates/source.list.erb b/templates/source.list.erb index 00457de64a..26838db51b 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,11 +1,11 @@ # <%= @comment %> <%- if @_include['deb'] then -%> -deb <%- if @architecture or @trusted_source -%> -[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> +deb <%- if @architecture or @allow_unsigned -%> +[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @allow_unsigned %>trusted=yes<% end -%> ] <%- end %><%= @location %> <%= @release %> <%= @repos %> <%- end -%> <%- if @_include['src'] then -%> -deb-src <%- if @architecture or @trusted_source -%> -[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @trusted_source %>trusted=yes<% end -%> +deb-src <%- if @architecture or @allow_unsigned -%> +[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @allow_unsigned %>trusted=yes<% end -%> ] <%- end %><%= @location %> <%= @release %> <%= @repos %> <%- end -%> From 4802a6fc776122d1ea77f1a5904b78442dcc205f Mon Sep 17 00:00:00 2001 From: Leslie Carr Date: Thu, 5 Mar 2015 16:56:03 -0800 Subject: [PATCH 458/574] MODULES-1827 adding Cumulus Linux detection the apt module did not correctly detect Cumulus Linux with lsbdistid. This change adds several lines in params.pp to detect Cumulus Linux and set $distid and $distcodename --- manifests/params.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/params.pp b/manifests/params.pp index 1c6cc99de7..f824c9107b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -25,6 +25,10 @@ } } } + 'Cumulus Networks': { + $distid = 'debian' + $distcodename = $::lsbdistcodename + } '': { fail('Unable to determine lsbdistid, is lsb-release installed?') } From 41a2725683bbaacfc827f8ebfe1fc1044d51df80 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 5 Mar 2015 20:35:02 +0100 Subject: [PATCH 459/574] apt::source: Make location mostly required. In what universe does it make sense to create a `sources.list.d` entry for a repository **without** specifying where this repository is? :confounded: :disappointed: :weary: :anguished: :scream: Only when removing the resource should a location not be required. --- manifests/source.pp | 6 ++++- spec/defines/source_spec.rb | 44 +++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 96c174c05e..163a411bb2 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -1,9 +1,9 @@ # source.pp # add an apt source define apt::source( + $location = undef, $comment = $name, $ensure = present, - $location = '', $release = $::apt::xfacts['lsbdistcodename'], $repos = 'main', $include = {}, @@ -20,6 +20,10 @@ fail('lsbdistcodename fact not available: release parameter required') } + if $ensure == 'present' and ! $location { + fail('cannot create a source entry without specifying a location') + } + $_before = Apt::Setting["list-${title}"] $_include = merge($::apt::include_defaults, $include) diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index d5e146a2f4..7fd86b56ff 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -12,18 +12,35 @@ end context 'defaults' do - let :facts do - { - :lsbdistid => 'Debian', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian' - } + context 'without location' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /source entry without specifying a location/) + end end + context 'with location' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + let(:params) { { :location => 'hello.there', } } - it { is_expected.to contain_apt__setting('list-my_source').with({ - :ensure => 'present', - }).without_content(/# my_source\ndeb-src wheezy main\n/) - } + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).without_content(/# my_source\ndeb-src hello.there wheezy main\n/) + } + end end describe 'no defaults' do @@ -149,13 +166,14 @@ end let :params do { + :location => 'hello.there', :allow_unsigned => true, } end it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', - }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/) + }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/) } end @@ -169,6 +187,7 @@ end let :params do { + :location => 'hello.there', :include => {'deb' => false, 'src' => true,}, :architecture => 'x86_64', } @@ -176,7 +195,7 @@ it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', - }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/) + }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] hello.there wheezy main\n/) } end @@ -208,6 +227,7 @@ :osfamily => 'Debian' } end + let(:params) { { :location => 'hello.there', } } it do expect { From 31f732e7894d18a52bb11f96160dc0e0be4f35e9 Mon Sep 17 00:00:00 2001 From: Johan Fleury Date: Mon, 9 Mar 2015 00:01:57 +0100 Subject: [PATCH 460/574] Cleaning 50unattended-upgrades.erb --- templates/50unattended-upgrades.erb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/templates/50unattended-upgrades.erb b/templates/50unattended-upgrades.erb index 1177922de0..47ecb3479a 100644 --- a/templates/50unattended-upgrades.erb +++ b/templates/50unattended-upgrades.erb @@ -33,25 +33,30 @@ Unattended-Upgrade::MinimalSteps "<%= @minimal_steps %>"; // This will (obviously) make shutdown slower Unattended-Upgrade::InstallOnShutdown "<%= @install_on_shutdown %>"; +<% if @mail_to != "NONE" %> // Send email to this address for problems or packages upgrades // If empty or unset then no email is sent, make sure that you // have a working mail setup on your system. A package that provides // 'mailx' must be installed. -<% if @mail_to != "NONE" %>Unattended-Upgrade::Mail "<%= @mail_to %>";<% end %> +Unattended-Upgrade::Mail "<%= @mail_to %>"; +<% end %> +<% if @mail_to != "NONE" %> // Set this value to "true" to get emails only on errors. Default // is to always send a mail if Unattended-Upgrade::Mail is set -<% if @mail_to != "NONE" %>Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>";<% end %> +Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>"; +<% end %> // Do automatic removal of new unused dependencies after the upgrade // (equivalent to apt-get autoremove) Unattended-Upgrade::Remove-Unused-Dependencies "<%= @remove_unused %>"; -// Automatically reboot *WITHOUT CONFIRMATION* if a -// the file /var/run/reboot-required is found after the upgrade +// Automatically reboot *WITHOUT CONFIRMATION* if a +// the file /var/run/reboot-required is found after the upgrade Unattended-Upgrade::Automatic-Reboot "<%= @auto_reboot %>"; - +<% if @dl_limit != "NONE" %> // Use apt bandwidth limit feature, this example limits the download // speed to 70kb/sec -<% if @dl_limit != "NONE" %>Acquire::http::Dl-Limit "<%= @dl_limit %>";<% end %> +Acquire::http::Dl-Limit "<%= @dl_limit %>"; +<% end %> From 79db539f336942ef3dda7ceb4bea7595f3b0eb70 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 10 Mar 2015 17:13:31 -0700 Subject: [PATCH 461/574] Inheritance of apt::params means it can't be private Otherwise, if another module has `class { 'apt': }` in it everything fails, as `$caller_module_name` will be the other module name. --- manifests/params.pp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index e3cc8252f9..f4489cdcb5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,9 +1,5 @@ class apt::params { - if defined('$caller_module_name') and $caller_module_name and $caller_module_name != $module_name { - fail('apt::params is a private class and cannot be accessed directly') - } - if $::osfamily != 'Debian' { fail('This module only works on Debian or derivatives like Ubuntu') } From f588f2651a68c5863aac7dac910d96bbc7531ef9 Mon Sep 17 00:00:00 2001 From: tphoney Date: Fri, 6 Mar 2015 16:14:40 +0000 Subject: [PATCH 462/574] initial commit for gpg key checking better attempt at gpg version checking adding in key length warning removing version check, adding key check adding tests clean up the code small changes use commands documentation updates --- README.md | 2 +- lib/puppet/provider/apt_key/apt_key.rb | 13 +++++++++ lib/puppet/type/apt_key.rb | 3 +++ spec/acceptance/apt_key_provider_spec.rb | 34 ++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c06e1760c..45e905248f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The apt module provides a simple interface for managing Apt source, key, and def The apt module automates obtaining and installing software packages on \*nix systems. -**Note**: While this module allows the use of short keys, **we urge you NOT to use short keys**, as they pose a serious security issue by opening you up to collision attacks. +**Note**: While this module allows the use of short keys, **warnings are thrown if a full fingerprint is not used**, as they pose a serious security issue by opening you up to collision attacks. ## Setup diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 67a8aa0643..687c99502e 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -16,6 +16,7 @@ confine :osfamily => :debian defaultfor :osfamily => :debian commands :apt_key => 'apt-key' + commands :gpg => '/usr/bin/gpg' def self.instances cli_args = ['adv','--list-keys', '--with-colons', '--fingerprint'] @@ -136,6 +137,18 @@ def tempfile(content) file = Tempfile.new('apt_key') file.write content file.close + #confirm that the fingerprint from the file, matches the long key that is in the manifest + if name.size == 40 + if File.executable? command(:gpg) + extracted_key = execute(["#{command(:gpg)} --with-fingerprint --with-colons #{file.path} | awk -F: '/^fpr:/ { print $10 }'"], :failonfail => false) + extracted_key = extracted_key.chomp + if extracted_key != name + fail ("The id in your manifest #{resource[:name]} and the fingerprint from content/source do not match. Please check there is not an error in the id or check the content/source is legitimate.") + end + else + warning ('/usr/bin/gpg cannot be found for verification of the id.') + end + end file.path end diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 70825ac218..7130496ea9 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -23,6 +23,9 @@ if self[:content] and self[:source] fail('The properties content and source are mutually exclusive.') end + if self[:id].length < 40 + warning('The id should be a full fingerprint (40 characters), see README.') + end end newparam(:id, :namevar => true) do diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 24277d237a..1f703c9ce6 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -520,4 +520,38 @@ end end end + + describe 'fingerprint validation against source/content' do + context 'fingerprint in id matches fingerprint from remote key' do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', + ensure => 'present', + source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) + end + end + + context 'fingerprint in id does NOT match fingerprint from remote key' do + it 'works' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6E666', + ensure => 'present', + source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/do not match/) + end + end + end + end + end From 0c357042451c13af66b25985a04a81cf0d3f8262 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 20 Feb 2015 14:25:53 -0800 Subject: [PATCH 463/574] Make installation of software-properties optional This is cherry-picked from the PPA cleanup happening for the 2.0.0 release. Conflicts: manifests/params.pp manifests/ppa.pp --- README.md | 8 +++++ manifests/params.pp | 12 ++++++- manifests/ppa.pp | 68 ++++++++++++++++++------------------- spec/defines/ppa_spec.rb | 72 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 1c06e1760c..7e39c8d9ee 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,14 @@ apt::sources: It is recommended to read the manpage 'apt_preferences(5)' +####apt::ppa + +* `ensure`: Whether we are adding or removing the PPA. Can be 'present' or 'absent'. Defaults to 'present'. +* `release`: The codename for the operating system you're running. Defaults to `$lsbdistcodename`. Required if lsb-release is not installed. +* `options`: Options to be passed to the `apt-add-repository` command. OS-dependent defaults are set in `apt::params`. +* `package_name`: The package that provides the `apt-add-repository` command. OS-dependent defaults are set in `apt::params`. +* `package_manage`: Whether or not to manage the package providing `apt-add-repository`. Defaults to true. + ### Testing The apt module is mostly a collection of defined resource types, which provide reusable logic for managing Apt. It provides smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. diff --git a/manifests/params.pp b/manifests/params.pp index f824c9107b..4efe872e5b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -64,18 +64,28 @@ 'lucid': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = undef + $ppa_package = 'python-software-properties' $legacy_origin = true $origins = ['${distro_id} ${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } - 'precise', 'trusty', 'utopic', 'vivid': { + 'precise': { $backports_location = 'http://us.archive.ubuntu.com/ubuntu' $ppa_options = '-y' + $ppa_package = 'python-software-properties' + $legacy_origin = true + $origins = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables + } + 'trusty', 'utopic', 'vivid': { + $backports_location = 'http://us.archive.ubuntu.com/ubuntu' + $ppa_options = '-y' + $ppa_package = 'software-properties-common' $legacy_origin = true $origins = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } default: { $backports_location = 'http://old-releases.ubuntu.com/ubuntu' $ppa_options = '-y' + $ppa_package = 'python-software-properties' $legacy_origin = true $origins = ['${distro_id}:${distro_codename}-security'] #lint:ignore:single_quote_string_with_variables } diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 0fdcc95f3a..e86a19fd9d 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,9 +1,11 @@ # ppa.pp define apt::ppa( - $ensure = 'present', - $release = $::lsbdistcodename, - $options = $apt::params::ppa_options, + $ensure = 'present', + $release = $::lsbdistcodename, + $options = $::apt::params::ppa_options, + $package_name = $::apt::params::ppa_package, + $package_manage = true, ) { include apt::params include apt::update @@ -24,52 +26,48 @@ $sources_list_d_filename = "${filename_without_ppa}-${release}.list" if $ensure == 'present' { - $package = $::lsbdistrelease ? { - /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties', - default => 'software-properties-common', - } + if $package_manage { + if ! defined(Package[$package_name]) { + package { $package_name: } + } - if ! defined(Package[$package]) { - package { $package: } + $_require = [File['sources.list.d'], Package[$package_name]] + } else { + $_require = File['sources.list.d'] } - if defined(Class[apt]) { - $proxy_host = $apt::proxy_host - $proxy_port = $apt::proxy_port - case $proxy_host { - false, '', undef: { - $proxy_env = [] - } - default: { - $proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"] - } + if defined(Class['apt']) { + case $::apt::proxy_host { + false, '', undef: { + $proxy_env = [] + } + default: { + $proxy_env = ["http_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}", "https_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}"] } + } } else { - $proxy_env = [] + $proxy_env = [] } + exec { "add-apt-repository-${name}": - environment => $proxy_env, - command => "/usr/bin/add-apt-repository ${options} ${name}", - unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", - user => 'root', - logoutput => 'on_failure', - notify => Exec['apt_update'], - require => [ - File['sources.list.d'], - Package[$package], - ], + environment => $proxy_env, + command => "/usr/bin/add-apt-repository ${options} ${name}", + unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", + user => 'root', + logoutput => 'on_failure', + notify => Exec['apt_update'], + require => $_require, } file { "${sources_list_d}/${sources_list_d_filename}": - ensure => file, - require => Exec["add-apt-repository-${name}"], + ensure => file, + require => Exec["add-apt-repository-${name}"], } } else { - file { "${sources_list_d}/${sources_list_d_filename}": - ensure => 'absent', - notify => Exec['apt_update'], + ensure => 'absent', + notify => Exec['apt_update'], } } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 3a4c381f67..866d323004 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -32,6 +32,78 @@ } end + describe 'package_name => software-properties-common' do + let :pre_condition do + 'class { "apt": }' + end + let :params do + { + :package_name => 'software-properties-common' + } + end + let :facts do + { + :lsbdistrelease => '11.04', + :lsbdistcodename => 'natty', + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistid => 'Ubuntu', + } + end + + let(:title) { 'ppa:needs/such.substitution/wow' } + it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ + 'environment' => [], + 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', + 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', + 'user' => 'root', + 'logoutput' => 'on_failure', + }) + } + + it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ + 'ensure' => 'file', + }) + } + end + + describe 'package_manage => false' do + let :pre_condition do + 'class { "apt": }' + end + let :facts do + { + :lsbdistrelease => '11.04', + :lsbdistcodename => 'natty', + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistid => 'Ubuntu', + } + end + let :params do + { + :package_manage => false, + } + end + + let(:title) { 'ppa:needs/such.substitution/wow' } + it { is_expected.to_not contain_package('python-software-properties') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ + 'environment' => [], + 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', + 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', + 'user' => 'root', + 'logoutput' => 'on_failure', + }) + } + + it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ + 'ensure' => 'file', + }) + } + end + describe 'apt included, no proxy' do let :pre_condition do 'class { "apt": }' From 3799e3a23c7d4e74c99aa4ec7e42de0b486ffe67 Mon Sep 17 00:00:00 2001 From: Mikko Pesari Date: Wed, 18 Feb 2015 18:09:53 +0200 Subject: [PATCH 464/574] unattended_upgrades: Allow changing legacy_origin This enables using Origins-Pattern in Ubuntu. --- README.md | 13 +++++++------ manifests/unattended_upgrades.pp | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b325ba9d2b..0bf17c4d63 100644 --- a/README.md +++ b/README.md @@ -74,12 +74,13 @@ class { 'apt': ``` class { 'apt::unattended_upgrades': - origins => $::apt::params::origins, - blacklist => [], - update => '1', - download => '1', - upgrade => '1', - autoclean => '7', + legacy_origin => $::apt::params::legacy_origin, + origins => $::apt::params::origins, + blacklist => [], + update => '1', + download => '1', + upgrade => '1', + autoclean => '7', } ``` diff --git a/manifests/unattended_upgrades.pp b/manifests/unattended_upgrades.pp index b835b9a6a5..028ffc647c 100644 --- a/manifests/unattended_upgrades.pp +++ b/manifests/unattended_upgrades.pp @@ -14,6 +14,7 @@ # file and in /etc/cron.daily/apt # class apt::unattended_upgrades ( + $legacy_origin = $::apt::params::legacy_origin, $origins = $::apt::params::origins, $blacklist = [], $update = '1', @@ -40,6 +41,7 @@ ) inherits ::apt::params { validate_bool( + $legacy_origin, $auto_fix, $minimal_steps, $install_on_shutdown, From 81bb96c898657f7d6045ddeb4b3701ab94cffa4d Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 13 Mar 2015 14:56:53 -0700 Subject: [PATCH 465/574] Update docs and test for $legacy_origin --- README.md | 1 + spec/classes/unattended_upgrades_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bf17c4d63..501adc658d 100644 --- a/README.md +++ b/README.md @@ -278,6 +278,7 @@ apt::sources: ####apt::unattended_upgrades +* `legacy_origin`: If set to true, use the old `Unattended-Upgrade::Allowed-Origins` variable. If false, use `Unattended-Upgrade::Origins-Pattern`. OS-dependent defaults are defined in `apt::params`. * `origins`: The repositories from which to automatically upgrade included packages. * `blacklist`: A list of packages to **not** automatically upgrade. * `update`: How often, in days, to run `apt-get update`. diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 3742bf1c2a..0a02755536 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -155,6 +155,7 @@ let :params do { + 'legacy_origin' => true, 'enable' => '0', 'backup_interval' => '3', 'backup_level' => '1', @@ -181,7 +182,7 @@ } end - it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"bananas";\n\};} } + it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Allowed-Origins \{\n\t"bananas";\n\};} } it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Package-Blacklist \{\n\t"foo";\n\t"bar";\n\};} } it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "false";}} it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "true";}} From 399d3cae5ab82e53e1ced1f0f9cdd48e815b952b Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 13 Mar 2015 14:56:53 -0700 Subject: [PATCH 466/574] Update docs and test for $legacy_origin --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 501adc658d..63e6a85870 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,6 @@ class { 'apt': ``` class { 'apt::unattended_upgrades': - legacy_origin => $::apt::params::legacy_origin, - origins => $::apt::params::origins, blacklist => [], update => '1', download => '1', From 42ab470d00ac45ceb5a4a5a9cec6260d7be98822 Mon Sep 17 00:00:00 2001 From: Chris Boot Date: Sun, 15 Mar 2015 22:33:22 +0000 Subject: [PATCH 467/574] apt_key: fix parsing invalid dates when using GnuPG 2.x If one should happen to have redirected /usr/bin/gpg to run GnuPG 2.x rather than the more usual GnuPG 1.x, the apt_key provider fails with the following error: Could not prefetch apt_key provider 'apt_key': invalid date This is because the output of "--with-colons" defaults to using "fixed-list-mode" in 2.x but did not do so for 1.x. This new format gives much more information about keys and also uses timestamps in seconds from 1970-01-01 (UNIX epoch) rather than dates in the format YYYY-MM-DD. This patch adds "--fixed-list-mode" when calling apt-key, and adjusts the code to parse the timestamps instead. This actually has several advantages: - Works the same with GnuPG 1.x and 2.x. - More accurate expiry time tracking, not just entire days. - No need to require 'date' any longer. - Will allow the provider to expose more key information in future. Tested on: - Debian Wheezy (Puppet 2.7.23, Ruby 1.8.7p358) - Debian Jessie (Puppet 3.7.2, Ruby 2.1.5p273) --- lib/puppet/provider/apt_key/apt_key.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 687c99502e..8878022d5e 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -1,4 +1,3 @@ -require 'date' require 'open-uri' require 'net/ftp' require 'tempfile' @@ -19,7 +18,7 @@ commands :gpg => '/usr/bin/gpg' def self.instances - cli_args = ['adv','--list-keys', '--with-colons', '--fingerprint'] + cli_args = ['adv','--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'] if RUBY_VERSION > '1.8.7' key_output = apt_key(cli_args).encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '') @@ -46,7 +45,7 @@ def self.instances expired = false if line_hash[:key_expiry] - expired = Date.today > Date.parse(line_hash[:key_expiry]) + expired = Time.now >= line_hash[:key_expiry] end new( @@ -57,10 +56,10 @@ def self.instances :long => line_hash[:key_long], :ensure => :present, :expired => expired, - :expiry => line_hash[:key_expiry], + :expiry => line_hash[:key_expiry].nil? ? nil : line_hash[:key_expiry].strftime("%Y-%m-%d"), :size => line_hash[:key_size], :type => line_hash[:key_type], - :created => line_hash[:key_created] + :created => line_hash[:key_created].strftime("%Y-%m-%d") ) end key_array.compact! @@ -96,8 +95,8 @@ def self.key_line_hash(pub_line, fpr_line) :key_short => fingerprint[-8..-1], # last 8 characters of fingerprint :key_size => pub_split[2], :key_type => nil, - :key_created => pub_split[5], - :key_expiry => pub_split[6].empty? ? nil : pub_split[6], + :key_created => Time.at(pub_split[5].to_i), + :key_expiry => pub_split[6].empty? ? nil : Time.at(pub_split[6].to_i), } # set key type based on types defined in /usr/share/doc/gnupg/DETAILS.gz From a24c41247f3b5e17fb20dce7e9ea4e9356f39d66 Mon Sep 17 00:00:00 2001 From: Chris Boot Date: Sun, 15 Mar 2015 22:47:15 +0000 Subject: [PATCH 468/574] apt_key: fix some whitespace issues --- lib/puppet/provider/apt_key/apt_key.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 8878022d5e..cd68d37063 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -142,11 +142,11 @@ def tempfile(content) extracted_key = execute(["#{command(:gpg)} --with-fingerprint --with-colons #{file.path} | awk -F: '/^fpr:/ { print $10 }'"], :failonfail => false) extracted_key = extracted_key.chomp if extracted_key != name - fail ("The id in your manifest #{resource[:name]} and the fingerprint from content/source do not match. Please check there is not an error in the id or check the content/source is legitimate.") + fail("The id in your manifest #{resource[:name]} and the fingerprint from content/source do not match. Please check there is not an error in the id or check the content/source is legitimate.") end else - warning ('/usr/bin/gpg cannot be found for verification of the id.') - end + warning('/usr/bin/gpg cannot be found for verification of the id.') + end end file.path end From 61a4fb6979f4269ddfbd6400940000fb12753e26 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Mon, 16 Mar 2015 19:34:24 +0100 Subject: [PATCH 469/574] Fix gpg key checking warings after f588f26 Use the full fingerprint for all keys to silence the warning. --- README.md | 2 +- manifests/backports.pp | 4 ++-- manifests/debian/testing.pp | 2 +- manifests/debian/unstable.pp | 2 +- spec/acceptance/apt_spec.rb | 2 +- spec/classes/apt_spec.rb | 4 ++-- spec/classes/backports_spec.rb | 12 ++++++------ tests/source.pp | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 63e6a85870..186c2c2d3c 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ class { 'apt': release => 'unstable', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '8B48AD6246925553', + key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', key_server => 'subkeys.pgp.net', pin => '-10', include_src => true, diff --git a/manifests/backports.pp b/manifests/backports.pp index a3ddb76e00..ff8cb44b97 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -58,8 +58,8 @@ } $key = $distid ? { - 'debian' => '46925553', - 'ubuntu' => '437D05B5', + 'debian' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + 'ubuntu' => '630239CC130E1A7FD81A27B140976EAF437D05B5', } $repos = $distid ? { 'debian' => 'main contrib non-free', diff --git a/manifests/debian/testing.pp b/manifests/debian/testing.pp index 3a82b4f7fd..7af48d2458 100644 --- a/manifests/debian/testing.pp +++ b/manifests/debian/testing.pp @@ -14,7 +14,7 @@ release => 'testing', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '46925553', + key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', key_server => 'subkeys.pgp.net', pin => '-10', } diff --git a/manifests/debian/unstable.pp b/manifests/debian/unstable.pp index 77df94b0af..23ce9b49bc 100644 --- a/manifests/debian/unstable.pp +++ b/manifests/debian/unstable.pp @@ -14,7 +14,7 @@ release => 'unstable', repos => 'main contrib non-free', required_packages => 'debian-keyring debian-archive-keyring', - key => '46925553', + key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', key_server => 'subkeys.pgp.net', pin => '-10', } diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 3011f9dfde..9ace221809 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -25,7 +25,7 @@ class { 'apt': 'ensure' => present, 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', - 'key' => '4BD6EC30', + 'key' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'key_server' => 'pgp.mit.edu', } }, diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index f65ed03093..d3ef34dfa3 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -155,7 +155,7 @@ 'release' => 'unstable', 'repos' => 'main contrib non-free', 'required_packages' => 'debian-keyring debian-archive-keyring', - 'key' => '55BE302B', + 'key' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'key_server' => 'subkeys.pgp.net', 'pin' => '-10', 'include_src' => true @@ -163,7 +163,7 @@ 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', - 'key' => '4BD6EC30', + 'key' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'key_server' => 'pgp.mit.edu', } } } } diff --git a/spec/classes/backports_spec.rb b/spec/classes/backports_spec.rb index 3c1f438561..721a4a613c 100644 --- a/spec/classes/backports_spec.rb +++ b/spec/classes/backports_spec.rb @@ -17,7 +17,7 @@ 'location' => 'http://old-releases.ubuntu.com/ubuntu', 'release' => 'karmic-backports', 'repos' => 'main universe multiverse restricted', - 'key' => '437D05B5', + 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', 'key_server' => 'pgp.mit.edu', }) } @@ -51,7 +51,7 @@ 'location' => 'http://old-releases.ubuntu.com/ubuntu', 'release' => 'karmic-backports', 'repos' => 'main universe multiverse restricted', - 'key' => '437D05B5', + 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', 'key_server' => 'pgp.mit.edu', }) } @@ -77,7 +77,7 @@ 'location' => 'http://backports.debian.org/debian-backports', 'release' => 'squeeze-backports', 'repos' => 'main contrib non-free', - 'key' => '46925553', + 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'key_server' => 'pgp.mit.edu', }) } @@ -103,7 +103,7 @@ 'location' => 'http://ftp.debian.org/debian/', 'release' => 'wheezy-backports', 'repos' => 'main contrib non-free', - 'key' => '46925553', + 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'key_server' => 'pgp.mit.edu', }) } @@ -129,7 +129,7 @@ 'location' => 'http://us.archive.ubuntu.com/ubuntu', 'release' => 'trusty-backports', 'repos' => 'main universe multiverse restricted', - 'key' => '437D05B5', + 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', 'key_server' => 'pgp.mit.edu', }) } @@ -163,7 +163,7 @@ 'location' => location, 'release' => 'squeeze-backports', 'repos' => 'main contrib non-free', - 'key' => '46925553', + 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'key_server' => 'pgp.mit.edu', }) } diff --git a/tests/source.pp b/tests/source.pp index c20b59662a..823b37b736 100644 --- a/tests/source.pp +++ b/tests/source.pp @@ -15,7 +15,7 @@ location => 'http://debian.mirror.iweb.ca/debian/', release => 'testing', repos => 'main contrib non-free', - key => '46925553', + key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', key_server => 'subkeys.pgp.net', pin => '-10', } @@ -23,7 +23,7 @@ location => 'http://debian.mirror.iweb.ca/debian/', release => 'unstable', repos => 'main contrib non-free', - key => '46925553', + key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', key_server => 'subkeys.pgp.net', pin => '-10', } From 58d06816e76acb5475afa6064f057e568c69a4c8 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 16 Mar 2015 14:05:58 -0700 Subject: [PATCH 470/574] 1.8.0 prep --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ metadata.json | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 736c0177a8..5b2a45a5ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,37 @@ +##2015-03-17 - Supported Release 1.8.0 +###Summary + +This is the last planned feature release of the 1.x series of this module. All new features will be evaluated for puppetlabs-apt 2.x. + +This release includes many important features, including support for full fingerprints, and fixes issues where `apt_key` was not supporting user/password and `apt_has_updates` was not properly parsing the `apt-check` output. + +####Changes to default behavior +- The apt module will now throw warnings if you don't use full fingerprints for `apt_key`s + +####Features +- Use gpg to check keys to work around https://bugs.launchpad.net/ubuntu/+source/gnupg2/+bug/1409117 (MODULES-1675) +- Add 'oldstable' to the default update origins for wheezy +- Add utopic, vivid, and cumulus compatibility +- Add support for full fingerprints +- New parameter for `apt::source` + - `trusted_source` +- New parameters for `apt::ppa` + - `package_name` + - `package_manage` +- New parameter for `apt::unattended_upgrades` + - `legacy_origin` +- Separate `apt::pin` from `apt::backports` to allow pin by release instead of origin + +####Bugfixes +- Cleanup lint and future parser issues +- Fix to support username and passwords again for `apt_key` (MODULES-1119) +- Fix issue where `apt::force` `$install_check` didn't work with non-English locales (MODULES-1231) +- Allow 5 digit ports in `apt_key` +- Fix for `ensure => absent` in `apt_key` (MODULES-1661) +- Fix `apt_has_updates` not parsing `apt-check` output correctly +- Fix inconsistent headers across files (MODULES-1200) +- Clean up formatting for 50unattended-upgrades.erb + ##2014-10-28 - Supported Release 1.7.0 ###Summary diff --git a/metadata.json b/metadata.json index 4c0e3d8c6a..5b14ae45cc 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-apt", - "version": "1.7.0", + "version": "1.8.0", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", From 6bf1ac351f9982c93b99ef828076bae3317406ed Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 16 Mar 2015 16:40:46 -0700 Subject: [PATCH 471/574] Update all the unit tests to look for full fingerprints Merged #466 too quickly --- spec/classes/debian_testing_spec.rb | 2 +- spec/classes/debian_unstable_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/debian_testing_spec.rb b/spec/classes/debian_testing_spec.rb index 6e0332652f..a2e35f5479 100644 --- a/spec/classes/debian_testing_spec.rb +++ b/spec/classes/debian_testing_spec.rb @@ -7,7 +7,7 @@ "release" => "testing", "repos" => "main contrib non-free", "required_packages" => "debian-keyring debian-archive-keyring", - "key" => "46925553", + "key" => "A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553", "key_server" => "subkeys.pgp.net", "pin" => "-10" }) diff --git a/spec/classes/debian_unstable_spec.rb b/spec/classes/debian_unstable_spec.rb index 8477a39e58..14d8650ffe 100644 --- a/spec/classes/debian_unstable_spec.rb +++ b/spec/classes/debian_unstable_spec.rb @@ -7,7 +7,7 @@ "release" => "unstable", "repos" => "main contrib non-free", "required_packages" => "debian-keyring debian-archive-keyring", - "key" => "46925553", + "key" => "A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553", "key_server" => "subkeys.pgp.net", "pin" => "-10" }) From c7354b90fbb91de685eea8ce3a01e360185550ce Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 18 Mar 2015 12:51:37 -0700 Subject: [PATCH 472/574] Actually make it possible to use apt_key The provider wasn't updated for a parameter rename. --- lib/puppet/provider/apt_key/apt_key.rb | 4 ++-- lib/puppet/type/apt_key.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 67a8aa0643..abf477b86b 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -149,8 +149,8 @@ def create # Breaking up the command like this is needed because it blows up # if --recv-keys isn't the last argument. command.push('adv', '--keyserver', resource[:server]) - unless resource[:keyserver_options].nil? - command.push('--keyserver-options', resource[:keyserver_options]) + unless resource[:options].nil? + command.push('--keyserver-options', resource[:options]) end command.push('--recv-keys', resource[:id]) elsif resource[:content] diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 8aae686816..4ba0e3eb43 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -58,7 +58,7 @@ newparam(:server) do desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' defaultto :'keyserver.ubuntu.com' - + newvalues(/\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$/) end From f5c677556435afb8dc13d7617e45b14f7344217d Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 18 Mar 2015 12:56:29 -0700 Subject: [PATCH 473/574] Make the acceptance tests work --- spec/acceptance/apt_key_provider_spec.rb | 14 +++++----- spec/acceptance/apt_spec.rb | 34 ++++++++++++++---------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 24277d237a..42fe19d2d6 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -488,14 +488,14 @@ end end - describe 'keyserver_options =>' do + describe 'options =>' do context 'debug' do it 'works' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - keyserver_options => 'debug', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', + ensure => 'present', + options => 'debug', } EOS @@ -507,9 +507,9 @@ it 'fails on invalid options' do pp = <<-EOS apt_key { 'puppetlabs': - id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', - ensure => 'present', - keyserver_options => 'this is totally bonkers', + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', + ensure => 'present', + options => 'this is totally bonkers', } EOS diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index e409a9098f..cea4dcde04 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -12,21 +12,27 @@ it 'should work with no errors' do pp = <<-EOS class { 'apt': - always_apt_update => true, - purge_sources_list => true, - purge_sources_list_d => true, - purge_preferences => true, - purge_preferences_d => true, - update_timeout => '400', - update_tries => '3', - sources => { + update => { + 'frequency' => 'always', + 'timeout' => '400', + 'tries' => '3', + }, + purge => { + 'sources.list' => true, + 'sources.list.d' => true, + 'preferences' => true, + 'preferences.d' => true, + }, + sources => { 'puppetlabs' => { - 'ensure' => present, - 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'key' => '4BD6EC30', - 'key_server' => 'pgp.mit.edu', - } + 'ensure' => present, + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'key' => { + 'id' => '4BD6EC30', + 'server' => 'pgp.mit.edu', + }, + }, }, } EOS From df47ca7ff4966bdc2725eb85be675f5e0ae798b5 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 18 Mar 2015 13:52:12 -0700 Subject: [PATCH 474/574] Remove `update['always'] = true` support We don't really need both of `update['always'] = true` and `update['frequency'] = 'always'`. --- manifests/init.pp | 5 +- manifests/params.pp | 1 - manifests/update.pp | 70 ++++++++--------- spec/classes/apt_spec.rb | 2 +- spec/classes/apt_update_spec.rb | 134 ++++++++++++-------------------- 5 files changed, 84 insertions(+), 128 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index dbf0332958..453df3171f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,9 +14,6 @@ if $update['frequency'] { validate_re($update['frequency'], $frequency_options) } - if $update['always'] { - validate_bool($update['always']) - } if $update['timeout'] { unless is_integer($update['timeout']) { fail('timeout value for update must be an integer') @@ -84,7 +81,7 @@ true => absent, } - if $_update['always'] { + if $_update['frequency'] == 'always' { Exec <| title=='apt_update' |> { refreshonly => false, } diff --git a/manifests/params.pp b/manifests/params.pp index f4489cdcb5..cf6547a44c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -57,7 +57,6 @@ } $update_defaults = { - 'always' => false, 'frequency' => 'reluctantly', 'timeout' => undef, 'tries' => undef, diff --git a/manifests/update.pp b/manifests/update.pp index a19e90aacd..86f068200c 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -4,51 +4,45 @@ #on the first run, but if it's not run in awhile something is likely borked #with apt and we'd want to know about it. - if $::apt::_update['always'] == false { - #if always_apt_update is true there's no point in parsing this logic. - - case $::apt::_update['frequency'] { - 'always': { - $_kick_apt = true - } - 'daily': { - #compare current date with the apt_update_last_success fact to determine - #if we should kick apt_update. - $daily_threshold = (strftime('%s') - 86400) - if $::apt_update_last_success { - if $::apt_update_last_success < $daily_threshold { - $_kick_apt = true - } else { - $_kick_apt = false - } - } else { - #if apt-get update has not successfully run, we should kick apt_update + case $::apt::_update['frequency'] { + 'always': { + $_kick_apt = true + } + 'daily': { + #compare current date with the apt_update_last_success fact to determine + #if we should kick apt_update. + $daily_threshold = (strftime('%s') - 86400) + if $::apt_update_last_success { + if $::apt_update_last_success < $daily_threshold { $_kick_apt = true + } else { + $_kick_apt = false } + } else { + #if apt-get update has not successfully run, we should kick apt_update + $_kick_apt = true } - 'weekly':{ - #compare current date with the apt_update_last_success fact to determine - #if we should kick apt_update. - $weekly_threshold = (strftime('%s') - 604800) - if $::apt_update_last_success { - if ( $::apt_update_last_success < $weekly_threshold ) { - $_kick_apt = true - } else { - $_kick_apt = false - } - } else { - #if apt-get update has not successfully run, we should kick apt_update + } + 'weekly':{ + #compare current date with the apt_update_last_success fact to determine + #if we should kick apt_update. + $weekly_threshold = (strftime('%s') - 604800) + if $::apt_update_last_success { + if ( $::apt_update_last_success < $weekly_threshold ) { $_kick_apt = true + } else { + $_kick_apt = false } - } - default: { - #catches 'recluctantly', and any other value (which should not occur). - #do nothing. - $_kick_apt = false + } else { + #if apt-get update has not successfully run, we should kick apt_update + $_kick_apt = true } } - } else { - $_kick_apt = false + default: { + #catches 'recluctantly', and any other value (which should not occur). + #do nothing. + $_kick_apt = false + } } if $_kick_apt { diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 856007bf50..2131c8ae9e 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -96,7 +96,7 @@ context 'lots of non-defaults' do let :params do { - :update => { 'always' => true, 'timeout' => 1, 'tries' => 3 }, + :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, :purge => { 'sources.list' => false, 'sources.list.d' => false, 'preferences' => false, 'preferences.d' => false, }, } diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 06f76de0e0..8fba4a0c98 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -2,108 +2,74 @@ require 'spec_helper' describe 'apt::update', :type => :class do - context "when update['always']=true" do - #This should completely disable all of this logic. These tests are to guarantee that we don't somehow magically change the behavior. - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } - let (:pre_condition) { "class{'::apt': update => {'always' => true},}" } - it 'should trigger an apt-get update run' do - #set the apt_update exec's refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false }) - end - ['always','daily','weekly','reluctantly'].each do |update_frequency| - context "when apt::update['frequency'] has the value of #{update_frequency}" do - { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } - let (:pre_condition) { "class{'::apt': update => {'always' => true, 'frequency' => '#{update_frequency}'}, }" } - it 'should trigger an apt-get update run' do - # set the apt_update exec's refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) - end - end - context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } - let (:pre_condition) { "class{'::apt': update => {'always' => true, 'frequency' => '#{update_frequency}'}, }" } - it 'should trigger an apt-get update run' do - #set the apt_update exec\'s refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) - end - end - end - end - end - end - - context "when apt::update['always']=false" do - context "and apt::update['frequency']='always'" do - { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } - let (:pre_condition) { "class{'::apt': update => {'always' => false, 'frequency' => 'always' },}" } - it 'should trigger an apt-get update run' do - #set the apt_update exec's refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) - end - end - end - context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } - let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'always' },}" } + context "and apt::update['frequency']='always'" do + { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| + context "and $::apt_update_last_success indicates #{desc}" do + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } + let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do - #set the apt_update exec\'s refreshonly attribute to false + #set the apt_update exec's refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end - context "and apt::update['frequency']='reluctantly'" do - {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy'} } - let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'reluctantly' },}" } - it 'should not trigger an apt-get update run' do - #don't change the apt_update exec's refreshonly attribute. (it should be true) - is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) - end - end + context 'when $::apt_update_last_success is nil' do + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" } + it 'should trigger an apt-get update run' do + #set the apt_update exec\'s refreshonly attribute to false + is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end - context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } - let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'reluctantly' },}" } + end + end + context "and apt::update['frequency']='reluctantly'" do + {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| + context "and $::apt_update_last_success indicates #{desc}" do + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy'} } + let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) end end end - ['daily','weekly'].each do |update_frequency| - context "and apt::update['frequency'] has the value of #{update_frequency}" do - { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| - context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } - let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } - it 'should trigger an apt-get update run' do - #set the apt_update exec\'s refreshonly attribute to false - is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) - end - end - end - context 'when the $::apt_update_last_success fact has a recent value' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i } } - let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } - it 'should not trigger an apt-get update run' do - #don't change the apt_update exec\'s refreshonly attribute. (it should be true) - is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) - end - end - context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil } } - let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" } + context 'when $::apt_update_last_success is nil' do + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } + it 'should not trigger an apt-get update run' do + #don't change the apt_update exec's refreshonly attribute. (it should be true) + is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) + end + end + end + ['daily','weekly'].each do |update_frequency| + context "and apt::update['frequency'] has the value of #{update_frequency}" do + { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| + context "and $::apt_update_last_success indicates #{desc}" do + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } + let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) end end end + context 'when the $::apt_update_last_success fact has a recent value' do + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i } } + let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } + it 'should not trigger an apt-get update run' do + #don't change the apt_update exec\'s refreshonly attribute. (it should be true) + is_expected.to contain_exec('apt_update').with({'refreshonly' => true}) + end + end + context 'when $::apt_update_last_success is nil' do + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil } } + let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } + it 'should trigger an apt-get update run' do + #set the apt_update exec\'s refreshonly attribute to false + is_expected.to contain_exec('apt_update').with({'refreshonly' => false}) + end + end end end end From adf9634b7154ea07c4872155763ab062dc10fc4a Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 18 Mar 2015 15:51:37 -0700 Subject: [PATCH 475/574] Linux open-source builds are regularly maxed out. Container-based are not. Let's switch! --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ec6f08dc6d..8b374e9bb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ --- language: ruby +sudo: false bundler_args: --without system_tests script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: From 3730f31688a917006e58a65abbbf06f2a964464d Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 19 Mar 2015 17:15:32 -0700 Subject: [PATCH 476/574] README updates for 2.x rewrite All classes, defines, parameters, and examples should be up to date. --- README.md | 291 +++++++++++++++++++----------------------------------- 1 file changed, 99 insertions(+), 192 deletions(-) diff --git a/README.md b/README.md index 9feb900cfe..01af4b1f9b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # apt -[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-apt.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-apt) - ## Overview The apt module provides a simple interface for managing Apt source, key, and definitions with Puppet. @@ -21,7 +19,7 @@ The apt module automates obtaining and installing software packages on \*nix sys * System repositories * Authentication keys -**Note**: Setting the apt module's `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will **destroy** any existing content that was not declared with Puppet. The default for these parameters is 'false'. +**Note**: By default, this module will **destroy** any existing content in `sources.list` and `sources.list.d` that was not declared with Puppet. ### Beginning with apt @@ -34,58 +32,18 @@ Any Puppet code that uses anything from the apt module requires that the core ap Using the apt module consists predominantly of declaring classes and defined types that provide the desired functionality and features. This module provides common resources and options that are shared by the various defined types in the apt module, so you **must always** include this class in your manifests. ``` -class { 'apt': - always_apt_update => false, - apt_update_frequency => undef, - disable_keys => undef, - proxy_host => false, - proxy_port => '8080', - purge_sources_list => false, - purge_sources_list_d => false, - purge_preferences_d => false, - update_timeout => undef, - fancy_progress => undef -} +class { 'apt': } ``` ## Reference ### Classes -* `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory, but it does its best to respect existing content. - - If you declare your apt class with `purge_sources_list`, `purge_sources_list_d`, `purge_preferences` and `purge_preferences_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. +* `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory. By default, it will purge any existing content it finds that wasn't declared with Puppet. -* `apt::backports`: This class adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined and potentially serious behavior. - - By default, this class drops a pin-file for backports, pinning it to a priority of 200. This is lower than the normal Debian archive, which gets a priority of 500 to ensure that packages with `ensure => latest` don't get magically upgraded from backports without your explicit permission. - - If you raise the priority through the `pin_priority` parameter to 500---identical to the rest of the Debian mirrors---normal policy goes into effect, and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. - * `apt::params`: Sets defaults for the apt module parameters. -* `apt::release`: Sets the default Apt release. This class is particularly useful when using repositories that are unstable in Ubuntu, such as Debian. - - ``` - class { 'apt::release': - release_id => 'precise', - } - ``` - -* `apt::unattended_upgrades`: This class manages the unattended-upgrades package and related configuration files for Ubuntu and Debian systems. You can configure the class to automatically upgrade all new package releases or just security releases. - - ``` - class { 'apt::unattended_upgrades': - origins => $::apt::params::origins, - blacklist => [], - update => '1', - download => '1', - upgrade => '1', - autoclean => '7', - } - ``` - -* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set the `always_apt_update` parameter to 'true', the update runs on every Puppet run. +* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to `true`, the update runs on every Puppet run. ### Types @@ -105,68 +63,23 @@ class { 'apt': * `source`: HTTP, HTTPS or FTP location of a GPG key or path to a file on the target host. * `content`: Instead of pointing to a file, pass the key in as a string. * `server`: The GPG key server to use. It defaults to *keyserver.ubuntu.com*. - * `keyserver_options`: Additional options to pass to `--keyserver`. - - Because apt_key is a native type, you can use it and query for it with MCollective. + * `options`: Additional options to pass to `apt-key`'s `--keyserver-options`. ### Defined Types -* `apt::builddep`: Installs the build dependencies of a specified package. - - `apt::builddep { 'glusterfs-server': }` - * `apt::conf`: Specifies a custom configuration file. The priority defaults to 50, but you can set the priority parameter to load the file earlier or later. The content parameter passes specified content, if any, into the file resource. -* `apt::hold`: Holds a specific version of a package. You can hold a package to a full version or a partial version. - - To set a package's ensure attribute to 'latest' but get the version specified by `apt::hold`: - - ``` - apt::hold { 'vim': - version => '2:7.3.547-7', - } - ``` - - Alternatively, if you want to hold your package at a partial version, you can use a wildcard. For example, you can hold Vim at version 7.3.*: - - - ``` - apt::hold { 'vim': - version => '2:7.3.*', - } - ``` - -* `apt::force`: Forces a package to be installed from a specific release. This is particularly useful when using repositories that are unstable in Ubuntu, such as Debian. - - ``` - apt::force { 'glusterfs-server': - release => 'unstable', - version => '3.0.3', - cfg_files => 'unchanged', - cfg_missing => true, - require => Apt::Source['debian_unstable'], - } - ``` - - Valid values for `cfg_files` are: - * 'new': Overwrites all existing configuration files with newer ones. - * 'old': Forces usage of all old files. - * 'unchanged: Updates only unchanged config files. - * 'none': Provides backward-compatibility with existing Puppet manifests. - - Valid values for `cfg_missing` are 'true', 'false'. Setting this to 'false' provides backward compatibility; setting it to 'true' checks for and installs missing configuration files for the selected package. - * `apt::key`: Adds a key to the list of keys used by Apt to authenticate packages. This type uses the aforementioned `apt_key` native type. As such, it no longer requires the `wget` command on which the old implementation depended. ``` apt::key { 'puppetlabs': - key => '1054B7A24BD6EC30', - key_server => 'pgp.mit.edu', + id => '1054B7A24BD6EC30', + server => 'pgp.mit.edu', } apt::key { 'jenkins': - key => '9B7D32F2D50582E6', - key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', + id => '9B7D32F2D50582E6', + source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', } ``` @@ -194,20 +107,25 @@ class { 'apt': * `apt::ppa`: Adds a PPA repository using `add-apt-repository`. For example, `apt::ppa { 'ppa:drizzle-developers/ppa': }`. +* `apt::setting`: Defined type to abstract the creation of Apt configuration files. + * `apt::source`: Adds an Apt source to `/etc/apt/sources.list.d/`. For example: ``` apt::source { 'debian_unstable': - comment => 'This is the iWeb Debian unstable mirror', - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'unstable', - repos => 'main contrib non-free', - required_packages => 'debian-keyring debian-archive-keyring', - key => '8B48AD6246925553', - key_server => 'subkeys.pgp.net', - pin => '-10', - include_src => true, - include_deb => true + comment => 'This is the iWeb Debian unstable mirror', + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + pin => '-10', + key => { + 'id' => '8B48AD6246925553', + 'server' => 'subkeys.pgp.net', + }, + include => { + 'src' => true, + 'deb' => true, + }, } ``` @@ -215,11 +133,12 @@ class { 'apt': ``` apt::source { 'puppetlabs': - location => 'http://apt.puppetlabs.com', - repos => 'main', - key => '1054B7A24BD6EC30', - key_server => 'pgp.mit.edu', - } + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => { + 'id' => '1054B7A24BD6EC30', + 'server' => 'pgp.mit.edu', + }, ``` ### Facts @@ -242,18 +161,20 @@ apt::sources: location: 'http://debian.mirror.iweb.ca/debian/' release: 'unstable' repos: 'main contrib non-free' - required_packages: 'debian-keyring debian-archive-keyring' - key: '9AA38DCD55BE302B' - key_server: 'subkeys.pgp.net' + key: + id: '9AA38DCD55BE302B' + server: 'subkeys.pgp.net' pin: '-10' - include_src: 'true' - include_deb: 'true' + include: + src: true + deb: true 'puppetlabs': location: 'http://apt.puppetlabs.com' repos: 'main' - key: '1054B7A24BD6EC30' - key_server: 'pgp.mit.edu' + key: + id:'1054B7A24BD6EC30' + server: 'pgp.mit.edu'
``` @@ -261,64 +182,48 @@ apt::sources: #### apt -* `always_apt_update`: Set to 'true' to update Apt on every run. This setting is intended for development environments where package updates are frequent. Defaults to 'false'. -* `apt_update_frequency`: Sets the run frequency for `apt-get update`. Defaults to 'reluctantly'. Accepts the following values: - * 'always': Runs update at every Puppet run. - * 'daily': Runs update daily; that is, `apt-get update` runs if the value of `apt_update_last_success` is less than current epoch time - 86400. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. - * 'weekly': Runs update weekly; that is, `apt-get update` runs if the value of `apt_update_last_success` is less than current epoch time - 604800. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. - * 'reluctantly': Only runs `apt-get update` if the exec resource `apt_update` is notified. This is the default setting. -* `disable_keys`: Disables the requirement for all packages to be signed. -* `proxy_host`: Configures a proxy host and stores the configuration in /etc/apt/apt.conf.d/01proxy. -* `proxy_port`: Configures a proxy port and stores the configuration in /etc/apt/apt.conf.d/01proxy. -* `purge_sources_list`: If set to 'true', Puppet purges all unmanaged entries from sources.list. Accepts 'true' or 'false'. Defaults to 'false'. -* `purge_sources_list_d`: If set to 'true', Puppet purges all unmanaged entries from sources.list.d. Accepts 'true' or 'false'. Defaults to 'false'. -* `update_timeout`: Overrides the exec timeout in seconds for `apt-get update`. Defaults to exec default (300). -* `update_tries`: Sets how many times to attempt running `apt-get update`. Use this to work around transient DNS and HTTP errors. By default, the command runs only once. +* `update`: Hash to configure various update settings. Valid keys are: + * 'frequency': The run frequency for `apt-get update`. Defaults to 'reluctantly'. Accepts the following values: + * 'always': Runs update at every Puppet run. + * 'daily': Runs update daily; that is, `apt-get update` runs if the value of `apt_update_last_success` is less than current epoch time - 86400. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. + * 'weekly': Runs update weekly; that is, `apt-get update` runs if the value of `apt_update_last_success` is less than current epoch time - 604800. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. + * 'reluctantly': Only runs `apt-get update` if the exec resource `apt_update` is notified. This is the default setting. + * 'timeout': Overrides the exec timeout in seconds for `apt-get update`. Defaults to exec default (300). + * 'tries': Sets how many times to attempt running `apt-get update`. Use this to work around transient DNS and HTTP errors. By default, the command runs only once. +* `purge`: Hash to configure various purge settings. Valid keys are: + * 'sources.list': If set to 'true', Puppet purges all unmanaged entries from sources.list. Accepts `true` or `false`. Defaults to `true`. + * 'sources.list.d': If set to 'true', Puppet purges all unmanaged entries from sources.list.d. Accepts `true` or `false`. Defaults to `true`. + * 'preferences.list': If set to 'true', Puppet purges all unmanaged entries from preferences.list. Accepts `true` or `false`. Defaults to `true`. + * 'preferences.list.d': If set to 'true', Puppet purges all unmanaged entries from preferences.list.d. Accepts `true` or `false`. Defaults to `true`. +* `proxy`: Hash to configure various proxy settings. Valid keys are: + * 'host': Configures a proxy host and stores the configuration in /etc/apt/apt.conf.d/01proxy. + * 'port': Configures a proxy port and stores the configuration in /etc/apt/apt.conf.d/01proxy. + * 'https': Boolean to configure whether or not to enable https proxies. Defaults to false. +* `keys`: Passes a hash to create_resource to make new `apt::key` resources. +* `ppas`: Passes a hash to create_resource to make new `apt::ppa` resources. +* `settings`: Passes a hash to create_resource to make new `apt::setting` resources. * `sources`: Passes a hash to create_resource to make new `apt::source` resources. -* `fancy_progress`: Enables fancy progress bars for apt. Accepts 'true', 'false'. Defaults to 'false'. -####apt::unattended_upgrades +####apt::conf -* `origins`: The repositories from which to automatically upgrade included packages. -* `blacklist`: A list of packages to **not** automatically upgrade. -* `update`: How often, in days, to run `apt-get update`. -* `download`: How often, in days, to run `apt-get upgrade --download-only`. -* `upgrade`: How often, in days, to upgrade packages included in the origins list. -* `autoclean`: How often, in days, to run `apt-get autoclean`. -* `randomsleep`: How long, in seconds, to randomly wait before applying upgrades. - -####apt::source - -* `comment`: Add a comment to the apt source file. -* `ensure`: Allows you to remove the apt source file. Can be 'present' or 'absent'. -* `location`: The URL of the apt repository. -* `release`: The distribution of the apt repository. Defaults to fact 'lsbdistcodename'. -* `repos`: The component of the apt repository. This defaults to 'main'. -* `include_deb`: References a Debian distribution's binary package. -* `include_src`: Enable the deb-src type, references a Debian distribution's source code in the same form as the include_deb type. A deb-src line is required to fetch source indexes. -* `required_packages`: install required packages via an exec. defaults to 'false'. -* `key`: See apt::key -* `key_server`: See apt::key -* `key_content`: See apt::key -* `key_source`: See apt::key -* `pin`: See apt::pin -* `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to 'undef' which means all. Example values can be 'i386' or 'i386,alpha,powerpc'. -* `trusted_source` can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to false. Can be 'true' or 'false'. +* `content`: The content of the configuration file. +* `ensure`: Whether the configuration file should be 'present' or 'absent'. Defaults to 'present'. +* `priority`: Numeric priority for the configuration file. Defaults to '50'. ####apt::key * `ensure`: The state we want this key in. Can be 'present' or 'absent'. -* `key`: Is a GPG key ID or full key fingerprint. This value is validated with a regex enforcing it to only contain valid hexadecimal characters, be precisely 8 or 16 hexadecimal characters long and optionally prefixed with 0x for key IDs, or 40 hexadecimal characters long for key fingerprints. -* `key_content`: This parameter can be used to pass in a GPG key as a string in case it cannot be fetched from a remote location and using a file resource is for other reasons inconvenient. -* `key_source`: This parameter can be used to pass in the location of a GPG key. This URI can take the form of a `URL` (ftp, http or https) and a `path` (absolute path to a file on the target system). -* `key_server`: The keyserver from where to fetch our GPG key. It can either be a domain name or URL. It defaults to undef which results in apt_key's default keyserver being used, currently `keyserver.ubuntu.com`. -* `key_options`: Additional options to pass on to `apt-key adv --keyserver-options`. +* `id`: Is a GPG key ID or full key fingerprint. This value is validated with a regex enforcing it to only contain valid hexadecimal characters, be precisely 8 or 16 hexadecimal characters long and optionally prefixed with 0x for key IDs, or 40 hexadecimal characters long for key fingerprints. +* `content`: This parameter can be used to pass in a GPG key as a string in case it cannot be fetched from a remote location and using a file resource is for other reasons inconvenient. +* `source`: This parameter can be used to pass in the location of a GPG key. This URI can take the form of a `URL` (ftp, http or https) and a `path` (absolute path to a file on the target system). +* `server`: The keyserver from where to fetch our GPG key. It can either be a domain name or URL. It defaults to 'keyserver.ubuntu.com'. +* `options`: Additional options to pass on to `apt-key adv --keyserver-options`. ####apt::pin * `ensure`: The state we want this pin in. Can be 'present' or 'absent'. * `explanation`: Add a comment. Defaults to `${caller_module_name}: ${name}`. -* `order`: The order of the file name. Defaults to '', otherwise must be an integer. +* `order`: The order of the file name. Defaults to undef, otherwise must be an integer. * `packages`: The list of packages to pin. Defaults to '\*'. Can be an array or string. * `priority`: Several versions of a package may be available for installation when the sources.list(5) file contains references to more than one distribution (for example, stable and testing). APT assigns a priority to each version that is available. Subject to dependency constraints, apt-get selects the version with the highest priority for installation. * `release`: The Debian release. Defaults to ''. Typical values can be 'stable', 'testing' and 'unstable'. @@ -334,39 +239,41 @@ apt::sources: It is recommended to read the manpage 'apt_preferences(5)' -### Testing - -The apt module is mostly a collection of defined resource types, which provide reusable logic for managing Apt. It provides smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. - -#### Example Test - -This test sets up a Puppet Labs Apt repository. Start by creating a new smoke test, called puppetlabs-apt.pp, in the apt module's test folder. In this test, declare a single resource representing the Puppet Labs Apt source and GPG key: - -``` -apt::source { 'puppetlabs': - location => 'http://apt.puppetlabs.com', - repos => 'main', - key => '1054B7A24BD6EC30', - key_server => 'pgp.mit.edu', -} -``` - -This resource creates an Apt source named puppetlabs and gives Puppet information about the repository's location and the key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set this directly by adding the release type. +####apt::ppa -Check your smoke test for syntax errors: +* `ensure`: Whether to add or remove the PPA. Valid values are 'present' or 'absent'. Defaults to 'present'. +* `options`: Options to pass to `add-apt-repository`. OS-dependent defaults are defined in `apt::params`. +* `release`: OS-release, used in the filename of the generated sources.list.d file. Defaults to `$::lsbdistcodename`. +* `package_name`: The package to install `add-apt-repository`. OS-dependent defaults are defined in `apt::params`. +* `package_manage`: Whether or not to manage the package for `add-apt-repository`. Defaults to false. -`$ puppet parser validate tests/puppetlabs-apt.pp` +####apt::setting -If you receive no output from that command, it means nothing is wrong. Then, apply the code: +* `priority`: Integer or zero-padded integer setting the file priority. Defaults to 50. +* `ensure`: Whether to add or remove the file. Valid values are 'present', 'absent', and 'file'. Defaults to `file`. +* `source`: The source for the file. Exactly one of `content` and `source` must be specified. +* `content`: The content for the file. Exactly one of `content` and `source` must be specified. +* `notify_update`: Boolean for whether or not this `apt::setting` should trigger an `apt-get update`. Defaults to `true`. -``` -$ puppet apply --verbose tests/puppetlabs-apt.pp -notice: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]/ensure: defined content as '{md5}3be1da4923fb910f1102a233b77e982e' -info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update] -notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events> -``` +####apt::source -The above example uses a smoke test to lay out a resource declaration and apply it on your system. In production, you might want to declare your Apt sources inside the classes where they’re needed. +* `comment`: Add a comment to the apt source file. +* `ensure`: Allows you to remove the apt source file. Can be 'present' or 'absent'. +* `location`: The URL of the apt repository. Defaults to undef. Required unless `ensure => 'absent'`. +* `release`: The distribution of the apt repository. Defaults to fact 'lsbdistcodename'. +* `repos`: The component of the apt repository. This defaults to 'main'. +* `include`: Hash to configure include options. Valid keys are: + * 'deb': References a Debian distribution's binary package. Defaults to `true`. + * 'src': Enable the deb-src type, references a Debian distribution's source code in the same form as the `include['deb']` type. A deb-src line is required to fetch source indexes. Defaults to `false`. +* `key`: Add key from source. Takes either a string or a hash. If a string, the value will be passed to `id` in the `apt::key`. If a hash, valid keys are: + * 'id': See `id` in `apt::key`. Required if a hash is specified. + * 'server': See `server` in `apt::key` + * 'content': See `content` in `apt::key` + * 'source': See `source` in `apt::key` + * 'options': See `options` in `apt::key` +* `pin`: See apt::pin. Defaults to false. +* `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to `undef` which means all. Example values can be 'i386' or 'i386,alpha,powerpc'. +* `allow_unsigned`: can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to `false`. Can be `true` or `false`. Limitations ----------- From 215b043063de90f0c2f4966382dd30921b8cd398 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 20 Mar 2015 14:12:12 -0400 Subject: [PATCH 477/574] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01af4b1f9b..3b62f8ae28 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ class { 'apt': } * `apt::params`: Sets defaults for the apt module parameters. -* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to `true`, the update runs on every Puppet run. +* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to 'always', the update runs on every Puppet run. ### Types From d64fc7423f8e30f3190e29d3721141f7fed7e198 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 20 Mar 2015 19:13:53 +0100 Subject: [PATCH 478/574] README: Add highlighting for code blocks. --- README.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3b62f8ae28..82da917f38 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Any Puppet code that uses anything from the apt module requires that the core ap Using the apt module consists predominantly of declaring classes and defined types that provide the desired functionality and features. This module provides common resources and options that are shared by the various defined types in the apt module, so you **must always** include this class in your manifests. -``` +```puppet class { 'apt': } ``` @@ -43,7 +43,7 @@ class { 'apt': } * `apt::params`: Sets defaults for the apt module parameters. -* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to 'always', the update runs on every Puppet run. +* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to `true`, the update runs on every Puppet run. ### Types @@ -51,7 +51,7 @@ class { 'apt': } A native Puppet type and provider for managing GPG keys for Apt is provided by this module. - ``` + ```puppet apt_key { 'puppetlabs': ensure => 'present', id => '1054B7A24BD6EC30', @@ -71,7 +71,7 @@ class { 'apt': } * `apt::key`: Adds a key to the list of keys used by Apt to authenticate packages. This type uses the aforementioned `apt_key` native type. As such, it no longer requires the `wget` command on which the old implementation depended. - ``` + ```puppet apt::key { 'puppetlabs': id => '1054B7A24BD6EC30', server => 'pgp.mit.edu', @@ -85,7 +85,7 @@ class { 'apt': } * `apt::pin`: Defined type that adds an Apt pin for a certain release. - ``` + ```puppet apt::pin { 'karmic': priority => 700 } apt::pin { 'karmic-updates': priority => 700 } apt::pin { 'karmic-security': priority => 700 } @@ -93,7 +93,7 @@ class { 'apt': } Note that you can also specify more complex pins using distribution properties. - ``` + ```puppet apt::pin { 'stable': priority => -10, originator => 'Debian', @@ -111,7 +111,7 @@ class { 'apt': } * `apt::source`: Adds an Apt source to `/etc/apt/sources.list.d/`. For example: - ``` + ```puppet apt::source { 'debian_unstable': comment => 'This is the iWeb Debian unstable mirror', location => 'http://debian.mirror.iweb.ca/debian/', @@ -131,7 +131,7 @@ class { 'apt': } For example, to configure your system so the source is the Puppet Labs Apt repository: - ``` + ```puppet apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', repos => 'main', @@ -154,8 +154,7 @@ The apt module includes a few facts to describe the state of the Apt system: #### Hiera example -``` -
+```yaml
 apt::sources:
   'debian_unstable':
     location: 'http://debian.mirror.iweb.ca/debian/'
@@ -175,7 +174,6 @@ apt::sources:
     key:
       id:'1054B7A24BD6EC30'
       server: 'pgp.mit.edu'
-
``` ### Parameters From 794c758c514d511f9634ead0fcb46ce910a7d01c Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 20 Mar 2015 19:15:42 +0100 Subject: [PATCH 479/574] README: update['frequency'] is not a boolean --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82da917f38..5097fffbdf 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ class { 'apt': } * `apt::params`: Sets defaults for the apt module parameters. -* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to `true`, the update runs on every Puppet run. +* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to `'always'`, the update runs on every Puppet run. ### Types From 6751213bc3b966766a5c1a55c08952e7b983c9dc Mon Sep 17 00:00:00 2001 From: Alexander Skiba Date: Sun, 22 Mar 2015 21:02:59 +0100 Subject: [PATCH 480/574] Extend docs for unattended_upgrades documented more common parameters --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 186c2c2d3c..5064fed093 100644 --- a/README.md +++ b/README.md @@ -277,13 +277,21 @@ apt::sources: ####apt::unattended_upgrades * `legacy_origin`: If set to true, use the old `Unattended-Upgrade::Allowed-Origins` variable. If false, use `Unattended-Upgrade::Origins-Pattern`. OS-dependent defaults are defined in `apt::params`. -* `origins`: The repositories from which to automatically upgrade included packages. -* `blacklist`: A list of packages to **not** automatically upgrade. -* `update`: How often, in days, to run `apt-get update`. -* `download`: How often, in days, to run `apt-get upgrade --download-only`. -* `upgrade`: How often, in days, to upgrade packages included in the origins list. -* `autoclean`: How often, in days, to run `apt-get autoclean`. -* `randomsleep`: How long, in seconds, to randomly wait before applying upgrades. +* `origins`: The repositories from which to automatically upgrade included packages. OS-dependent defaults are defined in `apt::params`. (Usually only security updates are enabled by default) +* `blacklist`: A list of packages to **not** automatically upgrade. This list is empty by default. +* `update`: How often, in days, to run `apt-get update`. Defaults to '1'. +* `download`: How often, in days, to run `apt-get upgrade --download-only`. Defaults to '1'. +* `upgrade`: How often, in days, to upgrade packages included in the origins list. Defaults to '1'. +* `autoclean`: How often, in days, to run `apt-get autoclean`. Defaults to '7'. +* `auto_fix`: Tries to automatically fix interrupted package installations. Defaults to 'true'. +* `minimal_steps`: Split the upgrade process into sections to allow shutdown during upgrade. Defaults to 'false'. +* `install_on_shutdown`: Install updates on shutdown instead of in the background. Defaults to 'false'. +* `mail_to`: Send e-mail to this address about packages upgrades or errors. This is not set by default. +* `mail_only_on_error`: Send e-mail only in case of error, not on successful upgrade. Defaults to 'false'. +* `remove_unused`: Removes unused dependencies. Defaults to 'true'. +* `auto_reboot`: Reboot the system **without confirmation** if an update requires rebooting. Defaults to 'false'. +* `dl_limit`: Use a bandwidth limit for downloading, specified in kb/sec. This is not set by default. +* `randomsleep`: How long, in seconds, to randomly wait before applying upgrades. This is not set by default. ####apt::source From 36e7dfef5af45448a6bc60dd280e757b760e51ea Mon Sep 17 00:00:00 2001 From: Alice Nodelman Date: Tue, 24 Mar 2015 11:40:24 -0700 Subject: [PATCH 481/574] (BKR-147) add Gemfile setting for BEAKER_VERSION for puppet... puppetdb, etc - support for BEAKER_VERSION and BEAKER_RSPEC_VERSION in gemfile --- Gemfile | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 62c5693973..e1ae0fa56a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,15 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" +def location_for(place, fake_version = nil) + if place =~ /^(git:[^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end + group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-core', '3.1.7', :require => false @@ -11,8 +21,17 @@ group :development, :unit_tests do gem 'json', :require => false end +beaker_version = ENV['BEAKER_VERSION'] +beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] group :system_tests do - gem 'beaker-rspec', :require => false + if beaker_version + gem 'beaker', *location_for(beaker_version) + end + if beaker_rspec_version + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end gem 'serverspec', :require => false end From 911c4de90fc493e4449d42a1ed6ea0e40925b330 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 23 Mar 2015 13:55:13 -0400 Subject: [PATCH 482/574] (MODULES-1156, MODULES-769) Remove unnecessary anchors `apt::ppa` and `apt::setting` don't actually include `apt::update` so anchors are unnecessary. Move `apt` to use contain instead of anchors, since it wasn't anchoring properly anyways. Update the tests to make sure it can have settings and ppas depending on each other without cycles. --- manifests/init.pp | 5 +---- manifests/ppa.pp | 5 ----- manifests/setting.pp | 6 ------ spec/defines/ppa_spec.rb | 14 ++++++++++++-- spec/defines/setting_spec.rb | 15 +++++++++++++++ 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 453df3171f..140e171c50 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -133,10 +133,7 @@ notify => Exec['apt_update'], } - # Need anchor to provide containment for dependencies. - anchor { 'apt::update': - require => Class['apt::update'], - } + contain 'apt::update' # manage sources if present if $sources { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 5fc7f3c503..5d4c8903d5 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -60,9 +60,4 @@ notify => Exec['apt_update'], } } - - # Need anchor to provide containment for dependencies. - anchor { "apt::ppa::${name}": - require => Class['apt::update'], - } } diff --git a/manifests/setting.pp b/manifests/setting.pp index bc0e15a8d5..ab84460232 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -60,10 +60,4 @@ source => $source, notify => $_notify, } - - if $notify_update { - anchor { "apt::setting::${name}": - require => Class['apt::update'] - } - } } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 7c0d072c08..30a09a48a0 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -27,10 +27,18 @@ } end - describe 'apt included, no proxy' do + describe 'ppa depending on ppa, MODULES-1156' do let :pre_condition do 'class { "apt": }' end + end + + describe 'apt included, no proxy' do + let :pre_condition do + 'class { "apt": } + apt::ppa { "ppa:foo2": } + ' + end let :facts do { :lsbdistrelease => '14.04', @@ -42,11 +50,13 @@ end let :params do { - :options => '', + :options => '', :package_manage => true, + :require => 'Apt::Ppa[ppa:foo2]', } end let(:title) { 'ppa:foo' } + it { is_expected.to compile.with_all_deps } 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 => [], diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index d69ae45a7e..6f09f9ccf0 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -55,6 +55,21 @@ end end + describe 'settings requiring settings, MODULES-769' do + let(:pre_condition) do + 'class { "apt": } + apt::setting { "list-teddybear": content => "foo" } + ' + end + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:title) { 'conf-teddybear' } + let(:default_params) { { :content => 'di' } } + + let(:params) { default_params.merge({ :require => 'Apt::Setting[list-teddybear]' }) } + + it { is_expected.to compile.with_all_deps } + end + describe 'when trying to pull one over' do context 'with source and content' do let(:params) { default_params.merge({ :source => 'la' }) } From 79890bc7ae18e0aa0de72e097f9b37769f8812f5 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 23 Mar 2015 15:24:35 -0400 Subject: [PATCH 483/574] We got rid of the funny proxy removal --- examples/proxy.pp | 1 - 1 file changed, 1 deletion(-) delete mode 100644 examples/proxy.pp diff --git a/examples/proxy.pp b/examples/proxy.pp deleted file mode 100644 index 464090415c..0000000000 --- a/examples/proxy.pp +++ /dev/null @@ -1 +0,0 @@ -# TODO From 556c1adfaacde722b0a7d4e1b674fd361486cd91 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 23 Mar 2015 16:13:37 -0400 Subject: [PATCH 484/574] Add an example for backports --- examples/backports.pp | 69 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/examples/backports.pp b/examples/backports.pp index 464090415c..819d43f64b 100644 --- a/examples/backports.pp +++ b/examples/backports.pp @@ -1 +1,68 @@ -# TODO +# If your environment includes mint you'll need something more like this: +# +#$location = $::lsbdistcodename ? { +# 'squeeze' => 'http://backports.debian.org/debian-backports', +# 'wheezy' => 'http://ftp.debian.org/debian/', +# 'debian' => 'http://ftp.debian.org/debian/', #thanks LinuxMint +# default => 'http://us.archive.ubuntu.com/ubuntu', +#} +# +#if ($::lsbdistid == 'LinuxMint' and $::lsbdistcodename == 'debian') or $::lsbdistid == 'Debian' { +# $repos = 'main contrib non-free' +# $key = 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' +# if $::lsbdistid == 'LinuxMint' { +# $release = 'wheezy' +# } else { +# $release = downcase($::lsbdistrelease) +# } +#} else { +# if $::lsbdistid == 'LinuxMint' { +# $release = $::lsbdistcodename ? { +# 'qiana' => 'trusty', +# 'petra' => 'saucy', +# 'olivia' => 'raring', +# 'nadia' => 'quantal', +# 'maya' => 'precise', +# } +# } else { +# $release = downcase($::lsbdistrelease) +# } +# $repos = 'main universe multiverse restricted' +# $key = '630239CC130E1A7FD81A27B140976EAF437D05B5' +#} + +## Start logic to figure out backports location, repos, key, and release +if $::lsbdistid == 'Debian' { + $repos = 'main contrib non-free' + $key = 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' + $release = downcase($::lsbdistrelease) + $location = $::lsbdistcodename ? { + 'squeeze' => 'http://backports.debian.org/debian-backports', + 'wheezy' => 'http://ftp.debian.org/debian/', + default => 'http://http.debian.net/debian/', + } +} else { + $release = downcase($::lsbdistrelease) + $repos = 'main universe multiverse restricted' + $key = '630239CC130E1A7FD81A27B140976EAF437D05B5' + $location = 'http://us.archive.ubuntu.com/ubuntu', +} +## end logic for variables + + +# set up the actual backports +apt::pin { 'backports': + before => Apt::Source['backports'], + release => "${release}-backports", + priority => 200, +} + +apt::source { 'backports': + location => $location, + release => "${release}-backports", + repos => $repos, + key => { + id => $key, + server => 'pgp.mit.edu', + }, +} From 411679c3c012e945f5a24c53c4bff2e9db11f68f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 25 Mar 2015 11:13:12 -0400 Subject: [PATCH 485/574] We've got things in params, let's use those! --- examples/backports.pp | 60 +++++++++---------------------------------- 1 file changed, 12 insertions(+), 48 deletions(-) diff --git a/examples/backports.pp b/examples/backports.pp index 819d43f64b..f3ca34cb77 100644 --- a/examples/backports.pp +++ b/examples/backports.pp @@ -1,54 +1,18 @@ -# If your environment includes mint you'll need something more like this: -# -#$location = $::lsbdistcodename ? { -# 'squeeze' => 'http://backports.debian.org/debian-backports', -# 'wheezy' => 'http://ftp.debian.org/debian/', -# 'debian' => 'http://ftp.debian.org/debian/', #thanks LinuxMint -# default => 'http://us.archive.ubuntu.com/ubuntu', -#} -# -#if ($::lsbdistid == 'LinuxMint' and $::lsbdistcodename == 'debian') or $::lsbdistid == 'Debian' { -# $repos = 'main contrib non-free' -# $key = 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' -# if $::lsbdistid == 'LinuxMint' { -# $release = 'wheezy' -# } else { -# $release = downcase($::lsbdistrelease) -# } -#} else { -# if $::lsbdistid == 'LinuxMint' { -# $release = $::lsbdistcodename ? { -# 'qiana' => 'trusty', -# 'petra' => 'saucy', -# 'olivia' => 'raring', -# 'nadia' => 'quantal', -# 'maya' => 'precise', -# } -# } else { -# $release = downcase($::lsbdistrelease) -# } -# $repos = 'main universe multiverse restricted' -# $key = '630239CC130E1A7FD81A27B140976EAF437D05B5' -#} +$location = $::apt::distcodename ? { + 'squeeze' => 'http://backports.debian.org/debian-backports', + 'wheezy' => 'http://ftp.debian.org/debian/', + default => 'http://us.archive.ubuntu.com/ubuntu', +} -## Start logic to figure out backports location, repos, key, and release -if $::lsbdistid == 'Debian' { - $repos = 'main contrib non-free' - $key = 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' - $release = downcase($::lsbdistrelease) - $location = $::lsbdistcodename ? { - 'squeeze' => 'http://backports.debian.org/debian-backports', - 'wheezy' => 'http://ftp.debian.org/debian/', - default => 'http://http.debian.net/debian/', - } +if $::apt::distid == 'debian' { + $repos = 'main contrib non-free' + $key = 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' + $release = $::apt::distcodename } else { - $release = downcase($::lsbdistrelease) - $repos = 'main universe multiverse restricted' - $key = '630239CC130E1A7FD81A27B140976EAF437D05B5' - $location = 'http://us.archive.ubuntu.com/ubuntu', + $repos = 'main universe multiverse restricted' + $key = '630239CC130E1A7FD81A27B140976EAF437D05B5' + $release = $::apt::distcodename } -## end logic for variables - # set up the actual backports apt::pin { 'backports': From 895ecb5737cee2a2b82fb943483e4776e9eb9083 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 25 Mar 2015 13:08:13 -0400 Subject: [PATCH 486/574] Add examples for force. --- examples/force.pp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/examples/force.pp b/examples/force.pp index 36d23f8546..355d91f03a 100644 --- a/examples/force.pp +++ b/examples/force.pp @@ -1,2 +1,28 @@ -# force.pp -# TODO: Update +#if you need to specify a release +$rel_string = "-t ${release}" +#else +$rel_string = '' + +#if you need to specify a version +$ensure = $version +#else +$ensure = installed + +#if overwrite existing cfg files +$config_files = '-o Dpkg::Options::="--force-confnew"' +#elsif force use of old files +$config_files = '-o Dpkg::Options::="--force-confold"' +#elsif update only unchanged files +$config_files = '-o Dpkg::Options::="--force-confdef"' +#else +$config_files = '' + +#if install missing configuration files for the package +$config_missing = '-o Dpkg::Options::="--force-confmiss"' +#else +$config_missing = '' + +package { $package: + ensure => $ensure, + install_options => "${config_files} ${config_missing} ${release_string}", +} From a96df4b25b81d928e4056fcbac06ae9c54392139 Mon Sep 17 00:00:00 2001 From: Leo Arnold Date: Wed, 25 Mar 2015 20:09:22 +0100 Subject: [PATCH 487/574] Updated key fingerprints in README to match v1.8.0 requirements --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5064fed093..3fd74b3d2c 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ class { 'apt': ``` apt_key { 'puppetlabs': ensure => 'present', - id => '1054B7A24BD6EC30', + id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', } ``` @@ -157,12 +157,12 @@ class { 'apt': ``` apt::key { 'puppetlabs': - key => '1054B7A24BD6EC30', + key => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', key_server => 'pgp.mit.edu', } apt::key { 'jenkins': - key => '9B7D32F2D50582E6', + key => '150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6', key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', } ``` @@ -213,10 +213,10 @@ class { 'apt': ``` apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', - repos => 'main', - key => '1054B7A24BD6EC30', + repos => 'main dependencies', + key => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', key_server => 'pgp.mit.edu', - } + } ``` ### Facts @@ -248,8 +248,8 @@ apt::sources: 'puppetlabs': location: 'http://apt.puppetlabs.com' - repos: 'main' - key: '1054B7A24BD6EC30' + repos: 'main dependencies' + key: '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' key_server: 'pgp.mit.edu'
``` @@ -357,10 +357,12 @@ The apt module is mostly a collection of defined resource types, which provide r This test sets up a Puppet Labs Apt repository. Start by creating a new smoke test, called puppetlabs-apt.pp, in the apt module's test folder. In this test, declare a single resource representing the Puppet Labs Apt source and GPG key: ``` +class { 'apt': } + apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', - repos => 'main', - key => '1054B7A24BD6EC30', + repos => 'main dependencies', + key => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', key_server => 'pgp.mit.edu', } ``` @@ -380,7 +382,7 @@ info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling re notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events> ``` -The above example uses a smoke test to lay out a resource declaration and apply it on your system. In production, you might want to declare your Apt sources inside the classes where they’re needed. +The above example uses a smoke test to lay out a resource declaration and apply it on your system. In production, you might want to declare your Apt sources inside the classes where they're needed. Limitations ----------- @@ -390,7 +392,7 @@ This module should work across all versions of Debian/Ubuntu and support all maj Development ------------ -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. From 1b4d8ba991c2072ec0e3347e48f1aca148970929 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 25 Mar 2015 15:16:04 -0400 Subject: [PATCH 488/574] Example for disabling keys --- examples/disable_keys.pp | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 examples/disable_keys.pp diff --git a/examples/disable_keys.pp b/examples/disable_keys.pp new file mode 100644 index 0000000000..ad61df0421 --- /dev/null +++ b/examples/disable_keys.pp @@ -0,0 +1,5 @@ +#Note: This is generally a bad idea. You should not disable keys. +apt::conf { 'unauth': + priority => 99, + content => 'APT::Get::AllowUnauthenticated 1;' +} From 073e8f162ad9c232a09af819946a691467407472 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 25 Mar 2015 15:30:16 -0400 Subject: [PATCH 489/574] Example for fancy progress. --- examples/fancy_progress.pp | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 examples/fancy_progress.pp diff --git a/examples/fancy_progress.pp b/examples/fancy_progress.pp new file mode 100644 index 0000000000..db78441b6b --- /dev/null +++ b/examples/fancy_progress.pp @@ -0,0 +1,4 @@ +apt::conf { 'progressbar': + priority => 99, + content => 'Dpkg::Progress-Fancy "1";', +} From 0f26779a2a9a7b73505dc87284f4baa4eb9842b0 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 25 Mar 2015 17:22:52 -0400 Subject: [PATCH 490/574] Example updates --- examples/backports.pp | 7 +++---- examples/disable_keys.pp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/backports.pp b/examples/backports.pp index f3ca34cb77..ed8213f0fa 100644 --- a/examples/backports.pp +++ b/examples/backports.pp @@ -1,7 +1,7 @@ $location = $::apt::distcodename ? { 'squeeze' => 'http://backports.debian.org/debian-backports', 'wheezy' => 'http://ftp.debian.org/debian/', - default => 'http://us.archive.ubuntu.com/ubuntu', + default => 'http://archive.ubuntu.com/ubuntu', } if $::apt::distid == 'debian' { @@ -16,7 +16,6 @@ # set up the actual backports apt::pin { 'backports': - before => Apt::Source['backports'], release => "${release}-backports", priority => 200, } @@ -26,7 +25,7 @@ release => "${release}-backports", repos => $repos, key => { - id => $key, - server => 'pgp.mit.edu', + id => $key, + server => 'pgp.mit.edu', }, } diff --git a/examples/disable_keys.pp b/examples/disable_keys.pp index ad61df0421..50d0ea8022 100644 --- a/examples/disable_keys.pp +++ b/examples/disable_keys.pp @@ -1,4 +1,4 @@ -#Note: This is generally a bad idea. You should not disable keys. +#Note: This is generally a bad idea. You should not disable verifying repository signatures. apt::conf { 'unauth': priority => 99, content => 'APT::Get::AllowUnauthenticated 1;' From 7aba77e2f69f266ee281c4ebe0818b37825443b8 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 6 Apr 2015 11:29:02 -0700 Subject: [PATCH 491/574] Lint cleanup --- examples/force.pp | 6 +++--- examples/key.pp | 6 +++--- examples/source.pp | 38 ++++++++++++++++++++++---------------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/examples/force.pp b/examples/force.pp index 355d91f03a..c096b97d8a 100644 --- a/examples/force.pp +++ b/examples/force.pp @@ -1,10 +1,10 @@ #if you need to specify a release -$rel_string = "-t ${release}" +$rel_string = '-t ' #else $rel_string = '' #if you need to specify a version -$ensure = $version +$ensure = '' #else $ensure = installed @@ -24,5 +24,5 @@ package { $package: ensure => $ensure, - install_options => "${config_files} ${config_missing} ${release_string}", + install_options => "${config_files} ${config_missing} ${rel_string}", } diff --git a/examples/key.pp b/examples/key.pp index 79e0e1b749..cc8681fbf8 100644 --- a/examples/key.pp +++ b/examples/key.pp @@ -1,6 +1,6 @@ # Declare Apt key for apt.puppetlabs.com source apt::key { 'puppetlabs': - key => '4BD6EC30', - key_server => 'pgp.mit.edu', - key_options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', + id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + server => 'pgp.mit.edu', + options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', } diff --git a/examples/source.pp b/examples/source.pp index 823b37b736..33dc2a1938 100644 --- a/examples/source.pp +++ b/examples/source.pp @@ -4,26 +4,32 @@ # Install the puppetlabs apt source # Release is automatically obtained from lsbdistcodename fact if available. apt::source { 'puppetlabs': - location => 'http://apt.puppetlabs.com', - repos => 'main', - key => '4BD6EC30', - key_server => 'pgp.mit.edu', + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => { + id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + server => 'pgp.mit.edu', + }, } # test two sources with the same key apt::source { 'debian_testing': - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'testing', - repos => 'main contrib non-free', - key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - key_server => 'subkeys.pgp.net', - pin => '-10', + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'testing', + repos => 'main contrib non-free', + key => { + id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + server => 'subkeys.pgp.net', + }, + pin => '-10', } apt::source { 'debian_unstable': - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'unstable', - repos => 'main contrib non-free', - key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - key_server => 'subkeys.pgp.net', - pin => '-10', + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + key => { + id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + server => 'subkeys.pgp.net', + }, + pin => '-10', } From 214a6caea7634d89e1101aaff6b415b073f6bc86 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 6 Apr 2015 13:18:58 -0700 Subject: [PATCH 492/574] more lint cleanup --- examples/force.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/force.pp b/examples/force.pp index c096b97d8a..4cfaa96fd9 100644 --- a/examples/force.pp +++ b/examples/force.pp @@ -22,7 +22,7 @@ #else $config_missing = '' -package { $package: +package { '': ensure => $ensure, install_options => "${config_files} ${config_missing} ${rel_string}", } From 791012b2c9c442a7417744d3592cc089771b06e9 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Mon, 6 Apr 2015 18:02:58 -0400 Subject: [PATCH 493/574] source: Support complex pin, like key does. This adds support for passing in a full pin declaration as the pin parameter on a source declaration. It keeps the old behaviour intact, you can still simply do `pin => '10'` and it will pin on origin with a priority of 10. Should that not be what you want you can now pass in a full pin declaration instead. We make no assumptions here, whatever you pass in will be passed through to pin as-is with the exception of the values for `ensure` and `before` which are always overridden by us to ensure everything keeps working as designed. --- manifests/source.pp | 27 ++++++++++++--------- spec/defines/source_spec.rb | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 11 deletions(-) diff --git a/manifests/source.pp b/manifests/source.pp index 163a411bb2..24d0ae4b8d 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -8,7 +8,7 @@ $repos = 'main', $include = {}, $key = undef, - $pin = false, + $pin = undef, $architecture = undef, $allow_unsigned = false, ) { @@ -44,17 +44,22 @@ content => template('apt/_header.erb', 'apt/source.list.erb'), } - if ($pin != false) { - # Get the host portion out of the url so we can pin to origin - $url_split = split($location, '/') - $host = $url_split[2] - - apt::pin { $name: - ensure => $ensure, - priority => $pin, - before => $_before, - origin => $host, + if $pin { + if is_hash($pin) { + $_pin = merge($pin, { 'ensure' => $ensure, 'before' => $_before }) + } elsif (is_numeric($pin) or is_string($pin)) { + $url_split = split($location, '/') + $host = $url_split[2] + $_pin = { + 'ensure' => $ensure, + 'priority' => $pin, + 'before' => $_before, + 'origin' => $host, + } + } else { + fail('Received invalid value for pin parameter') } + create_resources('apt::pin', { $name => $_pin }) } # We do not want to remove keys when the source is absent. diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 7fd86b56ff..3900158a16 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -51,6 +51,31 @@ :osfamily => 'Debian' } end + + context 'with complex pin' do + let :params do + { + :location => 'hello.there', + :pin => { 'release' => 'wishwash', + 'explanation' => 'wishwash', + 'priority' => 1001, }, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).with_content(/hello.there wheezy main\n/) + } + + it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ + :ensure => 'present', + :priority => 1001, + :explanation => 'wishwash', + :release => 'wishwash', + }) + } + end + context 'with simple key' do let :params do { @@ -235,5 +260,28 @@ }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end + + context 'invalid pin' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + let :params do + { + :location => 'hello.there', + :pin => true, + } + end + + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /invalid value for pin/) + end + end + end end From 37043dff8572f490fcb77317784d042d1f7a4c70 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Tue, 7 Apr 2015 13:51:10 +0200 Subject: [PATCH 494/574] backports: Add support back for backports. This is currently lacking tests. --- manifests/backports.pp | 59 ++++++++++++++++++++++++++++++++++++++++++ manifests/params.pp | 20 ++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 manifests/backports.pp diff --git a/manifests/backports.pp b/manifests/backports.pp new file mode 100644 index 0000000000..3cac0b5b5b --- /dev/null +++ b/manifests/backports.pp @@ -0,0 +1,59 @@ +class apt::backports ( + $location = undef, + $release = undef, + $repos = undef, + $key = undef, + $pin = 200, +){ + if $location { + validate_string($location) + $_location = $location + } + if $release { + validate_string($release) + $_release = $release + } + if $repos { + validate_string($repos) + $_repos = $repos + } + if $key { + unless is_hash($key) { + validate_string($key) + } + $_key = $key + } + unless is_hash($pin) { + unless (is_numeric($pin) or is_string($pin)) { + fail('pin must be either a string, number or hash') + } + } + + if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') { + unless $location { + $_location = $::apt::backports['location'] + } + unless $release { + $_release = "${::apt::xfacts['lsbdistcodename']}-backports" + } + unless $repos { + $_repos = $::apt::backports['repos'] + } + unless $key { + $_key = $::apt::backports['key'] + } + } else { + unless $location and $release and $repos and $key { + fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key') + } + } + + apt::source { 'backports': + location => $_location, + release => $_release, + repos => $_repos, + key => $_key, + pin => $pin, + } + +} diff --git a/manifests/params.pp b/manifests/params.pp index 57cee5007d..6f7e5f9dc0 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -119,7 +119,27 @@ } } case $distid { + 'debian': { + case $distcodename { + 'squeeze': { + $backports = {'location' => 'http://backports.debian.org/debian-backports', + 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + 'repos' => 'main contrib non-free', + } + } + default: { + $backports = {'location' => 'http://ftp.debian.org/debian/', + 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD624692555', + 'repos' => 'main contrib non-free', + } + } + } + } 'ubuntu': { + $backports = {'location' => 'http://archive.ubuntu.com/ubuntu', + 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', + 'repos' => 'main universe multiverse restricted', + } case $distcodename { 'lucid': { $ppa_options = undef From 044fb5faf545f1336c949bd5667da3d5dda2fa1f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 7 Apr 2015 12:12:06 -0700 Subject: [PATCH 495/574] Add testing, docs, and examples for backports --- README.md | 18 +- examples/backports.pp | 33 +--- manifests/params.pp | 23 ++- manifests/source.pp | 2 +- spec/classes/apt_backports_spec.rb | 261 +++++++++++++++++++++++++++++ 5 files changed, 298 insertions(+), 39 deletions(-) create mode 100644 spec/classes/apt_backports_spec.rb diff --git a/README.md b/README.md index 26feda3818..d461d05d2b 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,12 @@ class { 'apt': } * `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory. By default, it will purge any existing content it finds that wasn't declared with Puppet. + * `apt::backports`: This class adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to "$lsbdistcodename-backports". Setting this manually can cause undefined and potentially serious behavior. + + By default, this class drops a pin-file for backports, pinning it to a priority of 200. This is lower than the normal Debian archive, which gets a priority of 500 to ensure that packages with `ensure => latest` don't get magically upgraded from backports without your explicit permission. + + If you raise the priority through the `pin` parameter to 500---identical to the rest of the Debian mirrors---normal policy goes into effect, and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. + * `apt::params`: Sets defaults for the apt module parameters. * `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to `'always'`, the update runs on every Puppet run. @@ -178,7 +184,7 @@ apt::sources: ### Parameters -#### apt +####apt * `update`: Hash to configure various update settings. Valid keys are: * 'frequency': The run frequency for `apt-get update`. Defaults to 'reluctantly'. Accepts the following values: @@ -202,6 +208,14 @@ apt::sources: * `settings`: Passes a hash to `create\_resource` to make new `apt::setting` resources. * `sources`: Passes a hash to `create\_resource` to make new `apt::source` resources. +####apt::backports + +* `location`: The URL of the apt repository. OS-dependent defaults are specifed in `apt::params` for Ubuntu and Debian. Required parameter for other OSes. +* `release`: The distribution of the apt repository. Defaults to "${lsbdistcodename}-backports" for Ubuntu and Debian. Required parameter for other OSes. +* `repos`: The component of the apt repository. OS-dependent defaults are speicifed in `apt::params` for Ubuntu and Debian. Required parameter for other OSes. +* `key`: The key for the backports repository. Can either be a string or a hash. See apt::setting for details on passing key as a hash. OS-dependent defaults are specified in `apt::params` for Ubuntu and Debian. Required parameter for other OSes. +* `pin`: The pin priority for backports repository. Can either be a number, a string, or a hash that will be passed as parameters to `apt::pin`. Defaults to `200`. + ####apt::conf * `content`: The content of the configuration file. @@ -269,7 +283,7 @@ It is recommended to read the manpage 'apt_preferences(5)' * 'content': See `content` in `apt::key` * 'source': See `source` in `apt::key` * 'options': See `options` in `apt::key` -* `pin`: See apt::pin. Defaults to false. +* `pin`: See apt::pin. Defaults to undef. Can be a string, number, or a hash to be passed as parameters to `apt::pin`. * `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to `undef` which means all. Example values can be 'i386' or 'i386,alpha,powerpc'. * `allow\_unsigned`: can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to `false`. Can be `true` or `false`. diff --git a/examples/backports.pp b/examples/backports.pp index ed8213f0fa..fe77da3965 100644 --- a/examples/backports.pp +++ b/examples/backports.pp @@ -1,31 +1,10 @@ -$location = $::apt::distcodename ? { - 'squeeze' => 'http://backports.debian.org/debian-backports', - 'wheezy' => 'http://ftp.debian.org/debian/', - default => 'http://archive.ubuntu.com/ubuntu', -} - -if $::apt::distid == 'debian' { - $repos = 'main contrib non-free' - $key = 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' - $release = $::apt::distcodename -} else { - $repos = 'main universe multiverse restricted' - $key = '630239CC130E1A7FD81A27B140976EAF437D05B5' - $release = $::apt::distcodename -} - -# set up the actual backports -apt::pin { 'backports': - release => "${release}-backports", - priority => 200, -} - -apt::source { 'backports': - location => $location, - release => "${release}-backports", - repos => $repos, +# Set up a backport for linuxmint qiana +apt::backports { 'qiana': + location => 'http://us.archive.ubuntu.com/ubuntu', + release => 'trusty-backports', + repos => 'main universe multiverse restricted', key => { - id => $key, + id => '630239CC130E1A7FD81A27B140976EAF437D05B5', server => 'pgp.mit.edu', }, } diff --git a/manifests/params.pp b/manifests/params.pp index 6f7e5f9dc0..ef9904df87 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -122,24 +122,28 @@ 'debian': { case $distcodename { 'squeeze': { - $backports = {'location' => 'http://backports.debian.org/debian-backports', - 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - 'repos' => 'main contrib non-free', + $backports = { + 'location' => 'http://backports.debian.org/debian-backports', + 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + 'repos' => 'main contrib non-free', } } default: { - $backports = {'location' => 'http://ftp.debian.org/debian/', - 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD624692555', - 'repos' => 'main contrib non-free', + $backports = { + 'location' => 'http://ftp.debian.org/debian/', + 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + 'repos' => 'main contrib non-free', } } } } 'ubuntu': { - $backports = {'location' => 'http://archive.ubuntu.com/ubuntu', - 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', - 'repos' => 'main universe multiverse restricted', + $backports = { + 'location' => 'http://archive.ubuntu.com/ubuntu', + 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', + 'repos' => 'main universe multiverse restricted', } + case $distcodename { 'lucid': { $ppa_options = undef @@ -162,6 +166,7 @@ '', default: { $ppa_options = undef $ppa_package = undef + $backports = undef } } } diff --git a/manifests/source.pp b/manifests/source.pp index 24d0ae4b8d..40fc015bb6 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -59,7 +59,7 @@ } else { fail('Received invalid value for pin parameter') } - create_resources('apt::pin', { $name => $_pin }) + create_resources('apt::pin', { "${name}" => $_pin }) } # We do not want to remove keys when the source is absent. diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb new file mode 100644 index 0000000000..b9077a6bcd --- /dev/null +++ b/spec/classes/apt_backports_spec.rb @@ -0,0 +1,261 @@ +#!/usr/bin/env rspec +require 'spec_helper' + +describe 'apt::backports', :type => :class do + let (:pre_condition) { "class{ '::apt': }" } + describe 'debian/ubuntu tests' do + context 'defaults on deb' do + let(:facts) do + { + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :lsbdistcodename => 'wheezy', + } + end + it { is_expected.to contain_apt__source('backports').with({ + :location => 'http://ftp.debian.org/debian/', + :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + :repos => 'main contrib non-free', + :release => 'wheezy-backports', + :pin => 200, + }) + } + end + context 'defaults on squeeze' do + let(:facts) do + { + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :lsbdistcodename => 'squeeze', + } + end + it { is_expected.to contain_apt__source('backports').with({ + :location => 'http://backports.debian.org/debian-backports', + :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + :repos => 'main contrib non-free', + :release => 'squeeze-backports', + :pin => 200, + }) + } + end + context 'defaults on ubuntu' do + let(:facts) do + { + :lsbdistid => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistcodename => 'trusty', + } + end + it { is_expected.to contain_apt__source('backports').with({ + :location => 'http://archive.ubuntu.com/ubuntu', + :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + :repos => 'main universe multiverse restricted', + :release => 'trusty-backports', + :pin => 200, + }) + } + end + context 'set everything' do + let(:facts) do + { + :lsbdistid => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistcodename => 'trusty', + } + end + let(:params) do + { + :location => 'http://archive.ubuntu.com/ubuntu-test', + :release => 'vivid', + :repos => 'main', + :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + :pin => '90', + } + end + it { is_expected.to contain_apt__source('backports').with({ + :location => 'http://archive.ubuntu.com/ubuntu-test', + :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + :repos => 'main', + :release => 'vivid', + :pin => 90, + }) + } + end + context 'set things with hashes' do + let(:facts) do + { + :lsbdistid => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistcodename => 'trusty', + } + end + let(:params) do + { + :key => { + 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + }, + :pin => { + 'priority' => '90', + }, + } + end + it { is_expected.to contain_apt__source('backports').with({ + :key => { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' }, + :pin => { 'priority' => '90' }, + }) + } + end + end + describe 'mint tests' do + let(:facts) do + { + :lsbdistid => 'linuxmint', + :osfamily => 'Debian', + :lsbdistcodename => 'qiana', + } + end + context 'sets all the needed things' do + let(:params) do + { + :location => 'http://archive.ubuntu.com/ubuntu', + :release => 'trusty-backports', + :repos => 'main universe multiverse restricted', + :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + } + end + it { is_expected.to contain_apt__source('backports').with({ + :location => 'http://archive.ubuntu.com/ubuntu', + :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + :repos => 'main universe multiverse restricted', + :release => 'trusty-backports', + :pin => 200, + }) + } + end + context 'missing location' do + let(:params) do + { + :release => 'trusty-backports', + :repos => 'main universe multiverse restricted', + :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) + end + end + context 'missing release' do + let(:params) do + { + :location => 'http://archive.ubuntu.com/ubuntu', + :repos => 'main universe multiverse restricted', + :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) + end + end + context 'missing repos' do + let(:params) do + { + :location => 'http://archive.ubuntu.com/ubuntu', + :release => 'trusty-backports', + :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) + end + end + context 'missing key' do + let(:params) do + { + :location => 'http://archive.ubuntu.com/ubuntu', + :release => 'trusty-backports', + :repos => 'main universe multiverse restricted', + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) + end + end + end + describe 'validation' do + let(:facts) do + { + :lsbdistid => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistcodename => 'trusty', + } + end + context 'invalid location' do + let(:params) do + { + :location => true + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /is not a string/) + end + end + context 'invalid release' do + let(:params) do + { + :release => true + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /is not a string/) + end + end + context 'invalid repos' do + let(:params) do + { + :repos => true + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /is not a string/) + end + end + context 'invalid key' do + let(:params) do + { + :key => true + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /is not a string/) + end + end + context 'invalid pin' do + let(:params) do + { + :pin => true + } + end + it do + expect { + is_expected.to compile + }.to raise_error(Puppet::Error, /pin must be either a string, number or hash/) + end + end + end +end From d3ca10fd2f31d0161bcfc65c263bd044537a3c48 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 7 Apr 2015 15:45:20 -0700 Subject: [PATCH 496/574] Remove default support for Linux Mint and Cumulus Networks NOTE: While out-of-the box support is disabled, it is still possible to get the same configurations, it will just require explicitly setting the necessary codename-munging. This should only affect `apt::ppa` --- manifests/params.pp | 40 ++++++------------------------------- manifests/ppa.pp | 4 ++-- spec/classes/params_spec.rb | 13 ------------ spec/defines/ppa_spec.rb | 2 +- 4 files changed, 9 insertions(+), 50 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index ef9904df87..abc7536eab 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -88,39 +88,8 @@ } case $xfacts['lsbdistid'] { - 'ubuntu', 'debian': { - $distid = $xfacts['lsbdistid'] - $distcodename = $xfacts['lsbdistcodename'] - } - 'linuxmint': { - if $xfacts['lsbdistcodename'] == 'debian' { - $distid = 'debian' - $distcodename = 'wheezy' - } else { - $distid = 'ubuntu' - $distcodename = $xfacts['lsbdistcodename'] ? { - 'qiana' => 'trusty', - 'petra' => 'saucy', - 'olivia' => 'raring', - 'nadia' => 'quantal', - 'maya' => 'precise', - } - } - } - 'Cumulus Networks': { - $distid = 'debian' - $distcodename = $::lsbdistcodename - } - undef: { - fail('Unable to determine lsbdistid, is lsb-release installed?') - } - default: { - fail("Unsupported lsbdistid (${::lsbdistid})") - } - } - case $distid { 'debian': { - case $distcodename { + case $xfacts['lsbdistcodename'] { 'squeeze': { $backports = { 'location' => 'http://backports.debian.org/debian-backports', @@ -144,7 +113,7 @@ 'repos' => 'main universe multiverse restricted', } - case $distcodename { + case $xfacts['lsbdistcodename'] { 'lucid': { $ppa_options = undef $ppa_package = 'python-software-properties' @@ -163,7 +132,10 @@ } } } - '', default: { + undef: { + fail('Unable to determine lsbdistid, is lsb-release installed?') + } + default: { $ppa_options = undef $ppa_package = undef $backports = undef diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 5d4c8903d5..808c9751a0 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -10,8 +10,8 @@ fail('lsbdistcodename fact not available: release parameter required') } - if $::apt::distid != 'ubuntu' { - fail('apt::ppa is currently supported on Ubuntu and LinuxMint only.') + if $::apt::xfacts['lsbdistid'] == 'Debian' { + fail('apt::ppa is not currently supported on Debian.') } $filename_without_slashes = regsubst($name, '/', '-', 'G') diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index f8ca89f2a3..f8599b3699 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -12,19 +12,6 @@ expect(subject.resources.size).to eq(4) end - describe "With unknown lsbdistid" do - - let(:facts) { { :lsbdistid => 'CentOS', :osfamily => 'Debian' } } - let (:title) { 'my_package' } - - it do - expect { - is_expected.to compile - }.to raise_error(Puppet::Error, /Unsupported lsbdistid/) - end - - end - describe "With lsb-release not installed" do let(:facts) { { :lsbdistid => '', :osfamily => 'Debian' } } let (:title) { 'my_package' } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 7903e47037..521b42ba2b 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -298,7 +298,7 @@ it do expect { is_expected.to compile - }.to raise_error(Puppet::Error, /supported on Ubuntu and LinuxMint only/) + }.to raise_error(Puppet::Error, /not currently supported on Debian/) end end end From c8c171065d9f8338e1f6c7823740c91ccd19840d Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 13 Apr 2015 11:13:26 -0700 Subject: [PATCH 497/574] Try to make gepetto happy. --- examples/backports.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/backports.pp b/examples/backports.pp index fe77da3965..0dfe084850 100644 --- a/examples/backports.pp +++ b/examples/backports.pp @@ -1,4 +1,5 @@ # Set up a backport for linuxmint qiana +class { 'apt': } apt::backports { 'qiana': location => 'http://us.archive.ubuntu.com/ubuntu', release => 'trusty-backports', From fe609807819cbf8126c3ae43cd96da7a62bce9a7 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Tue, 14 Apr 2015 12:41:57 +0200 Subject: [PATCH 498/574] apt::conf: Don't require content `ensure=>absent`. --- manifests/conf.pp | 9 ++++++++- spec/defines/conf_spec.rb | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/manifests/conf.pp b/manifests/conf.pp index 2850205281..da6d64e738 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -1,8 +1,15 @@ define apt::conf ( - $content, + $content = undef, $ensure = present, $priority = '50', ) { + + unless $ensure == 'absent' { + unless $content { + fail('Need to pass in content parameter') + } + } + apt::setting { "conf-${name}": ensure => $ensure, priority => $priority, diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index a7db4e61e3..e96f8bcd82 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -30,12 +30,23 @@ } end + describe "when creating a preference without content" do + let :params do + { + :priority => '00', + } + end + + it 'fails' do + expect { subject } .to raise_error(/pass in content/) + end + end + describe "when removing an apt preference" do let :params do { :ensure => 'absent', :priority => '00', - :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" } end @@ -45,7 +56,6 @@ it { is_expected.to contain_file(filename).with({ 'ensure' => 'absent', - 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, 'owner' => 'root', 'group' => 'root', 'mode' => '0644', From 3a202541085acde355d036f8ad016eab22498511 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 14 Apr 2015 11:03:17 -0700 Subject: [PATCH 499/574] Don't purge by default. That seems unnecessarily destructive. --- README.md | 10 +++++----- manifests/params.pp | 8 ++++---- spec/classes/apt_spec.rb | 11 +++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d461d05d2b..318bc53d2c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ class { 'apt': } ### Classes -* `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory. By default, it will purge any existing content it finds that wasn't declared with Puppet. +* `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory. By default, it will not purge existing content it finds that wasn't declared with Puppet. * `apt::backports`: This class adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to "$lsbdistcodename-backports". Setting this manually can cause undefined and potentially serious behavior. @@ -195,10 +195,10 @@ apt::sources: * 'timeout': Overrides the exec timeout in seconds for `apt-get update`. Defaults to exec default (300). * 'tries': Sets how many times to attempt running `apt-get update`. Use this to work around transient DNS and HTTP errors. By default, the command runs only once. * `purge`: Hash to configure various purge settings. Valid keys are: - * 'sources.list': If set to 'true', Puppet purges all unmanaged entries from sources.list. Accepts `true` or `false`. Defaults to `true`. - * 'sources.list.d': If set to 'true', Puppet purges all unmanaged entries from sources.list.d. Accepts `true` or `false`. Defaults to `true`. - * 'preferences.list': If set to 'true', Puppet purges all unmanaged entries from preferences.list. Accepts `true` or `false`. Defaults to `true`. - * 'preferences.list.d': If set to 'true', Puppet purges all unmanaged entries from preferences.list.d. Accepts `true` or `false`. Defaults to `true`. + * 'sources.list': If set to 'true', Puppet purges all unmanaged entries from sources.list. Accepts `true` or `false`. Defaults to `false`. + * 'sources.list.d': If set to 'true', Puppet purges all unmanaged entries from sources.list.d. Accepts `true` or `false`. Defaults to `false`. + * 'preferences.list': If set to 'true', Puppet purges all unmanaged entries from preferences.list. Accepts `true` or `false`. Defaults to `false`. + * 'preferences.list.d': If set to 'true', Puppet purges all unmanaged entries from preferences.list.d. Accepts `true` or `false`. Defaults to `false`. * `proxy`: Hash to configure various proxy settings. Valid keys are: * 'host': Configures a proxy host and stores the configuration in /etc/apt/apt.conf.d/01proxy. * 'port': Configures a proxy port and stores the configuration in /etc/apt/apt.conf.d/01proxy. diff --git a/manifests/params.pp b/manifests/params.pp index abc7536eab..5a0c170d91 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -69,10 +69,10 @@ } $purge_defaults = { - 'sources.list' => true, - 'sources.list.d' => true, - 'preferences' => true, - 'preferences.d' => true, + 'sources.list' => false, + 'sources.list.d' => false, + 'preferences' => false, + 'preferences.d' => false, } $source_key_defaults = { diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 81d5d1bee6..ee7cd33a24 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -9,7 +9,6 @@ :owner => 'root', :group => 'root', :mode => '0644', - :content => "# Repos managed by puppet.\n", :notify => 'Exec[apt_update]', })} @@ -19,13 +18,13 @@ :owner => 'root', :group => 'root', :mode => '0644', - :purge => true, - :recurse => true, + :purge => false, + :recurse => false, :notify => 'Exec[apt_update]', })} it { is_expected.to contain_file('preferences').that_notifies('Exec[apt_update]').only_with({ - :ensure => 'absent', + :ensure => 'file', :path => '/etc/apt/preferences', :owner => 'root', :group => 'root', @@ -39,8 +38,8 @@ :owner => 'root', :group => 'root', :mode => '0644', - :purge => true, - :recurse => true, + :purge => false, + :recurse => false, :notify => 'Exec[apt_update]', })} From 94976bbd7ca6100c1fb7c1aeb773a7b5b16cbf4b Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 30 Mar 2015 13:17:37 -0400 Subject: [PATCH 500/574] 2.0.0 prep --- CHANGELOG.md | 81 +++++++++++++++++++++++++++++++++++++ examples/debian_testing.pp | 18 +++++++++ examples/debian_unstable.pp | 18 +++++++++ metadata.json | 4 +- 4 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 examples/debian_testing.pp create mode 100644 examples/debian_unstable.pp diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b2a45a5ca..06eb422d01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,84 @@ +##2015-04-07 - Supported Release 2.0.0 +###Summary + +This is a major rewrite of the apt module. Many classes and defines were removed, but all existing functionality should still work. Please carefully review documentation before upgrading. + +####Backwards-incompatible changes + +As this is a major rewrite of the module there are a great number of backwards incompatible changes. Please review this and the updated README carefully before upgrading. + +#####`apt_key` +- `keyserver_options` parameter renamed to `options` + +#####`apt::backports` +- This no longer works out of the box on Linux Mint. If using this on mint, you must specify the `location`, `release`, `repos`, and `key` parameters. [Example](examples/backports.pp) + +#####`apt::builddep` +- This define was removed. Functionality can be matched passing 'build-dep' to `install_options` in the package resource. [Example](examples/builddep.pp) + +#####`apt::debian::testing` +- This class was removed. Manually add an `apt::source` instead. [Example](examples/debian_testing.pp) + +#####`apt::debian::unstable` +- This class was removed. Manually add an `apt::source` instead. [Example](examples/debian_unstable.pp) + +#####`apt::force` +- This define was removed. Functionallity can be matched by setting `install_options` in the package resource. See [here](examples/force.pp) for how to set the options. + +#####`apt::hold` +- This define was removed. Simply use an `apt::pin` with `priority => 1001` for the same functionality. + +#####`apt` +- `always_apt_update` - This parameter was removed. Use `update => { 'frequency' => 'always' }` instead. +- `apt_update_frequency` - This parameter was removed. Use `update => { 'frequency' => }` instead. +- `disable_keys` - This parameter was removed. See this [example](examples/disable_keys.pp) if you need this functionality. +- `proxy_host` - This parameter was removed. Use `proxy => { 'host' => }` instead. +- `proxy_port` - This parameter was removed. Use `proxy => { 'port' => }` instead. +- `purge_sources_list` - This parameter was removed. Use `purge => { 'sources.list' => }` instead. +- `purge_sources_list_d` - This parameter was removed. Use `purge => { 'sources.list.d' => }` instead. +- `purge_preferences` - This parameter was removed. Use `purge => { 'preferences' => }` instead. +- `purge_preferences_d` - This parameter was removed. Use `purge => { 'preferences.d' => }` instead. +- `update_timeout` - This parameter was removed. Use `update => { 'timeout' => }` instead. +- `update_tries` - This parameter was removed. Use `update => { 'tries' => }` instead. + +#####`apt::key` +- `key` - This parameter was renamed to `id`. +- `key_content` - This parameter was renamed to `content`. +- `key_source` - This parameter was renamed to `source`. +- `key_server` - This parameter was renamed to `server`. +- `key_options` - This parameter was renamed to `options`. + +#####`apt::release` +- This class was removed. See this [example](examples/release.pp) for how to achieve this functionality. + +#####`apt::source` +- `include_src` - This parameter was removed. Use `include => { 'src' => }` instead. ***NOTE*** This now defaults to false. +- `include_deb` - This parameter was removed. Use `include => { 'deb' => }` instead. +- `required_packages` - This parameter was removed. Use package resources for these packages if needed. +- `key` - This can either be a key id or a hash including key options. If using a hash, `key => { 'id' => }` must be specified. +- `key_server` - This parameter was removed. Use `key => { 'server' => }` instead. +- `key_content` - This parameter was removed. Use `key => { 'content' => }` instead. +- `key_source` - This parameter was removed. Use `key => { 'source' => }` instead. +- `trusted_source` - This parameter was renamed to `allow_unsigned`. + +#####`apt::unattended_upgrades` +- This class was removed and is being republished under the puppet-community namespace. The git repository is available [here](https://github.com/puppet-community/puppet-unattended_upgrades) and it will be published to the forge [here](https://forge.puppetlabs.com/puppet/unattended_upgrades). + +####Changes to default behavior +- By default purge unmanaged files in 'sources.list', 'sources.list.d', 'preferences', and 'preferences.d'. +- Changed default for `package_manage` in `apt::ppa` to `false`. Set to `true` in a single PPA if you need the package to be managed. +- `apt::source` will no longer include the `src` entries by default. +- `pin` in `apt::source` now defaults to `undef` instead of `false` + +####Features +- Added the ability to pass hashes of `apt::key`s, `apt::ppa`s, and `apt::setting`s to `apt`. +- Added 'https' key to `proxy` hash to allow disabling `https_proxy` for the `apt::ppa` environment. +- Added `apt::setting` define to abstract away configuration. +- Added the ability to pass hashes to `pin` and `key` in `apt::backports` and `apt::source`. + +####Bugfixes +- Fixes for strict variables. + ##2015-03-17 - Supported Release 1.8.0 ###Summary diff --git a/examples/debian_testing.pp b/examples/debian_testing.pp new file mode 100644 index 0000000000..3ed98f21f1 --- /dev/null +++ b/examples/debian_testing.pp @@ -0,0 +1,18 @@ +package { 'debian-keyring': + ensure => present +} + +package { 'debian-archive-keyring': + ensure => present +} + +apt::source { 'debian_testing': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'testing', + repos => 'main contrib non-free', + pin => '-10', + key => { + id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + server => 'subkeys.pgp.net', + }, +} diff --git a/examples/debian_unstable.pp b/examples/debian_unstable.pp new file mode 100644 index 0000000000..b1492cd538 --- /dev/null +++ b/examples/debian_unstable.pp @@ -0,0 +1,18 @@ +package { 'debian-keyring': + ensure => present +} + +package { 'debian-archive-keyring': + ensure => present +} + +apt::source { 'debian_unstable': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + pin => '-10', + key => { + id => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + server => 'subkeys.pgp.net', + }, +} diff --git a/metadata.json b/metadata.json index 8534aafbd3..10e859ef1c 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-apt", - "version": "1.8.0", + "version": "2.0.0", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", @@ -31,7 +31,7 @@ }, { "name": "puppet", - "version_requirement": "3.x" + "version_requirement": ">= 3.4.0" } ], "dependencies": [ From cdbb2e82c06618f723aecf1e1f2931b54937aeb0 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 14 Apr 2015 11:31:16 -0700 Subject: [PATCH 501/574] Fogot to remove the purge warning --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 318bc53d2c..9ae90e1d7d 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,6 @@ The apt module automates obtaining and installing software packages on \*nix sys * System repositories * Authentication keys -**Note**: By default, this module will **destroy** any existing content in `sources.list` and `sources.list.d` that was not declared with Puppet. - ### Beginning with apt To begin using the apt module with default parameters, declare the class with `include apt`. From 2802868f96b8c9c2e42b6342317c540bf818aad0 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 20 Apr 2015 12:44:10 -0700 Subject: [PATCH 502/574] Iterate through multiple keys --- lib/puppet/provider/apt_key/apt_key.rb | 9 +- spec/acceptance/apt_key_provider_spec.rb | 181 +++++++++++++++++++++++ 2 files changed, 189 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index bac5b373e9..f8c7d1976a 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -141,7 +141,14 @@ def tempfile(content) if File.executable? command(:gpg) extracted_key = execute(["#{command(:gpg)} --with-fingerprint --with-colons #{file.path} | awk -F: '/^fpr:/ { print $10 }'"], :failonfail => false) extracted_key = extracted_key.chomp - if extracted_key != name + + found_match = false + extracted_key.each_line do |line| + if line.chomp == name + found_match = true + end + end + if not found_match fail("The id in your manifest #{resource[:name]} and the fingerprint from content/source do not match. Please check there is not an error in the id or check the content/source is legitimate.") end else diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index b098e82fc0..f1f232e7a9 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -202,6 +202,187 @@ end end + context 'multiple keys' do + it 'runs without errors' do + pp = <<-EOS + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}', + ensure => 'present', + content => "-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.12 (GNU/Linux) +Comment: GPGTools - http://gpgtools.org + +mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b +fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg +5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ +S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY +GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH +Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v +VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 +Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI +wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN +NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl +f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB +tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL +ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn +AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob +pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF +eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+ +aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M +2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ +VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU +3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh +qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1 +IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8 +1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp +HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN +MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+ +UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh +R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+ +N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc +kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e +lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT +DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb +kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf +DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei +BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z +XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2 ++zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU +fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH +dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4 +qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2 +7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq +UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x +Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA +KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3 +okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7 +bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4 +4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX +vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0 +jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y +ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD +7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR +M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf +REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y +DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk +ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYWJAhwEEAEC +AAYFAlHk3M4ACgkQSjMLmtZI+uP5hA//UTZfD340ukip6jPlMzxwSD/QapwtO7D4 +gsGTsXezDkO97D21d1pNaNT0RrXAMagwk1ElDxmn/YHUDfMovZa2bKagjWmV38xk +Ws+Prh1P44vUDG30CAU6KZ+mTGLUbolfOvDffCTm9Mn1i2kxFaJxbVhWR6zR28KZ +R28s1IBsrqeTCksYfdKdkuw1/j850hW8MM3hPBJ/48VLx5QEFfnlXwt1fp+LygAv +rIyJw7vJtsa9QjCIkQk2tcv77rhkiZ6ADthgVIx5j3yDWSm4nLqFpwbQTKrNRrCb +5XbL/oIMeHJuFICb2HckDS1KuKXHmqvDuLoRr0/wFEZMps5XQevomUa7JkMeS5j9 +AubCG4g1zKEtPPaGDsfDKBljCHBKwUysQj5oGU5w8VvlOPnS62DBfsgU2y5ipmmI +TYkjSOL6LXwO6xG5/sxA8cyoJSmbN286imcY6AHloTiiu6/N7Us+CNrhw/V7HAun +56etWBn3bZWCRGGAPF3qJr4y2sUMY0E3Ha7OPEHIKfBb4MiJnpXntWT28nQfF3dl +TFTthAzwcnZchx2es4yrfDXn33Y4eisqxWCbTluErXUogUEKH1KohSatYMtxencv +7bUlzIr22zSUCYyVf9cyg50kBy+0J7seEpqG5K5R8z9s/63BT5Oghmi6bB2s5iK5 +fBt3Tu1IYpyZAg0EURGeeQEQALoU2rlo+usvGKqmBKaEl8Cbx0UZY4tQa1OQSDCj +6QeCBc36rq2NCAFpjYg0nrxMN86e0aHYVVetT75rSX701jRJD/TRCPzr03QVwEtk +GpGIpBXtdx0962I0We5rSZL2TWKuPtGRKrbs6CSVlNynLprIEnN+2sJYd/1yEsrR +9wBtUfVOkq6o4hBWOj4oEqhqQv1MPv1RPqGEgJl19s4LS9277cMIwrj553nGzsy1 +XwO6BQIP8IhJQZ+8Okw3UaJjLHkJExgo3UHMFdZhAOOYbrlxwq3lENmkdgjxCUBZ +iVNiEX9NLm8x1HWaW/nnBIHu6g7r+1Ff5qMSI2hBVan6om4gKHdI9wThG89V16Nq +3YztuK5L6Nh9a7BVQJos0r419NHGXPqXqN99jWRL+jAqwKozviUYijDx8k4xLnpQ +1dIbHfwE0MPuIkgHeQIoBMkxD1tiQC7ouqVRqU1gg9VKhOZf0opDnvqQ+cDMyfUC +hgrjjikSoCBIVCDvr1r7T/gUMDEXfnaMfAdEy1z9qnUzTRRzMbl4BN3Zn+4Htf+B +zpAln6H8h7sBb6CO1TX2Qh3JPTrV9zSSbbOW/kuySU+rkHBQPza5l+pnWD7eXaVj +7+WEx+TsYIP9Gpe/FOVp2ht93NgjNFAodPW+i5jm7MRk+vlzjidHJ69pEUoQQtuk +Td8LABEBAAG0V1B1cHBldCBMYWJzIE5pZ2h0bHkgQnVpbGQgS2V5IChQdXBwZXQg +TGFicyBOaWdodGx5IEJ1aWxkIEtleSkgPGRlbGl2ZXJ5QHB1cHBldGxhYnMuY29t +PokCPwQTAQIAKQUCURGzrQIbAwUJBaOagAcLCQgHAwIBBhUIAgkKCwQWAgMBAh4B +AheAAAoJELj5mcAHu2xX7UUQAKGDOQS20BRNEa3top+dQONWmC/j1ABDVTOkF7Zc +9JT5oEESzVof/yIWKAfCbYyH5l3yySZI3NOQt7CswIWDYe0JR/uBhyGoHkA1t52L +zP45UxI29K5XaeBm3qoQbV3W6GWScGkijfaJ2yz/dIHh0m3SkC8mUGBrIqqVwV38 +JcsW1/CzTetZiWGlk8/nPeUg+snGwd22zUlZkTaVh3FbHrqh2xsMFdrphDOtSU5s +Jzebu5h6mp7cMZELaRNNmg3O7VeQMA1hwaq05jQuPisS/ktOqSgJXh8pOaUpDoV0 +ta4JSwaqEkWsZHv3tmaXGy0Qzs9X9bOjRbIKgN2w9JY+z2OKJ5L4Yg5VMJPYMdKp +wGSQf70YaaT0d1N/84P8j7CRsDBnVME/TDuE2u1XM/9B7xmdcI28FxZrqQc06OGS +UvK9vSgTkTxXSsjobah8ssi4C4/zRgTZu94KOhSlH4YGrzLX7g25M708NxgXJiPZ +7K8Ceea28mHYf3f+JobEbpzPeewURAFCXHCm4cFU31FsiXQrNhGmUpRKVayiMMzN +JF8yjuHpwB2DjGdV3QR5C8Ms+RO86JnD/Yq9zeoF7T7jCAkQKuh76cQe60XllKhV +Dlh2rpKXAtLAbea9hcSraZkm3Lj+oKzXUSf3Ml9xp65yjUjm9O+a4AMQ1wFroGEP +QUEEiQEcBBABCgAGBQJT0XkMAAoJELrV8KOS6YVy7O8IAKJYT0Afd6Ufkx4cR0rj +soCoPpDDiyITmSdeLSzvl9rr1X39+PqR0dcncEhO1heCZo8sm/iMNsiV4UORv2Wh +lCriE2fDpu9ByX1rwuKl9nEu9xx2WTRWtdx4M4fB+ZXYiJbgb1vuM46mGp51NYRK +ByPIm1EAjOhsfXm14BZICOQO5WLy5Sv/oRVSEBiGXNXf1kweXSzrhRCNEWYfPhQJ +4pCsvNeiQuhqQIB+J9FbA48x47JikMM92w0aEa4aVVokNF2PBCp9/SdRAzlY7Ikx +aAdIzuyc0ANIZBPgYxIgdH/Fltwz6VW6iFNk3gS7jR6TFBjRQba73I53IBbiVIRq +dnWJAhwEEAECAAYFAlPRd2QACgkQRp6bNpsPDx1HiQ//TEOYPkp+iHT/wNcTUO4A +r00La6xl9bw3v5XlnW83YjrB0ieChbXcHpChNRk08vdRSgxyWCtbIwmMeOO8mDiv +aJbYrgngJY+FSMsAzhSyPauze0l4PV3dnLRMZmK5Nro4GNI4oiOGp0qXPcBjstlc +BnEa6XuLHDnRYFhkcVboZDu2o/tdz+OJD+CZjyeiIAtChMJ+ghlpfO3cOuK0wmTh +Jtn/eDAfjB34CZdkt1paKZap5bLZCF0QwP+DbJd189HZy/ot6w2jpNXFt1JFnoyn +7Nluo6MPNTZSG3pzh7fvzb924M1sm+CyLFzEV1rYi6ujyHOsW+KYc6fOUB5jk/BZ +QPaU6vG1JRDLHWPjbPf9Ax8uGQSrVXC3txiu2OLZcn4Ti54PoHed5m7Fxk9fnaiT +gNGL0ox/wmIPbIsdGrXuTHcdmPyuRM5btXFWCMbknTIbefEEOQdbPl+e5QgWR5cf +EVOvo6qTBstH7aHqiWMQpuvnU7l9xpfcJ40SawHxiY/UCKXhpf7SJXAvE8zkMIvi +PJaHKDy2FyCwtCHwG1wiQSqjnCJt5gmTGCXzO/yAGhcgUWbTpykIMij9IPboL7VL +er+I/3CikWeszcjBp5lJhg4k2OCBi5LOiI+8EUTlFcAqxbTFEyM+IQDOwnW8Gznf +nMb070gS9iBk0GTVC9iXHla0U1B1cHBldCBMYWJzIE5pZ2h0bHkgQnVpbGQgS2V5 +IChQdXBwZXQgTGFicyBOaWdodGx5IEJ1aWxkIEtleSkgPGluZm9AcHVwcGV0bGFi +cy5jb20+iQI+BBMBAgAoBQJREZ55AhsDBQkFo5qABgsJCAcDAgYVCAIJCgsEFgID +AQIeAQIXgAAKCRC4+ZnAB7tsVyjmEACSw9ZLq1ehcq8/QemiB+i8W/yVYZAxphmq +w547JXOxk19V5joR5Wp0fwqIEvE1Thw0mAiMUDAgM4TpdZc8zOaILj2OH1gWsuyi +fbFTHExTZAuZ1Lx1Nc1AlUv5Q+bmrzjAhx13Nk3LE7yfe4DLZnSyF3cZxAcSXYSq +wSo1sBrWxf2bOYnuyJwLlz94eeEkNdSi0mfANqt+ihiiAeTe9OXf65iPFn8SYRqV +W0hUayVlOedoCl0kviVXHvIgHxgkfazeIPqncFgPiRyYGNCVhKjaFjpUm+RzBFOk +HQzzcyNovlnjHmhxKkN+L2f1JqmHmUQguTTpJfpRdwmnEkA1BYY6m0WQ5Owga1eE +WEeHh9AjtVrukJOOibvpoS/M5FdAgaUgGXPIOziURDKBjQ0zuYMtlXgEDzKt0ugp +7YO74EAv1JiyeZ0Mu+m6WnxRX0Sb/op0ef74xZYD4eKYixOxahQ7kxtO9qTy+pOs +c3/KSNGv+oQh/CgChBbN3oq1UBfL6gVioRIp2GmP6Jmfipfod+VGIVI8xyfD3h/Z +nKF7dEHHMsyB03Ap2ypCcy8OEVwCeAZ4eY+lKXNyBSnddXcMGuFTqgJ1IMvTm0T8 +BfYn74A4fDqwNKKQGYjb67MZ+3N7YaWwCgWUvFpfd557fTQmZfV1arok2urvWIGa +x82lgKTA64kBHAQQAQoABgUCU9F5DwAKCRC61fCjkumFchUwB/wLfX/PA0LUbSen +es6ilcbHOZVZKyppMA5bIU6fG6SIS9FVauL0lgkEnJAhr5w3rXGd14LM33QkkPbs +/uNe2YQHzzrsffLhFyJkKJXH5rc6sSM7RYbAxtMNXKpkdMhPGmHgIgMzJo3ZuD8+ +ixsyR/8tGAMXbHwX5aAJDKYfg8X4kkPBxzysWJzN5/wFbYEK8FHiULkHNfJv480H +UBLNwczVeg9Etaje0tCQuGkD/CJHR50Kxuc/BiGYdYVjAnQVILXa2NcBizXtUU3f +N+6L+K2m9Fm3Dvhw0ZVEq7TxTMmHA23HGt8fMJ7zNCRO3krK7vtjUQxSXKOM7HF+ +D60QA/oGiQIcBBABAgAGBQJT0XdkAAoJEEaemzabDw8dtt0QAITarh4rsJWupVXD +BFHbxsUyT7AXspJ7kW3vxG3Y/gHSjleDX0VdblzUUBmD5y5JvR/DHrAgDd8XQN4E +4+hTOpZhzILZcoSWhiAW+VuL5b+R5NxSzIiHEt/qKgslvcx/sbQz8+Ro/zWHxhn9 +1uFf5JOFw+5W2wBmC4OdQby7B8AiV58OBAGcVUs0+57oJRYIU0zTRAJKRstMlD7s +F3R1d6EyNUbGjnJhPcltk6RRsYuJJx8vJzyY4pEy5eZPNSPEpFBjWlWyRnKDbQ6/ +TbtSB7bojbtjQFhh905kvdKxzcBkFgYTyzqJffUwHqJti8QQMraGAtC79/D/0vmf +lIJtzTB+gA/NOhyriaSXoGzi0oA/ZKReU3uJd5Yl202s/hvG+xpBkh7ouaVa5zFX +cqfi6gmmpQzVo6snI7d+Wonyvg1lhqZ7TXvtUIilsmbc5zEedidaCei77buX/ZuV +8jo+32HtsSKTYYHVsJzY6YzEy1SVfrUY+EdXXWG7Y97JaXKJc8oCNT1YA8BG4c+M +1cMXO1LTiP56gyYnrH6/oTIFrBXMl3dO/gKpcwUmf8lScFXIfVn5Wm3D0n6cUBKT +aRmmpfu7UhzBMEA7ZrIGxNBuD8WwfVi8ZSwBbV92fHkukkfixkhmeUmCB9vyq31+ +UfTwFXkHDTMZ4jfctKuBU+3p5sEwuQINBFERnnkBEAC0XpaBe0L9yvF1oc7rDLEt +XMrjDWHL6qPEW8ei94D619n1eo1QbZA4zZSZFjmN1SWtxg+2VRJazIlaFNMTpp+q +7lpmHPwzGdFdZZPVvjwd7cIe5KrGjEiTD1zf7i5Ws5Xh9jTh6VzY8nseakhIGTOC +lWzxl/+X2cJlMAR4/nLJjiTi3VwI2JBT8w2H8j8EgfRpjf6P1FyLv0WWMODc/hgc +/o5koLb4WRsK2w5usP/a3RNeh6L6iqHiiAL1Y9+0GZXOrjtNpkzPRarIL3MiX29o +VKSFcjUREpsEZHBHLwuA3WIR6WBX49LhrA6uLgofYhALeky6/H3ZFEH9ZS3plmnX +/vow8YWmz0Lyzzf848qsg5E5cHg36m2CXSEUeZfH748H78R62uIf/shusffl9Op2 +aZnQoPyeYIkA6N8m29CqIa/pzd68rLEQ+MNHHkp0KjQ0oKyrz9/YCXeQg3lIBXAv ++FIVK/04fMA3rr5tnynkeG9Ow6fGEtqzNjZhMZtx5BnkhdLTt6qu+wyaDw3q9X1/ +/j3lhplXteYzUkNUIinCHODGXaI55R/I4HNsbvtvy904g5sTHZX9QBn0x7QpVZaW +90jCgl6+NPH96g1cuHFuk+HED4H6XYFcdt1VRVb9YA7GgRXkSyfw6KdtGFT15e7o +7PcaD6NpqyBfbYfrNQmiOwARAQABiQIlBBgBAgAPBQJREZ55AhsMBQkFo5qAAAoJ +ELj5mcAHu2xXR8cP/Ai4PqUKBZdN6Jz628VQdiVX2EO7jhQ7KYdt9RWz87kfm0rC +LhdROCyeddgGsYbpdikC3Gzrk0JFIs/qAzpZOMIip0cXTxDEWWObuwShIac8hmZz +BE5SM7TcA9+/jmBwLajcreGgKs/MfDkkWkiBT/B+FyHkqS6O/rdBvYqFzLtvUigG +SRf1clP4QEGWcR6LLsJ1uiH+brK3G1GsILVpX5iQ0Y4wNv0xNRGZzAPVZ1/vgHCM +sAG7TZy26oOraigvnZeo1Q9r7pg+i6uSIu4ywfdNTOuoBK+VY+RKyAybBHIqH07w +p9TmYOY1x+wmIe0oSYcR47OcvZU57fdLsEB9djYvkGkkmbz0gwXQL0iEW3kX+05J +zrLzPsx6muR35SPNCvfR2T/0VCDwtNwwxACWuZI/tqsobU/+lA/MqRZ4kOD/Bx07 +CpZfYIAi2STc0MIDvpyDnZLiYVMMkqV4+gn2ANtkF+GKbra3Aeof9b4KEVabSaQ5 +5W70DJF0G5bmHBSdyqdYnKB/yRj1rH+dgRbiRMv7rBAx5Q8rbYiym8im+5XNUDy2 +ZTQcCD53HcBLvKX6RJ4ByYawKaQqMa27WK/YWVmFXqVDVk12iKrQW6zktDdGInnD ++f0rRH7c/7F/QuBR6Y4Zkso0CuVMNsmxv0E+7Zk0z4dWalzQuXpN7OXcZ8Gp +=Gl+v +-----END PGP PUBLIC KEY BLOCK-----", + } + EOS + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) + shell(PUPPETLABS_KEY_CHECK_COMMAND) + end + end + context 'bogus key' do it 'fails' do pp = <<-EOS From fff702270e69458b6cf30109c4a66a9c14813d7f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 22 Apr 2015 16:31:47 -0700 Subject: [PATCH 503/574] Update tests to work with rspec-puppet 2.x Also enable future parser testing. Need to allow failures with future parser for now since none of the published gems have the fix for PUP-4379 --- .travis.yml | 11 ++++++++++ Gemfile | 2 +- spec/classes/apt_backports_spec.rb | 18 ++++++++--------- spec/classes/apt_spec.rb | 14 ++++++------- spec/classes/params_spec.rb | 6 +++--- spec/defines/conf_spec.rb | 2 +- spec/defines/key_spec.rb | 32 +++++++++++++++--------------- spec/defines/pin_spec.rb | 10 +++++----- spec/defines/ppa_spec.rb | 4 ++-- spec/defines/setting_spec.rb | 10 +++++----- spec/defines/source_spec.rb | 6 +++--- 11 files changed, 63 insertions(+), 52 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8b374e9bb0..6ff1d8a2a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,5 +12,16 @@ matrix: env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 4.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 4.0" + allow_failures: + - env: PUPPET_GEM_VERSION="~> 4.0" + - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" notifications: email: false diff --git a/Gemfile b/Gemfile index e1ae0fa56a..64e206f185 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ end group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-core', '3.1.7', :require => false - gem 'rspec-puppet', '~> 1.0', :require => false + gem 'rspec-puppet', '~> 2.0', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false gem 'simplecov', :require => false diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index b9077a6bcd..1b596789e0 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -142,7 +142,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) end end @@ -156,7 +156,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) end end @@ -170,7 +170,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) end end @@ -184,7 +184,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/) end end @@ -205,7 +205,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /is not a string/) end end @@ -217,7 +217,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /is not a string/) end end @@ -229,7 +229,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /is not a string/) end end @@ -241,7 +241,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /is not a string/) end end @@ -253,7 +253,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /pin must be either a string, number or hash/) end end diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index ee7cd33a24..a470667b0d 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -101,8 +101,8 @@ } end - it { is_expected.to contain_file('sources.list').without({ - :content => "# Repos managed by puppet.\n", + it { is_expected.to contain_file('sources.list').with({ + :content => nil, })} it { is_expected.to contain_file('sources.list.d').with({ @@ -230,7 +230,7 @@ let(:params) { { :purge => { 'sources.list' => 'banana' }, } } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error) end end @@ -239,7 +239,7 @@ let(:params) { { :purge => { 'sources.list.d' => 'banana' }, } } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error) end end @@ -248,7 +248,7 @@ let(:params) { { :purge => { 'preferences' => 'banana' }, } } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error) end end @@ -257,7 +257,7 @@ let(:params) { { :purge => { 'preferences.d' => 'banana' }, } } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error) end end @@ -269,7 +269,7 @@ it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/) end end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index f8599b3699..d90ae7e993 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -9,16 +9,16 @@ # there should not be any more resources because it is a params class # The resources are class[apt::params], class[main], class[settings], stage[main] it "Should not contain any resources" do - expect(subject.resources.size).to eq(4) + expect(subject.call.resources.size).to eq(4) end describe "With lsb-release not installed" do - let(:facts) { { :lsbdistid => '', :osfamily => 'Debian' } } + let(:facts) { { :osfamily => 'Debian' } } let (:title) { 'my_package' } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, is lsb-release installed/) end end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index e96f8bcd82..d0c5ed976d 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -38,7 +38,7 @@ end it 'fails' do - expect { subject } .to raise_error(/pass in content/) + expect { subject.call } .to raise_error(/pass in content/) end end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index b9bcea845a..6725dc8f25 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -143,7 +143,7 @@ :server => '-pgp.mit.edu', } end it 'fails' do - expect { subject } .to raise_error(/does not match/) + expect { subject.call } .to raise_error(/does not match/) end end @@ -152,7 +152,7 @@ :server => '.pgp.mit.edu', } end it 'fails' do - expect { subject } .to raise_error(/does not match/) + expect { subject.call } .to raise_error(/does not match/) end end @@ -161,7 +161,7 @@ :server => "pgp.mit.edu.", } end it 'fails' do - expect { subject } .to raise_error(/does not match/) + expect { subject.call } .to raise_error(/does not match/) end end context "exceed character url" do @@ -171,7 +171,7 @@ } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end context "incorrect port number url" do @@ -181,7 +181,7 @@ } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end context "incorrect protocol for url" do @@ -191,7 +191,7 @@ } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end context "missing port number url" do @@ -201,7 +201,7 @@ } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end context "url ending with a dot" do @@ -211,7 +211,7 @@ } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end context "url begin with a dash" do @@ -219,7 +219,7 @@ :server => "hkp://-pgp.mit.edu", } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end context 'invalid key' do @@ -227,7 +227,7 @@ 'Out of rum. Why? Why are we out of rum?' end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end @@ -236,7 +236,7 @@ :source => 'afp://puppetlabs.com/key.gpg', } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end @@ -245,7 +245,7 @@ :content => [], } end it 'fails' do - expect { subject }.to raise_error(/is not a string/) + expect { subject.call }.to raise_error(/is not a string/) end end @@ -254,7 +254,7 @@ :server => 'two bottles of rum', } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end @@ -263,7 +263,7 @@ :options => {}, } end it 'fails' do - expect { subject }.to raise_error(/is not a string/) + expect { subject.call }.to raise_error(/is not a string/) end end @@ -274,7 +274,7 @@ } end it 'fails' do - expect { subject }.to raise_error(/does not match/) + expect { subject.call }.to raise_error(/does not match/) end end @@ -315,7 +315,7 @@ apt::key { 'duplicate': id => '#{title}', ensure => 'absent', }" end it 'informs the user of the impossibility' do - expect { subject }.to raise_error(/already ensured as absent/) + expect { subject.call }.to raise_error(/already ensured as absent/) end end end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index a11c3b5c25..c77bb6ba6e 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -80,7 +80,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /Only integers are allowed/) end end @@ -93,7 +93,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/) end end @@ -107,7 +107,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/) end end @@ -122,7 +122,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) end end @@ -137,7 +137,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/) end end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 521b42ba2b..7046475736 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -279,7 +279,7 @@ let(:title) { 'ppa:foo' } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end @@ -297,7 +297,7 @@ let(:title) { 'ppa:foo' } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /not currently supported on Debian/) end end diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 6f09f9ccf0..16c80163aa 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -10,7 +10,7 @@ describe 'when using the defaults' do context 'without source or content' do it do - expect { is_expected.to compile }.to raise_error(Puppet::Error, /needs either of /) + expect { subject.call }.to raise_error(Puppet::Error, /needs either of /) end end @@ -74,7 +74,7 @@ context 'with source and content' do let(:params) { default_params.merge({ :source => 'la' }) } it do - expect { is_expected.to compile }.to raise_error(Puppet::Error, /cannot have both /) + expect { subject.call }.to raise_error(Puppet::Error, /cannot have both /) end end @@ -82,21 +82,21 @@ let(:title) { 'ext-teddybear' } let(:params) { default_params } it do - expect { is_expected.to compile }.to raise_error(Puppet::Error, /must start with /) + expect { subject.call }.to raise_error(Puppet::Error, /must start with /) end end context 'with ensure=banana' do let(:params) { default_params.merge({ :ensure => 'banana' }) } it do - expect { is_expected.to compile }.to raise_error(Puppet::Error, /"banana" does not /) + expect { subject.call }.to raise_error(Puppet::Error, /"banana" does not /) end end context 'with priority=1.2' do let(:params) { default_params.merge({ :priority => 1.2 }) } it do - expect { is_expected.to compile }.to raise_error(Puppet::Error, /be an integer /) + expect { subject.call }.to raise_error(Puppet::Error, /be an integer /) end end end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 3900158a16..24f50f7963 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -22,7 +22,7 @@ end it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /source entry without specifying a location/) end end @@ -256,7 +256,7 @@ it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end @@ -278,7 +278,7 @@ it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /invalid value for pin/) end end From e41fc4bbb4565986af2fe6b5f411cb5ddc74ca00 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 27 Apr 2015 10:21:03 -0700 Subject: [PATCH 504/574] Switch back to anchor, for moar compatibility --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 140e171c50..5d9baa29ed 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -133,7 +133,7 @@ notify => Exec['apt_update'], } - contain 'apt::update' + anchor { 'apt_first': } -> Class['apt::update'] -> anchor { 'apt_last': } # manage sources if present if $sources { From ccd5cea444a4f9762cd3f1cf1732eb4d03111f30 Mon Sep 17 00:00:00 2001 From: Pete Soloway Date: Mon, 13 Apr 2015 18:35:10 -0700 Subject: [PATCH 505/574] Update README per DOC-1503 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Make sure that for each parameter, where applicable, there is a default value. 2. Make sure that for each parameter that's applicable, there is a note if the parameter is optional. 3. Make sure the links in the README work and are accurate. 4. Update the link in the Contributing section to point here: https://docs.puppetlabs.com/forge/contributing.html 5. General copyediting. * Add a ToC * Reorganize Usage & Reference sections * Standardize capitalization of "Apt" (as opposed to "apt", the module) * Standardize Development section Apply edits from @jbondpdx * Re-emphasize the warning about short key names * Restore the “What apt affects” section * Re-correct capitalization of “Apt” (where it had reverted to “APT”) * Clarify OS compatibility in Limitations and elsewhere * Various edits for clarity --- README.md | 697 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 404 insertions(+), 293 deletions(-) diff --git a/README.md b/README.md index 9ae90e1d7d..52030c730a 100644 --- a/README.md +++ b/README.md @@ -1,335 +1,446 @@ # apt +#### Table of Contents + +1. [Overview](#overview) +2. [Module Description - What the module does and why it is useful](#module-description) +3. [Setup - The basics of getting started with [apt]](#setup) + * [What apt affects](#what-apt-affects) + * [Beginning with apt](#beginning-with-apt) +4. [Usage - Configuration options and additional functionality](#usage) +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) + * [Classes](#classes) + * [Defines](#defines) + * [Types](#types) + * [Facts](#facts) +6. [Limitations - OS compatibility, etc.](#limitations) +7. [Development - Guide for contributing to the module](#development) + ## Overview -The apt module provides a simple interface for managing Apt source, key, and definitions with Puppet. +The apt module lets you use Puppet to manage Apt sources, keys, and other configuration options. ## Module Description -The apt module automates obtaining and installing software packages on \*nix systems. - -**Note**: While this module allows the use of short keys, **warnings are thrown if a full fingerprint is not used**, as they pose a serious security issue by opening you up to collision attacks. +Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, and several other operating systems. The apt module provides a series of classes, defines, types, and facts to help you automate Apt package management. ## Setup -### What apt affects: +### What apt affects -* Package/service/configuration files for Apt * Your system's `sources.list` file and `sources.list.d` directory * System repositories * Authentication keys +**Note:** Setting the apt module's `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that you haven't declared through Puppet. The default for these parameters is 'false'. + ### Beginning with apt -To begin using the apt module with default parameters, declare the class with `include apt`. +To use the apt module with default parameters, declare the `apt` class. -Any Puppet code that uses anything from the apt module requires that the core apt class be declared. +~~~puppet +include apt +~~~ + +**Note:** The main `apt` class is required by all other classes, types, and defines in this module. You must declare it whenever you use the module. ## Usage -Using the apt module consists predominantly of declaring classes and defined types that provide the desired functionality and features. This module provides common resources and options that are shared by the various defined types in the apt module, so you **must always** include this class in your manifests. +### Add GPG keys + +**Warning:** Using short key IDs presents a serious security issue, potentially leaving you open to collision attacks. We recommend you always use full fingerprints to identify your GPG keys. This module allows short keys, but issues a security warning if you use them. + +Declare the `apt::key` class: + +~~~puppet +apt::key { 'puppetlabs': + id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + server => 'pgp.mit.edu', + options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', +} +~~~ + +You can make Apt load your key before others by adjusting the `priority` parameter (the default priority is 50). + +~~~puppet +apt::key { 'puppetlabs': + id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + server => 'pgp.mit.edu', + options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', + priority => '50', +} +~~~ + +### Prioritize backports + +~~~puppet +class { 'apt::backports': + pin => 500, +} +~~~ + +By default, the `apt::backports` class drops a pin file for backports, pinning it to a priority of 200. This is lower than the normal default of 500, so packages with `ensure => latest` don't get upgraded from backports without your explicit permission. + +If you raise the priority through the `pin` parameter to 500, normal policy goes into effect and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. + +### Update the list of packages + +By default, Puppet runs `apt-get update` on the first Puppet run after you include the `apt` class, and anytime `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to 'always', the update runs on every Puppet run. You can also set `update['frequency']` to 'daily' or 'weekly': + +~~~puppet +class { 'apt': + update => { + frequency => 'daily', + }, +} +~~~ + +### Pin a specific release + +~~~puppet +apt::pin { 'karmic': priority => 700 } +apt::pin { 'karmic-updates': priority => 700 } +apt::pin { 'karmic-security': priority => 700 } +~~~ + +You can also specify more complex pins using distribution properties: + +~~~puppet +apt::pin { 'stable': + priority => -10, + originator => 'Debian', + release_version => '3.0', + component => 'main', + label => 'Debian' +} +~~~ + +To pin multiple packages, pass them to the `packages` parameter as an array or a space-delimited string. + +### Add a PPA (Personal Package Archive) repository + +~~~puppet +apt::ppa { 'ppa:drizzle-developers/ppa': } +~~~ + +### Add an Apt source to `/etc/apt/sources.list.d/` + +~~~puppet +apt::source { 'debian_unstable': + comment => 'This is the iWeb Debian unstable mirror', + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + pin => '-10', + key => { + 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + 'server' => 'subkeys.pgp.net', + }, + include => { + 'src' => true, + 'deb' => true, + }, +} +~~~ + +To use the Puppet Labs Apt repository as a source: + +~~~puppet +apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => { + 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + 'server' => 'pgp.mit.edu', + }, +}, +~~~ + +### Configure Apt from Hiera + +~~~yaml +apt::sources: + 'debian_unstable': + location: 'http://debian.mirror.iweb.ca/debian/' + release: 'unstable' + repos: 'main contrib non-free' + key: + id: '9AA38DCD55BE302B' + server: 'subkeys.pgp.net' + pin: '-10' + include: + src: true + deb: true -```puppet -class { 'apt': } -``` + 'puppetlabs': + location: 'http://apt.puppetlabs.com' + repos: 'main' + key: + id: '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' + server: 'pgp.mit.edu' +~~~ ## Reference ### Classes -* `apt`: Main class, provides common resources and options. Allows Puppet to manage your system's sources.list file and sources.list.d directory. By default, it will not purge existing content it finds that wasn't declared with Puppet. - - * `apt::backports`: This class adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to "$lsbdistcodename-backports". Setting this manually can cause undefined and potentially serious behavior. +#### Public Classes - By default, this class drops a pin-file for backports, pinning it to a priority of 200. This is lower than the normal Debian archive, which gets a priority of 500 to ensure that packages with `ensure => latest` don't get magically upgraded from backports without your explicit permission. +* [`apt`](#class-apt) +* [`apt::backports`](#class-aptbackports) - If you raise the priority through the `pin` parameter to 500---identical to the rest of the Debian mirrors---normal policy goes into effect, and Apt installs or upgrades to the newest version. This means that if a package is available from backports, it and its dependencies are pulled in from backports unless you explicitly set the `ensure` attribute of the `package` resource to `installed`/`present` or a specific version. +#### Private Classes -* `apt::params`: Sets defaults for the apt module parameters. +* `apt::params`: Provides defaults for the apt module parameters. +* `apt::update`: Updates the list of available packages using `apt-get update`. -* `apt::update`: Runs `apt-get update`, updating the list of available packages and their versions without installing or upgrading any packages. The update runs on the first Puppet run after you include the class, then whenever `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to `'always'`, the update runs on every Puppet run. +### Defines + +* [`apt::conf`](#define-aptconf) +* [`apt::key`](#define-aptkey) +* [`apt::pin`](#define-aptpin) +* [`apt::ppa`](#define-aptppa) +* [`apt::setting`](#define-aptsetting) +* [`apt::source`](#define-aptsource) ### Types -* `apt_key` - - A native Puppet type and provider for managing GPG keys for Apt is provided by this module. - - ```puppet - apt_key { 'puppetlabs': - ensure => 'present', - id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - } - ``` - - You can additionally set the following attributes: - - * `source`: HTTP, HTTPS or FTP location of a GPG key or path to a file on the target host. - * `content`: Instead of pointing to a file, pass the key in as a string. - * `server`: The GPG key server to use. It defaults to *keyserver.ubuntu.com*. - * `options`: Additional options to pass to `apt-key`'s `--keyserver-options`. - -### Defined Types - -* `apt::conf`: Specifies a custom configuration file. The priority defaults to 50, but you can set the priority parameter to load the file earlier or later. The content parameter passes specified content, if any, into the file resource. - -* `apt::key`: Adds a key to the list of keys used by Apt to authenticate packages. This type uses the aforementioned `apt\_key` native type. As such, it no longer requires the `wget` command on which the old implementation depended. - - ```puppet - apt::key { 'puppetlabs': - id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - server => 'pgp.mit.edu', - } - - apt::key { 'jenkins': - id => '150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6', - source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', - } - ``` - -* `apt::pin`: Defined type that adds an Apt pin for a certain release. - - ```puppet - apt::pin { 'karmic': priority => 700 } - apt::pin { 'karmic-updates': priority => 700 } - apt::pin { 'karmic-security': priority => 700 } - ``` - - Note that you can also specify more complex pins using distribution properties. - - ```puppet - apt::pin { 'stable': - priority => -10, - originator => 'Debian', - release_version => '3.0', - component => 'main', - label => 'Debian' - } - ``` - - If you want to pin a number of packages, you can specify the packages as a space-delimited string using the `packages` attribute, or you can pass in an array of package names. - -* `apt::ppa`: Adds a PPA repository using `add-apt-repository`. For example, `apt::ppa { 'ppa:drizzle-developers/ppa': }`. - -* `apt::setting`: Defined type to abstract the creation of Apt configuration files. - -* `apt::source`: Adds an Apt source to `/etc/apt/sources.list.d/`. For example: - - ```puppet - apt::source { 'debian_unstable': - comment => 'This is the iWeb Debian unstable mirror', - location => 'http://debian.mirror.iweb.ca/debian/', - release => 'unstable', - repos => 'main contrib non-free', - pin => '-10', - key => { - 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - 'server' => 'subkeys.pgp.net', - }, - include => { - 'src' => true, - 'deb' => true, - }, - } - ``` - - For example, to configure your system so the source is the Puppet Labs Apt repository: - - ```puppet - apt::source { 'puppetlabs': - location => 'http://apt.puppetlabs.com', - repos => 'main', - key => { - 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - 'server' => 'pgp.mit.edu', - }, - ``` +* [`apt_key`](#type-apt_key) ### Facts -The apt module includes a few facts to describe the state of the Apt system: +* `apt_updates`: The number of installed packages with available updates. -* `apt\_updates`: The number of updates available on the system -* `apt\_security\_updates`: The number of updates which are security updates -* `apt\_package\_updates`: The package names that are available for update. In Facter 2.0 and later, this will be a list type; in earlier versions, it is a comma-delimited string. -* `apt\_update\_last\_success`: The date, in epochtime, of the most recent successful `apt-get update` run. This is determined by reading the mtime of /var/lib/apt/periodic/update-success-stamp. +* `apt_security_updates`: The number of installed packages with available security updates. -**Note:** The facts depend on 'update-notifier' being installed on your system. Though this is a GNOME daemon only the support files are needed so the package 'update-notifier-common' is enough to enable this functionality. +* `apt_package_updates`: The names of all installed packages with available updates. In Facter 2.0 and later this data is formatted as an array; in earlier versions it is a comma-delimited string. -#### Hiera example +* `apt_update_last_success`: The date, in epochtime, of the most recent successful `apt-get update` run (based on the mtime of /var/lib/apt/periodic/update-success-stamp). -```yaml -apt::sources: - 'debian_unstable': - location: 'http://debian.mirror.iweb.ca/debian/' - release: 'unstable' - repos: 'main contrib non-free' - key: - id: '9AA38DCD55BE302B' - server: 'subkeys.pgp.net' - pin: '-10' - include: - src: true - deb: true +#### Class: `apt` - 'puppetlabs': - location: 'http://apt.puppetlabs.com' - repos: 'main' - key: - id: '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' - server: 'pgp.mit.edu' -``` - -### Parameters - -####apt - -* `update`: Hash to configure various update settings. Valid keys are: - * 'frequency': The run frequency for `apt-get update`. Defaults to 'reluctantly'. Accepts the following values: - * 'always': Runs update at every Puppet run. - * 'daily': Runs update daily; that is, `apt-get update` runs if the value of `apt\_update\_last\_success` is less than current epoch time - 86400. If the exec resource `apt\_update` is notified, `apt-get update` runs regardless of this value. - * 'weekly': Runs update weekly; that is, `apt-get update` runs if the value of `apt\_update\_last\_success` is less than current epoch time - 604800. If the exec resource `apt\_update` is notified, `apt-get update` runs regardless of this value. - * 'reluctantly': Only runs `apt-get update` if the exec resource `apt\_update` is notified. This is the default setting. - * 'timeout': Overrides the exec timeout in seconds for `apt-get update`. Defaults to exec default (300). - * 'tries': Sets how many times to attempt running `apt-get update`. Use this to work around transient DNS and HTTP errors. By default, the command runs only once. -* `purge`: Hash to configure various purge settings. Valid keys are: - * 'sources.list': If set to 'true', Puppet purges all unmanaged entries from sources.list. Accepts `true` or `false`. Defaults to `false`. - * 'sources.list.d': If set to 'true', Puppet purges all unmanaged entries from sources.list.d. Accepts `true` or `false`. Defaults to `false`. - * 'preferences.list': If set to 'true', Puppet purges all unmanaged entries from preferences.list. Accepts `true` or `false`. Defaults to `false`. - * 'preferences.list.d': If set to 'true', Puppet purges all unmanaged entries from preferences.list.d. Accepts `true` or `false`. Defaults to `false`. -* `proxy`: Hash to configure various proxy settings. Valid keys are: - * 'host': Configures a proxy host and stores the configuration in /etc/apt/apt.conf.d/01proxy. - * 'port': Configures a proxy port and stores the configuration in /etc/apt/apt.conf.d/01proxy. - * 'https': Boolean to configure whether or not to enable https proxies. Defaults to false. -* `keys`: Passes a hash to `create\_resource` to make new `apt::key` resources. -* `ppas`: Passes a hash to `create\_resource` to make new `apt::ppa` resources. -* `settings`: Passes a hash to `create\_resource` to make new `apt::setting` resources. -* `sources`: Passes a hash to `create\_resource` to make new `apt::source` resources. - -####apt::backports - -* `location`: The URL of the apt repository. OS-dependent defaults are specifed in `apt::params` for Ubuntu and Debian. Required parameter for other OSes. -* `release`: The distribution of the apt repository. Defaults to "${lsbdistcodename}-backports" for Ubuntu and Debian. Required parameter for other OSes. -* `repos`: The component of the apt repository. OS-dependent defaults are speicifed in `apt::params` for Ubuntu and Debian. Required parameter for other OSes. -* `key`: The key for the backports repository. Can either be a string or a hash. See apt::setting for details on passing key as a hash. OS-dependent defaults are specified in `apt::params` for Ubuntu and Debian. Required parameter for other OSes. -* `pin`: The pin priority for backports repository. Can either be a number, a string, or a hash that will be passed as parameters to `apt::pin`. Defaults to `200`. - -####apt::conf - -* `content`: The content of the configuration file. -* `ensure`: Whether the configuration file should be 'present' or 'absent'. Defaults to 'present'. -* `priority`: Numeric priority for the configuration file. Defaults to '50'. - -####apt::key - -* `ensure`: The state we want this key in. Can be 'present' or 'absent'. -* `id`: Is a GPG key ID or full key fingerprint. This value is validated with a regex enforcing it to only contain valid hexadecimal characters, be precisely 8 or 16 hexadecimal characters long and optionally prefixed with 0x for key IDs, or 40 hexadecimal characters long for key fingerprints. -* `content`: This parameter can be used to pass in a GPG key as a string in case it cannot be fetched from a remote location and using a file resource is for other reasons inconvenient. -* `source`: This parameter can be used to pass in the location of a GPG key. This URI can take the form of a `URL` (ftp, http or https) and a `path` (absolute path to a file on the target system). -* `server`: The keyserver from where to fetch our GPG key. It can either be a domain name or URL. It defaults to 'keyserver.ubuntu.com'. -* `options`: Additional options to pass on to `apt-key adv --keyserver-options`. - -####apt::pin - -* `ensure`: The state we want this pin in. Can be 'present' or 'absent'. -* `explanation`: Add a comment. Defaults to `${caller\_module\_name}: ${name}`. -* `order`: The order of the file name. Defaults to undef, otherwise must be an integer. -* `packages`: The list of packages to pin. Defaults to '\*'. Can be an array or string. -* `priority`: Several versions of a package may be available for installation when the sources.list(5) file contains references to more than one distribution (for example, stable and testing). APT assigns a priority to each version that is available. Subject to dependency constraints, apt-get selects the version with the highest priority for installation. -* `release`: The Debian release. Defaults to ''. Typical values can be 'stable', 'testing' and 'unstable'. -* `origin`: Can be used to match a hostname. The following record will assign a high priority to all versions available from the server identified by the hostname. Defaults to ''. -* `version`: The specific form assigns a priority (a "Pin-Priority") to one or more specified packages with a specified version or version range. -* `codename`: The distribution (lsbdistcodename) of the apt repository. Defaults to ''. -* `release\_version`: Names the release version. For example, the packages in the tree might belong to Debian release version 7. Defaults to ''. -* `component`: Names the licensing component associated with the packages in the directory tree of the Release file. defaults to ''. Typical values can be 'main', 'dependencies' and 'restricted' -* `originator`: Names the originator of the packages in the directory tree of the Release file. Defaults to ''. Most commonly, this is Debian. -* `label`: Names the label of the packages in the directory tree of the Release file. Defaults to ''. Most commonly, this is Debian. - -**Note**: Parameters release, origin, and version are mutually exclusive. - -It is recommended to read the manpage 'apt_preferences(5)' - -####apt::ppa - -* `ensure`: Whether we are adding or removing the PPA. Can be 'present' or 'absent'. Defaults to 'present'. -* `release`: The codename for the operating system you're running. Defaults to `$lsbdistcodename`. Required if lsb-release is not installed. -* `options`: Options to be passed to the `apt-add-repository` command. OS-dependent defaults are set in `apt::params`. -* `package\_name`: The package that provides the `apt-add-repository` command. OS-dependent defaults are set in `apt::params`. -* `package\_manage`: Whether or not to manage the package providing `apt-add-repository`. Defaults to true. - -####apt::setting - -* `priority`: Integer or zero-padded integer setting the file priority. Defaults to 50. -* `ensure`: Whether to add or remove the file. Valid values are 'present', 'absent', and 'file'. Defaults to `file`. -* `source`: The source for the file. Exactly one of `content` and `source` must be specified. -* `content`: The content for the file. Exactly one of `content` and `source` must be specified. -* `notify\_update`: Boolean for whether or not this `apt::setting` should trigger an `apt-get update`. Defaults to `true`. - -####apt::source - -* `comment`: Add a comment to the apt source file. -* `ensure`: Allows you to remove the apt source file. Can be 'present' or 'absent'. -* `location`: The URL of the apt repository. Defaults to undef. Required unless `ensure => 'absent'`. -* `release`: The distribution of the apt repository. Defaults to fact 'lsbdistcodename'. -* `repos`: The component of the apt repository. This defaults to 'main'. -* `include`: Hash to configure include options. Valid keys are: - * 'deb': References a Debian distribution's binary package. Defaults to `true`. - * 'src': Enable the deb-src type, references a Debian distribution's source code in the same form as the `include['deb']` type. A deb-src line is required to fetch source indexes. Defaults to `false`. -* `key`: Add key from source. Takes either a string or a hash. If a string, the value will be passed to `id` in the `apt::key`. If a hash, valid keys are: - * 'id': See `id` in `apt::key`. Required if a hash is specified. - * 'server': See `server` in `apt::key` - * 'content': See `content` in `apt::key` - * 'source': See `source` in `apt::key` - * 'options': See `options` in `apt::key` -* `pin`: See apt::pin. Defaults to undef. Can be a string, number, or a hash to be passed as parameters to `apt::pin`. -* `architecture`: can be used to specify for which architectures information should be downloaded. If this option is not set all architectures defined by the APT::Architectures option will be downloaded. Defaults to `undef` which means all. Example values can be 'i386' or 'i386,alpha,powerpc'. -* `allow\_unsigned`: can be set to indicate that packages from this source are always authenticated even if the Release file is not signed or the signature can't be checked. Defaults to `false`. Can be `true` or `false`. - -Limitations ------------ - -This module should work across all versions of Debian/Ubuntu and support all major Apt repository management features. - -Development ------------- - -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. - -We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. - -You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) - -License -------- - -The original code for this module comes from Evolving Web and was licensed under the MIT license. Code added since the fork of this module is licensed under the Apache 2.0 License like the rest of the Puppet Labs products. - -The LICENSE contains both licenses. - -Contributors ------------- - -A lot of great people have contributed to this module. A somewhat current list follows: - -* Ben Godfrey -* Branan Purvine-Riley -* Christian G. Warden -* Dan Bode -* Daniel Tremblay -* Garrett Honeycutt -* Jeff Wallace -* Ken Barber -* Matthaus Litteken -* Matthias Pigulla -* Monty Taylor -* Peter Drake -* Reid Vandewiele -* Robert Navarro -* Ryan Coleman -* Scott McLeod -* Spencer Krum -* William Van Hevelingen -* Zach Leslie -* Daniele Sluijters -* Daniel Paulus -* Wolf Noble +Main class, includes all other classes. + +##### Parameters (all optional) + +* `keys`: Creates new `apt::key` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. + +* `ppas`: Creates new `apt::ppa` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. + +* `proxy`: Configures Apt to connect to a proxy server. Valid options: a hash made up from the following keys: + + * 'host': Specifies a proxy host to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: a string containing a hostname. Default: undef. + + * 'port': Specifies a proxy port to be stored in `/etc/apt/apt.conf.d/01proxy`. Valid options: a string containing a port number. Default: '8080'. + + * 'https': Specifies whether to enable https proxies. Valid options: 'true' and 'false'. Default: 'false'. + +* `purge`: Specifies whether to purge any existing settings that aren't managed by Puppet. Valid options: a hash made up from the following keys: + + * 'sources.list': Specifies whether to purge any unmanaged entries from `sources.list`. Valid options: 'true' and 'false'. Default: 'false'. + + * 'sources.list.d': Specifies whether to purge any unmanaged entries from `sources.list.d`. Valid options: 'true' and 'false'. Default: 'false'. + + * 'preferences.list': Specifies whether to purge any unmanaged entries from `preferences.list`. Valid options: 'true' and 'false'. Default: 'false'. + + * 'preferences.list.d': Specifies whether to purge any unmanaged entries from `preferences.list.d`. Valid options: 'true' and 'false'. Default: 'false'. + +* `settings`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. + +* `sources`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. + +* `update`: Configures various update settings. Valid options: a hash made up from the following keys: + + * 'frequency': Specifies how often to run `apt-get update`. If the exec resource `apt_update` is notified, `apt-get update` runs regardless of this value. Valid options: 'always' (at every Puppet run); 'daily' (if the value of `apt_update_last_success` is less than current epoch time minus 86400); 'weekly' (if the value of `apt_update_last_success` is less than current epoch time minus 604800); and 'reluctantly' (only if the exec resource `apt_update` is notified). Default: 'reluctantly'. + + * 'timeout': Specifies how long to wait for the update to complete before canceling it. Valid options: an integer, in seconds. Default: 300. + + * 'tries': Specifies how many times to retry the update after receiving a DNS or HTTP error. Valid options: an integer. Default: 1. + +#### Class: `apt::backports` + +Manages backports. + +##### Parameters (all optional on Debian and Ubuntu; all required on other operating systems, except where specified) + +* `key`: Specifies a key to authenticate the backports. Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Defaults: + + * Debian: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' + * Ubuntu: '630239CC130E1A7FD81A27B140976EAF437D05B5' + +* `location`: Specifies an Apt repository containing the backports to manage. Valid options: a string containing a URL. Defaults: + + * Debian (squeeze): 'http://backports.debian.org/debian-backports' + * Debian (other): 'http://ftp.debian.org/debian/' + * Ubuntu: 'http://archive.ubuntu.com/ubuntu' + +* `pin`: *Optional.* Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` define, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: '200'. + +* `release`: Specifies a distribution of the Apt repository containing the backports to manage. Valid options: a string containing the release, used in populating the `source.list` configuration file. Default: on Debian and Ubuntu, ''${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating systems. + +* `repos`: Specifies a component of the Apt repository containing the backports to manage. Valid options: A string containing the repos to include, used in populating the `source.list` configuration file. Defaults: + + * Debian: 'main contrib non-free' + * Ubuntu: 'main universe multiverse restricted' + +#### Define: `apt::conf` + +Specifies a custom Apt configuration file. + +##### Parameters + +* `content`: *Required, unless `ensure` is set to 'absent'.* Directly supplies content for the configuration file. Valid options: a string. Default: undef. + +* `ensure`: Specifies whether the configuration file should exist. Valid options: 'present' and 'absent'. Default: 'present'. + +* `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. Valid options: a string containing an integer. Default: '50'. + +#### Define: `apt::key` + +Manages the GPG keys that Apt uses to authenticate packages. + +The `apt::key` define makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. + +##### Parameters (all optional) + +* `content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Valid options: a string. Default: undef. + +* `ensure`: Specifies whether the key should exist. Valid options: 'present' and 'absent'. Default: present. + +* `id`: Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). Default: $title. + +* `options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. + +* `source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. + +* `server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. + +#### Define: `apt::pin` + +Manages Apt pins. + +**Note:** For context on these parameters, we recommend reading the man page ['apt_preferences(5)'](http://linux.die.net/man/5/apt_preferences) + +##### Parameters (all optional) + +* `codename`: Specifies the distribution (lsbdistcodename) of the Apt repository. Valid options: a string. Default: ''. + +* `component`: Names the licensing component associated with the packages in the directory tree of the Release file. Valid options: a string. Default: ''. + +* `ensure`: Specifies whether the pin should exist. Valid options: 'file', 'present', and 'absent'. Default: present. + +* `explanation`: Supplies a comment to explain the pin. Valid options: a string. Default: "${caller_module_name}: ${name}". + +* `label`: Names the label of the packages in the directory tree of the Release file. Valid options: a string (most commonly, 'debian'). Default: ''. + +* `order`: Determines the order in which Apt processes the pin file. Files with lower order numbers are loaded first. Valid options: an integer. Default: 50. + +* `origin`: Tells Apt to prefer packages from the specified server. Valid options: a string containing a hostname. Default: ''. + +* `originator`: Names the originator of the packages in the directory tree of the Release file. Valid options: a string (most commonly, 'debian'). Default: ''. + +* `packages`: Specifies which package(s) to pin. Valid options: a string or an array. Default: '*'. + +* `priority`: Sets the priority of the package. If multiple versions of a given package are available, `apt-get` installs the one with the highest priority number (subject to dependency constraints). Valid options: an integer. Default: 0. + +* `release`: Tells Apt to prefer packages that support the specified release. Typical values include 'stable', 'testing', and 'unstable' Valid options: a string. Default: ''. + +* `release_version`: Tells Apt to prefer packages that support the specified operating system release version (e.g., Debian release version 7). Valid options: a string. Default: ''. + +* `version`: Tells Apt to prefer a specified package version or version range. Valid options: a string. Default: ''. + +#### Define: `apt::ppa` + +Manages PPA repositories using `add-apt-repository`. Not supported on Debian. + +##### Parameters (all optional, except where specified) + +* `ensure`: Specifies whether the PPA should exist. Valid options: 'present' and 'absent'. Default: 'present'. + +* `options`: Supplies options to be passed to the `add-apt-repository` command. Valid options: a string. Defaults: + + * Lucid: undef + * All others: '-y' + +* `package_manage`: Specifies whether Puppet should manage the package that provides `apt-add-repository`. Valid options: 'true' and 'false'. Default: 'false'. + +* `package_name`: Names the package that provides the `apt-add-repository` command. Valid options: a string. Defaults: + + * Lucid and Precise: 'python-software-properties' + * Trusty, Utopic, and Vivid: 'software-properties-common' + * All others: undef + +* `release`: *Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint).* Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename. Default: "$lsbdistcodename". + +#### Define: `apt:setting` + +Manages Apt configuration files. + +##### Parameters + +* `content`: *Required, unless `source` is set.* Directly supplies content for the configuration file. Cannot be used in combination with `source`. Valid options: see the `content` attribute of [Puppet's native `file` type](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-content). Default: undef. + +* `ensure`: Specifies whether the file should exist. Valid options: 'present', 'absent', and 'file'. Default: 'file'. + +* `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'. + +* `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with higher priority numbers are loaded first. Valid options: an integer or zero-padded integer. Default: 50. + +* `source`: *Required, unless `content` is set.* Specifies a source file to supply the content of the configuration file. Cannot be used in combination with `content`. Valid options: see the `source` attribute of [Puppet's native `file` type](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-source). Default: undef. + +#### Define: `apt::source` + +Manages the Apt sources in `/etc/apt/sources.list.d/`. + +##### Parameters (all optional, except where specified) + +* `allow_unsigned`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: 'false'. + +* `architecture`: Tells Apt to only download information for specified architectures. Valid options: a string containing one or more architecture names, separated by commas (e.g., 'i386' or 'i386,alpha,powerpc'). Default: undef (if unspecified, Apt downloads information for all architectures defined in the Apt::Architectures option). + +* `comment`: Supplies a comment for adding to the Apt source file. Valid options: a string. Default: $name. + +* `ensure`: Specifies whether the Apt source file should exist. Valid options: 'present' and 'absent'. Default: present. + +* `key`: Creates a declaration of the apt::key define Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. + +* `include`: Configures include options. Valid options: a hash made up from the following keys: + +* 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false. Default: 'true'. + +* 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. Default: {}. + +* `location`: *Required, unless `ensure` is set to 'absent'.* Specifies an Apt repository. Valid options: a string containing a repository URL. Default: undef. + +* `pin`: Creates a declaration of the apt::pin define Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` define, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: undef. + +* `release`: Specifies a distribution of the Apt repository. Valid options: a string. Default: "$lsbdistcodename". + +* `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'. + +#### Type: `apt_key` + +Manages the GPG keys that Apt uses to authenticate packages. + +**Note:** In most cases, we recommend using the `apt::key` define. It makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. + +##### Parameters (all optional) + +* `content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Cannot be used in combination with `source`. Valid options: a string. Default: undef. + +* `options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. + +* `server`: Specifies a keyserver to provide Puppet's GPG key. Valid options: a string containing a domain name or a full URL. Default: 'keyserver.ubuntu.com'. + +* `source`: Specifies the location of an existing GPG key file to copy. Cannot be used in combination with `content`. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. + +## Limitations + +This module is tested and officially supported on Debian 6 and 7 and Ubuntu 10.04, 12.04, and 14.04. Testing on other platforms has been light and cannot be guaranteed. + +## Development +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. + +For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html) + +To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) \ No newline at end of file From 21a2462a58938d126b66985c0b0fa1f8e09f27cd Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 27 Apr 2015 11:31:39 -0700 Subject: [PATCH 506/574] Compatibility for puppet < 3.5.0 --- manifests/params.pp | 69 +++++++++++++++++++----------- spec/classes/apt_backports_spec.rb | 7 +++ spec/classes/apt_spec.rb | 8 +++- spec/classes/apt_update_spec.rb | 14 +++--- spec/classes/params_spec.rb | 17 +++++++- spec/defines/conf_spec.rb | 2 +- spec/defines/key_spec.rb | 2 +- spec/defines/pin_spec.rb | 2 +- spec/defines/ppa_spec.rb | 10 +++++ spec/defines/setting_spec.rb | 4 +- spec/defines/source_spec.rb | 24 +++++++---- 11 files changed, 109 insertions(+), 50 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 5a0c170d91..32e4dbae6f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,32 +4,45 @@ fail('This module only works on Debian or derivatives like Ubuntu') } - # Strict variables facts lookup compatibility - $xfacts = { - 'lsbdistcodename' => defined('$lsbdistcodename') ? { - true => $::lsbdistcodename, - default => undef, - }, - 'lsbdistrelease' => defined('$lsbdistrelease') ? { - true => $::lsbdistrelease, - default => undef, - }, - 'lsbmajdistrelease' => defined('$lsbmajdistrelease') ? { - true => $::lsbmajdistrelease, - default => undef, - }, - 'lsbdistdescription' => defined('$lsbdistdescription') ? { - true => $::lsbdistdescription, - default => undef, - }, - 'lsbminordistrelease' => defined('$lsbminordistrelease') ? { - true => $::lsbminordistrelease, - default => undef, - }, - 'lsbdistid' => defined('$lsbdistid') ? { - true => $::lsbdistid, - default => undef, - }, + # prior to puppet 3.5.0, defined couldn't test if a variable was defined + # strict variables wasn't added until 3.5.0, so this should be fine. + if versioncmp($::puppetversion, '3.5.0') < 0 { + $xfacts = { + 'lsbdistcodename' => $::lsbdistcodename, + 'lsbdistrelease' => $::lsbdistrelease, + 'lsbmajdistrelease' => $::lsbmajdistrelease, + 'lsbdistdescription' => $::lsbdistdescription, + 'lsbminordistrelease' => $::lsbminordistrelease, + 'lsbdistid' => $::lsbdistid, + } + } else { + # Strict variables facts lookup compatibility + $xfacts = { + 'lsbdistcodename' => defined('$lsbdistcodename') ? { + true => $::lsbdistcodename, + default => undef, + }, + 'lsbdistrelease' => defined('$lsbdistrelease') ? { + true => $::lsbdistrelease, + default => undef, + }, + 'lsbmajdistrelease' => defined('$lsbmajdistrelease') ? { + true => $::lsbmajdistrelease, + default => undef, + }, + 'lsbdistdescription' => defined('$lsbdistdescription') ? { + true => $::lsbdistdescription, + default => undef, + }, + 'lsbminordistrelease' => defined('$lsbminordistrelease') ? { + true => $::lsbminordistrelease, + default => undef, + }, + 'lsbdistid' => defined('$lsbdistid') ? { + true => $::lsbdistid, + default => undef, + }, + } } $root = '/etc/apt' @@ -105,6 +118,10 @@ } } } + + $ppa_options = undef + $ppa_package = undef + } 'ubuntu': { $backports = { diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 1b596789e0..200d6f1333 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -10,6 +10,7 @@ :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', + :puppetversion => '3.5.0', } end it { is_expected.to contain_apt__source('backports').with({ @@ -27,6 +28,7 @@ :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'squeeze', + :puppetversion => '3.5.0', } end it { is_expected.to contain_apt__source('backports').with({ @@ -44,6 +46,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', + :puppetversion => '3.5.0', } end it { is_expected.to contain_apt__source('backports').with({ @@ -61,6 +64,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', + :puppetversion => '3.5.0', } end let(:params) do @@ -87,6 +91,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', + :puppetversion => '3.5.0', } end let(:params) do @@ -112,6 +117,7 @@ :lsbdistid => 'linuxmint', :osfamily => 'Debian', :lsbdistcodename => 'qiana', + :puppetversion => '3.5.0', } end context 'sets all the needed things' do @@ -195,6 +201,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', + :puppetversion => '3.5.0', } end context 'invalid location' do diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index a470667b0d..7e97453b28 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy'} } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0'} } context 'defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({ @@ -132,6 +132,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', + :puppetversion => '3.5.0', } end let(:params) { { :sources => { @@ -173,6 +174,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', + :puppetversion => '3.5.0', } end let(:params) { { :keys => { @@ -198,6 +200,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'ubuntu', + :puppetversion => '3.5.0', } end let(:params) { { :ppas => { @@ -214,6 +217,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', + :puppetversion => '3.5.0', } end let(:params) { { :settings => { @@ -264,7 +268,7 @@ context 'with unsupported osfamily' do let :facts do - { :osfamily => 'Darwin', } + { :osfamily => 'Darwin', :puppetversion => '3.5.0',} end it do diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 8fba4a0c98..11de16aa07 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -5,7 +5,7 @@ context "and apt::update['frequency']='always'" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do #set the apt_update exec's refreshonly attribute to false @@ -14,7 +14,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false @@ -25,7 +25,7 @@ context "and apt::update['frequency']='reluctantly'" do {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy'} } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0',} } let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) @@ -34,7 +34,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) @@ -46,7 +46,7 @@ context "and apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false @@ -55,7 +55,7 @@ end end context 'when the $::apt_update_last_success fact has a recent value' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i, :puppetversion => '3.5.0', } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec\'s refreshonly attribute. (it should be true) @@ -63,7 +63,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil, :puppetversion => '3.5.0', } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index d90ae7e993..e28296b2cc 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::params', :type => :class do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let (:title) { 'my_package' } it { is_expected.to contain_apt__params } @@ -13,7 +13,7 @@ end describe "With lsb-release not installed" do - let(:facts) { { :osfamily => 'Debian' } } + let(:facts) { { :osfamily => 'Debian', :puppetversion => '3.5.0', } } let (:title) { 'my_package' } it do @@ -23,4 +23,17 @@ end end + describe "With old puppet version" do + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :lsbdistrelease => 'foo', :lsbdistdescription => 'bar', :lsbminordistrelease => 'baz', :lsbmajdistrelease => 'foobar', :puppetversion => '3.4.0', } } + let(:title) { 'my_package' } + it { is_expected.to contain_apt__params } + + # There are 4 resources in this class currently + # there should not be any more resources because it is a params class + # The resources are class[apt::params], class[main], class[settings], stage[main] + it "Should not contain any resources" do + expect(subject.call.resources.size).to eq(4) + end + end + end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index d0c5ed976d..1df0f341ee 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -3,7 +3,7 @@ let :pre_condition do 'class { "apt": }' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let :title do 'norecommends' end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 6725dc8f25..c13c255bdb 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -5,7 +5,7 @@ 'class { "apt": }' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index c77bb6ba6e..7ae41a9cba 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -3,7 +3,7 @@ let :pre_condition do 'class { "apt": }' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let(:title) { 'my_pin' } context 'defaults' do diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 7046475736..63c297b82c 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -12,6 +12,7 @@ :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', + :puppetversion => '3.5.0', } end @@ -50,6 +51,7 @@ :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', + :puppetversion => '3.5.0', } end @@ -81,6 +83,7 @@ :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', + :puppetversion => '3.5.0', } end let :params do @@ -119,6 +122,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let :params do @@ -154,6 +158,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let :params do @@ -187,6 +192,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let :params do @@ -220,6 +226,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let :params do @@ -251,6 +258,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let(:title) { 'ppa:foo' } @@ -274,6 +282,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodeanme => nil, + :puppetversion => '3.5.0', } end let(:title) { 'ppa:foo' } @@ -292,6 +301,7 @@ :operatingsystem => 'Debian', :lsbdistid => 'debian', :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let(:title) { 'ppa:foo' } diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 16c80163aa..4ab7595eee 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -2,7 +2,7 @@ describe 'apt::setting' do let(:pre_condition) { 'class { "apt": }' } - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let(:title) { 'conf-teddybear' } let(:default_params) { { :content => 'di' } } @@ -61,7 +61,7 @@ apt::setting { "list-teddybear": content => "foo" } ' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } let(:title) { 'conf-teddybear' } let(:default_params) { { :content => 'di' } } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 24f50f7963..4dff24a467 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -17,7 +17,8 @@ { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', - :osfamily => 'Debian' + :osfamily => 'Debian', + :puppetversion => '3.5.0', } end it do @@ -31,7 +32,8 @@ { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', - :osfamily => 'Debian' + :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let(:params) { { :location => 'hello.there', } } @@ -48,7 +50,8 @@ { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', - :osfamily => 'Debian' + :osfamily => 'Debian', + :puppetversion => '3.5.0', } end @@ -186,7 +189,8 @@ { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', - :osfamily => 'Debian' + :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let :params do @@ -207,7 +211,8 @@ { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', - :osfamily => 'Debian' + :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let :params do @@ -229,7 +234,8 @@ { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', - :osfamily => 'Debian' + :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let :params do @@ -249,7 +255,8 @@ let :facts do { :lsbdistid => 'Debian', - :osfamily => 'Debian' + :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let(:params) { { :location => 'hello.there', } } @@ -266,7 +273,8 @@ { :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', - :osfamily => 'Debian' + :osfamily => 'Debian', + :puppetversion => '3.5.0', } end let :params do From 229518f359bc1874eb1cae4bc6fd00b672975880 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 27 Apr 2015 11:31:23 -0700 Subject: [PATCH 507/574] Make compatibility in metadata.json accurate --- metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index 10e859ef1c..d1fdcabf92 100644 --- a/metadata.json +++ b/metadata.json @@ -27,11 +27,11 @@ "requirements": [ { "name": "pe", - "version_requirement": "3.x" + "version_requirement": ">= 3.3.0" }, { "name": "puppet", - "version_requirement": ">= 3.4.0" + "version_requirement": "3.x" } ], "dependencies": [ From bef7a180635b9c8558b34bbfd73404222eb33dbf Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 27 Apr 2015 14:46:06 -0700 Subject: [PATCH 508/574] 2.0.1 prep --- CHANGELOG.md | 9 +++++++++ metadata.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06eb422d01..d70dfd8447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +##2015-04-28 - Supported Release 2.0.1 +###Summary + +This bug fixes a few compatibility issues that came up with the 2.0.0 release, and includes test and documentation updates. + +####Bugfixes +- Fix incompatibility with keyrings containing multiple keys +- Fix bugs preventing the module from working with Puppet < 3.5.0 + ##2015-04-07 - Supported Release 2.0.0 ###Summary diff --git a/metadata.json b/metadata.json index d1fdcabf92..19cb5ade72 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-apt", - "version": "2.0.0", + "version": "2.0.1", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", From 616516b9d799cad5cfe8171c8087bfc890b6151d Mon Sep 17 00:00:00 2001 From: Pete Soloway Date: Mon, 27 Apr 2015 17:08:42 -0700 Subject: [PATCH 509/574] Correct some README punctuation --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 52030c730a..e8e6d39bd3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 1. [Overview](#overview) 2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with [apt]](#setup) +3. [Setup - The basics of getting started with apt](#setup) * [What apt affects](#what-apt-affects) * [Beginning with apt](#beginning-with-apt) 4. [Usage - Configuration options and additional functionality](#usage) @@ -276,7 +276,7 @@ Manages backports. * `pin`: *Optional.* Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` define, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: '200'. -* `release`: Specifies a distribution of the Apt repository containing the backports to manage. Valid options: a string containing the release, used in populating the `source.list` configuration file. Default: on Debian and Ubuntu, ''${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating systems. +* `release`: Specifies a distribution of the Apt repository containing the backports to manage. Valid options: a string containing the release, used in populating the `source.list` configuration file. Default: on Debian and Ubuntu, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating systems. * `repos`: Specifies a component of the Apt repository containing the backports to manage. Valid options: A string containing the repos to include, used in populating the `source.list` configuration file. Defaults: @@ -305,7 +305,7 @@ The `apt::key` define makes use of the `apt_key` type, but includes extra functi * `content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Valid options: a string. Default: undef. -* `ensure`: Specifies whether the key should exist. Valid options: 'present' and 'absent'. Default: present. +* `ensure`: Specifies whether the key should exist. Valid options: 'present' and 'absent'. Default: 'present'. * `id`: Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). Default: $title. @@ -327,7 +327,7 @@ Manages Apt pins. * `component`: Names the licensing component associated with the packages in the directory tree of the Release file. Valid options: a string. Default: ''. -* `ensure`: Specifies whether the pin should exist. Valid options: 'file', 'present', and 'absent'. Default: present. +* `ensure`: Specifies whether the pin should exist. Valid options: 'file', 'present', and 'absent'. Default: 'present'. * `explanation`: Supplies a comment to explain the pin. Valid options: a string. Default: "${caller_module_name}: ${name}". @@ -400,7 +400,7 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `comment`: Supplies a comment for adding to the Apt source file. Valid options: a string. Default: $name. -* `ensure`: Specifies whether the Apt source file should exist. Valid options: 'present' and 'absent'. Default: present. +* `ensure`: Specifies whether the Apt source file should exist. Valid options: 'present' and 'absent'. Default: 'present'. * `key`: Creates a declaration of the apt::key define Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. From 6e51be76ea09c83d5d1615ad2de50428829559f7 Mon Sep 17 00:00:00 2001 From: Dustin Lactin Date: Wed, 29 Apr 2015 11:36:51 -0600 Subject: [PATCH 510/574] Added new apt_reboot_required fact, updated readme, and added unit tests --- README.md | 4 +++- lib/facter/apt_reboot_required.rb | 7 ++++++ spec/unit/facter/apt_reboot_required_spec.rb | 23 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 lib/facter/apt_reboot_required.rb create mode 100644 spec/unit/facter/apt_reboot_required_spec.rb diff --git a/README.md b/README.md index e8e6d39bd3..3ec5f436c3 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,8 @@ apt::sources: * `apt_update_last_success`: The date, in epochtime, of the most recent successful `apt-get update` run (based on the mtime of /var/lib/apt/periodic/update-success-stamp). +* `apt_reboot_required`: Determines if a reboot is necessary after updates have been installed. + #### Class: `apt` Main class, includes all other classes. @@ -443,4 +445,4 @@ Puppet Labs modules on the Puppet Forge are open projects, and community contrib For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html) -To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) \ No newline at end of file +To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) diff --git a/lib/facter/apt_reboot_required.rb b/lib/facter/apt_reboot_required.rb new file mode 100644 index 0000000000..8de904af2c --- /dev/null +++ b/lib/facter/apt_reboot_required.rb @@ -0,0 +1,7 @@ +# apt_reboot_required.rb +Facter.add(:apt_reboot_required) do + confine :osfamily => 'Debian' + setcode do + File.file?('/var/run/reboot-required') + end +end diff --git a/spec/unit/facter/apt_reboot_required_spec.rb b/spec/unit/facter/apt_reboot_required_spec.rb new file mode 100644 index 0000000000..ab3490a20f --- /dev/null +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe 'apt_reboot_required fact' do + subject { Facter.fact(:apt_reboot_required).value } + after(:each) { Facter.clear } + + describe 'if a reboot is required' do + before { + Facter.fact(:osfamily).stubs(:value).returns 'Debian' + File.stubs(:file?).returns true + } + it { expect(Facter.fact(:apt_reboot_required).value).to eq true } + end + + describe 'if a reboot is not required' do + before { + Facter.fact(:osfamily).stubs(:value).returns 'Debian' + File.stubs(:file?).returns false + } + it { expect(Facter.fact(:apt_reboot_required).value).to eq false } + end + +end From 1318344500cff03cf0c715fd94664d70a7e74358 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 23 Apr 2015 22:54:17 +0200 Subject: [PATCH 511/574] Give clearer instructions around lsb-release --- README.md | 2 ++ manifests/params.pp | 2 +- spec/classes/params_spec.rb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8e6d39bd3..79a0dec5e5 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ The apt module lets you use Puppet to manage Apt sources, keys, and other config Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, and several other operating systems. The apt module provides a series of classes, defines, types, and facts to help you automate Apt package management. +**Note**: For this module to be able to correctly auto detect which version of Debian/Ubuntu or derivative you're running you need to make sure the 'lsb-release' package is installed. We highly recommend making this part of your provisioning layer if you run many Debian or derivative systems or ensuring that you have at least Facter 2.2.0 installed which will pull in this dependency for you. + ## Setup ### What apt affects diff --git a/manifests/params.pp b/manifests/params.pp index 32e4dbae6f..0b1afe74aa 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -150,7 +150,7 @@ } } undef: { - fail('Unable to determine lsbdistid, is lsb-release installed?') + fail('Unable to determine lsbdistid, please install lsb-release first') } default: { $ppa_options = undef diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index e28296b2cc..5d7236ecaa 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -19,7 +19,7 @@ it do expect { subject.call - }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, is lsb-release installed/) + }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, please install lsb-release first/) end end From e3100fc172768ff09b03401ba453d3b98e785f13 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 23 Apr 2015 23:33:58 +0200 Subject: [PATCH 512/574] travis: Test on a bigger matrix * Puppet 3 on all supported Ruby versions with strict variables and random ordering. * Puppet 3 on 2.1 with strict variables, future parser and random ordering. * Puppet 4 on all supported Ruby versions and random ordering. --- .travis.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ff1d8a2a6..22ee56f6b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,21 +7,26 @@ matrix: fast_finish: true include: - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" + - rvm: 2.1 + env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" + - rvm: 2.1 + env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 4.0" + env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 4.0" - allow_failures: - - env: PUPPET_GEM_VERSION="~> 4.0" - - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" + - rvm: 2.1 + env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" notifications: email: false From f62d6a9adfec074895b7c7d781d3d6e1c4b711a3 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 23 Apr 2015 23:36:58 +0200 Subject: [PATCH 513/574] Gemfile: Upgrade to rspec-puppet 2.1+ This is needed in order to be able to test on Puppet 4. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 64e206f185..0cd8078115 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ end group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-core', '3.1.7', :require => false - gem 'rspec-puppet', '~> 2.0', :require => false + gem 'rspec-puppet', '~> 2.1', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false gem 'simplecov', :require => false From 494abedaebb87be7208581e28142f68a3f3404a2 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 24 Apr 2015 00:12:30 +0200 Subject: [PATCH 514/574] Work around PUP-4133 --- manifests/ppa.pp | 4 ++-- manifests/source.pp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 808c9751a0..f3e2bfda04 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -31,9 +31,9 @@ $_proxy = $::apt::_proxy if $_proxy['host'] { if $_proxy['https'] { - $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=https://${_proxy['host']}:${_proxy['port']}"] + $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}", "https_proxy=https://${$_proxy['host']}:${$_proxy['port']}"] } else { - $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}"] + $_proxy_env = ["http_proxy=http://${$_proxy['host']}:${$_proxy['port']}"] } } else { $_proxy_env = [] diff --git a/manifests/source.pp b/manifests/source.pp index 40fc015bb6..958bf25c79 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -65,7 +65,7 @@ # We do not want to remove keys when the source is absent. if $key and ($ensure == 'present') { if is_hash($_key) { - apt::key { "Add key: ${_key['id']} from Apt::Source ${title}": + apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}": ensure => present, id => $_key['id'], server => $_key['server'], From bb692503bb699b1e675c86dc9bcd08effb746f07 Mon Sep 17 00:00:00 2001 From: Dustin Lactin Date: Wed, 29 Apr 2015 15:51:59 -0600 Subject: [PATCH 515/574] Removed eol from README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ec5f436c3..f3a8fc7005 100644 --- a/README.md +++ b/README.md @@ -445,4 +445,4 @@ Puppet Labs modules on the Puppet Forge are open projects, and community contrib For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html) -To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) +To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) \ No newline at end of file From 1be2560e1e6afc7ff19fe52688e0e9e753f92f00 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 30 Apr 2015 12:54:37 -0700 Subject: [PATCH 516/574] Stubbing File.file? is hard --- spec/unit/facter/apt_reboot_required_spec.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/unit/facter/apt_reboot_required_spec.rb b/spec/unit/facter/apt_reboot_required_spec.rb index ab3490a20f..ed6efd075e 100644 --- a/spec/unit/facter/apt_reboot_required_spec.rb +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -6,18 +6,20 @@ describe 'if a reboot is required' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' + Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' File.stubs(:file?).returns true + File.expects(:file?).at_least(1).with('/var/run/reboot-required').returns true } - it { expect(Facter.fact(:apt_reboot_required).value).to eq true } + it { is_expected.to eq true } end describe 'if a reboot is not required' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:file?).returns false + Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' + File.stubs(:file?).returns true + File.expects(:file?).at_least(1).with('/var/run/reboot-required').returns false } - it { expect(Facter.fact(:apt_reboot_required).value).to eq false } + it { is_expected.to eq false } end end From b7c6e804978c8faa868bab358c450e267c9d00a3 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Thu, 30 Apr 2015 23:20:12 +0200 Subject: [PATCH 517/574] Test with strict variables on Puppet 4 too. It's only as of Puppet 5 that strict variables becomes the default so we need to specify it too for Puppet 4. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 22ee56f6b3..167abaca8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,10 +23,10 @@ matrix: - rvm: 2.1 env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" + env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" STRICT_VARIABLES="yes" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" + env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" STRICT_VARIABLES="yes" - rvm: 2.1 - env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" + env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" STRICT_VARIABLES="yes" notifications: email: false From 3d3e2449f38c1f2abc5f02e8af8358ed27be7e53 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 6 May 2015 14:38:15 -0700 Subject: [PATCH 518/574] test against puppet4 --- .sync.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.sync.yml b/.sync.yml index 08e91a74a0..59b44a0855 100644 --- a/.sync.yml +++ b/.sync.yml @@ -7,3 +7,5 @@ env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" From 48152d4a89f17a06ddae5ac5dba774bed8a8a887 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 6 May 2015 15:10:05 -0700 Subject: [PATCH 519/574] Don't stub puppetversion The puppetversion fact still needs to represent puppet's version that is being used to test --- spec/classes/apt_backports_spec.rb | 14 +++++++------- spec/classes/apt_spec.rb | 12 ++++++------ spec/classes/apt_update_spec.rb | 14 +++++++------- spec/classes/params_spec.rb | 18 ++---------------- spec/defines/conf_spec.rb | 2 +- spec/defines/key_spec.rb | 2 +- spec/defines/pin_spec.rb | 2 +- spec/defines/ppa_spec.rb | 20 ++++++++++---------- spec/defines/setting_spec.rb | 4 ++-- spec/defines/source_spec.rb | 16 ++++++++-------- 10 files changed, 45 insertions(+), 59 deletions(-) diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 200d6f1333..efaa9cc955 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -10,7 +10,7 @@ :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end it { is_expected.to contain_apt__source('backports').with({ @@ -28,7 +28,7 @@ :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'squeeze', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end it { is_expected.to contain_apt__source('backports').with({ @@ -46,7 +46,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end it { is_expected.to contain_apt__source('backports').with({ @@ -64,7 +64,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:params) do @@ -91,7 +91,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:params) do @@ -117,7 +117,7 @@ :lsbdistid => 'linuxmint', :osfamily => 'Debian', :lsbdistcodename => 'qiana', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end context 'sets all the needed things' do @@ -201,7 +201,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodename => 'trusty', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end context 'invalid location' do diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 7e97453b28..1c8cac7a03 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0'} } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version} } context 'defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({ @@ -132,7 +132,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:params) { { :sources => { @@ -174,7 +174,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:params) { { :keys => { @@ -200,7 +200,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'ubuntu', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:params) { { :ppas => { @@ -217,7 +217,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:params) { { :settings => { @@ -268,7 +268,7 @@ context 'with unsupported osfamily' do let :facts do - { :osfamily => 'Darwin', :puppetversion => '3.5.0',} + { :osfamily => 'Darwin', :puppetversion => Puppet.version,} end it do diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 11de16aa07..d031104ddd 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -5,7 +5,7 @@ context "and apt::update['frequency']='always'" do { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do #set the apt_update exec's refreshonly attribute to false @@ -14,7 +14,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false @@ -25,7 +25,7 @@ context "and apt::update['frequency']='reluctantly'" do {'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0',} } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version,} } let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) @@ -34,7 +34,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec's refreshonly attribute. (it should be true) @@ -46,7 +46,7 @@ context "and apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "and $::apt_update_last_success indicates #{desc}" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false @@ -55,7 +55,7 @@ end end context 'when the $::apt_update_last_success fact has a recent value' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i, :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i, :puppetversion => Puppet.version, } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'should not trigger an apt-get update run' do #don't change the apt_update exec\'s refreshonly attribute. (it should be true) @@ -63,7 +63,7 @@ end end context 'when $::apt_update_last_success is nil' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil, :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil, :puppetversion => Puppet.version, } } let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } it 'should trigger an apt-get update run' do #set the apt_update exec\'s refreshonly attribute to false diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index 5d7236ecaa..e9eb6fb9d6 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt::params', :type => :class do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let (:title) { 'my_package' } it { is_expected.to contain_apt__params } @@ -13,7 +13,7 @@ end describe "With lsb-release not installed" do - let(:facts) { { :osfamily => 'Debian', :puppetversion => '3.5.0', } } + let(:facts) { { :osfamily => 'Debian', :puppetversion => Puppet.version, } } let (:title) { 'my_package' } it do @@ -22,18 +22,4 @@ }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, please install lsb-release first/) end end - - describe "With old puppet version" do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :lsbdistrelease => 'foo', :lsbdistdescription => 'bar', :lsbminordistrelease => 'baz', :lsbmajdistrelease => 'foobar', :puppetversion => '3.4.0', } } - let(:title) { 'my_package' } - it { is_expected.to contain_apt__params } - - # There are 4 resources in this class currently - # there should not be any more resources because it is a params class - # The resources are class[apt::params], class[main], class[settings], stage[main] - it "Should not contain any resources" do - expect(subject.call.resources.size).to eq(4) - end - end - end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 1df0f341ee..f0192d61c4 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -3,7 +3,7 @@ let :pre_condition do 'class { "apt": }' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let :title do 'norecommends' end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index c13c255bdb..d4a85a4150 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -5,7 +5,7 @@ 'class { "apt": }' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 7ae41a9cba..9fb28c6652 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -3,7 +3,7 @@ let :pre_condition do 'class { "apt": }' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let(:title) { 'my_pin' } context 'defaults' do diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 63c297b82c..c110e50f43 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -12,7 +12,7 @@ :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end @@ -51,7 +51,7 @@ :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end @@ -83,7 +83,7 @@ :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do @@ -122,7 +122,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do @@ -158,7 +158,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do @@ -192,7 +192,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do @@ -226,7 +226,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do @@ -258,7 +258,7 @@ :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:title) { 'ppa:foo' } @@ -282,7 +282,7 @@ :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodeanme => nil, - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:title) { 'ppa:foo' } @@ -301,7 +301,7 @@ :operatingsystem => 'Debian', :lsbdistid => 'debian', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:title) { 'ppa:foo' } diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 4ab7595eee..b109ea6b6b 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -2,7 +2,7 @@ describe 'apt::setting' do let(:pre_condition) { 'class { "apt": }' } - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let(:title) { 'conf-teddybear' } let(:default_params) { { :content => 'di' } } @@ -61,7 +61,7 @@ apt::setting { "list-teddybear": content => "foo" } ' end - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => '3.5.0', } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } } let(:title) { 'conf-teddybear' } let(:default_params) { { :content => 'di' } } diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 4dff24a467..26c8fa78d2 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -18,7 +18,7 @@ :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end it do @@ -33,7 +33,7 @@ :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:params) { { :location => 'hello.there', } } @@ -51,7 +51,7 @@ :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end @@ -190,7 +190,7 @@ :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do @@ -212,7 +212,7 @@ :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do @@ -235,7 +235,7 @@ :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do @@ -256,7 +256,7 @@ { :lsbdistid => 'Debian', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let(:params) { { :location => 'hello.there', } } @@ -274,7 +274,7 @@ :lsbdistid => 'Debian', :lsbdistcodename => 'wheezy', :osfamily => 'Debian', - :puppetversion => '3.5.0', + :puppetversion => Puppet.version, } end let :params do From b9822c6eb75b8a4fc108a736b310c2647afddc03 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 6 May 2015 15:15:21 -0700 Subject: [PATCH 520/574] sync via modulesync --- .travis.yml | 24 +++++------------------- Gemfile | 11 ++++------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 167abaca8e..76217a1eb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,18 @@ --- -language: ruby sudo: false +language: ruby bundler_args: --without system_tests script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" matrix: fast_finish: true include: - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" - - rvm: 2.1 - env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" - - rvm: 2.1 - env: PUPPET_GEM_VERSION="~> 3.0" ORDERING="random" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" STRICT_VARIABLES="yes" + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" STRICT_VARIABLES="yes" - - rvm: 2.1 - env: PUPPET_GEM_VERSION="~> 4.0" ORDERING="random" STRICT_VARIABLES="yes" + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" notifications: email: false diff --git a/Gemfile b/Gemfile index 0cd8078115..2b1b7cd8d9 100644 --- a/Gemfile +++ b/Gemfile @@ -11,23 +11,18 @@ def location_for(place, fake_version = nil) end group :development, :unit_tests do - gem 'rake', :require => false gem 'rspec-core', '3.1.7', :require => false - gem 'rspec-puppet', '~> 2.1', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', :require => false gem 'simplecov', :require => false gem 'puppet_facts', :require => false gem 'json', :require => false end -beaker_version = ENV['BEAKER_VERSION'] -beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] group :system_tests do - if beaker_version + if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) end - if beaker_rspec_version + if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] gem 'beaker-rspec', *location_for(beaker_rspec_version) else gem 'beaker-rspec', :require => false @@ -35,6 +30,8 @@ group :system_tests do gem 'serverspec', :require => false end + + if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion, :require => false else From 9699b42d976256b460dbd67cc8b7249912ba26d9 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 7 May 2015 09:48:33 -0700 Subject: [PATCH 521/574] Add gem to sync.yml --- .sync.yml | 20 +++++++++++++++++--- .travis.yml | 6 +++--- Gemfile | 18 +----------------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.sync.yml b/.sync.yml index 59b44a0855..3c87782f80 100644 --- a/.sync.yml +++ b/.sync.yml @@ -2,10 +2,24 @@ .travis.yml: includes: - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" +Gemfile: + required: + ':development, :unit_tests': + - gem: rspec-puppet + version: '~> 2.1' + - gem: rspec-core + version: '3.1.7' + - gem: puppetlabs_spec_helper + - gem: simplecov + - gem: puppet_facts + - gem: json + ':system_tests': + - gem: beaker-rspec + - gem: serverspec diff --git a/.travis.yml b/.travis.yml index 76217a1eb4..a4bcba6001 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,11 @@ matrix: fast_finish: true include: - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" notifications: diff --git a/Gemfile b/Gemfile index 2b1b7cd8d9..9f4f7b6250 100644 --- a/Gemfile +++ b/Gemfile @@ -11,23 +11,7 @@ def location_for(place, fake_version = nil) end group :development, :unit_tests do - gem 'rspec-core', '3.1.7', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'simplecov', :require => false - gem 'puppet_facts', :require => false - gem 'json', :require => false -end - -group :system_tests do - if beaker_version = ENV['BEAKER_VERSION'] - gem 'beaker', *location_for(beaker_version) - end - if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] - gem 'beaker-rspec', *location_for(beaker_rspec_version) - else - gem 'beaker-rspec', :require => false - end - gem 'serverspec', :require => false + gem 'rspec-puppet', '~> 2.1', :require => false end From cbaf43d7a1ceee1fe815d0ccd1dc591523ecb0af Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 7 May 2015 10:09:21 -0700 Subject: [PATCH 522/574] have the right gems --- Gemfile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Gemfile b/Gemfile index 9f4f7b6250..b3facaaad1 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,23 @@ end group :development, :unit_tests do gem 'rspec-puppet', '~> 2.1', :require => false + gem 'rspec-core', '3.1.7', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'simplecov', :require => false + gem 'puppet_facts', :require => false + gem 'json', :require => false +end + +group :system_tests do + if beaker_version = ENV['BEAKER_VERSION'] + gem 'beaker', *location_for(beaker_version) + end + if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end + gem 'serverspec', :require => false end From 3838c666f561278f2caa73d50d392bfa2f9f8b1f Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 11 May 2015 10:26:20 -0700 Subject: [PATCH 523/574] Only use the strict variables workaround if using strict variables This should avoid issues with defined on earlier versions of puppet --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 0b1afe74aa..d4f838946a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,7 +6,7 @@ # prior to puppet 3.5.0, defined couldn't test if a variable was defined # strict variables wasn't added until 3.5.0, so this should be fine. - if versioncmp($::puppetversion, '3.5.0') < 0 { + if ! $::settings::strict_variables { $xfacts = { 'lsbdistcodename' => $::lsbdistcodename, 'lsbdistrelease' => $::lsbdistrelease, From e52145110c28b714da78f0cfcb32d8e3b858ae29 Mon Sep 17 00:00:00 2001 From: Ian MacLennan Date: Mon, 25 May 2015 09:28:04 -0400 Subject: [PATCH 524/574] Backwards compatibility with older versions of puppet --- manifests/init.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 5d9baa29ed..ded13f2fc4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -72,13 +72,13 @@ } $sources_list_content = $_purge['sources.list'] ? { - false => undef, - true => "# Repos managed by puppet.\n", + true => "# Repos managed by puppet.\n", + default => undef, } $preferences_ensure = $_purge['preferences'] ? { - false => file, - true => absent, + true => absent, + default => file, } if $_update['frequency'] == 'always' { From 8260d7a95c80cae25ca01dd39418137fd4faf3fe Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 27 May 2015 08:11:16 -0700 Subject: [PATCH 525/574] Add ability to unittest puppet 4 --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index a4bcba6001..2abfca1373 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,5 +14,8 @@ matrix: env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" + allow_failures: + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" notifications: email: false From a467f1b978976b3283161bae04ef00225f757f94 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Wed, 27 May 2015 08:25:44 -0700 Subject: [PATCH 526/574] Fix travis.yml for puppet 4 I accidentally pushed a commit with modulesync that made puppet 4 a non-voting job. This should make it more in line with modulesync. Also, we should look at bumping these ORDERING="random" changes back to msync if they are valuable. --- .sync.yml | 3 ++- .travis.yml | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.sync.yml b/.sync.yml index 3c87782f80..625d045a31 100644 --- a/.sync.yml +++ b/.sync.yml @@ -7,8 +7,9 @@ env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - - rvm: 2.0.0 + - rvm: 2.1.6 env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" + allow_failures: Gemfile: required: ':development, :unit_tests': diff --git a/.travis.yml b/.travis.yml index 2abfca1373..8b6adc2d2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,7 @@ matrix: env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - - rvm: 2.0.0 + - rvm: 2.1.6 env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" - allow_failures: - - rvm: 2.1.6 - env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" notifications: email: false From d50fef82e8a1865fda8fdfa5f7afa0aaa6465163 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 4 Jun 2015 09:41:27 -0700 Subject: [PATCH 527/574] Make apt::key compatible with 1.8.x --- README.md | 12 +- manifests/key.pp | 155 ++++++++-------- spec/defines/key_compat_spec.rb | 316 ++++++++++++++++++++++++++++++++ 3 files changed, 400 insertions(+), 83 deletions(-) create mode 100644 spec/defines/key_compat_spec.rb diff --git a/README.md b/README.md index ec27807eac..0e2dfd6520 100644 --- a/README.md +++ b/README.md @@ -319,6 +319,16 @@ The `apt::key` define makes use of the `apt_key` type, but includes extra functi * `server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. +* `key`: Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). Default: undef. **Note** This parameter is deprecated and will be removed in a future release. + +* `key_content`: Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. + +* `key_source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. + +* `key_server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com' .**Note** This parameter is deprecated and will be removed in a future release. + +* `key_options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. + #### Define: `apt::pin` Manages Apt pins. @@ -447,4 +457,4 @@ Puppet Labs modules on the Puppet Forge are open projects, and community contrib For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html) -To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) \ No newline at end of file +To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-apt/graphs/contributors) diff --git a/manifests/key.pp b/manifests/key.pp index 6761e6912d..8fbb47abd0 100644 --- a/manifests/key.pp +++ b/manifests/key.pp @@ -1,115 +1,106 @@ # == Define: apt::key -# -# The apt::key defined type allows for keys to be added to apt's keyring -# which is used for package validation. This defined type uses the apt_key -# native type to manage keys. This is a simple wrapper around apt_key with -# a few safeguards in place. -# -# === Parameters -# -# [*id*] -# _default_: +$title+, the title/name of the resource -# -# Is a GPG key ID or full key fingerprint. This value is validated with -# a regex enforcing it to only contain valid hexadecimal characters, be -# precisely 8 or 16 hexadecimal characters long and optionally prefixed -# with 0x for key IDs, or 40 hexadecimal characters long for key -# fingerprints. -# -# [*ensure*] -# _default_: +present+ -# -# The state we want this key in, may be either one of: -# * +present+ -# * +absent+ -# -# [*content*] -# _default_: +undef+ -# -# This parameter can be used to pass in a GPG key as a -# string in case it cannot be fetched from a remote location -# and using a file resource is for other reasons inconvenient. -# -# [*source*] -# _default_: +undef+ -# -# This parameter can be used to pass in the location of a GPG -# key. This URI can take the form of a: -# * +URL+: ftp, http or https -# * +path+: absolute path to a file on the target system. -# -# [*server*] -# _default_: +undef+ -# -# The keyserver from where to fetch our GPG key. It can either be a domain -# name or url. It defaults to +keyserver.ubuntu.com+. -# -# [*options*] -# _default_: +undef+ -# -# Additional options to pass on to `apt-key adv --keyserver-options`. define apt::key ( - $id = $title, - $ensure = present, - $content = undef, - $source = undef, - $server = $::apt::keyserver, - $options = undef, + $id = $title, + $ensure = present, + $content = undef, + $source = undef, + $server = $::apt::keyserver, + $options = undef, + $key = undef, + $key_content = undef, + $key_source = undef, + $key_server = undef, + $key_options = undef, ) { - validate_re($id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z']) + if $key != undef { + warning('$key is deprecated and will be removed in the next major release. Please use $id instead.') + $_id = $key + } else { + $_id = $id + } + + if $key_content != undef { + warning('$key_content is deprecated and will be removed in the next major release. Please use $content instead.') + $_content = $key_content + } else { + $_content = $content + } + + if $key_source != undef { + warning('$key_source is deprecated and will be removed in the next major release. Please use $source instead.') + $_source = $key_source + } else { + $_source = $source + } + + if $key_server != undef { + warning('$key_server is deprecated and will be removed in the next major release. Please use $server instead.') + $_server = $key_server + } else { + $_server = $server + } + + if $key_options != undef { + warning('$key_options is deprecated and will be removed in the next major release. Please use $options instead.') + $_options = $key_options + } else { + $_options = $options + } + + validate_re($_id, ['\A(0x)?[0-9a-fA-F]{8}\Z', '\A(0x)?[0-9a-fA-F]{16}\Z', '\A(0x)?[0-9a-fA-F]{40}\Z']) validate_re($ensure, ['\Aabsent|present\Z',]) - if $content { - validate_string($content) + if $_content { + validate_string($_content) } - if $source { - validate_re($source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+']) + if $_source { + validate_re($_source, ['\Ahttps?:\/\/', '\Aftp:\/\/', '\A\/\w+']) } - if $server { - validate_re($server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$']) + if $_server { + validate_re($_server,['\A((hkp|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?$']) } - if $options { - validate_string($options) + if $_options { + validate_string($_options) } case $ensure { present: { - if defined(Anchor["apt_key ${id} absent"]){ - fail("key with id ${id} already ensured as absent") + if defined(Anchor["apt_key ${_id} absent"]){ + fail("key with id ${_id} already ensured as absent") } - if !defined(Anchor["apt_key ${id} present"]) { + if !defined(Anchor["apt_key ${_id} present"]) { apt_key { $title: ensure => $ensure, - id => $id, - source => $source, - content => $content, - server => $server, - options => $options, + id => $_id, + source => $_source, + content => $_content, + server => $_server, + options => $_options, } -> - anchor { "apt_key ${id} present": } + anchor { "apt_key ${_id} present": } } } absent: { - if defined(Anchor["apt_key ${id} present"]){ - fail("key with id ${id} already ensured as present") + if defined(Anchor["apt_key ${_id} present"]){ + fail("key with id ${_id} already ensured as present") } - if !defined(Anchor["apt_key ${id} absent"]){ + if !defined(Anchor["apt_key ${_id} absent"]){ apt_key { $title: ensure => $ensure, - id => $id, - source => $source, - content => $content, - server => $server, - options => $options, + id => $_id, + source => $_source, + content => $_content, + server => $_server, + options => $_options, } -> - anchor { "apt_key ${id} absent": } + anchor { "apt_key ${_id} absent": } } } diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb new file mode 100644 index 0000000000..872bcadcd6 --- /dev/null +++ b/spec/defines/key_compat_spec.rb @@ -0,0 +1,316 @@ +require 'spec_helper' + +describe 'apt::key', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } + GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' + + let :title do + GPG_KEY_ID + end + + describe 'normal operation' do + describe 'default options' do + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{title} present") + end + end + + describe 'title and key =>' do + let :title do + 'puppetlabs' + end + + let :params do { + :key => GPG_KEY_ID, + } end + + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => GPG_KEY_ID, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{GPG_KEY_ID} present") + end + end + + describe 'ensure => absent' do + let :params do { + :ensure => 'absent', + } end + + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'absent', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + end + it 'contains the apt_key absent anchor' do + should contain_anchor("apt_key #{title} absent") + end + end + + describe 'set a bunch of things!' do + let :params do { + :key_content => 'GPG key content', + :key_source => 'http://apt.puppetlabs.com/pubkey.gpg', + :key_server => 'pgp.mit.edu', + :key_options => 'debug', + } end + + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :ensure => 'present', + :source => 'http://apt.puppetlabs.com/pubkey.gpg', + :server => 'pgp.mit.edu', + :content => params[:key_content], + :options => 'debug', + }) + end + it 'contains the apt_key present anchor' do + should contain_anchor("apt_key #{title} present") + end + end + + context "domain with dash" do + let(:params) do{ + :key_server => 'p-gp.m-it.edu', + } end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :server => 'p-gp.m-it.edu', + }) + end + end + + context "url" do + let :params do + { + :key_server => 'hkp://pgp.mit.edu', + } + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :server => 'hkp://pgp.mit.edu', + }) + end + end + context "url with port number" do + let :params do + { + :key_server => 'hkp://pgp.mit.edu:80', + } + end + it 'contains the apt_key' do + should contain_apt_key(title).with({ + :id => title, + :server => 'hkp://pgp.mit.edu:80', + }) + end + end + end + + describe 'validation' do + context "domain begin with dash" do + let(:params) do{ + :key_server => '-pgp.mit.edu', + } end + it 'fails' do + expect { subject.call } .to raise_error(/does not match/) + end + end + + context "domain begin with dot" do + let(:params) do{ + :key_server => '.pgp.mit.edu', + } end + it 'fails' do + expect { subject.call } .to raise_error(/does not match/) + end + end + + context "domain end with dot" do + let(:params) do{ + :key_server => "pgp.mit.edu.", + } end + it 'fails' do + expect { subject.call } .to raise_error(/does not match/) + end + end + context "exceed character url" do + let :params do + { + :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' + } + end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + context "incorrect port number url" do + let :params do + { + :key_server => 'hkp://pgp.mit.edu:8008080' + } + end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + context "incorrect protocol for url" do + let :params do + { + :key_server => 'abc://pgp.mit.edu:80' + } + end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + context "missing port number url" do + let :params do + { + :key_server => 'hkp://pgp.mit.edu:' + } + end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + context "url ending with a dot" do + let :params do + { + :key_server => 'hkp://pgp.mit.edu.' + } + end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + context "url begin with a dash" do + let(:params) do{ + :key_server => "hkp://-pgp.mit.edu", + } end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + context 'invalid key' do + let :title do + 'Out of rum. Why? Why are we out of rum?' + end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + + context 'invalid source' do + let :params do { + :key_source => 'afp://puppetlabs.com/key.gpg', + } end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + + context 'invalid content' do + let :params do { + :key_content => [], + } end + it 'fails' do + expect { subject.call }.to raise_error(/is not a string/) + end + end + + context 'invalid server' do + let :params do { + :key_server => 'two bottles of rum', + } end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + + context 'invalid keyserver_options' do + let :params do { + :key_options => {}, + } end + it 'fails' do + expect { subject.call }.to raise_error(/is not a string/) + end + end + + context 'invalid ensure' do + let :params do + { + :ensure => 'foo', + } + end + it 'fails' do + expect { subject.call }.to raise_error(/does not match/) + end + end + + describe 'duplication' do + context 'two apt::key resources for same key, different titles' do + let :pre_condition do + "apt::key { 'duplicate': key => '#{title}', }" + end + + it 'contains two apt::key resources' do + should contain_apt__key('duplicate').with({ + :key => title, + :ensure => 'present', + }) + should contain_apt__key(title).with({ + :id => title, + :ensure => 'present', + }) + end + + it 'contains only a single apt_key' do + should contain_apt_key('duplicate').with({ + :id => title, + :ensure => 'present', + :source => nil, + :server => nil, + :content => nil, + :keyserver_options => nil, + }) + should_not contain_apt_key(title) + end + end + + context 'two apt::key resources, different ensure' do + let :pre_condition do + "apt::key { 'duplicate': key => '#{title}', ensure => 'absent', }" + end + it 'informs the user of the impossibility' do + expect { subject.call }.to raise_error(/already ensured as absent/) + end + end + end + end +end From 396f308e6ad4798461a6471ee8bb8e764d8b03cb Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 3 Jun 2015 17:19:16 -0700 Subject: [PATCH 528/574] Compatibility between 1.8.x and 2.x for apt::source --- README.md | 20 +++- manifests/setting.pp | 5 +- manifests/source.pp | 128 +++++++++++++++++------ spec/defines/source_compat_spec.rb | 158 +++++++++++++++++++++++++++++ spec/defines/source_spec.rb | 94 +++++++++++++++++ templates/source.list.erb | 12 +-- 6 files changed, 377 insertions(+), 40 deletions(-) create mode 100644 spec/defines/source_compat_spec.rb diff --git a/README.md b/README.md index 0e2dfd6520..4babf3c71b 100644 --- a/README.md +++ b/README.md @@ -418,11 +418,11 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `key`: Creates a declaration of the apt::key define Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. -* `include`: Configures include options. Valid options: a hash made up from the following keys: +* `include`: Configures include options. Valid options: a hash made up from the following keys: Default: {} -* 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false. Default: 'true'. +* 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false'. Default: 'true'. -* 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. Default: {}. +* 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. * `location`: *Required, unless `ensure` is set to 'absent'.* Specifies an Apt repository. Valid options: a string containing a repository URL. Default: undef. @@ -432,6 +432,20 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'. +* `include_deb`: Specify whether to request the distrubution's compiled binaries. Valid options: 'true' and 'false'. Default: undef **Note** this parameter is deprecated and will be removed in future versions of the module. + +* `include_src`: Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: undef **Note** this parameter is deprecated andd will be removed in future versions of the module. + +* `required_packages`: install packages required for this Apt source via an exec. Default: 'false'. **Note** this parameter is deprecated and will be removed in future versions of the module. + +* `key_content`: Specify the content to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. + +* `key_server`: Specify the server to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. + +* `key_source`: Specify the source to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. + +* `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. + #### Type: `apt_key` Manages the GPG keys that Apt uses to authenticate packages. diff --git a/manifests/setting.pp b/manifests/setting.pp index ab84460232..59d0dd4dfe 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -6,6 +6,7 @@ $notify_update = true, ) { + include 'apt::params' if $content and $source { fail('apt::setting cannot have both content and source') } @@ -42,8 +43,8 @@ $_priority = $priority } - $_path = $::apt::config_files[$setting_type]['path'] - $_ext = $::apt::config_files[$setting_type]['ext'] + $_path = $::apt::params::config_files[$setting_type]['path'] + $_ext = $::apt::params::config_files[$setting_type]['ext'] if $notify_update { $_notify = Exec['apt_update'] diff --git a/manifests/source.pp b/manifests/source.pp index 958bf25c79..734f375f21 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -1,41 +1,114 @@ # source.pp # add an apt source define apt::source( - $location = undef, - $comment = $name, - $ensure = present, - $release = $::apt::xfacts['lsbdistcodename'], - $repos = 'main', - $include = {}, - $key = undef, - $pin = undef, - $architecture = undef, - $allow_unsigned = false, + $location = undef, + $comment = $name, + $ensure = present, + $release = undef, + $repos = 'main', + $include = {}, + $key = undef, + $pin = undef, + $architecture = undef, + $allow_unsigned = false, + $include_src = undef, + $include_deb = undef, + $required_packages = undef, + $key_server = undef, + $key_content = undef, + $key_source = undef, + $trusted_source = undef, ) { validate_string($architecture, $comment, $location, $repos) validate_bool($allow_unsigned) validate_hash($include) - unless $release { - fail('lsbdistcodename fact not available: release parameter required') + include 'apt::params' + + $_before = Apt::Setting["list-${title}"] + + if $include_src != undef { + warning("\$include_src is deprecated and will be removed in the next major release, please use \$include => { 'src' => ${include_src} } instead") + } + + if $include_deb != undef { + warning("\$include_deb is deprecated and will be removed in the next major release, please use \$include => { 'deb' => ${include_deb} } instead") + } + + if $required_packages != undef { + warning('$required_packages is deprecated and will be removed in the next major release, please use package resources instead.') + exec { "Required packages: '${required_packages}' for ${name}": + command => "${::apt::params::provider} -y install ${required_packages}", + logoutput => 'on_failure', + refreshonly => true, + tries => 3, + try_sleep => 1, + before => $_before, + } + } + + if $key_server != undef { + warning("\$key_server is deprecated and will be removed in the next major release, please use \$key => { 'server' => ${key_server} } instead.") + } + + if $key_content != undef { + warning("\$key_content is deprecated and will be removed in the next major release, please use \$key => { 'content' => ${key_content} } instead.") + } + + if $key_source != undef { + warning("\$key_source is deprecated and will be removed in the next major release, please use \$key => { 'source' => ${key_source} } instead.") + } + + if $trusted_source != undef { + warning('$trusted_source is deprecated and will be removed in the next major release, please use $allow_unsigned instead.') + $_allow_unsigned = $trusted_source + } else { + $_allow_unsigned = $allow_unsigned + } + + if ! $release { + $_release = $::apt::params::xfacts['lsbdistcodename'] + unless $_release { + fail('lsbdistcodename fact not available: release parameter required') + } + } else { + $_release = $release } if $ensure == 'present' and ! $location { fail('cannot create a source entry without specifying a location') } - $_before = Apt::Setting["list-${title}"] - $_include = merge($::apt::include_defaults, $include) + if $include_src != undef and $include_deb != undef { + $_deprecated_include = { + 'src' => $include_src, + 'deb' => $include_deb, + } + } elsif $include_src != undef { + $_deprecated_include = { 'src' => $include_src } + } elsif $include_deb != undef { + $_deprecated_include = { 'deb' => $include_deb } + } else { + $_deprecated_include = {} + } + + $_include = merge($::apt::params::include_defaults, $_deprecated_include, $include) + + $_deprecated_key = { + 'key_server' => $key_server, + 'key_content' => $key_content, + 'key_source' => $key_source, + } if $key { if is_hash($key) { unless $key['id'] { fail('key hash must contain at least an id entry') } - $_key = merge($::apt::source_key_defaults, $key) + $_key = merge($::apt::params::source_key_defaults, $_deprecated_key, $key) } else { validate_string($key) - $_key = $key + $_key = merge( { 'id' => $key }, $_deprecated_key) } } @@ -66,19 +139,16 @@ if $key and ($ensure == 'present') { if is_hash($_key) { apt::key { "Add key: ${$_key['id']} from Apt::Source ${title}": - ensure => present, - id => $_key['id'], - server => $_key['server'], - content => $_key['content'], - source => $_key['source'], - options => $_key['options'], - before => $_before, - } - } else { - apt::key { "Add key: ${_key} from Apt::Source ${title}": - ensure => present, - id => $_key, - before => $_before, + ensure => present, + id => $_key['id'], + server => $_key['server'], + content => $_key['content'], + source => $_key['source'], + options => $_key['options'], + key_server => $_key['key_server'], + key_content => $_key['key_content'], + key_source => $_key['key_source'], + before => $_before, } } } diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb new file mode 100644 index 0000000000..2e813f327b --- /dev/null +++ b/spec/defines/source_compat_spec.rb @@ -0,0 +1,158 @@ +require 'spec_helper' + +describe 'apt::source', :type => :define do + GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' + + let :title do + 'my_source' + end + + context 'mostly defaults' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian', + } + end + + let :params do + { + 'include_deb' => false, + 'include_src' => true, + 'location' => 'http://debian.mirror.iweb.ca/debian/', + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb-src http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) + } + end + + context 'no defaults' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + let :params do + { + 'comment' => 'foo', + 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'release' => 'sid', + 'repos' => 'testing', + 'include_src' => false, + 'required_packages' => 'vim', + 'key' => GPG_KEY_ID, + 'key_server' => 'pgp.mit.edu', + 'key_content' => 'GPG key content', + 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg', + 'pin' => '10', + 'architecture' => 'x86_64', + 'trusted_source' => true, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/) + } + + it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ + 'ensure' => 'present', + 'priority' => '10', + 'origin' => 'debian.mirror.iweb.ca', + }) + } + + it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Apt::Setting[list-my_source]').with({ + 'command' => '/usr/bin/apt-get -y install vim', + 'logoutput' => 'on_failure', + 'refreshonly' => true, + 'tries' => '3', + 'try_sleep' => '1', + }) + } + + it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({ + 'ensure' => 'present', + 'id' => GPG_KEY_ID, + 'key_server' => 'pgp.mit.edu', + 'key_content' => 'GPG key content', + 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg', + }) + } + end + + context 'trusted_source true' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + let :params do + { + 'include_src' => false, + 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'trusted_source' => true, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) } + end + + context 'architecture equals x86_64' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + let :params do + { + 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'architecture' => 'x86_64', + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[arch=x86_64 \] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) + } + end + + context 'ensure => absent' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian' + } + end + let :params do + { + 'ensure' => 'absent', + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + 'ensure' => 'absent' + }) + } + end + + describe 'validation' do + context 'no release' do + let :facts do + { + :lsbdistid => 'Debian', + :osfamily => 'Debian' + } + end + + it do + expect { subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) + end + end + end +end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 26c8fa78d2..c9863dd96f 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -229,6 +229,100 @@ } end + context 'include_src => true' do + let :facts do + { + :lsbdistid => 'Debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'Debian', + :puppetversion => Puppet.version, + } + end + let :params do + { + :location => 'hello.there', + :include_src => true, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/) + } + end + + context 'include_deb => false' do + let :facts do + { + :lsbdistid => 'debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'debian', + :puppetversion => Puppet.version, + } + end + let :params do + { + :location => 'hello.there', + :include_deb => false, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).without_content(/deb-src hello.there wheezy main\n/) + } + it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) } + end + + context 'include_src => true and include_deb => false' do + let :facts do + { + :lsbdistid => 'debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'debian', + :puppetversion => Puppet.version, + } + end + let :params do + { + :location => 'hello.there', + :include_deb => false, + :include_src => true, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).with_content(/deb-src hello.there wheezy main\n/) + } + it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) } + end + + context 'include precedence' do + let :facts do + { + :lsbdistid => 'debian', + :lsbdistcodename => 'wheezy', + :osfamily => 'debian', + :puppetversion => Puppet.version, + } + end + let :params do + { + :location => 'hello.there', + :include_deb => true, + :include_src => false, + :include => { 'deb' => false, 'src' => true }, + } + end + + it { is_expected.to contain_apt__setting('list-my_source').with({ + :ensure => 'present', + }).with_content(/deb-src hello.there wheezy main\n/) + } + it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) } + end + context 'ensure => absent' do let :facts do { diff --git a/templates/source.list.erb b/templates/source.list.erb index 26838db51b..fe7f55941a 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,11 +1,11 @@ # <%= @comment %> <%- if @_include['deb'] then -%> -deb <%- if @architecture or @allow_unsigned -%> -[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @allow_unsigned %>trusted=yes<% end -%> -] <%- end %><%= @location %> <%= @release %> <%= @repos %> +deb <%- if @architecture or @_allow_unsigned -%> +[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @_allow_unsigned %>trusted=yes<% end -%> +] <%- end %><%= @location %> <%= @_release %> <%= @repos %> <%- end -%> <%- if @_include['src'] then -%> -deb-src <%- if @architecture or @allow_unsigned -%> -[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @allow_unsigned %>trusted=yes<% end -%> -] <%- end %><%= @location %> <%= @release %> <%= @repos %> +deb-src <%- if @architecture or @_allow_unsigned -%> +[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @_allow_unsigned %>trusted=yes<% end -%> +] <%- end %><%= @location %> <%= @_release %> <%= @repos %> <%- end -%> From 6dba8100909346f1e871ba6a34d2f140d7958eca Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Mon, 8 Jun 2015 21:50:05 -0700 Subject: [PATCH 529/574] (maint) allow setting PUPPET_VERSION in acceptance --- spec/spec_helper_acceptance.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 56b8dadc62..f1e1161546 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -4,7 +4,10 @@ unless ENV['RS_PROVISION'] == 'no' # This will install the latest available package on el and deb based # systems fail on windows and osx, and install via gem on other *nixes - foss_opts = { :default_action => 'gem_install' } + foss_opts = { + :default_action => 'gem_install', + :version => (ENV['PUPPET_VERSION'] || '3.8.1'), + } if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end From 083bed34378ad7056e6117ef19d8e9fb838817a3 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 8 Jun 2015 16:13:59 -0700 Subject: [PATCH 530/574] 2.1.0 prep --- CHANGELOG.md | 13 +++++++++++++ metadata.json | 12 ++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d70dfd8447..9d7838238f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +##2015-06-16 - Supported Release 2.1.0 +###Summary + +This release largely makes `apt::key` and `apt::source` API-compatible with the 1.8.x versions for ease in upgrading, and also addresses some compatibility issues with older versions of Puppet. + +####Features +- Add API compatibility to `apt::key` and `apt::source` +- Added `apt_reboot_required` fact + +####Bugfixes +- Fix compatibility with Puppet versions 3.0-3.4 +- Work around future parser bug PUP-4133 + ##2015-04-28 - Supported Release 2.0.1 ###Summary diff --git a/metadata.json b/metadata.json index 19cb5ade72..9675c3a38d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,12 +1,15 @@ { "name": "puppetlabs-apt", - "version": "2.0.1", + "version": "2.1.0", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-apt", "project_page": "https://github.com/puppetlabs/puppetlabs-apt", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", + "dependencies": [ + {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0 < 5.0.0"} + ], "operatingsystem_support": [ { "operatingsystem": "Debian", @@ -27,14 +30,11 @@ "requirements": [ { "name": "pe", - "version_requirement": ">= 3.3.0" + "version_requirement": ">= 3.3.0 < 5.0.0" }, { "name": "puppet", - "version_requirement": "3.x" + "version_requirement": ">= 3.0.0 < 5.0.0" } - ], - "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0"} ] } From 40c130c4cfda186f459b8407d5912f5368b91e47 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 11 Jun 2015 15:26:17 -0700 Subject: [PATCH 531/574] Add helper to install puppet/pe/puppet-agent --- Gemfile | 1 + spec/spec_helper_acceptance.rb | 17 ++--------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index b3facaaad1..643d3f5d9e 100644 --- a/Gemfile +++ b/Gemfile @@ -29,6 +29,7 @@ group :system_tests do gem 'beaker-rspec', :require => false end gem 'serverspec', :require => false + gem 'beaker-puppet_install_helper', :require => false end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index f1e1161546..409ce68b29 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,20 +1,7 @@ require 'beaker-rspec' +require 'beaker/puppet_install_helper' -# Install Puppet -unless ENV['RS_PROVISION'] == 'no' - # This will install the latest available package on el and deb based - # systems fail on windows and osx, and install via gem on other *nixes - foss_opts = { - :default_action => 'gem_install', - :version => (ENV['PUPPET_VERSION'] || '3.8.1'), - } - - if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end - - hosts.each do |host| - on host, "mkdir -p #{host['distmoduledir']}" - end -end +run_puppet_install_helper UNSUPPORTED_PLATFORMS = ['RedHat','Suse','windows','AIX','Solaris'] From b3697f7ccd923b5f8b439bf33d40bef36706e3b7 Mon Sep 17 00:00:00 2001 From: jbondpdx Date: Mon, 15 Jun 2015 11:45:59 -0700 Subject: [PATCH 532/574] DOCS: Edits to README.md Just mostly commas and wording and other edit-y stuff. --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4babf3c71b..6cc1aa436a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The apt module lets you use Puppet to manage Apt sources, keys, and other config Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, and several other operating systems. The apt module provides a series of classes, defines, types, and facts to help you automate Apt package management. -**Note**: For this module to be able to correctly auto detect which version of Debian/Ubuntu or derivative you're running you need to make sure the 'lsb-release' package is installed. We highly recommend making this part of your provisioning layer if you run many Debian or derivative systems or ensuring that you have at least Facter 2.2.0 installed which will pull in this dependency for you. +**Note**: For this module to correctly autodetect which version of Debian/Ubuntu (or derivative) you're running, you need to make sure the 'lsb-release' package is installed. We highly recommend you either make this part of your provisioning layer, if you run many Debian or derivative systems, or ensure that you have Facter 2.2.0 or later installed, which will pull this dependency in for you. ## Setup @@ -325,7 +325,7 @@ The `apt::key` define makes use of the `apt_key` type, but includes extra functi * `key_source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. -* `key_server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com' .**Note** This parameter is deprecated and will be removed in a future release. +* `key_server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. **Note** This parameter is deprecated and will be removed in a future release. * `key_options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. @@ -418,11 +418,11 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `key`: Creates a declaration of the apt::key define Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. -* `include`: Configures include options. Valid options: a hash made up from the following keys: Default: {} +* `include`: Configures include options. Valid options: a hash of available keys. Default: {}. Available keys are: -* 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false'. Default: 'true'. + * 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false'. Default: 'true'. -* 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. + * 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. * `location`: *Required, unless `ensure` is set to 'absent'.* Specifies an Apt repository. Valid options: a string containing a repository URL. Default: undef. @@ -430,21 +430,21 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `release`: Specifies a distribution of the Apt repository. Valid options: a string. Default: "$lsbdistcodename". -* `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'. + * `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'. -* `include_deb`: Specify whether to request the distrubution's compiled binaries. Valid options: 'true' and 'false'. Default: undef **Note** this parameter is deprecated and will be removed in future versions of the module. +* `include_deb`: Specify whether to request the distrubution's compiled binaries. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `include_src`: Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: undef **Note** this parameter is deprecated andd will be removed in future versions of the module. +* `include_src`: Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `required_packages`: install packages required for this Apt source via an exec. Default: 'false'. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `required_packages`: Installs packages required for this Apt source via an exec. Default: 'false'. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `key_content`: Specify the content to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `key_content`: Specifies the content to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `key_server`: Specify the server to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `key_server`: Specifies the server to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `key_source`: Specify the source to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `key_source`: Specifies the source to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. This parameter is **deprecated** and will be removed in a future version of the module. #### Type: `apt_key` From 3f6248046a28b843691f1217acfe68563bfc4501 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 15 Jun 2015 13:48:38 -0700 Subject: [PATCH 533/574] Apt::key doesn't have priority. --- README.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/README.md b/README.md index 6cc1aa436a..0592202f5a 100644 --- a/README.md +++ b/README.md @@ -62,17 +62,6 @@ apt::key { 'puppetlabs': } ~~~ -You can make Apt load your key before others by adjusting the `priority` parameter (the default priority is 50). - -~~~puppet -apt::key { 'puppetlabs': - id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - server => 'pgp.mit.edu', - options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', - priority => '50', -} -~~~ - ### Prioritize backports ~~~puppet From f766663643e745d8618b623eb529462bc98986cb Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 8 Jun 2015 16:13:59 -0700 Subject: [PATCH 534/574] 2.1.0 prep --- CHANGELOG.md | 13 +++++++++++++ metadata.json | 12 ++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d70dfd8447..9d7838238f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +##2015-06-16 - Supported Release 2.1.0 +###Summary + +This release largely makes `apt::key` and `apt::source` API-compatible with the 1.8.x versions for ease in upgrading, and also addresses some compatibility issues with older versions of Puppet. + +####Features +- Add API compatibility to `apt::key` and `apt::source` +- Added `apt_reboot_required` fact + +####Bugfixes +- Fix compatibility with Puppet versions 3.0-3.4 +- Work around future parser bug PUP-4133 + ##2015-04-28 - Supported Release 2.0.1 ###Summary diff --git a/metadata.json b/metadata.json index 19cb5ade72..9675c3a38d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,12 +1,15 @@ { "name": "puppetlabs-apt", - "version": "2.0.1", + "version": "2.1.0", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-apt", "project_page": "https://github.com/puppetlabs/puppetlabs-apt", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", + "dependencies": [ + {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0 < 5.0.0"} + ], "operatingsystem_support": [ { "operatingsystem": "Debian", @@ -27,14 +30,11 @@ "requirements": [ { "name": "pe", - "version_requirement": ">= 3.3.0" + "version_requirement": ">= 3.3.0 < 5.0.0" }, { "name": "puppet", - "version_requirement": "3.x" + "version_requirement": ">= 3.0.0 < 5.0.0" } - ], - "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 4.5.0"} ] } From 2bba5d716773c778c22011d401347b07d974a3f5 Mon Sep 17 00:00:00 2001 From: jbondpdx Date: Mon, 15 Jun 2015 11:45:59 -0700 Subject: [PATCH 535/574] DOCS: Edits to README.md Just mostly commas and wording and other edit-y stuff. --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4babf3c71b..6cc1aa436a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The apt module lets you use Puppet to manage Apt sources, keys, and other config Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, and several other operating systems. The apt module provides a series of classes, defines, types, and facts to help you automate Apt package management. -**Note**: For this module to be able to correctly auto detect which version of Debian/Ubuntu or derivative you're running you need to make sure the 'lsb-release' package is installed. We highly recommend making this part of your provisioning layer if you run many Debian or derivative systems or ensuring that you have at least Facter 2.2.0 installed which will pull in this dependency for you. +**Note**: For this module to correctly autodetect which version of Debian/Ubuntu (or derivative) you're running, you need to make sure the 'lsb-release' package is installed. We highly recommend you either make this part of your provisioning layer, if you run many Debian or derivative systems, or ensure that you have Facter 2.2.0 or later installed, which will pull this dependency in for you. ## Setup @@ -325,7 +325,7 @@ The `apt::key` define makes use of the `apt_key` type, but includes extra functi * `key_source`: Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or an absolute path. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. -* `key_server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com' .**Note** This parameter is deprecated and will be removed in a future release. +* `key_server`: Specifies a keyserver to provide the GPG key. Valid options: a string containing a domain name or a full URL (http://, https://, or hkp://). Default: 'keyserver.ubuntu.com'. **Note** This parameter is deprecated and will be removed in a future release. * `key_options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. @@ -418,11 +418,11 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `key`: Creates a declaration of the apt::key define Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. -* `include`: Configures include options. Valid options: a hash made up from the following keys: Default: {} +* `include`: Configures include options. Valid options: a hash of available keys. Default: {}. Available keys are: -* 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false'. Default: 'true'. + * 'deb' - Specifies whether to request the distribution's compiled binaries. Valid options: 'true' and 'false'. Default: 'true'. -* 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. + * 'src' - Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: 'false'. * `location`: *Required, unless `ensure` is set to 'absent'.* Specifies an Apt repository. Valid options: a string containing a repository URL. Default: undef. @@ -430,21 +430,21 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `release`: Specifies a distribution of the Apt repository. Valid options: a string. Default: "$lsbdistcodename". -* `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'. + * `repos`: Specifies a component of the Apt repository. Valid options: a string. Default: 'main'. -* `include_deb`: Specify whether to request the distrubution's compiled binaries. Valid options: 'true' and 'false'. Default: undef **Note** this parameter is deprecated and will be removed in future versions of the module. +* `include_deb`: Specify whether to request the distrubution's compiled binaries. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `include_src`: Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: undef **Note** this parameter is deprecated andd will be removed in future versions of the module. +* `include_src`: Specifies whether to request the distribution's uncompiled source code. Valid options: 'true' and 'false'. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `required_packages`: install packages required for this Apt source via an exec. Default: 'false'. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `required_packages`: Installs packages required for this Apt source via an exec. Default: 'false'. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `key_content`: Specify the content to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `key_content`: Specifies the content to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `key_server`: Specify the server to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `key_server`: Specifies the server to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `key_source`: Specify the source to be passed to `apt::key`. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `key_source`: Specifies the source to be passed to `apt::key`. Default: undef. **Note**: This parameter is deprecated and will be removed in future versions of the module. -* `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. **Note** this parameter is deprecated and will be removed in future versions of the module. +* `trusted_source`: Specifies whether to authenticate packages from this release, even if the Release file is not signed or the signature can't be checked. Valid options: 'true' and 'false'. Default: undef. This parameter is **deprecated** and will be removed in a future version of the module. #### Type: `apt_key` From f1a5499541c893ffb18e591bcb857c78e3001c24 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 15 Jun 2015 13:48:38 -0700 Subject: [PATCH 536/574] Apt::key doesn't have priority. --- README.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/README.md b/README.md index 6cc1aa436a..0592202f5a 100644 --- a/README.md +++ b/README.md @@ -62,17 +62,6 @@ apt::key { 'puppetlabs': } ~~~ -You can make Apt load your key before others by adjusting the `priority` parameter (the default priority is 50). - -~~~puppet -apt::key { 'puppetlabs': - id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - server => 'pgp.mit.edu', - options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', - priority => '50', -} -~~~ - ### Prioritize backports ~~~puppet From c1d49048c0ebda388ff32175e8de069247bd75c9 Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 17 Jun 2015 12:05:37 +0100 Subject: [PATCH 537/574] Update update.pp Corrected typo --- manifests/update.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/update.pp b/manifests/update.pp index 86f068200c..9b1f686709 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -39,7 +39,7 @@ } } default: { - #catches 'recluctantly', and any other value (which should not occur). + #catches 'reluctantly', and any other value (which should not occur). #do nothing. $_kick_apt = false } From 8d981057748e050f7b652160d86540ef09a593cc Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 17 Jun 2015 11:59:40 -0700 Subject: [PATCH 538/574] Don't add puppetlabs sources for lucid They no longer exist --- spec/acceptance/apt_spec.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index c948df2ac2..882c066fd8 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -23,14 +23,16 @@ class { 'apt': 'preferences' => true, 'preferences.d' => true, }, - sources => { - 'puppetlabs' => { - 'ensure' => present, - 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'key' => { - 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - 'server' => 'pgp.mit.edu', + sources => ? $::lsbdiscodename { + 'lucid' => undef, + default => { 'puppetlabs' => { + 'ensure' => present, + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'key' => { + 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + 'server' => 'pgp.mit.edu', + }, }, }, }, From a09dcafb3253aaddc1c6a69a85afef1e35a7fea1 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 17 Jun 2015 13:24:49 -0700 Subject: [PATCH 539/574] typo --- spec/acceptance/apt_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 882c066fd8..843dd0a83d 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -23,7 +23,7 @@ class { 'apt': 'preferences' => true, 'preferences.d' => true, }, - sources => ? $::lsbdiscodename { + sources => $::lsbdiscodename ? { 'lucid' => undef, default => { 'puppetlabs' => { 'ensure' => present, From 74bb26d148120187e483c3b8d723cbb7ec8889d4 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 17 Jun 2015 14:56:22 -0700 Subject: [PATCH 540/574] hashes are not supported in selectors --- spec/acceptance/apt_spec.rb | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 843dd0a83d..d3bd76174c 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -11,6 +11,21 @@ context 'all the things' do it 'should work with no errors' do pp = <<-EOS + if $::lsbdistcodename == 'lucid' { + $sources = undef + } else { + $sources = { + 'puppetlabs' => { + 'ensure' => present, + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'key' => { + 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + 'server' => 'pgp.mit.edu', + }, + }, + } + } class { 'apt': update => { 'frequency' => 'always', @@ -23,19 +38,7 @@ class { 'apt': 'preferences' => true, 'preferences.d' => true, }, - sources => $::lsbdiscodename ? { - 'lucid' => undef, - default => { 'puppetlabs' => { - 'ensure' => present, - 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'key' => { - 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', - 'server' => 'pgp.mit.edu', - }, - }, - }, - }, + sources => $sources, } EOS From ec1c50a4ad4749c30a23b1905b879ae00bdee035 Mon Sep 17 00:00:00 2001 From: Ed Szynaka Date: Fri, 19 Jun 2015 02:01:48 -0400 Subject: [PATCH 541/574] Added additional header template for apt.conf style comments --- manifests/conf.pp | 2 +- manifests/init.pp | 4 ++-- templates/_conf_header.erb | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 templates/_conf_header.erb diff --git a/manifests/conf.pp b/manifests/conf.pp index da6d64e738..c0cd55ba9e 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -13,6 +13,6 @@ apt::setting { "conf-${name}": ensure => $ensure, priority => $priority, - content => template('apt/_header.erb', 'apt/conf.erb'), + content => template('apt/_conf_header.erb', 'apt/conf.erb'), } } diff --git a/manifests/init.pp b/manifests/init.pp index ded13f2fc4..48c4f53050 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -67,7 +67,7 @@ if $proxy['host'] { apt::setting { 'conf-proxy': priority => '01', - content => template('apt/_header.erb', 'apt/proxy.erb'), + content => template('apt/_conf_header.erb', 'apt/proxy.erb'), } } @@ -89,7 +89,7 @@ apt::setting { 'conf-update-stamp': priority => 15, - content => template('apt/_header.erb', 'apt/15update-stamp.erb'), + content => template('apt/_conf_header.erb', 'apt/15update-stamp.erb'), } file { 'sources.list': diff --git a/templates/_conf_header.erb b/templates/_conf_header.erb new file mode 100644 index 0000000000..bfa365e23e --- /dev/null +++ b/templates/_conf_header.erb @@ -0,0 +1 @@ +// This file is managed by Puppet. DO NOT EDIT. From 93f40ca8928109956f3ecebbe8077414c5b52a29 Mon Sep 17 00:00:00 2001 From: Farzad FARID Date: Mon, 22 Jun 2015 14:32:58 +0200 Subject: [PATCH 542/574] Fix use of $::apt::params::backports and $::apt::params::xfacts. --- manifests/backports.pp | 12 ++++++------ manifests/ppa.pp | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index 3cac0b5b5b..f4c5faaf89 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -4,7 +4,7 @@ $repos = undef, $key = undef, $pin = 200, -){ +) inherits apt::params { if $location { validate_string($location) $_location = $location @@ -29,18 +29,18 @@ } } - if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') { + if ($::apt::params::xfacts['lsbdistid'] == 'debian' or $::apt::params::xfacts['lsbdistid'] == 'ubuntu') { unless $location { - $_location = $::apt::backports['location'] + $_location = $::apt::params::backports['location'] } unless $release { - $_release = "${::apt::xfacts['lsbdistcodename']}-backports" + $_release = "${::apt::params::xfacts['lsbdistcodename']}-backports" } unless $repos { - $_repos = $::apt::backports['repos'] + $_repos = $::apt::params::backports['repos'] } unless $key { - $_key = $::apt::backports['key'] + $_key = $::apt::params::backports['key'] } } else { unless $location and $release and $repos and $key { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index f3e2bfda04..cf98fdd5e1 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -2,15 +2,17 @@ define apt::ppa( $ensure = 'present', $options = $::apt::ppa_options, - $release = $::apt::xfacts['lsbdistcodename'], + $release = $::apt::params::xfacts['lsbdistcodename'], $package_name = $::apt::ppa_package, $package_manage = false, ) { + include 'apt::params' + unless $release { fail('lsbdistcodename fact not available: release parameter required') } - if $::apt::xfacts['lsbdistid'] == 'Debian' { + if $::apt::params::xfacts['lsbdistid'] == 'Debian' { fail('apt::ppa is not currently supported on Debian.') } From 70c18639c12194e0e2c391c7b42065605510ac5a Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 22 Jun 2015 09:30:15 -0700 Subject: [PATCH 543/574] Revert "Fix use of $::apt::params::backports and $::apt::params::xfacts." --- manifests/backports.pp | 12 ++++++------ manifests/ppa.pp | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index f4c5faaf89..3cac0b5b5b 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -4,7 +4,7 @@ $repos = undef, $key = undef, $pin = 200, -) inherits apt::params { +){ if $location { validate_string($location) $_location = $location @@ -29,18 +29,18 @@ } } - if ($::apt::params::xfacts['lsbdistid'] == 'debian' or $::apt::params::xfacts['lsbdistid'] == 'ubuntu') { + if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') { unless $location { - $_location = $::apt::params::backports['location'] + $_location = $::apt::backports['location'] } unless $release { - $_release = "${::apt::params::xfacts['lsbdistcodename']}-backports" + $_release = "${::apt::xfacts['lsbdistcodename']}-backports" } unless $repos { - $_repos = $::apt::params::backports['repos'] + $_repos = $::apt::backports['repos'] } unless $key { - $_key = $::apt::params::backports['key'] + $_key = $::apt::backports['key'] } } else { unless $location and $release and $repos and $key { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index cf98fdd5e1..f3e2bfda04 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -2,17 +2,15 @@ define apt::ppa( $ensure = 'present', $options = $::apt::ppa_options, - $release = $::apt::params::xfacts['lsbdistcodename'], + $release = $::apt::xfacts['lsbdistcodename'], $package_name = $::apt::ppa_package, $package_manage = false, ) { - include 'apt::params' - unless $release { fail('lsbdistcodename fact not available: release parameter required') } - if $::apt::params::xfacts['lsbdistid'] == 'Debian' { + if $::apt::xfacts['lsbdistid'] == 'Debian' { fail('apt::ppa is not currently supported on Debian.') } From b8462bdc43f788ea3cc91d4e4c6cb0a49d67cb64 Mon Sep 17 00:00:00 2001 From: Raoul Bhatia Date: Sun, 5 Jul 2015 08:56:38 +0200 Subject: [PATCH 544/574] Use Debian's new official mirrors redirector See https://www.debian.org/News/weekly/2015/05/#httpredir --- README.md | 4 ++-- manifests/params.pp | 4 ++-- spec/classes/apt_backports_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0592202f5a..fa7c3de698 100644 --- a/README.md +++ b/README.md @@ -263,8 +263,8 @@ Manages backports. * `location`: Specifies an Apt repository containing the backports to manage. Valid options: a string containing a URL. Defaults: - * Debian (squeeze): 'http://backports.debian.org/debian-backports' - * Debian (other): 'http://ftp.debian.org/debian/' + * Debian (squeeze): 'http://httpredir.debian.org/debian-backports' + * Debian (other): 'http://httpredir.debian.org/debian' * Ubuntu: 'http://archive.ubuntu.com/ubuntu' * `pin`: *Optional.* Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` define, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: '200'. diff --git a/manifests/params.pp b/manifests/params.pp index d4f838946a..cdf8e6e09f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -105,14 +105,14 @@ case $xfacts['lsbdistcodename'] { 'squeeze': { $backports = { - 'location' => 'http://backports.debian.org/debian-backports', + 'location' => 'http://httpredir.debian.org/debian-backports', 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'repos' => 'main contrib non-free', } } default: { $backports = { - 'location' => 'http://ftp.debian.org/debian/', + 'location' => 'http://httpredir.debian.org/debian', 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'repos' => 'main contrib non-free', } diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index efaa9cc955..a80af1e4bd 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -14,7 +14,7 @@ } end it { is_expected.to contain_apt__source('backports').with({ - :location => 'http://ftp.debian.org/debian/', + :location => 'http://httpredir.debian.org/debian', :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :repos => 'main contrib non-free', :release => 'wheezy-backports', @@ -32,7 +32,7 @@ } end it { is_expected.to contain_apt__source('backports').with({ - :location => 'http://backports.debian.org/debian-backports', + :location => 'http://httpredir.debian.org/debian-backports', :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :repos => 'main contrib non-free', :release => 'squeeze-backports', From 97a14dd6a4d234362e066b648f2ef5d65fa7c24a Mon Sep 17 00:00:00 2001 From: Leo Arnold Date: Sat, 18 Jul 2015 21:58:23 +0200 Subject: [PATCH 545/574] Corrected documentation warning about `purge` parameters to fit v2.1.0 syntax --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0592202f5a..c5f4340857 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,12 @@ Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, an ### What apt affects +* Your system's `preferences.list` file and `preferences.list.d` directory * Your system's `sources.list` file and `sources.list.d` directory * System repositories * Authentication keys -**Note:** Setting the apt module's `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that you haven't declared through Puppet. The default for these parameters is 'false'. +**Note:** This module offers `purge` parameters which will cause the module to destroy any configuration on the node's `sources.list(.d)` and `preferences.list(.d)` that you haven't declared through Puppet. The default for these parameters is 'false'. ### Beginning with apt From cd37fc34f25a6032c30e4b4fadd1731a79f3e3a4 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 17 Jul 2015 16:19:33 -0700 Subject: [PATCH 546/574] MODULES-2190 - Fix anchor issues --- manifests/init.pp | 12 +++++------- manifests/ppa.pp | 4 ++-- manifests/setting.pp | 2 +- manifests/source.pp | 3 ++- spec/classes/apt_spec.rb | 16 ++++++++-------- spec/defines/ppa_spec.rb | 16 ++++++++-------- spec/defines/setting_spec.rb | 14 +++++++------- spec/defines/source_spec.rb | 2 ++ 8 files changed, 35 insertions(+), 34 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 48c4f53050..578d73356e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -26,7 +26,7 @@ } $_update = merge($::apt::update_defaults, $update) - include apt::update + include ::apt::update validate_hash($purge) if $purge['sources.list'] { @@ -99,7 +99,7 @@ group => root, mode => '0644', content => $sources_list_content, - notify => Exec['apt_update'], + notify => Class['apt::update'], } file { 'sources.list.d': @@ -110,7 +110,7 @@ mode => '0644', purge => $_purge['sources.list.d'], recurse => $_purge['sources.list.d'], - notify => Exec['apt_update'], + notify => Class['apt::update'], } file { 'preferences': @@ -119,7 +119,7 @@ owner => root, group => root, mode => '0644', - notify => Exec['apt_update'], + notify => Class['apt::update'], } file { 'preferences.d': @@ -130,11 +130,9 @@ mode => '0644', purge => $_purge['preferences.d'], recurse => $_purge['preferences.d'], - notify => Exec['apt_update'], + notify => Class['apt::update'], } - anchor { 'apt_first': } -> Class['apt::update'] -> anchor { 'apt_last': } - # manage sources if present if $sources { create_resources('apt::source', $sources) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index f3e2bfda04..6352352c8d 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -45,7 +45,7 @@ unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}", user => 'root', logoutput => 'on_failure', - notify => Exec['apt_update'], + notify => Class['apt::update'], require => $_require, } @@ -57,7 +57,7 @@ else { file { "${::apt::sources_list_d}/${sources_list_d_filename}": ensure => 'absent', - notify => Exec['apt_update'], + notify => Class['apt::update'], } } } diff --git a/manifests/setting.pp b/manifests/setting.pp index 59d0dd4dfe..d723eb2c53 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -47,7 +47,7 @@ $_ext = $::apt::params::config_files[$setting_type]['ext'] if $notify_update { - $_notify = Exec['apt_update'] + $_notify = Class['apt::update'] } else { $_notify = undef } diff --git a/manifests/source.pp b/manifests/source.pp index 734f375f21..1307a3a552 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -23,7 +23,8 @@ validate_bool($allow_unsigned) validate_hash($include) - include 'apt::params' + # This is needed for compat with 1.8.x + include ::apt $_before = Apt::Setting["list-${title}"] diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 1c8cac7a03..5a71fb581a 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -3,16 +3,16 @@ let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version} } context 'defaults' do - it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({ + it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'file', :path => '/etc/apt/sources.list', :owner => 'root', :group => 'root', :mode => '0644', - :notify => 'Exec[apt_update]', + :notify => 'Class[Apt::Update]', })} - it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({ + it { is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'directory', :path => '/etc/apt/sources.list.d', :owner => 'root', @@ -20,19 +20,19 @@ :mode => '0644', :purge => false, :recurse => false, - :notify => 'Exec[apt_update]', + :notify => 'Class[Apt::Update]', })} - it { is_expected.to contain_file('preferences').that_notifies('Exec[apt_update]').only_with({ + it { is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'file', :path => '/etc/apt/preferences', :owner => 'root', :group => 'root', :mode => '0644', - :notify => 'Exec[apt_update]', + :notify => 'Class[Apt::Update]', })} - it { is_expected.to contain_file('preferences.d').that_notifies('Exec[apt_update]').only_with({ + it { is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'directory', :path => '/etc/apt/preferences.d', :owner => 'root', @@ -40,7 +40,7 @@ :mode => '0644', :purge => false, :recurse => false, - :notify => 'Exec[apt_update]', + :notify => 'Class[Apt::Update]', })} it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index c110e50f43..b7a2f6c004 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -18,7 +18,7 @@ let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.to_not contain_package('python-software-properties') } - it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ :environment => [], :command => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', @@ -57,7 +57,7 @@ let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ 'environment' => [], 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', @@ -94,7 +94,7 @@ let(:title) { 'ppa:needs/such.substitution/wow' } it { is_expected.to_not contain_package('python-software-properties') } - it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ 'environment' => [], 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', @@ -135,7 +135,7 @@ let(:title) { 'ppa:foo' } it { is_expected.to compile.with_all_deps } 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ :environment => [], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', @@ -169,7 +169,7 @@ 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8080'], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', @@ -203,7 +203,7 @@ 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8180'], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', @@ -237,7 +237,7 @@ 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'], :command => '/usr/bin/add-apt-repository ppa:foo', :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', @@ -267,7 +267,7 @@ :ensure => 'absent' } end - it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Class[Apt::Update]').with({ :ensure => 'absent', }) } diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index b109ea6b6b..07d94ef480 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -16,25 +16,25 @@ context 'with title=conf-teddybear ' do let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') } + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') } end context 'with title=pref-teddybear' do let(:title) { 'pref-teddybear' } let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Exec[apt_update]') } + it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Class[Apt::Update]') } end context 'with title=list-teddybear' do let(:title) { 'list-teddybear' } let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Exec[apt_update]') } + it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Class[Apt::Update]') } end context 'with source' do let(:params) { { :source => 'puppet:///la/die/dah' } } it { - is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ + is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ :ensure => 'file', :owner => 'root', :group => 'root', @@ -45,7 +45,7 @@ context 'with content' do let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ :ensure => 'file', :owner => 'root', :group => 'root', @@ -103,12 +103,12 @@ describe 'with priority=100' do let(:params) { default_params.merge({ :priority => 100 }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Exec[apt_update]') } + it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[Apt::Update]') } end describe 'with ensure=absent' do let(:params) { default_params.merge({ :ensure => 'absent' }) } - it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({ :ensure => 'absent', })} end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index c9863dd96f..8a2cfcc747 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -70,6 +70,8 @@ }).with_content(/hello.there wheezy main\n/) } + it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]')} + it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({ :ensure => 'present', :priority => 1001, From c01e5e29ea2229015769a75a3cff79e0595b754e Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Tue, 21 Jul 2015 10:46:34 -0700 Subject: [PATCH 547/574] Add limitations note --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 0592202f5a..78c84b4de6 100644 --- a/README.md +++ b/README.md @@ -455,6 +455,14 @@ Manages the GPG keys that Apt uses to authenticate packages. This module is tested and officially supported on Debian 6 and 7 and Ubuntu 10.04, 12.04, and 14.04. Testing on other platforms has been light and cannot be guaranteed. +### Adding new sources or PPAs + +If you are adding a new source or PPA and trying to install packages from the new source or PPA on the same puppet run, in addition to depending on the `Apt::Source` or the `Apt::Ppa`, your `package` resource should depend on `Class['apt::update']`. You can also add [collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html) to ensure all packages happen after `apt::update`, but this can lead to dependency cycles and has implications for [virtual resources](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html#behavior) + +~~~puppet +Class['apt::update'] -> Package<| |> +~~~ + ## Development Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. From 479a7683b71413a39506c1d1815a87e4fdde82e7 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 22 Jul 2015 17:29:56 -0700 Subject: [PATCH 548/574] 2.1.1 prep --- CHANGELOG.md | 11 +++++++++++ metadata.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d7838238f..7403b6fe86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +##2015-07-28 - Supported Release 2.1.1 +###Summary + +This release includes a few bugfixes. + +####Bugfixes +- Fix incorrect use of anchoring (MODULES-2190) +- Use correct comment type for apt.conf files +- Test fixes +- Documentation fixes + ##2015-06-16 - Supported Release 2.1.0 ###Summary diff --git a/metadata.json b/metadata.json index 9675c3a38d..7c694e717e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-apt", - "version": "2.1.0", + "version": "2.1.1", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", @@ -30,7 +30,7 @@ "requirements": [ { "name": "pe", - "version_requirement": ">= 3.3.0 < 5.0.0" + "version_requirement": ">= 3.3.0 < 2015.3.0" }, { "name": "puppet", From b085c3787c134216e323189989d3c7717fc32d80 Mon Sep 17 00:00:00 2001 From: jbondpdx Date: Mon, 27 Jul 2015 10:29:01 -0700 Subject: [PATCH 549/574] light edits to apt README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a40a0eb3e2..fac0cedf32 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, an * System repositories * Authentication keys -**Note:** This module offers `purge` parameters which will cause the module to destroy any configuration on the node's `sources.list(.d)` and `preferences.list(.d)` that you haven't declared through Puppet. The default for these parameters is 'false'. +**Note:** This module offers `purge` parameters which, if set to 'true', **destroy** any configuration on the node's `sources.list(.d)` and `preferences.list(.d)` that you haven't declared through Puppet. The default for these parameters is 'false'. ### Beginning with apt @@ -458,7 +458,7 @@ This module is tested and officially supported on Debian 6 and 7 and Ubuntu 10.0 ### Adding new sources or PPAs -If you are adding a new source or PPA and trying to install packages from the new source or PPA on the same puppet run, in addition to depending on the `Apt::Source` or the `Apt::Ppa`, your `package` resource should depend on `Class['apt::update']`. You can also add [collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html) to ensure all packages happen after `apt::update`, but this can lead to dependency cycles and has implications for [virtual resources](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html#behavior) +If you are adding a new source or PPA and trying to install packages from the new source or PPA on the same Puppet run, your `package` resource should depend on `Class['apt::update']`, in addition to depending on the `Apt::Source` or the `Apt::Ppa`. You can also add [collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html) to ensure that all packages happen after `apt::update`, but this can lead to dependency cycles and has implications for [virtual resources](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html#behavior). ~~~puppet Class['apt::update'] -> Package<| |> From afa4d45ee904092ef17f4cb1a6189817819adc67 Mon Sep 17 00:00:00 2001 From: "Callahan, Michael Joseph" Date: Tue, 4 Aug 2015 15:58:32 -0400 Subject: [PATCH 550/574] Added an ensure parameter for user control of proxy presence. Defaults to undef to resist breaking any current setup. added spec entry Added validation fixed ensure hash --- README.md | 2 ++ manifests/init.pp | 6 +++++- manifests/params.pp | 7 ++++--- spec/classes/apt_spec.rb | 8 ++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 950649539e..4220775b99 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,8 @@ Main class, includes all other classes. * 'https': Specifies whether to enable https proxies. Valid options: 'true' and 'false'. Default: 'false'. + * 'ensure': Optional parameter. Valid options: 'file', 'present', and 'absent'. Default: 'undef'. Prefer 'file' over 'present'. + * `purge`: Specifies whether to purge any existing settings that aren't managed by Puppet. Valid options: a hash made up from the following keys: * 'sources.list': Specifies whether to purge any unmanaged entries from `sources.list`. Valid options: 'true' and 'false'. Default: 'false'. diff --git a/manifests/init.pp b/manifests/init.pp index 578d73356e..b9087cfb7a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -45,6 +45,9 @@ $_purge = merge($::apt::purge_defaults, $purge) validate_hash($proxy) + if $proxy['ensure'] { + validate_re($proxy['ensure'], ['file', 'present', 'absent']) + } if $proxy['host'] { validate_string($proxy['host']) } @@ -64,8 +67,9 @@ validate_hash($settings) validate_hash($ppas) - if $proxy['host'] { + if $_proxy['ensure'] == 'absent' or $_proxy['host'] { apt::setting { 'conf-proxy': + ensure => $_proxy['ensure'], priority => '01', content => template('apt/_conf_header.erb', 'apt/proxy.erb'), } diff --git a/manifests/params.pp b/manifests/params.pp index cdf8e6e09f..ea18460654 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -76,9 +76,10 @@ } $proxy_defaults = { - 'host' => undef, - 'port' => 8080, - 'https' => false, + 'ensure' => undef, + 'host' => undef, + 'port' => 8080, + 'https' => false, } $purge_defaults = { diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 5a71fb581a..7578d2eb78 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -91,6 +91,14 @@ /Acquire::https::proxy "https:\/\/localhost:8080\/";/ )} end + + context 'ensure=absent' do + let(:params) { { :proxy => { 'ensure' => 'absent'} } } + it { is_expected.to contain_apt__setting('conf-proxy').with({ + :ensure => 'absent', + :priority => '01', + })} + end end context 'lots of non-defaults' do let :params do From 9ad4fd682d3223fbd6be3192e5841c366c156cf6 Mon Sep 17 00:00:00 2001 From: Brett Delle Grazie Date: Thu, 23 Jul 2015 17:15:53 +0100 Subject: [PATCH 551/574] MODULES-2269: Expose notify_update setting * Expose the underlying notify_update setting of the apt::settings resource This is because not all configuration file changes should trigger an apt::update notification * apt::pin also shouldn't result in an apt-update call Adding a pin configuration should apply to the next apt-get update call it shouldn't trigger one itself. * Added documentation * Add tests for apt::conf notify_update --- README.md | 4 +++- manifests/conf.pp | 14 ++++++++------ manifests/pin.pp | 7 ++++--- spec/defines/conf_spec.rb | 21 ++++++++++++++++++++- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4220775b99..8c3819b262 100644 --- a/README.md +++ b/README.md @@ -291,6 +291,8 @@ Specifies a custom Apt configuration file. * `priority`: *Optional.* Determines the order in which Apt processes the configuration file. Files with lower priority numbers are loaded first. Valid options: a string containing an integer. Default: '50'. +* `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'. + #### Define: `apt::key` Manages the GPG keys that Apt uses to authenticate packages. @@ -323,7 +325,7 @@ The `apt::key` define makes use of the `apt_key` type, but includes extra functi #### Define: `apt::pin` -Manages Apt pins. +Manages Apt pins. Does not trigger an `apt-get update` run. **Note:** For context on these parameters, we recommend reading the man page ['apt_preferences(5)'](http://linux.die.net/man/5/apt_preferences) diff --git a/manifests/conf.pp b/manifests/conf.pp index c0cd55ba9e..97b70a1eeb 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -1,7 +1,8 @@ define apt::conf ( - $content = undef, - $ensure = present, - $priority = '50', + $content = undef, + $ensure = present, + $priority = '50', + $notify_update = undef, ) { unless $ensure == 'absent' { @@ -11,8 +12,9 @@ } apt::setting { "conf-${name}": - ensure => $ensure, - priority => $priority, - content => template('apt/_conf_header.erb', 'apt/conf.erb'), + ensure => $ensure, + priority => $priority, + content => template('apt/_conf_header.erb', 'apt/conf.erb'), + notify_update => $notify_update, } } diff --git a/manifests/pin.pp b/manifests/pin.pp index bcccf28b7c..cc896896d7 100644 --- a/manifests/pin.pp +++ b/manifests/pin.pp @@ -72,8 +72,9 @@ $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG') apt::setting { "pref-${file_name}": - ensure => $ensure, - priority => $order, - content => template('apt/_header.erb', 'apt/pin.pref.erb'), + ensure => $ensure, + priority => $order, + content => template('apt/_header.erb', 'apt/pin.pref.erb'), + notify_update => false, } } diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index f0192d61c4..c74bf1aca3 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -9,12 +9,15 @@ end describe "when creating an apt preference" do - let :params do + let :default_params do { :priority => '00', :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" } end + let :params do + default_params + end let :filename do "/etc/apt/apt.conf.d/00norecommends" @@ -28,6 +31,22 @@ 'mode' => '0644', }) } + + context "with notify_update = true (default)" do + let :params do + default_params + end + it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(true) } + end + + context "with notify_update = false" do + let :params do + default_params.merge({ + :notify_update => false + }) + end + it { is_expected.to contain_apt__setting("conf-#{title}").with_notify_update(false) } + end end describe "when creating a preference without content" do From 9f55e31316774c436e1b3f6d2dfed7a8d75762f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Barbeira?= Date: Mon, 17 Aug 2015 14:52:25 +0200 Subject: [PATCH 552/574] Fix path to 'preferences' and 'preferences.d'. If you follow the documentacion, the hiera file does not work. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4220775b99..d4831787e0 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,12 @@ Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, an ### What apt affects -* Your system's `preferences.list` file and `preferences.list.d` directory +* Your system's `preferences` file and `preferences.d` directory * Your system's `sources.list` file and `sources.list.d` directory * System repositories * Authentication keys -**Note:** This module offers `purge` parameters which, if set to 'true', **destroy** any configuration on the node's `sources.list(.d)` and `preferences.list(.d)` that you haven't declared through Puppet. The default for these parameters is 'false'. +**Note:** This module offers `purge` parameters which, if set to 'true', **destroy** any configuration on the node's `sources.list(.d)` and `preferences(.d)` that you haven't declared through Puppet. The default for these parameters is 'false'. ### Beginning with apt @@ -237,9 +237,9 @@ Main class, includes all other classes. * 'sources.list.d': Specifies whether to purge any unmanaged entries from `sources.list.d`. Valid options: 'true' and 'false'. Default: 'false'. - * 'preferences.list': Specifies whether to purge any unmanaged entries from `preferences.list`. Valid options: 'true' and 'false'. Default: 'false'. + * 'preferences': Specifies whether to purge any unmanaged entries from `preferences`. Valid options: 'true' and 'false'. Default: 'false'. - * 'preferences.list.d': Specifies whether to purge any unmanaged entries from `preferences.list.d`. Valid options: 'true' and 'false'. Default: 'false'. + * 'preferences.d': Specifies whether to purge any unmanaged entries from `preferences.d`. Valid options: 'true' and 'false'. Default: 'false'. * `settings`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. From 9f43b2db2655e216035c129b1031b225c83a6030 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Wed, 26 Aug 2015 16:29:54 -0700 Subject: [PATCH 553/574] MODULES-2446 - Fix pinning for backports The 2.x series added a changed behavior for backport pinning to pin to origin instead of release. Pinning to release is the correct behavior for backports though. --- manifests/backports.pp | 22 ++++++++++++++-------- spec/classes/apt_backports_spec.rb | 10 +++++----- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/manifests/backports.pp b/manifests/backports.pp index 3cac0b5b5b..f7e85f59ed 100644 --- a/manifests/backports.pp +++ b/manifests/backports.pp @@ -23,12 +23,6 @@ } $_key = $key } - unless is_hash($pin) { - unless (is_numeric($pin) or is_string($pin)) { - fail('pin must be either a string, number or hash') - } - } - if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') { unless $location { $_location = $::apt::backports['location'] @@ -48,12 +42,24 @@ } } + if is_hash($pin) { + $_pin = $pin + } elsif is_numeric($pin) or is_string($pin) { + # apt::source defaults to pinning to origin, but we should pin to release + # for backports + $_pin = { + 'priority' => $pin, + 'release' => $_release, + } + } else { + fail('pin must be either a string, number or hash') + } + apt::source { 'backports': location => $_location, release => $_release, repos => $_repos, key => $_key, - pin => $pin, + pin => $_pin, } - } diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index a80af1e4bd..496fec0cdf 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -18,7 +18,7 @@ :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :repos => 'main contrib non-free', :release => 'wheezy-backports', - :pin => 200, + :pin => { 'priority' => 200, 'release' => 'wheezy-backports' }, }) } end @@ -36,7 +36,7 @@ :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :repos => 'main contrib non-free', :release => 'squeeze-backports', - :pin => 200, + :pin => { 'priority' => 200, 'release' => 'squeeze-backports' }, }) } end @@ -54,7 +54,7 @@ :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', :repos => 'main universe multiverse restricted', :release => 'trusty-backports', - :pin => 200, + :pin => { 'priority' => 200, 'release' => 'trusty-backports' }, }) } end @@ -81,7 +81,7 @@ :key => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', :repos => 'main', :release => 'vivid', - :pin => 90, + :pin => { 'priority' => 90, 'release' => 'vivid' }, }) } end @@ -134,7 +134,7 @@ :key => '630239CC130E1A7FD81A27B140976EAF437D05B5', :repos => 'main universe multiverse restricted', :release => 'trusty-backports', - :pin => 200, + :pin => { 'priority' => 200, 'release' => 'trusty-backports' }, }) } end From a531b2b4245f2df86ddf8a11e53568f43b6e1ffb Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 24 Aug 2015 17:53:02 +0100 Subject: [PATCH 554/574] Corrected regression with preference files name Signed-off-by: Vincent Deygas --- manifests/params.pp | 2 +- manifests/setting.pp | 2 +- spec/defines/setting_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index ea18460654..861a6af34f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -61,7 +61,7 @@ }, 'pref' => { 'path' => $preferences_d, - 'ext' => '', + 'ext' => '.pref', }, 'list' => { 'path' => $sources_list_d, diff --git a/manifests/setting.pp b/manifests/setting.pp index d723eb2c53..b0fb62b1de 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -37,7 +37,7 @@ validate_string($content) } - if $setting_type == 'list' { + if ($setting_type == 'list') or ($setting_type == 'pref') { $_priority = '' } else { $_priority = $priority diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 07d94ef480..a326bdbdd3 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -22,7 +22,7 @@ context 'with title=pref-teddybear' do let(:title) { 'pref-teddybear' } let(:params) { default_params } - it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Class[Apt::Update]') } + it { is_expected.to contain_file('/etc/apt/preferences.d/teddybear.pref').that_notifies('Class[Apt::Update]') } end context 'with title=list-teddybear' do From 0dce05adaec1b3f789302dfec026b79aeded220c Mon Sep 17 00:00:00 2001 From: Robert Drake Date: Tue, 1 Sep 2015 12:00:24 -0400 Subject: [PATCH 555/574] Add support for creating pins from main class This lets you create apt::pin resources as an apt param hash. It also supplies appropriate tests and documentation. --- README.md | 4 +++- manifests/init.pp | 7 +++++++ spec/classes/apt_spec.rb | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b2b554633d..1c9591dcb7 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,9 @@ Main class, includes all other classes. * `settings`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. -* `sources`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. +* `sources`: Creates new `apt::source` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. + +* `pins`: Creates new `apt::pin` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}. * `update`: Configures various update settings. Valid options: a hash made up from the following keys: diff --git a/manifests/init.pp b/manifests/init.pp index b9087cfb7a..2e82502622 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -6,6 +6,7 @@ $sources = {}, $keys = {}, $ppas = {}, + $pins = {}, $settings = {}, ) inherits ::apt::params { @@ -66,6 +67,7 @@ validate_hash($keys) validate_hash($settings) validate_hash($ppas) + validate_hash($pins) if $_proxy['ensure'] == 'absent' or $_proxy['host'] { apt::setting { 'conf-proxy': @@ -153,4 +155,9 @@ if $settings { create_resources('apt::setting', $settings) } + + # manage pins if present + if $pins { + create_resources('apt::pin', $pins) + } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 7578d2eb78..5aded56b75 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -237,6 +237,23 @@ it { is_expected.to contain_apt__setting('pref-banana')} end + context 'with pins defined on valid osfamily' do + let :facts do + { :osfamily => 'Debian', + :lsbdistcodename => 'precise', + :lsbdistid => 'Debian', + :puppetversion => Puppet.version, + } + end + let(:params) { { :pins => { + 'stable' => { 'priority' => 600, 'order' => 50 }, + 'testing' => { 'priority' => 700, 'order' => 100 }, + } } } + + it { is_expected.to contain_apt__pin('stable') } + it { is_expected.to contain_apt__pin('testing') } + end + describe 'failing tests' do context "purge['sources.list']=>'banana'" do let(:params) { { :purge => { 'sources.list' => 'banana' }, } } From a7d0f9fb31772ee467e2b67b5ad035cd4daae5da Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Fri, 25 Sep 2015 16:07:57 -0700 Subject: [PATCH 556/574] Release prep for 2.2.0 --- CHANGELOG.md | 17 +++++++++++++++++ metadata.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7403b6fe86..393a907db9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +##2015-09-29 - Supported Release 2.2.0 +###Summary + +This release includes a few bugfixes. + +####Features +- Adds an `ensure` parameter for user control of proxy presence. +- Adds ability to set `notify_update` to `apt::conf` (MODULES-2269). +- Apt pins no longer trigger an `apt-get update` run. +- Adds support for creating pins from main class. + +####Bugfixes +- Updates to use the official Debian mirrors. +- Fixes path to `preferences` and `preferences.d` +- Fixes pinning for backports (MODULES-2446). +- Fixes the name/extension of the preferences files. + ##2015-07-28 - Supported Release 2.1.1 ###Summary diff --git a/metadata.json b/metadata.json index 7c694e717e..8632a36dfd 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-apt", - "version": "2.1.1", + "version": "2.2.0", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", From 68693418f48e1440b5262b4550eb64897c772272 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Fri, 9 Oct 2015 13:07:32 +0100 Subject: [PATCH 557/574] (MAINT) improve hiera description --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c9591dcb7..5ab4275a38 100644 --- a/README.md +++ b/README.md @@ -150,16 +150,21 @@ apt::source { 'puppetlabs': ### Configure Apt from Hiera +Instead of specifying your sources directly as resources, you can instead just +include the `apt` class, which will pick up the values automatically from +hiera. + ~~~yaml apt::sources: 'debian_unstable': + comment: 'This is the iWeb Debian unstable mirror' location: 'http://debian.mirror.iweb.ca/debian/' release: 'unstable' repos: 'main contrib non-free' + pin: '-10' key: - id: '9AA38DCD55BE302B' + id: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' server: 'subkeys.pgp.net' - pin: '-10' include: src: true deb: true From b11a45ec690642fd65588ce25957140d49650c0c Mon Sep 17 00:00:00 2001 From: Patrick Hervieux Date: Wed, 4 Nov 2015 16:48:22 +0100 Subject: [PATCH 558/574] Add 15.10 support --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 861a6af34f..a8f014b8f3 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -140,7 +140,7 @@ $ppa_options = '-y' $ppa_package = 'python-software-properties' } - 'trusty', 'utopic', 'vivid': { + 'trusty', 'utopic', 'vivid', 'wily': { $ppa_options = '-y' $ppa_package = 'software-properties-common' } From ea6a84f336d5bb7e2ccab04cc6b2a4b2722b503d Mon Sep 17 00:00:00 2001 From: Clayton O'Neill Date: Wed, 11 Nov 2015 20:11:24 +0000 Subject: [PATCH 559/574] Fix apt_key tempfile race condition The Ruby Tempfile class has a finalizer that removes the file when the GC runs. It's not predictible when the GC will run, so you have to ensure that the instance of the class stays in scope for as long as you need it. Unfortunately the tempfile method is returning just the filename of the temporary file, which means it goes out of scope when that method returns. This allows the GC to reap it at any time after return. In both CI and production environments we've seen this race fail, causing apt-key add to fail a small (2-3%) amount of the time. This changes the tempfile and source_to_file methods to return the underlying Tempfile object, pushing it up into the caller's scope. Both of the callers immediately use the object to get its filename and then open the file, eliminating the race. Tested this by adding 'GC.start; sleep(1)' immediately before the command is run, to give the GC plenty of time to remove the tempfile if it was going to. --- lib/puppet/provider/apt_key/apt_key.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index f8c7d1976a..a6d68b1732 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -118,7 +118,13 @@ def source_to_file(value) parsedValue = URI::parse(value) if parsedValue.scheme.nil? fail("The file #{value} does not exist") unless File.exists?(value) - value + # Because the tempfile method has to return a live object to prevent GC + # of the underlying file from occuring too early, we also have to return + # a file object here. The caller can still call the #path method on the + # closed file handle to get the path. + f = File.open(value, 'r') + f.close + f else begin key = parsedValue.read @@ -132,6 +138,9 @@ def source_to_file(value) end end + # The tempfile method needs to return the tempfile object to the caller, so + # that it doesn't get deleted by the GC immediately after it returns. We + # want the caller to control when it goes out of scope. def tempfile(content) file = Tempfile.new('apt_key') file.write content @@ -155,7 +164,7 @@ def tempfile(content) warning('/usr/bin/gpg cannot be found for verification of the id.') end end - file.path + file end def exists? @@ -173,9 +182,11 @@ def create end command.push('--recv-keys', resource[:id]) elsif resource[:content] - command.push('add', tempfile(resource[:content])) + key_file = tempfile(resource[:content]) + command.push('add', key_file.path) elsif resource[:source] - command.push('add', source_to_file(resource[:source])) + key_file = source_to_file(resource[:source]) + command.push('add', key_file.path) # In case we really screwed up, better safe than sorry. else fail("an unexpected condition occurred while trying to add the key: #{resource[:id]}") From c14f39965905a2ce950e145f76daef6e2b2343a4 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Mon, 23 Nov 2015 12:31:23 +0000 Subject: [PATCH 560/574] Release 2.2.1 --- CHANGELOG.md | 5 +++++ metadata.json | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 393a907db9..c310fb695b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +##Supported Release 2.2.1 +###Summary + +Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. + ##2015-09-29 - Supported Release 2.2.0 ###Summary diff --git a/metadata.json b/metadata.json index 8632a36dfd..77ba0fcafa 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-apt", - "version": "2.2.0", + "version": "2.2.1", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", @@ -30,7 +30,7 @@ "requirements": [ { "name": "pe", - "version_requirement": ">= 3.3.0 < 2015.3.0" + "version_requirement": ">= 3.3.0 < 2015.4.0" }, { "name": "puppet", From cf708a7aad070da078e12cabd611a0c8fe3cec91 Mon Sep 17 00:00:00 2001 From: Rudy YAYON Date: Thu, 10 Dec 2015 11:22:22 +0100 Subject: [PATCH 561/574] MODULES-2861: run stages limitation added to the documentation --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ab4275a38..cfad084da7 100644 --- a/README.md +++ b/README.md @@ -467,12 +467,14 @@ Manages the GPG keys that Apt uses to authenticate packages. This module is tested and officially supported on Debian 6 and 7 and Ubuntu 10.04, 12.04, and 14.04. Testing on other platforms has been light and cannot be guaranteed. +This module is not designed to be split across [run stages](https://docs.puppetlabs.com/puppet/latest/reference/lang_run_stages.html). + ### Adding new sources or PPAs If you are adding a new source or PPA and trying to install packages from the new source or PPA on the same Puppet run, your `package` resource should depend on `Class['apt::update']`, in addition to depending on the `Apt::Source` or the `Apt::Ppa`. You can also add [collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html) to ensure that all packages happen after `apt::update`, but this can lead to dependency cycles and has implications for [virtual resources](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html#behavior). ~~~puppet -Class['apt::update'] -> Package<| |> +Class['apt::update'] -> Package <| provider == 'apt' |> ~~~ ## Development From 6698cbe94bffec8469fe82b8dfafffe2ee3e6089 Mon Sep 17 00:00:00 2001 From: Andreas Mauf Date: Mon, 14 Dec 2015 10:20:40 +0100 Subject: [PATCH 562/574] MODULES-2889 - remove unneeded whitespace in source.list template --- spec/defines/source_compat_spec.rb | 2 +- spec/defines/source_spec.rb | 2 +- templates/source.list.erb | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index 2e813f327b..0b98176e2a 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -117,7 +117,7 @@ } end - it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[arch=x86_64 \] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) + it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) } end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 8a2cfcc747..cfae55cc8f 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -227,7 +227,7 @@ it { is_expected.to contain_apt__setting('list-my_source').with({ :ensure => 'present', - }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] hello.there wheezy main\n/) + }).with_content(/# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n/) } end diff --git a/templates/source.list.erb b/templates/source.list.erb index fe7f55941a..84cd2cf728 100644 --- a/templates/source.list.erb +++ b/templates/source.list.erb @@ -1,11 +1,9 @@ # <%= @comment %> <%- if @_include['deb'] then -%> deb <%- if @architecture or @_allow_unsigned -%> -[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @_allow_unsigned %>trusted=yes<% end -%> -] <%- end %><%= @location %> <%= @_release %> <%= @repos %> +[<%- if @architecture %>arch=<%= @architecture %><% end %><%if @architecture and @_allow_unsigned %> <% end%><% if @_allow_unsigned %>trusted=yes<% end %>] <%- end %><%= @location %> <%= @_release %> <%= @repos %> <%- end -%> <%- if @_include['src'] then -%> deb-src <%- if @architecture or @_allow_unsigned -%> -[<%- if @architecture %>arch=<%= @architecture %> <% end %><% if @_allow_unsigned %>trusted=yes<% end -%> -] <%- end %><%= @location %> <%= @_release %> <%= @repos %> +[<%- if @architecture %>arch=<%= @architecture %><% end %><%if @architecture and @_allow_unsigned %> <% end%><% if @_allow_unsigned %>trusted=yes<% end %>] <%- end %><%= @location %> <%= @_release %> <%= @repos %> <%- end -%> From 7fa207e335d165b1ec55339735db12a54d95902d Mon Sep 17 00:00:00 2001 From: Tim Bishop Date: Mon, 18 Jan 2016 21:47:32 +0000 Subject: [PATCH 563/574] Handle PPA names that contain a plus character. It looks like add-apt-repository changes pluses to underscores when creating the sources.list.d file. So the name it creates doesn't match what Puppet expects, and the resource keeps applying on every Puppet run. This works around that problem. --- manifests/ppa.pp | 3 ++- spec/defines/ppa_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 6352352c8d..d6b4900760 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -16,7 +16,8 @@ $filename_without_slashes = regsubst($name, '/', '-', 'G') $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G') - $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') + $filename_without_pluses = regsubst($filename_without_dots, '\+', '_', 'G') + $filename_without_ppa = regsubst($filename_without_pluses, '^ppa:', '', 'G') $sources_list_d_filename = "${filename_without_ppa}-${release}.list" if $ensure == 'present' { diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index b7a2f6c004..fe25978255 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -16,12 +16,12 @@ } end - let(:title) { 'ppa:needs/such.substitution/wow' } + let(:title) { 'ppa:needs/such.substitution/wow+type' } it { is_expected.to_not contain_package('python-software-properties') } - it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with({ :environment => [], - :command => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', + :command => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow_type-natty.list', :user => 'root', :logoutput => 'on_failure', }) From 10a8e79e7fba1d0f3ae01eaf4439de32a92c2138 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 25 Jan 2016 15:42:27 +0000 Subject: [PATCH 564/574] (FM-4049) Update to current msync configs [2c99161] --- .gitignore | 1 + .rspec | 2 ++ .sync.yml | 26 -------------------------- .travis.yml | 17 +++++++++-------- CONTRIBUTING.md | 6 +++--- Gemfile | 23 +++++++++++------------ Rakefile | 3 ++- spec/spec_helper.rb | 6 ++++++ 8 files changed, 34 insertions(+), 50 deletions(-) create mode 100644 .rspec delete mode 100644 .sync.yml diff --git a/.gitignore b/.gitignore index b5db85e051..3190277498 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ spec/fixtures/ .vagrant/ .bundle/ coverage/ +log/ .idea/ *.iml diff --git a/.rspec b/.rspec new file mode 100644 index 0000000000..16f9cdb013 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.sync.yml b/.sync.yml deleted file mode 100644 index 625d045a31..0000000000 --- a/.sync.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -.travis.yml: - includes: - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - - rvm: 2.1.6 - env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" - allow_failures: -Gemfile: - required: - ':development, :unit_tests': - - gem: rspec-puppet - version: '~> 2.1' - - gem: rspec-core - version: '3.1.7' - - gem: puppetlabs_spec_helper - - gem: simplecov - - gem: puppet_facts - - gem: json - ':system_tests': - - gem: beaker-rspec - - gem: serverspec diff --git a/.travis.yml b/.travis.yml index 8b6adc2d2c..e6314a4700 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,19 @@ --- sudo: false language: ruby +cache: bundler bundler_args: --without system_tests -script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--format documentation'" +script: "bundle exec rake validate lint spec" matrix: fast_finish: true include: - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES="yes" ORDERING="random" - rvm: 2.1.6 - env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" ORDERING="random" + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 3.0" notifications: email: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1cbde4bbf..bfeaa701ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -159,7 +159,7 @@ If you already have those gems installed, make sure they are up-to-date: With all dependencies in place and up-to-date we can now run the tests: ```shell -% rake spec +% bundle exec rake spec ``` This will execute all the [rspec tests](http://rspec-puppet.com/) tests @@ -178,8 +178,8 @@ installed on your system. You can run them by issuing the following command ```shell -% rake spec_clean -% rspec spec/acceptance +% bundle exec rake spec_clean +% bundle exec rspec spec/acceptance ``` This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), diff --git a/Gemfile b/Gemfile index 643d3f5d9e..ced190e770 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" def location_for(place, fake_version = nil) - if place =~ /^(git:[^#]*)#(.*)/ + if place =~ /^(git[:@][^#]*)#(.*)/ [fake_version, { :git => $1, :branch => $2, :require => false }].compact elsif place =~ /^file:\/\/(.*)/ ['>= 0', { :path => File.expand_path($1), :require => false }] @@ -11,15 +11,16 @@ def location_for(place, fake_version = nil) end group :development, :unit_tests do - gem 'rspec-puppet', '~> 2.1', :require => false - gem 'rspec-core', '3.1.7', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'simplecov', :require => false - gem 'puppet_facts', :require => false - gem 'json', :require => false + gem 'json', :require => false + gem 'metadata-json-lint', :require => false + gem 'puppet_facts', :require => false + gem 'puppet-blacksmith', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-puppet', '>= 2.3.2', :require => false + gem 'simplecov', :require => false end - group :system_tests do + gem 'beaker-puppet_install_helper', :require => false if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) end @@ -28,12 +29,10 @@ group :system_tests do else gem 'beaker-rspec', :require => false end - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false + gem 'master_manipulator', :require => false + gem 'serverspec', :require => false end - - if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion, :require => false else diff --git a/Rakefile b/Rakefile index 181157e6e0..35ce31140e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ -require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet_blacksmith/rake_tasks' require 'puppet-lint/tasks/puppet-lint' +require 'puppetlabs_spec_helper/rake_tasks' PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.send('relative') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2c6f56649a..a7f5b4ecb3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1 +1,7 @@ require 'puppetlabs_spec_helper/module_spec_helper' + +# put local configuration and setup into spec_helper_local +begin + require 'spec_helper_local' +rescue LoadError +end From c70491dcef31ca48a5224439dfe20a3acbf2840a Mon Sep 17 00:00:00 2001 From: jbondpdx Date: Thu, 28 Jan 2016 11:45:35 -0800 Subject: [PATCH 565/574] MODULES-2941: add example to README --- README.md | 134 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index cfad084da7..33e65a968e 100644 --- a/README.md +++ b/README.md @@ -2,26 +2,31 @@ #### Table of Contents -1. [Overview](#overview) + 2. [Module Description - What the module does and why it is useful](#module-description) 3. [Setup - The basics of getting started with apt](#setup) * [What apt affects](#what-apt-affects) * [Beginning with apt](#beginning-with-apt) 4. [Usage - Configuration options and additional functionality](#usage) + * [Add GPG keys](#add-gpg-keys) + * [Prioritize backports](#prioritize-backports) + * [Update the list of packages](#update-the-list-of-packages) + * [Pin a specific release](#pin-a-specific-release) + * [Add a Personal Package Archive repository](#add-a-personal-package-archive-repository) + * [Configure Apt from Hiera](#configure-apt-from-hiera) + * [Replace the default sources.list file](#replace-the-default-sourceslist-file) 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) * [Classes](#classes) - * [Defines](#defines) + * [Defined Types](#defined-types) * [Types](#types) * [Facts](#facts) 6. [Limitations - OS compatibility, etc.](#limitations) 7. [Development - Guide for contributing to the module](#development) -## Overview +## Module Description The apt module lets you use Puppet to manage Apt sources, keys, and other configuration options. -## Module Description - Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, and several other operating systems. The apt module provides a series of classes, defines, types, and facts to help you automate Apt package management. **Note**: For this module to correctly autodetect which version of Debian/Ubuntu (or derivative) you're running, you need to make sure the 'lsb-release' package is installed. We highly recommend you either make this part of your provisioning layer, if you run many Debian or derivative systems, or ensure that you have Facter 2.2.0 or later installed, which will pull this dependency in for you. @@ -41,11 +46,11 @@ Apt (Advanced Package Tool) is a package manager available on Debian, Ubuntu, an To use the apt module with default parameters, declare the `apt` class. -~~~puppet +```puppet include apt -~~~ +``` -**Note:** The main `apt` class is required by all other classes, types, and defines in this module. You must declare it whenever you use the module. +**Note:** The main `apt` class is required by all other classes, types, and defined types in this module. You must declare it whenever you use the module. ## Usage @@ -55,21 +60,21 @@ include apt Declare the `apt::key` class: -~~~puppet +```puppet apt::key { 'puppetlabs': id => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', server => 'pgp.mit.edu', options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', } -~~~ +``` ### Prioritize backports -~~~puppet +```puppet class { 'apt::backports': pin => 500, } -~~~ +``` By default, the `apt::backports` class drops a pin file for backports, pinning it to a priority of 200. This is lower than the normal default of 500, so packages with `ensure => latest` don't get upgraded from backports without your explicit permission. @@ -79,25 +84,25 @@ If you raise the priority through the `pin` parameter to 500, normal policy goes By default, Puppet runs `apt-get update` on the first Puppet run after you include the `apt` class, and anytime `notify => Exec['apt_update']` occurs; i.e., whenever config files get updated or other relevant changes occur. If you set `update['frequency']` to 'always', the update runs on every Puppet run. You can also set `update['frequency']` to 'daily' or 'weekly': -~~~puppet +```puppet class { 'apt': update => { frequency => 'daily', }, } -~~~ +``` ### Pin a specific release -~~~puppet +```puppet apt::pin { 'karmic': priority => 700 } apt::pin { 'karmic-updates': priority => 700 } apt::pin { 'karmic-security': priority => 700 } -~~~ +``` You can also specify more complex pins using distribution properties: -~~~puppet +```puppet apt::pin { 'stable': priority => -10, originator => 'Debian', @@ -105,19 +110,19 @@ apt::pin { 'stable': component => 'main', label => 'Debian' } -~~~ +``` To pin multiple packages, pass them to the `packages` parameter as an array or a space-delimited string. -### Add a PPA (Personal Package Archive) repository +### Add a Personal Package Archive repository -~~~puppet +```puppet apt::ppa { 'ppa:drizzle-developers/ppa': } -~~~ +``` ### Add an Apt source to `/etc/apt/sources.list.d/` -~~~puppet +```puppet apt::source { 'debian_unstable': comment => 'This is the iWeb Debian unstable mirror', location => 'http://debian.mirror.iweb.ca/debian/', @@ -133,11 +138,11 @@ apt::source { 'debian_unstable': 'deb' => true, }, } -~~~ +``` To use the Puppet Labs Apt repository as a source: -~~~puppet +```puppet apt::source { 'puppetlabs': location => 'http://apt.puppetlabs.com', repos => 'main', @@ -146,7 +151,7 @@ apt::source { 'puppetlabs': 'server' => 'pgp.mit.edu', }, }, -~~~ +``` ### Configure Apt from Hiera @@ -154,7 +159,7 @@ Instead of specifying your sources directly as resources, you can instead just include the `apt` class, which will pick up the values automatically from hiera. -~~~yaml +```yaml apt::sources: 'debian_unstable': comment: 'This is the iWeb Debian unstable mirror' @@ -175,7 +180,40 @@ apt::sources: key: id: '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30' server: 'pgp.mit.edu' -~~~ +``` + +### Replace the default sources.list file + +To replace the default `/etc/apt/sources.list` file on standard Ubuntu machines: + +```puppet +apt::source { "archive.ubuntu.com-${lsbdistcodename}": + location => 'http://archive.ubuntu.com/ubuntu', + key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + repos => 'main universe multiverse restricted', +} + +apt::source { "archive.ubuntu.com-${lsbdistcodename}-security": + location => 'http://archive.ubuntu.com/ubuntu', + key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + repos => 'main universe multiverse restricted', + release => "${lsbdistcodename}-security" +} + +apt::source { "archive.ubuntu.com-${lsbdistcodename}-updates": + location => 'http://archive.ubuntu.com/ubuntu', + key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + repos => 'main universe multiverse restricted', + release => "${lsbdistcodename}-updates" +} + +apt::source { "archive.ubuntu.com-${lsbdistcodename}-backports": + location => 'http://archive.ubuntu.com/ubuntu', + key => '630239CC130E1A7FD81A27B140976EAF437D05B5', + repos => 'main universe multiverse restricted', + release => "${lsbdistcodename}-backports" +} +``` ## Reference @@ -191,14 +229,14 @@ apt::sources: * `apt::params`: Provides defaults for the apt module parameters. * `apt::update`: Updates the list of available packages using `apt-get update`. -### Defines +### Defined Types -* [`apt::conf`](#define-aptconf) -* [`apt::key`](#define-aptkey) -* [`apt::pin`](#define-aptpin) -* [`apt::ppa`](#define-aptppa) -* [`apt::setting`](#define-aptsetting) -* [`apt::source`](#define-aptsource) +* [`apt::conf`](#defined-type-aptconf) +* [`apt::key`](#defined-type-aptkey) +* [`apt::pin`](#defined-type-aptpin) +* [`apt::ppa`](#defined-type-aptppa) +* [`apt::setting`](#defined-type-aptsetting) +* [`apt::source`](#defined-type-aptsource) ### Types @@ -266,7 +304,7 @@ Manages backports. ##### Parameters (all optional on Debian and Ubuntu; all required on other operating systems, except where specified) -* `key`: Specifies a key to authenticate the backports. Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Defaults: +* `key`: Specifies a key to authenticate the backports. Valid options: a string to be passed to the `id` parameter of the `apt::key` defined type, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Defaults: * Debian: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' * Ubuntu: '630239CC130E1A7FD81A27B140976EAF437D05B5' @@ -277,7 +315,7 @@ Manages backports. * Debian (other): 'http://httpredir.debian.org/debian' * Ubuntu: 'http://archive.ubuntu.com/ubuntu' -* `pin`: *Optional.* Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` define, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: '200'. +* `pin`: *Optional.* Specifies a pin priority for the backports. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: '200'. * `release`: Specifies a distribution of the Apt repository containing the backports to manage. Valid options: a string containing the release, used in populating the `source.list` configuration file. Default: on Debian and Ubuntu, '${lsbdistcodename}-backports'. We recommend keeping this default, except on other operating systems. @@ -286,7 +324,7 @@ Manages backports. * Debian: 'main contrib non-free' * Ubuntu: 'main universe multiverse restricted' -#### Define: `apt::conf` +#### Defined Type: `apt::conf` Specifies a custom Apt configuration file. @@ -300,11 +338,11 @@ Specifies a custom Apt configuration file. * `notify_update`: *Optional.* Specifies whether to trigger an `apt-get update` run. Valid options: 'true' and 'false'. Default: 'true'. -#### Define: `apt::key` +#### Defined Type: `apt::key` Manages the GPG keys that Apt uses to authenticate packages. -The `apt::key` define makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. +The `apt::key` defined type makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. ##### Parameters (all optional) @@ -330,7 +368,7 @@ The `apt::key` define makes use of the `apt_key` type, but includes extra functi * `key_options`: Passes additional options to `apt-key adv --keyserver-options`. Valid options: a string. Default: undef. **Note** This parameter is deprecated and will be removed in a future release. -#### Define: `apt::pin` +#### Defined Type: `apt::pin` Manages Apt pins. Does not trigger an `apt-get update` run. @@ -364,7 +402,7 @@ Manages Apt pins. Does not trigger an `apt-get update` run. * `version`: Tells Apt to prefer a specified package version or version range. Valid options: a string. Default: ''. -#### Define: `apt::ppa` +#### Defined Type: `apt::ppa` Manages PPA repositories using `add-apt-repository`. Not supported on Debian. @@ -387,7 +425,7 @@ Manages PPA repositories using `add-apt-repository`. Not supported on Debian. * `release`: *Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint).* Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename. Default: "$lsbdistcodename". -#### Define: `apt:setting` +#### Defined Type: `apt:setting` Manages Apt configuration files. @@ -403,7 +441,7 @@ Manages Apt configuration files. * `source`: *Required, unless `content` is set.* Specifies a source file to supply the content of the configuration file. Cannot be used in combination with `content`. Valid options: see the `source` attribute of [Puppet's native `file` type](https://docs.puppetlabs.com/references/latest/type.html#file-attribute-source). Default: undef. -#### Define: `apt::source` +#### Defined Type: `apt::source` Manages the Apt sources in `/etc/apt/sources.list.d/`. @@ -417,7 +455,7 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `ensure`: Specifies whether the Apt source file should exist. Valid options: 'present' and 'absent'. Default: 'present'. -* `key`: Creates a declaration of the apt::key define Valid options: a string to be passed to the `id` parameter of the `apt::key` define, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. +* `key`: Creates a declaration of the apt::key defined type. Valid options: a string to be passed to the `id` parameter of the `apt::key` defined type, or a hash of `parameter => value` pairs to be passed to `apt::key`'s `id`, `server`, `content`, `source`, and/or `options` parameters. Default: undef. * `include`: Configures include options. Valid options: a hash of available keys. Default: {}. Available keys are: @@ -427,7 +465,7 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. * `location`: *Required, unless `ensure` is set to 'absent'.* Specifies an Apt repository. Valid options: a string containing a repository URL. Default: undef. -* `pin`: Creates a declaration of the apt::pin define Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` define, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: undef. +* `pin`: Creates a declaration of the apt::pin defined type. Valid options: a number or string to be passed to the `id` parameter of the `apt::pin` defined type, or a hash of `parameter => value` pairs to be passed to `apt::pin`'s corresponding parameters. Default: undef. * `release`: Specifies a distribution of the Apt repository. Valid options: a string. Default: "$lsbdistcodename". @@ -451,7 +489,7 @@ Manages the Apt sources in `/etc/apt/sources.list.d/`. Manages the GPG keys that Apt uses to authenticate packages. -**Note:** In most cases, we recommend using the `apt::key` define. It makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. +**Note:** In most cases, we recommend using the `apt::key` defined type. It makes use of the `apt_key` type, but includes extra functionality to help prevent duplicate keys. ##### Parameters (all optional) @@ -473,9 +511,9 @@ This module is not designed to be split across [run stages](https://docs.puppetl If you are adding a new source or PPA and trying to install packages from the new source or PPA on the same Puppet run, your `package` resource should depend on `Class['apt::update']`, in addition to depending on the `Apt::Source` or the `Apt::Ppa`. You can also add [collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html) to ensure that all packages happen after `apt::update`, but this can lead to dependency cycles and has implications for [virtual resources](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html#behavior). -~~~puppet +```puppet Class['apt::update'] -> Package <| provider == 'apt' |> -~~~ +``` ## Development Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. From 6fa0b9a382249190e4df68a71aab0571a681f5b2 Mon Sep 17 00:00:00 2001 From: jbondpdx Date: Fri, 29 Jan 2016 11:11:46 -0800 Subject: [PATCH 566/574] MODULES-2941: added more info about replacing sources.list --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33e65a968e..345a0f3ab9 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ apt::sources: ### Replace the default sources.list file -To replace the default `/etc/apt/sources.list` file on standard Ubuntu machines: +The following example replaces the default `/etc/apt/sources.list`. Along with this code, be sure to use the `purge` parameter, or you might get duplicate source warnings when running Apt. ```puppet apt::source { "archive.ubuntu.com-${lsbdistcodename}": From 08c8b582647f76fa22ee07d49c38ae029fe079a1 Mon Sep 17 00:00:00 2001 From: "matt.cover" Date: Tue, 2 Feb 2016 08:54:43 -0700 Subject: [PATCH 567/574] MODULES-2873 - Avoid duplicate package resources when package_manage => true --- manifests/ppa.pp | 2 +- spec/defines/ppa_spec.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index d6b4900760..b83500b919 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -22,7 +22,7 @@ if $ensure == 'present' { if $package_manage { - package { $package_name: } + ensure_packages($package_name) $_require = [File['sources.list.d'], Package[$package_name]] } else { diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index fe25978255..5080a876bb 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -72,6 +72,46 @@ } end + describe 'package_manage => true, multiple ppas, MODULES-2873' do + let :pre_condition do + 'class { "apt": } + apt::ppa {"ppa:foo": + package_manage => true + }' + end + let :facts do + { + :lsbdistrelease => '11.04', + :lsbdistcodename => 'natty', + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistid => 'Ubuntu', + :puppetversion => Puppet.version, + } + end + let :params do + { + :package_manage => true, + } + end + + let(:title) { 'ppa:bar' } + it { is_expected.to contain_package('python-software-properties') } + it { is_expected.to contain_exec('add-apt-repository-ppa:bar').that_notifies('Class[Apt::Update]').with({ + 'environment' => [], + 'command' => '/usr/bin/add-apt-repository -y ppa:bar', + 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/bar-natty.list', + 'user' => 'root', + 'logoutput' => 'on_failure', + }) + } + + it { is_expected.to contain_file('/etc/apt/sources.list.d/bar-natty.list').that_requires('Exec[add-apt-repository-ppa:bar]').with({ + 'ensure' => 'file', + }) + } + end + describe 'package_manage => false' do let :pre_condition do 'class { "apt": }' From 4d66d23becb51efd0eb0766352ce5f53dfacd7ba Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Wed, 3 Feb 2016 17:09:40 +0100 Subject: [PATCH 568/574] Ensure PPAs in tests have valid form "man apt-add-repository" notes: "REPOSITORY can be either a line that can be added directly to sources.list(5), in the form ppa:/ for adding Personal Package Archives". Fix the tests to always use the format ppa:/ when adding PPAs. --- spec/defines/ppa_spec.rb | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 5080a876bb..1e7e23a42f 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -75,7 +75,7 @@ describe 'package_manage => true, multiple ppas, MODULES-2873' do let :pre_condition do 'class { "apt": } - apt::ppa {"ppa:foo": + apt::ppa {"ppa:user/foo": package_manage => true }' end @@ -95,18 +95,18 @@ } end - let(:title) { 'ppa:bar' } + let(:title) { 'ppa:user/bar' } it { is_expected.to contain_package('python-software-properties') } - it { is_expected.to contain_exec('add-apt-repository-ppa:bar').that_notifies('Class[Apt::Update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/bar').that_notifies('Class[Apt::Update]').with({ 'environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:bar', - 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/bar-natty.list', + 'command' => '/usr/bin/add-apt-repository -y ppa:user/bar', + 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/user-bar-natty.list', 'user' => 'root', 'logoutput' => 'on_failure', }) } - it { is_expected.to contain_file('/etc/apt/sources.list.d/bar-natty.list').that_requires('Exec[add-apt-repository-ppa:bar]').with({ + it { is_expected.to contain_file('/etc/apt/sources.list.d/user-bar-natty.list').that_requires('Exec[add-apt-repository-ppa:user/bar]').with({ 'ensure' => 'file', }) } @@ -152,7 +152,7 @@ describe 'apt included, no proxy' do let :pre_condition do 'class { "apt": } - apt::ppa { "ppa:foo2": } + apt::ppa { "ppa:user/foo2": } ' end let :facts do @@ -169,16 +169,16 @@ { :options => '', :package_manage => true, - :require => 'Apt::Ppa[ppa:foo2]', + :require => 'Apt::Ppa[ppa:user/foo2]', } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } it { is_expected.to compile.with_all_deps } it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ :environment => [], - :command => '/usr/bin/add-apt-repository ppa:foo', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :command => '/usr/bin/add-apt-repository ppa:user/foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/user-foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) @@ -207,12 +207,12 @@ 'package_manage' => true, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8080'], - :command => '/usr/bin/add-apt-repository ppa:foo', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :command => '/usr/bin/add-apt-repository ppa:user/foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/user-foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) @@ -241,12 +241,12 @@ :package_manage => true, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8180'], - :command => '/usr/bin/add-apt-repository ppa:foo', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :command => '/usr/bin/add-apt-repository ppa:user/foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/user-foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) @@ -275,12 +275,12 @@ :package_manage => true, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } - it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'], - :command => '/usr/bin/add-apt-repository ppa:foo', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :command => '/usr/bin/add-apt-repository ppa:user/foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/user-foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) @@ -301,13 +301,13 @@ :puppetversion => Puppet.version, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } let :params do { :ensure => 'absent' } end - it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Class[Apt::Update]').with({ + it { is_expected.to contain_file('/etc/apt/sources.list.d/user-foo-trusty.list').that_notifies('Class[Apt::Update]').with({ :ensure => 'absent', }) } @@ -325,7 +325,7 @@ :puppetversion => Puppet.version, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } it do expect { subject.call @@ -344,7 +344,7 @@ :puppetversion => Puppet.version, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } it do expect { subject.call From a02654e36ca0cec2fa8360d0f52d34801df9229a Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Wed, 3 Feb 2016 17:13:46 +0100 Subject: [PATCH 569/574] Look for correct sources.list.d file for apt::ppa In Ubuntu 15.10 the path of the apt sources file, which is generated by apt-add-repository, changed to include the distid. This breaks apt::ppa idempotency, since it does not recognize the repository is already added. Reported on puppet-users as well: https://groups.google.com/forum/#!topic/puppet-users/YzeMyZYUo98 --- manifests/ppa.pp | 18 +++++++++++++----- spec/classes/apt_spec.rb | 1 + spec/defines/ppa_spec.rb | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/manifests/ppa.pp b/manifests/ppa.pp index b83500b919..7069e2ed09 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -14,11 +14,19 @@ fail('apt::ppa is not currently supported on Debian.') } - $filename_without_slashes = regsubst($name, '/', '-', 'G') - $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G') - $filename_without_pluses = regsubst($filename_without_dots, '\+', '_', 'G') - $filename_without_ppa = regsubst($filename_without_pluses, '^ppa:', '', 'G') - $sources_list_d_filename = "${filename_without_ppa}-${release}.list" + $ubuntu_release_year = regsubst($::apt::xfacts['lsbdistrelease'], '\.\d+$', '', 'G') + 0 + $ubuntu_release_month = regsubst($::apt::xfacts['lsbdistrelease'], '^\d+\.', '', 'G') + 0 + + if $ubuntu_release_year >= 15 and $ubuntu_release_month >= 10 { + $distid = downcase($::apt::xfacts['lsbdistid']) + $filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2-${release}") + } else { + $filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2-${release}") + } + + $filename_no_slashes = regsubst($filename, '/', '-', 'G') + $filename_no_specialchars = regsubst($filename_no_slashes, '[\.\+]', '_', 'G') + $sources_list_d_filename = "${filename_no_specialchars}.list" if $ensure == 'present' { if $package_manage { diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 5aded56b75..cc2264bc7a 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -208,6 +208,7 @@ { :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'ubuntu', + :lsbdistrelease => '12.04', :puppetversion => Puppet.version, } end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 1e7e23a42f..74b52ea9c9 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -28,6 +28,29 @@ } end + describe 'Ubuntu 15.10 sources.list filename' do + let :facts do + { + :lsbdistrelease => '15.10', + :lsbdistcodename => 'wily', + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistid => 'Ubuntu', + :puppetversion => Puppet.version, + } + end + + let(:title) { 'ppa:user/foo' } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ + :environment => [], + :command => '/usr/bin/add-apt-repository -y ppa:user/foo', + :unless => '/usr/bin/test -s /etc/apt/sources.list.d/user-ubuntu-foo-wily.list', + :user => 'root', + :logoutput => 'on_failure', + }) + } + end + describe 'ppa depending on ppa, MODULES-1156' do let :pre_condition do 'class { "apt": }' From 541585668b22608a9e67a38b72d2675a64ca88e5 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 16 Feb 2016 15:59:57 +0000 Subject: [PATCH 570/574] (FM-4046) Update to current msync configs [006831f] This moves all copyright statements to the NOTICE file in accordance with the ASFs guidelines on applying the Apache-2.0 license. --- .gitattributes | 5 + .gitignore | 1 + .travis.yml | 1 + Gemfile | 39 +++----- LICENSE | 220 ++++++++++++++++++++++++++++++++++++++------ NOTICE | 40 ++++++++ Rakefile | 31 +++++++ spec/spec_helper.rb | 1 + 8 files changed, 288 insertions(+), 50 deletions(-) create mode 100644 .gitattributes create mode 100644 NOTICE diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..900ea0cbb5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +#This file is generated by ModuleSync, do not edit. +*.rb eol=lf +*.erb eol=lf +*.pp eol=lf +*.sh eol=lf diff --git a/.gitignore b/.gitignore index 3190277498..dd126f2fb2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. pkg/ Gemfile.lock vendor/ diff --git a/.travis.yml b/.travis.yml index e6314a4700..588fb5b002 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. --- sudo: false language: ruby diff --git a/Gemfile b/Gemfile index ced190e770..e490bc9b98 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,14 @@ +#This file is generated by ModuleSync, do not edit. + source ENV['GEM_SOURCE'] || "https://rubygems.org" -def location_for(place, fake_version = nil) +def location_for(place, version = nil) if place =~ /^(git[:@][^#]*)#(.*)/ - [fake_version, { :git => $1, :branch => $2, :require => false }].compact + [version, { :git => $1, :branch => $2, :require => false}].compact elsif place =~ /^file:\/\/(.*)/ - ['>= 0', { :path => File.expand_path($1), :require => false }] + ['>= 0', { :path => File.expand_path($1), :require => false}] else - [place, { :require => false }] + [place, version, { :require => false}].compact end end @@ -20,29 +22,18 @@ group :development, :unit_tests do gem 'simplecov', :require => false end group :system_tests do + gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') + gem 'beaker', *location_for(ENV['BEAKER_VERSION']) + gem 'serverspec', :require => false gem 'beaker-puppet_install_helper', :require => false - if beaker_version = ENV['BEAKER_VERSION'] - gem 'beaker', *location_for(beaker_version) - end - if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] - gem 'beaker-rspec', *location_for(beaker_rspec_version) - else - gem 'beaker-rspec', :require => false - end gem 'master_manipulator', :require => false - gem 'serverspec', :require => false + gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) end -if facterversion = ENV['FACTER_GEM_VERSION'] - gem 'facter', facterversion, :require => false -else - gem 'facter', :require => false -end +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) +gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false -else - gem 'puppet', :require => false -end -# vim:ft=ruby +if File.exists? "#{__FILE__}.local" + eval(File.read("#{__FILE__}.local"), binding) +end diff --git a/LICENSE b/LICENSE index 30ce036d5e..d645695673 100644 --- a/LICENSE +++ b/LICENSE @@ -1,34 +1,202 @@ -Copyright (c) 2011 Evolving Web Inc. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. + 1. Definitions. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. -Copyright 2014 Puppet Labs + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. - http://www.apache.org/licenses/LICENSE-2.0 + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000..8da18e1c7f --- /dev/null +++ b/NOTICE @@ -0,0 +1,40 @@ +apt puppet module + +Copyright (C) 2014-2016 Puppet Labs, Inc. + +Puppet Labs can be contacted at: info@puppetlabs.com + + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + + +Copyright (c) 2011 Evolving Web Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Rakefile b/Rakefile index 35ce31140e..7e9a13d5df 100644 --- a/Rakefile +++ b/Rakefile @@ -9,3 +9,34 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] + +desc 'Generate pooler nodesets' +task :gen_nodeset do + require 'beaker-hostgenerator' + require 'securerandom' + require 'fileutils' + + agent_target = ENV['TEST_TARGET'] + if ! agent_target + STDERR.puts 'TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat-64default."' + agent_target = 'redhat-64default.' + end + + master_target = ENV['MASTER_TEST_TARGET'] + if ! master_target + STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat7-64mdcl"' + master_target = 'redhat7-64mdcl' + end + + targets = "#{master_target}-#{agent_target}" + cli = BeakerHostGenerator::CLI.new([targets]) + nodeset_dir = "tmp/nodesets" + nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" + FileUtils.mkdir_p(nodeset_dir) + File.open(nodeset, 'w') do |fh| + fh.print(cli.execute) + end + puts nodeset +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a7f5b4ecb3..22d5d689f4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ +#This file is generated by ModuleSync, do not edit. require 'puppetlabs_spec_helper/module_spec_helper' # put local configuration and setup into spec_helper_local From 429f0dda8b55208d5faa2122f262ba3eae3c73b4 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 17 Feb 2016 11:52:31 +0000 Subject: [PATCH 571/574] Update metadata to note Debian 8 support --- metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 77ba0fcafa..716e5fe25f 100644 --- a/metadata.json +++ b/metadata.json @@ -15,7 +15,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "6", - "7" + "7", + "8" ] }, { From 0cdb62359e7a40c992098cd35ec15272aa0117c5 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Thu, 25 Feb 2016 12:50:12 +0000 Subject: [PATCH 572/574] Prep for 2.2.2 Release --- CHANGELOG.md | 19 +++++++++++++++++++ metadata.json | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c310fb695b..d0bb5e8c07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +##Supported Release 2.2.2 +###Summary + +Several bug fixes and the addition of support updates to Debian 8 and Ubunto Wily. + +####Bugfixes +- Small fixes to descriptions within the readme and the addition of some examples. +- Updates to run on Ubunto Wily. +- Fixed apt_key tempfile race condition. +- Run stages limitation added to the documentation. +- Remove unneeded whitespace in source.list template. +- Handle PPA names that contain a plus character. +- Update to current msync configs. +- Avoid duplicate package resources when package_manage => true. +- Avoid multiple package resource declarations. +- Ensure PPAs in tests have valid form. +- Look for correct sources.list.d file for apt::ppa. +- Debian 8 support addiiton to metadata. + ##Supported Release 2.2.1 ###Summary diff --git a/metadata.json b/metadata.json index 716e5fe25f..168eb29cba 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-apt", - "version": "2.2.1", + "version": "2.2.2", "author": "Puppet Labs", "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet", "license": "Apache-2.0", From 6bd04e4e49332985758f0f2c75565fde2e0434ed Mon Sep 17 00:00:00 2001 From: Daniel Hoherd Date: Wed, 16 Mar 2016 17:58:08 -0700 Subject: [PATCH 573/574] Typo: missing colon --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 345a0f3ab9..30dfed2416 100644 --- a/README.md +++ b/README.md @@ -425,7 +425,7 @@ Manages PPA repositories using `add-apt-repository`. Not supported on Debian. * `release`: *Optional if lsb-release is installed (unless you're using a different release than indicated by lsb-release, e.g., Linux Mint).* Specifies the operating system of your node. Valid options: a string containing a valid LSB distribution codename. Default: "$lsbdistcodename". -#### Defined Type: `apt:setting` +#### Defined Type: `apt::setting` Manages Apt configuration files. From 562a40bdd5a9da7b79127466082cd2c4d1c248ca Mon Sep 17 00:00:00 2001 From: Jonathan Tripathy Date: Wed, 30 Mar 2016 16:25:54 +0100 Subject: [PATCH 574/574] Pinned rspec_puppet to 2.3.2 --- Gemfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e490bc9b98..3007280c65 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,12 @@ group :development, :unit_tests do gem 'puppet_facts', :require => false gem 'puppet-blacksmith', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-puppet', '>= 2.3.2', :require => false + + # Modulesync will override the following. This is only a temporary measure until we fix + # our tests for rspec-puppet 2.4.0 support. + # Actual update work to be done in https://tickets.puppetlabs.com/browse/FM-5035 + gem 'rspec-puppet', '= 2.3.2', :require => false + gem 'simplecov', :require => false end group :system_tests do