From dfbfc7a05f7ac6713b4ac1379cfb6e2cefa85093 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 13:03:59 -0500 Subject: rename preseeded_package into package keep a wrapper in place with a deprecation notice for the old name so that ppl can know about the change and migrate to the new name --- README.md | 11 +++++++---- manifests/package.pp | 25 +++++++++++++++++++++++++ manifests/preseeded_package.pp | 25 +++++-------------------- 3 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 manifests/package.pp diff --git a/README.md b/README.md index 9405bd8..49110ba 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ * [Defines](#defines) * [apt::apt_conf](#apt-apt_conf) * [apt::preferences_snippet](#apt-preferences_snippet) - * [apt::preseeded_package](#apt-preseeded_package) + * [apt::package](#apt-package) * [apt::sources_list](#apt-sources_list) * [apt::key](#apt-key) * [`apt::key::plain`](#apt-key-plain) @@ -155,6 +155,9 @@ Ubuntu support is lagging behind but not absent either. port => '666'; } + * the `apt::preseeded_package` defined type was renamed `apt::package` the + previous name is now deprecated and will be removed in the future. + # Requirements @@ -505,7 +508,7 @@ From apt_preferences(5): characters - otherwise they will be silently ignored. -## apt::preseeded_package +## apt::package This simplifies installation of packages for which you wish to preseed the answers to debconf. For example, if you wish to provide a preseed file for the @@ -513,12 +516,12 @@ locales package, you would place the `locales.seed` file in `site_apt/templates/${::lsbdistcodename}/locales.seeds` and then include the following in your manifest: - apt::preseeded_package { locales: } + apt::package { locales: } You can also specify the content of the seed via the content parameter, for example: - apt::preseeded_package { 'apticron': + apt::package { 'apticron': content => 'apticron apticron/notification string root@example.com', } diff --git a/manifests/package.pp b/manifests/package.pp new file mode 100644 index 0000000..b2ae79d --- /dev/null +++ b/manifests/package.pp @@ -0,0 +1,25 @@ +# Install a package with a preseed file to automatically answer some questions. +define apt::package ( + $ensure = 'present', + $seedfile_content = '', +) { + + $seedfile = "/var/cache/local/preseeding/${name}.seeds" + $real_seedfile_content = $seedfile_content ? { + '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), + default => $seedfile_content, + } + + file { $seedfile: + content => $real_seedfile_content, + mode => '0600', + owner => 'root', + group => 0, + } + + package { $name: + ensure => $ensure, + responsefile => $seedfile, + require => File[$seedfile], + } +} diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 29a981e..e1d1dcc 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -1,26 +1,11 @@ -# Install a package with a preseed file to automatically answer some questions. - +# This is a wrapper that will be removed after a while define apt::preseeded_package ( $ensure = 'present', $content = '', ) { - - $seedfile = "/var/cache/local/preseeding/${name}.seeds" - $real_content = $content ? { - '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), - default => $content, - } - - file { $seedfile: - content => $real_content, - mode => '0600', - owner => 'root', - group => 0, - } - - package { $name: - ensure => $ensure, - responsefile => $seedfile, - require => File[$seedfile], + warning('apt::preseeded_package is deprecated! you should now use apt::package instead.') + apt::package { $name: + ensure => $ensure, + content => $content, } } -- cgit v1.2.3 From 38a2b7900178fa00c8dfd16481c84818d2b9a47a Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 15:50:32 -0500 Subject: teach apt::package to mange pins for packages --- manifests/package.pp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/manifests/package.pp b/manifests/package.pp index b2ae79d..159d693 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -2,6 +2,8 @@ define apt::package ( $ensure = 'present', $seedfile_content = '', + $pin = '', + $pin_priority = 1000 ) { $seedfile = "/var/cache/local/preseeding/${name}.seeds" @@ -17,9 +19,17 @@ define apt::package ( group => 0, } + if $pin { + apt::preferences_snippet { $name: + ensure => $ensure, + priority => $pin_priority, + pin => $pin, + } + } + package { $name: ensure => $ensure, responsefile => $seedfile, - require => File[$seedfile], + require => [File[$seedfile], Apt::Preferences_snippet[$name]], } } -- cgit v1.2.3 From 1893f692dc430929240e5ec53480444d98055462 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 16:46:27 -0500 Subject: make use of preseed optional and disabled by default We currently can't use apt::package without preseeding. Also by default the preseed content is grabbed from an implicit template, which makes puppet runs fail for a non-obvious reason. To keep previous functionality, force use of seed file when using the deprecated apt::preseeded_package type. --- manifests/package.pp | 36 ++++++++++++++++++++++-------------- manifests/preseeded_package.pp | 7 ++++--- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/manifests/package.pp b/manifests/package.pp index 159d693..e83ac68 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -1,22 +1,33 @@ # Install a package with a preseed file to automatically answer some questions. define apt::package ( $ensure = 'present', + $use_seed = false, + $seedfile_template = "site_apt/${::debian_codename}/${name}.seeds", $seedfile_content = '', $pin = '', $pin_priority = 1000 ) { - $seedfile = "/var/cache/local/preseeding/${name}.seeds" - $real_seedfile_content = $seedfile_content ? { - '' => template ( "site_apt/${::debian_codename}/${name}.seeds" ), - default => $seedfile_content, + package { $name: + ensure => $ensure, + responsefile => $seedfile, } - file { $seedfile: - content => $real_seedfile_content, - mode => '0600', - owner => 'root', - group => 0, + if $use_seed { + $seedfile = "/var/cache/local/preseeding/${name}.seeds" + $real_seedfile_content = $seedfile_content ? { + '' => template ( $seedfile_template ), + default => $seedfile_content, + } + + file { $seedfile: + content => $real_seedfile_content, + mode => '0600', + owner => 'root', + group => 0, + } + + File[$seedfile] -> Package[$name] } if $pin { @@ -25,11 +36,8 @@ define apt::package ( priority => $pin_priority, pin => $pin, } - } - package { $name: - ensure => $ensure, - responsefile => $seedfile, - require => [File[$seedfile], Apt::Preferences_snippet[$name]], + Apt::Preferences_snippet[$name] -> Package[$name] } + } diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index e1d1dcc..7db740f 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -3,9 +3,10 @@ define apt::preseeded_package ( $ensure = 'present', $content = '', ) { - warning('apt::preseeded_package is deprecated! you should now use apt::package instead.') + warning('apt::preseeded_package is deprecated! you should now use apt::package with parameter use_seed set to true instead.') apt::package { $name: - ensure => $ensure, - content => $content, + ensure => $ensure, + use_seed => true, + content => $content, } } -- cgit v1.2.3 From 7687c41a759f8a138a51f922b19d6ab4149df950 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 17:01:05 -0500 Subject: Adjust README to show new parameter that's needed for preseeding. --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 49110ba..eb83437 100644 --- a/README.md +++ b/README.md @@ -511,18 +511,25 @@ From apt_preferences(5): ## apt::package This simplifies installation of packages for which you wish to preseed the -answers to debconf. For example, if you wish to provide a preseed file for the -locales package, you would place the `locales.seed` file in +answers to debconf. To use preseeding you need to set the `use_seed` parameter +to true. For example, if you wish to provide a preseed file for the locales +package, you would place the `locales.seed` file in `site_apt/templates/${::lsbdistcodename}/locales.seeds` and then include the following in your manifest: - apt::package { locales: } + apt::package { 'locales': + use_seed => true, + } + +You can change what template is used by setting `seedfile_template` to a +template path (same as you would pass to the template() function). -You can also specify the content of the seed via the content parameter, -for example: +You can also specify the content of the seed via the content parameter instead +of using a template, for example: apt::package { 'apticron': - content => 'apticron apticron/notification string root@example.com', + use_seed => true, + content => 'apticron apticron/notification string root@example.com', } -- cgit v1.2.3 From cd84a163d068e5dd368731b51f6934495a30313c Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Fri, 24 Feb 2017 17:09:27 -0500 Subject: README: document new pin/pin_priority parameters to apt::package --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb83437..fd9f587 100644 --- a/README.md +++ b/README.md @@ -511,9 +511,11 @@ From apt_preferences(5): ## apt::package This simplifies installation of packages for which you wish to preseed the -answers to debconf. To use preseeding you need to set the `use_seed` parameter -to true. For example, if you wish to provide a preseed file for the locales -package, you would place the `locales.seed` file in +answers to debconf or pin to a certain version. + +To use preseeding you need to set the `use_seed` parameter to true. For +example, if you wish to provide a preseed file for the locales package, you +would place the `locales.seed` file in `site_apt/templates/${::lsbdistcodename}/locales.seeds` and then include the following in your manifest: @@ -532,6 +534,18 @@ of using a template, for example: content => 'apticron apticron/notification string root@example.com', } +To pin a package to a certain release or version, you need to set the `pin` +parameter to the restriction that you want (this value corresponds to the +'Pin:' line in preferences files). For example this would pin the package +ganeti to the jessie release: + + apt::package { 'ganeti': + pin => 'release o=Debian Backports,a=jessie', + } + +Also, if you want to set a priority number to a package pin, you can set +`pin_priority` to an integer value. The default value of this parameter is +1000, which will install but not downgrade a package. ## apt::sources_list -- cgit v1.2.3 From d24b79310523e4823214d6b52883f0f4debc56af Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 16 Apr 2017 21:19:49 -0400 Subject: README: missing sentence end in deprecation notice for preseeded_package The missing dot made the announcement confusing. There are really two different informations in there that should be split. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd9f587..aac4a8e 100644 --- a/README.md +++ b/README.md @@ -155,8 +155,9 @@ Ubuntu support is lagging behind but not absent either. port => '666'; } - * the `apt::preseeded_package` defined type was renamed `apt::package` the - previous name is now deprecated and will be removed in the future. + * the `apt::preseeded_package` defined + type was renamed `apt::package`. the previous name is now deprecated and + will be removed in the future. # Requirements -- cgit v1.2.3 From bbf4bc03fa076ae3984d8eae18e27fd09627f177 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 16 Apr 2017 21:29:30 -0400 Subject: package wrongly documented and used with content parameter There are some references to the old `content` parameter (from preseeded_package) that mistakenly weren't replaced with the new parameter `seedfile_content`. This meant the documentation was wrong and the `preseeded_package` wrapper was erroring out because of an unknown parameter. --- README.md | 6 +++--- manifests/preseeded_package.pp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index aac4a8e..944044b 100644 --- a/README.md +++ b/README.md @@ -527,12 +527,12 @@ following in your manifest: You can change what template is used by setting `seedfile_template` to a template path (same as you would pass to the template() function). -You can also specify the content of the seed via the content parameter instead -of using a template, for example: +You can also specify the content of the seed via the `seedfile_content` +parameter instead of using a template, for example: apt::package { 'apticron': use_seed => true, - content => 'apticron apticron/notification string root@example.com', + seedfile_content => 'apticron apticron/notification string root@example.com', } To pin a package to a certain release or version, you need to set the `pin` diff --git a/manifests/preseeded_package.pp b/manifests/preseeded_package.pp index 7db740f..e6fcab1 100644 --- a/manifests/preseeded_package.pp +++ b/manifests/preseeded_package.pp @@ -5,8 +5,8 @@ define apt::preseeded_package ( ) { warning('apt::preseeded_package is deprecated! you should now use apt::package with parameter use_seed set to true instead.') apt::package { $name: - ensure => $ensure, - use_seed => true, - content => $content, + ensure => $ensure, + use_seed => true, + seedfile_content => $content, } } -- cgit v1.2.3 From 9a4adac94a72d8bd8c3d5b4657adac15f43ecd30 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 16 Apr 2017 21:31:50 -0400 Subject: README: slightly reword template usage for apt::package The current wording is not super clear on what type of file should be dropped in `site_apt/...`. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 944044b..3343393 100644 --- a/README.md +++ b/README.md @@ -515,7 +515,7 @@ This simplifies installation of packages for which you wish to preseed the answers to debconf or pin to a certain version. To use preseeding you need to set the `use_seed` parameter to true. For -example, if you wish to provide a preseed file for the locales package, you +example, if you wish to provide a preseed template for the locales package, you would place the `locales.seed` file in `site_apt/templates/${::lsbdistcodename}/locales.seeds` and then include the following in your manifest: @@ -525,7 +525,8 @@ following in your manifest: } You can change what template is used by setting `seedfile_template` to a -template path (same as you would pass to the template() function). +template path of your choosing (same as you would pass to the template() +function). You can also specify the content of the seed via the `seedfile_content` parameter instead of using a template, for example: -- cgit v1.2.3