From 5bbc86ff4f4a601a3924805a13fc1c5154670289 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 2 Jul 2017 01:39:34 -0400 Subject: remove template for main preferences config this file is not used anymore. we've moved all of this to preferences.d so the template is useless now, but we forgot to remove it. --- templates/Debian/preferences.erb | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 templates/Debian/preferences.erb diff --git a/templates/Debian/preferences.erb b/templates/Debian/preferences.erb deleted file mode 100644 index 37cf80d..0000000 --- a/templates/Debian/preferences.erb +++ /dev/null @@ -1,33 +0,0 @@ -# This file is managed by puppet -# all local modifications will be overwritten - -Explanation: Debian <%= codename=scope.lookupvar('::debian_codename') %> -Package: * -Pin: release o=Debian,n=<%= codename %> -Pin-Priority: 990 - -<% if use_volatile=scope.lookupvar('apt::use_volatile') -%> -Explanation: Debian <%= codename %>-updates -Package: * -Pin: release o=Debian,n=<%= codename %>-updates -Pin-Priority: 990 -<%- end -%> - -<% if (use_lts=scope.lookupvar('apt::use_lts')) && (scope.lookupvar('::debian_lts') == "true") -%> -Explanation: Debian <%= codename %>-lts -Package: * -Pin: release o=Debian,n=<%= codename %>-lts -Pin-Priority: 990 -<%- end -%> - -<% if (next_codename=scope.lookupvar('::debian_nextcodename')) && (next_codename != "experimental") -%> -Explanation: Debian <%= next_codename %> -Package: * -Pin: release o=Debian,n=<%= next_codename %> -Pin-Priority: 2 -<%- end -%> - -Explanation: Debian fallback -Package: * -Pin: release o=Debian -Pin-Priority: -10 -- cgit v1.2.3 From 14872fa632f4ae73b75464706e100967c9c9035f Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 2 Jul 2017 01:44:38 -0400 Subject: Rename "stable" preferences file to "current_codename" The file that we call "stable" can make apt actually pin testing or sid if one of these is the running codename, which is nothing stable. In order to make this file's name more relevant it should be named current_codename. --- manifests/preferences.pp | 14 ++++++++++---- templates/Debian/current_codename.erb | 7 +++++++ templates/Debian/stable.erb | 7 ------- 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 templates/Debian/current_codename.erb delete mode 100644 templates/Debian/stable.erb diff --git a/manifests/preferences.pp b/manifests/preferences.pp index ce28d37..d2f6ab4 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -4,6 +4,12 @@ class apt::preferences { ensure => absent; } + # Remove the file that we were previously deploying. It's now been renamed to + # current_codename + file { '/etc/apt/preferences.d/stable': + ensure => absent, + } + if ($apt::manage_preferences == true) and ($apt::custom_preferences != undef) { file { @@ -14,7 +20,7 @@ class apt::preferences { require => File['/etc/apt/sources.list'], owner => root, group => 0, mode => '0644'; - '/etc/apt/preferences.d/stable': + '/etc/apt/preferences.d/current_codename': ensure => absent; '/etc/apt/preferences.d/volatile': @@ -33,10 +39,10 @@ class apt::preferences { if $::operatingsystem == "Debian" { file { - '/etc/apt/preferences.d/stable': + '/etc/apt/preferences.d/current_codename': ensure => present, alias => 'apt_config', - content => template('apt/Debian/stable.erb'), + content => template('apt/Debian/current_codename.erb'), require => File['/etc/apt/sources.list'], owner => root, group => 0, mode => '0644'; @@ -94,7 +100,7 @@ class apt::preferences { '/etc/apt/preferences.d/custom': ensure => absent; - '/etc/apt/preferences.d/stable': + '/etc/apt/preferences.d/current_codename': ensure => absent; '/etc/apt/preferences.d/volatile': diff --git a/templates/Debian/current_codename.erb b/templates/Debian/current_codename.erb new file mode 100644 index 0000000..be05e51 --- /dev/null +++ b/templates/Debian/current_codename.erb @@ -0,0 +1,7 @@ +# This file is managed by puppet +# all local modifications will be overwritten + +Explanation: Debian <%= @debian_codename %> +Package: * +Pin: release o=Debian,n=<%= @debian_codename %> +Pin-Priority: 990 diff --git a/templates/Debian/stable.erb b/templates/Debian/stable.erb deleted file mode 100644 index be05e51..0000000 --- a/templates/Debian/stable.erb +++ /dev/null @@ -1,7 +0,0 @@ -# This file is managed by puppet -# all local modifications will be overwritten - -Explanation: Debian <%= @debian_codename %> -Package: * -Pin: release o=Debian,n=<%= @debian_codename %> -Pin-Priority: 990 -- cgit v1.2.3 From 994934798031c0f91e8628edee7b848d0444c57e Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 2 Jul 2017 01:58:34 -0400 Subject: Deploy forgotten fallback for debian to avoid upgrade mishaps During the change from the monolithic preferences file to the series of snippets in preferences.d, one part was left out possibly as an oversight, which prevents installing packages by mistake that belong to a release that hasn't been explicitely pinned. --- files/Debian/preferences_fallback | 7 +++++++ manifests/preferences.pp | 11 +++++++++++ templates/Debian/fallback.erb | 7 ------- 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 files/Debian/preferences_fallback delete mode 100644 templates/Debian/fallback.erb diff --git a/files/Debian/preferences_fallback b/files/Debian/preferences_fallback new file mode 100644 index 0000000..1c75e83 --- /dev/null +++ b/files/Debian/preferences_fallback @@ -0,0 +1,7 @@ +# This file is managed by puppet +# all local modifications will be overwritten + +Explanation: Debian fallback +Package: * +Pin: release o=Debian +Pin-Priority: -10 diff --git a/manifests/preferences.pp b/manifests/preferences.pp index d2f6ab4..04a09b0 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -49,6 +49,17 @@ class apt::preferences { '/etc/apt/preferences.d/custom': ensure => absent; } + # This file ensures that all debian packages that don't have a + # preference file shouldn't be considered for auto-install or upgrade at + # all. + file { '/etc/apt/preferences.d/debian_fallback': + ensure => present, + source => 'puppet:///modules/apt/Debian/preferences_fallback', + owner => 'root', + group => 0, + mode => '0644', + require => File['/etc/apt/sources.list'], + } if $apt::use_volatile { diff --git a/templates/Debian/fallback.erb b/templates/Debian/fallback.erb deleted file mode 100644 index 1c75e83..0000000 --- a/templates/Debian/fallback.erb +++ /dev/null @@ -1,7 +0,0 @@ -# This file is managed by puppet -# all local modifications will be overwritten - -Explanation: Debian fallback -Package: * -Pin: release o=Debian -Pin-Priority: -10 -- cgit v1.2.3 From 2fbab4798f4683f5b4e70887b8d33c2f1bc97f40 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 2 Jul 2017 02:13:54 -0400 Subject: lint preferences.pp that file is using multiple coding style elements that don't follow community best practices which are designed to make code easier to read. --- manifests/preferences.pp | 144 +++++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 68 deletions(-) diff --git a/manifests/preferences.pp b/manifests/preferences.pp index 04a09b0..0ec77cf 100644 --- a/manifests/preferences.pp +++ b/manifests/preferences.pp @@ -1,9 +1,16 @@ +# Configure basic pins for debian/Ubuntu codenames +# +# This all ensures that apt behaves as expected with regards to packages when +# we have more sources than just the one for the current codenamed release. +# +# This class should not be included directly. It is automatically called in by +# the 'apt' class. Thus you should use the apt class instead. +# class apt::preferences { file { '/etc/apt/preferences': - ensure => absent; + ensure => absent, } - # Remove the file that we were previously deploying. It's now been renamed to # current_codename file { '/etc/apt/preferences.d/stable': @@ -11,43 +18,44 @@ class apt::preferences { } if ($apt::manage_preferences == true) and ($apt::custom_preferences != undef) { - - file { - '/etc/apt/preferences.d/custom': - ensure => present, - alias => 'apt_config', - content => template($apt::custom_preferences), - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; - - '/etc/apt/preferences.d/current_codename': - ensure => absent; - - '/etc/apt/preferences.d/volatile': - ensure => absent; - - '/etc/apt/preferences.d/lts': - ensure => absent; - - '/etc/apt/preferences.d/nextcodename': - ensure => absent; + file { '/etc/apt/preferences.d/custom': + ensure => present, + alias => 'apt_config', + content => template($apt::custom_preferences), + owner => 'root', + group => 0, + mode => '0644', + require => File['/etc/apt/sources.list'], + } + file { '/etc/apt/preferences.d/current_codename': + ensure => absent, + } + file { '/etc/apt/preferences.d/volatile': + ensure => absent, + } + file { '/etc/apt/preferences.d/lts': + ensure => absent, + } + file { '/etc/apt/preferences.d/nextcodename': + ensure => absent, } } - elsif $apt::manage_preferences == true { - if $::operatingsystem == "Debian" { - - file { - '/etc/apt/preferences.d/current_codename': - ensure => present, - alias => 'apt_config', - content => template('apt/Debian/current_codename.erb'), - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; - - '/etc/apt/preferences.d/custom': - ensure => absent; + if $::operatingsystem == 'Debian' { + file { '/etc/apt/preferences.d/current_codename': + ensure => present, + alias => 'apt_config', + content => template('apt/Debian/current_codename.erb'), + owner => 'root', + group => 0, + mode => '0644', + require => File['/etc/apt/sources.list'], + } + # Cleanup for cases where users might switch from using + # custom_preferences to not using it anymore. + file { '/etc/apt/preferences.d/custom': + ensure => absent, } # This file ensures that all debian packages that don't have a # preference file shouldn't be considered for auto-install or upgrade at @@ -62,66 +70,66 @@ class apt::preferences { } if $apt::use_volatile { - file { '/etc/apt/preferences.d/volatile': ensure => present, content => template('apt/Debian/volatile.erb'), + owner => 'root', + group => 0, + mode => '0644', require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; } } if $apt::use_lts { - file { '/etc/apt/preferences.d/lts': ensure => present, content => template('apt/Debian/lts.erb'), + owner => 'root', + group => 0, + mode => '0644', require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; } } - if ($::debian_nextcodename) and ($::debian_nextcodename != "experimental") { - + if ($::debian_nextcodename) and ($::debian_nextcodename != 'experimental') { file { '/etc/apt/preferences.d/nextcodename': ensure => present, content => template('apt/Debian/nextcodename.erb'), + owner => 'root', + group => 0, + mode => '0644', require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; } } } - - elsif $::operatingsystem == "Ubuntu" { - + elsif $::operatingsystem == 'Ubuntu' { file { '/etc/apt/preferences': - ensure => present, - alias => 'apt_config', - # only update together - content => template("apt/Ubuntu/preferences_${apt::codename}.erb"), - require => File['/etc/apt/sources.list'], - owner => root, group => 0, mode => '0644'; + ensure => present, + alias => 'apt_config', + # only update together + content => template("apt/Ubuntu/preferences_${apt::codename}.erb"), + owner => 'root', + group => 0, + mode => '0644', + require => File['/etc/apt/sources.list'], } } } - elsif $apt::manage_preferences == false { - - file { - '/etc/apt/preferences.d/custom': - ensure => absent; - - '/etc/apt/preferences.d/current_codename': - ensure => absent; - - '/etc/apt/preferences.d/volatile': - ensure => absent; - - '/etc/apt/preferences.d/lts': - ensure => absent; - - '/etc/apt/preferences.d/nextcodename': - ensure => absent; + file { '/etc/apt/preferences.d/custom': + ensure => absent, + } + file { '/etc/apt/preferences.d/current_codename': + ensure => absent, + } + file { '/etc/apt/preferences.d/volatile': + ensure => absent, + } + file { '/etc/apt/preferences.d/lts': + ensure => absent, + } + file { '/etc/apt/preferences.d/nextcodename': + ensure => absent, } } } -- cgit v1.2.3