From 140a3227b4f4a8f81d8c6458aa39b6e968a0c00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Wed, 7 Feb 2018 18:34:38 -0500 Subject: add UPGRADING.md, close issue #25 --- UPGRADING.md | 229 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 UPGRADING.md (limited to 'UPGRADING.md') diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 0000000..ed4c355 --- /dev/null +++ b/UPGRADING.md @@ -0,0 +1,229 @@ +# Introduction + +This aims to document the replacement of the shared apt module by the [puppetlabs](https://github.com/puppetlabs/puppetlabs-apt) one. + +I've tried to look at all the classes supported by our shared module. + +## Some thoughts on moving to the puppetlabs module + +Whereas the shared module tried to be a coherent mass of code doing all the apt-related things we needed to do, the puppetlabs module takes a more modular approach. This means some of the features we had are not present and will never be added, since "they are not part of the main apt core functionalities"... + +This means we'll have to start using multiple modules as "plugins" to the main puppetlabs apt module. + +# Minor deprecations & warnings + +## lsb +One has to make sure `lsb-release` package is installed. Our shared apt module used to have a dependency on our `lsb` module that did that, but we deprecated that module. + +## `apt_updated` deprecation +The puppetlabs module uses the `apt_update` exec, whereas the shared module uses `apt_updated`. If you where calling this exec in other modules, you'll need to update this for the new exec name. + +## stdlib + +Make sure your version of stdlib is recent. Mine wasn't and the apt module was failing on the pin functions because the `length` function was missing. + +## Partial management of the config files by default +By default, the puppetlabs apt module only partially manages the apt configuration and will not purge configuration added by hand. This differs from the shared module behavior, where those modifications would get overwritten by our templates. + +To keep the old behavior, pass: + + class { 'apt': + purge => { + sources.list => true, + sources.list.d => true, + preferences => true, + preferences.d => true, + }, + } + +## apt sources + +By default, the puppetlabs module won't create any sources. To replicate the shared module template, use this: + + apt::source { + "${lsbdistcodename}": + location => 'http://deb.debian.org/debian', + repos => 'main contrib non-free'; + + "${lsbdistcodename}-security": + location => 'http://security.debian.org/debian-security', + repos => 'main contrib non-free', + release => "${lsbdistcodename}/updates"; + + "${lsbdistcodename}-backports": + location => 'http://deb.debian.org/debian', + repos => 'main contrib non-free', + release => "${lsbdistcodename}-backports"; + + 'testing': + location => 'http://deb.debian.org/debian', + repos => 'main contrib non-free', + release => "testing"; + } + +Sadly I can't find a way to iter the next codename from the facts :(. You can either use testing instead of "the next release" or specify it manually. + +# Classes comparison + +## apticron + +Apticron is not supported by the puppetlabs module either, but [this slightly out of date](https://github.com/dhoppe/puppet-apticron) module from the Forge (the most popular one), although it doesn't state support for Debian 9 and could profit from a little love. + +## dist_upgrade + +The behavior of the three `dist_upgrade` classes (`apt::cron::dist_upgrade`, `apt::dist_upgrade` and `apt::dist_upgrade::initiator`) are not supported by the puppetlabs module. + +Maybe consider moving to a workflow using `unattended-upgrades`? + +## dselect + +`dselect` is not supported and nothing seems to do what the shared module feature did. + +## apt-listchanges + +Sadly, `apt-listchanges` is not supported by the module. [Someone created a PR in 2014](https://github.com/puppetlabs/puppetlabs-apt/pull/379) but it was rejected. + +Nothing seems to do this on the Forge either, so we would have to make our own "add-on" module to manage this. We could recycle and tweak our existing code for this. + +## proxy + +Here is how you would configure an apt proxy: + + class { 'apt': + proxy => { + host => 'hostname', + port => '8080', + https => true, + ensure => file, + }, + } + +## reboot required + +The puppetlabs notice will not manage `reboot-required` like the shared one did, but it creates a fact named `apt_reboot_required` that could be used by some external monitoring system. + +Since it only looks at `/var/run/reboot-required`, it might be a better idea to use something like a combination of the `needrestart` package and an external monitoring system. + +The [needrestart](https://github.com/hetznerZA/hetzner-needrestart) module seems to work well. + +## unattended-upgrades + +The puppetlabs modules does not support `unattended-upgrades` natively anymore [it used to](https://tickets.puppetlabs.com/browse/MODULES-4943). + +The recommended way to setup this feature is to use the compatible [voxpopuli/unattended-upgrades](https://github.com/voxpupuli/puppet-unattended_upgrades) module. + +This modules does quite a lot and is quite complex. More to come on this. + +# Defines comparison + +## apt confs + +You can using the `apt::conf` define: + + class { 'apt::conf': + 'whatever_config': + ensure => present, + content => 'foo bar the config you want to see', + priority => '20', + notify_update => true, + } + +The content part can get quite long, so I would recommend using [heredocs](https://puppet.com/docs/puppet/4.8/lang_data_string.html#heredocs). + +## preferences_snippet + +The way to pin a package is now [much more fleshed out](https://github.com/puppetlabs/puppetlabs-apt#defined-type-aptpin) and looks like: + + apt::pin { 'certbot': + codename => 'buster', + packages => [ 'python3-certbot', 'python3-certbot-apache' ], + } + +Be aware, as by default if you don't specify a list of packages, this define pins all packages. + +## apt_packages (preseed) + +As far as I can see, there is nothing in the puppetlabs module that lets you preseed packages. + +## GPG key management + +The shared module simply used to push a `.gpg` file to `/etc/apt/trusted.gpg.d` to manage GPG keys. + +The puppetlabs module is a bit more sophisticated and lets you either import a key from a source (path, ftp, https, etc.) or fetches keys from a keyserver. + + apt::key { 'my_local_key': + id => '13C904F0CE085E7C36307985DECF849AA6357FB7', + source => "puppet://files/gpg/13C904F0CE085E7C36307985DECF849AA6357FB7.gpg", + } + + apt::key { 'puppetlabs': + id => '6F6B15509CF8E59E6E469F327F438280EF8D349F', + server => 'pgp.mit.edu', + options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', + } + +The heavy lifting is done by [these](https://github.com/puppetlabs/puppetlabs-apt/blob/dc3ead0ed5f4d735869565660c982983d379a519/lib/puppet/type/apt_key.rb) [two](https://github.com/puppetlabs/puppetlabs-apt/blob/dc3ead0ed5f4d735869565660c982983d379a519/lib/puppet/provider/apt_key/apt_key.rb) Ruby files. + +## upgrade_package + +This can be done by using `apt::pin` and specifying a version: + + apt::pin { 'perl': + packages => 'perl', + version => '5.26.1-4', + } + +## dpkg_statoverride + +Is there a reason you are using this instead of using `file`? + +## Facts + +There are a bunch of new and [interesting facts](https://github.com/puppetlabs/puppetlabs-apt#facts). + +# Contributing to the puppetlabs module + +[Submitting a patch seems to be feasible](https://docs.puppet.com/forge/contributing.html), but is also a lot more work than just creating a pull request. + +# Hiera + +Here's some sane Hiera config I'm using. + +``` +classes: + - apt + - needrestart + - unattended_upgrades + +apt::purge: + 'sources.list': true + 'sources.list.d': true + 'preferences': true + 'preferences.d': true + +apt::sources: + "%{facts.lsbdistcodename}": + comment: 'Stable' + pin: '990' + location: 'http://deb.debian.org/debian/' + repos: 'main contrib non-free' + "%{facts.lsbdistcodename}-security": + comment: 'Stable security' + location: 'http://security.debian.org/debian-security' + repos: 'main contrib non-free' + release: "%{facts.lsbdistcodename}/updates" + "%{facts.lsbdistcodename}-backports": + comment: 'Backports' + pin: 200 + location: 'http://deb.debian.org/debian/' + repos: 'main contrib non-free' + release: "%{facts.lsbdistcodename}-backports" + 'buster': + comment: 'Buster' + pin: 2 + location: 'http://deb.debian.org/debian/' + repos: 'main contrib non-free' + release: 'buster' + +needrestart::action: automatic +``` -- cgit v1.2.3 From 53096b4c212878f102d4c414c860146b03d5d270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Tue, 20 Feb 2018 19:21:47 +0000 Subject: mention new apt_listchanges module. --- UPGRADING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'UPGRADING.md') diff --git a/UPGRADING.md b/UPGRADING.md index ed4c355..7085f06 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -81,9 +81,11 @@ Maybe consider moving to a workflow using `unattended-upgrades`? ## apt-listchanges -Sadly, `apt-listchanges` is not supported by the module. [Someone created a PR in 2014](https://github.com/puppetlabs/puppetlabs-apt/pull/379) but it was rejected. +I ported and upgraded our modules `apt::listchanges` code to a +[separate module](https://gitlab.com/baldurmen/puppet-apt_listchanges). -Nothing seems to do this on the Forge either, so we would have to make our own "add-on" module to manage this. We could recycle and tweak our existing code for this. +It basically does the same thing, but in a more modern style. Check the +parameters list as types are now defined. ## proxy -- cgit v1.2.3 From 4334f9f2b9adb2e7881192494bcbd882dc1e2456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Tue, 6 Mar 2018 21:13:17 +0000 Subject: Clarify how to use apt::pin and add `create_ressources` example --- UPGRADING.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'UPGRADING.md') diff --git a/UPGRADING.md b/UPGRADING.md index 7085f06..7054637 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -60,6 +60,15 @@ By default, the puppetlabs module won't create any sources. To replicate the sha repos => 'main contrib non-free', release => "testing"; } + apt::pin { + "${lsbdistcodename}": + priority => 990; + "${lsbdistcodename}-backports": + priority => 200; + 'buster': + priority => 2; + } + Sadly I can't find a way to iter the next codename from the facts :(. You can either use testing instead of "the next release" or specify it manually. @@ -189,7 +198,12 @@ There are a bunch of new and [interesting facts](https://github.com/puppetlabs/p # Hiera -Here's some sane Hiera config I'm using. +Here's some sane Hiera config I'm using. You'll need to specify a `create_ressources` statement somewhere since `apt::pin` is a define: + +``` +$aptpins = hiera('apt::pin', {}) +create_resources(apt::pin, $aptpins) +``` ``` classes: @@ -206,7 +220,6 @@ apt::purge: apt::sources: "%{facts.lsbdistcodename}": comment: 'Stable' - pin: '990' location: 'http://deb.debian.org/debian/' repos: 'main contrib non-free' "%{facts.lsbdistcodename}-security": @@ -216,16 +229,22 @@ apt::sources: release: "%{facts.lsbdistcodename}/updates" "%{facts.lsbdistcodename}-backports": comment: 'Backports' - pin: 200 location: 'http://deb.debian.org/debian/' repos: 'main contrib non-free' release: "%{facts.lsbdistcodename}-backports" 'buster': comment: 'Buster' - pin: 2 location: 'http://deb.debian.org/debian/' repos: 'main contrib non-free' release: 'buster' + +apt::pin: + "%{facts.lsbdistcodename}": + priority: 990 + "%{facts.lsbdistcodename}-backports": + priority: 200 + 'buster': + priority: 2 needrestart::action: automatic ``` -- cgit v1.2.3 From f500d5a65e34f25eed062b2087c28a1e397c9c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Thu, 8 Mar 2018 04:05:07 +0000 Subject: Make sure you are using testing instead of buster, as it seems the apt preferences pin for buster are not working properly... --- UPGRADING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'UPGRADING.md') diff --git a/UPGRADING.md b/UPGRADING.md index 7054637..505a29b 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -65,7 +65,7 @@ By default, the puppetlabs module won't create any sources. To replicate the sha priority => 990; "${lsbdistcodename}-backports": priority => 200; - 'buster': + 'testing': priority => 2; } @@ -232,18 +232,18 @@ apt::sources: location: 'http://deb.debian.org/debian/' repos: 'main contrib non-free' release: "%{facts.lsbdistcodename}-backports" - 'buster': - comment: 'Buster' + 'testing': + comment: 'Testing' location: 'http://deb.debian.org/debian/' repos: 'main contrib non-free' - release: 'buster' + release: 'testing' apt::pin: "%{facts.lsbdistcodename}": priority: 990 "%{facts.lsbdistcodename}-backports": priority: 200 - 'buster': + 'testing': priority: 2 needrestart::action: automatic -- cgit v1.2.3 From 386804ccb21903a030be39c3a4b4f4513018fe23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Philippe=20V=C3=A9ronneau?= Date: Tue, 13 Mar 2018 16:13:25 +0000 Subject: Add more details on unattended_upgrades --- UPGRADING.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'UPGRADING.md') diff --git a/UPGRADING.md b/UPGRADING.md index 505a29b..2d31516 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -123,7 +123,12 @@ The puppetlabs modules does not support `unattended-upgrades` natively anymore [ The recommended way to setup this feature is to use the compatible [voxpopuli/unattended-upgrades](https://github.com/voxpupuli/puppet-unattended_upgrades) module. -This modules does quite a lot and is quite complex. More to come on this. +The default configuration is quite sane, but you might want to set up automatic upgrades for the stable release too (and not just stable security): + + class { 'unattended_upgrades': + origins => [ 'origin=Debian,archive=stable', + 'origin=Debian,archive=stable,label=Debian-Security' ] + } # Defines comparison @@ -247,4 +252,8 @@ apt::pin: priority: 2 needrestart::action: automatic + +unattended_upgrades::origins: + - origin=Debian,archive=stable + - origin=Debian,archive=stable,label=Debian-Security ``` -- cgit v1.2.3 From 9f43d3f74a0464b7d9f4b4da5afaee780dbdb8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Tue, 19 Jun 2018 11:55:07 -0400 Subject: Fix variable scope warnings in examples --- UPGRADING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'UPGRADING.md') diff --git a/UPGRADING.md b/UPGRADING.md index 2d31516..1a89e30 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -41,16 +41,16 @@ To keep the old behavior, pass: By default, the puppetlabs module won't create any sources. To replicate the shared module template, use this: apt::source { - "${lsbdistcodename}": + $::lsbdistcodename: location => 'http://deb.debian.org/debian', repos => 'main contrib non-free'; - "${lsbdistcodename}-security": + "${::lsbdistcodename}-security": location => 'http://security.debian.org/debian-security', repos => 'main contrib non-free', release => "${lsbdistcodename}/updates"; - "${lsbdistcodename}-backports": + "${::lsbdistcodename}-backports": location => 'http://deb.debian.org/debian', repos => 'main contrib non-free', release => "${lsbdistcodename}-backports"; @@ -61,9 +61,9 @@ By default, the puppetlabs module won't create any sources. To replicate the sha release => "testing"; } apt::pin { - "${lsbdistcodename}": + "${::lsbdistcodename}": priority => 990; - "${lsbdistcodename}-backports": + "${::lsbdistcodename}-backports": priority => 200; 'testing': priority => 2; -- cgit v1.2.3 From 7d4d086c6f272aa5f0d3823a7266632c8d3debb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Tue, 19 Jun 2018 12:02:44 -0400 Subject: Improve backports example --- UPGRADING.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'UPGRADING.md') diff --git a/UPGRADING.md b/UPGRADING.md index 1a89e30..a8f094e 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -50,11 +50,6 @@ By default, the puppetlabs module won't create any sources. To replicate the sha repos => 'main contrib non-free', release => "${lsbdistcodename}/updates"; - "${::lsbdistcodename}-backports": - location => 'http://deb.debian.org/debian', - repos => 'main contrib non-free', - release => "${lsbdistcodename}-backports"; - 'testing': location => 'http://deb.debian.org/debian', repos => 'main contrib non-free', @@ -63,8 +58,6 @@ By default, the puppetlabs module won't create any sources. To replicate the sha apt::pin { "${::lsbdistcodename}": priority => 990; - "${::lsbdistcodename}-backports": - priority => 200; 'testing': priority => 2; } @@ -72,6 +65,15 @@ By default, the puppetlabs module won't create any sources. To replicate the sha Sadly I can't find a way to iter the next codename from the facts :(. You can either use testing instead of "the next release" or specify it manually. +## backports + +The module provides a class specifically for deploying the backports repository and pin. + + class { 'apt::backports': + pin => 200, + location => 'http://deb.debian.org/debian', + } + # Classes comparison ## apticron -- cgit v1.2.3 From 145b5238258827702ad3ac4a0a9713981209e1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Tue, 19 Jun 2018 14:15:28 -0400 Subject: Fix another fact var scope issue in upgrade example --- UPGRADING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'UPGRADING.md') diff --git a/UPGRADING.md b/UPGRADING.md index a8f094e..e6ed719 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -48,7 +48,7 @@ By default, the puppetlabs module won't create any sources. To replicate the sha "${::lsbdistcodename}-security": location => 'http://security.debian.org/debian-security', repos => 'main contrib non-free', - release => "${lsbdistcodename}/updates"; + release => "${::lsbdistcodename}/updates"; 'testing': location => 'http://deb.debian.org/debian', -- cgit v1.2.3