From 770f8fb5dafa442bc018fa95fcab2fb60d817020 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 3 Oct 2015 01:13:50 -0400 Subject: make backports_url follow debian_url by default backports_url was already set to the same value than debian_url by default, but it was set to the default value of debian_url. this meant that when giving a url to the debian_url parameter to the apt class, the backports_url would not follow and would still be using the default value for debian_url. with this change, when backports_url is not specified, but debian_url is, then both of them take on the value given to the debian_url. of course if backports_url is also given a value, then it keeps the value given by the user. --- manifests/init.pp | 9 +++++++-- manifests/params.pp | 5 +---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 4c44af2..9c186cc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -35,6 +35,11 @@ class apt( } } + $real_backports_url = $backports_url ? { + false => $debian_url, + default => $backports_url, + } + package { 'apt': ensure => installed, require => undef, @@ -99,12 +104,12 @@ class apt( if ($use_backports and !($::debian_release in ['testing', 'unstable', 'experimental'])) { apt::sources_list { 'backports': - content => "deb $backports_url ${::debian_codename}-backports ${apt::real_repos}", + content => "deb ${real_backports_url} ${::debian_codename}-backports ${apt::repos}", } if $include_src { apt::sources_list { 'backports-src': - content => "deb-src $backports_url ${::debian_codename}-backports ${apt::real_repos}", + content => "deb-src ${real_backports_url} ${::debian_codename}-backports ${apt::repos}", } } } diff --git a/manifests/params.pp b/manifests/params.pp index 28af06e..be7262d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -9,10 +9,7 @@ class apt::params () { $ubuntu_url = 'http://archive.ubuntu.com/ubuntu' $backports_url = $::debian_codename ? { 'squeeze' => 'http://backports.debian.org/debian-backports/', - default => $::operatingsystem ? { - 'Ubuntu' => $ubuntu_url, - default => $debian_url, - } + default => false, } $lts_url = $debian_url $volatile_url = 'http://volatile.debian.org/debian-volatile/' -- cgit v1.2.3 From 0752201ce40e7bf4a9acdf642b455e1d97e8789f Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sat, 3 Oct 2015 01:18:07 -0400 Subject: push logic behind apt::repos back in apt::params The logic in specifying the default value for apt::repos is in the wrong place: it should be in apt::params since this is exactly what this latter class is for. There's no special case that can involve making default the value follow the value of another parameter so there's no point in having that logic in the main class. --- manifests/init.pp | 14 -------------- manifests/params.pp | 12 +++++++++++- templates/Debian/sources.list.erb | 2 +- templates/Ubuntu/sources.list.erb | 4 ++-- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9c186cc..46e5cb0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,20 +20,6 @@ class apt( $custom_sources_list = '', $custom_key_dir = $apt::params::custom_key_dir ) inherits apt::params { - case $::operatingsystem { - 'debian': { - $real_repos = $repos ? { - 'auto' => 'main contrib non-free', - default => $repos, - } - } - 'ubuntu': { - $real_repos = $repos ? { - 'auto' => 'main restricted universe multiverse', - default => $repos, - } - } - } $real_backports_url = $backports_url ? { false => $debian_url, diff --git a/manifests/params.pp b/manifests/params.pp index be7262d..a70dac1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -13,7 +13,17 @@ class apt::params () { } $lts_url = $debian_url $volatile_url = 'http://volatile.debian.org/debian-volatile/' - $repos = 'auto' + case $::operatingsystem { + 'debian': { + $repos = 'main contrib non-free' + } + 'ubuntu': { + $repos = 'main restricted universe multiverse' + } + default: { + fail("Unsupported system '${::operatingsystem}'.") + } + } $custom_preferences = '' $custom_key_dir = false } diff --git a/templates/Debian/sources.list.erb b/templates/Debian/sources.list.erb index 44eea53..c7318a2 100644 --- a/templates/Debian/sources.list.erb +++ b/templates/Debian/sources.list.erb @@ -4,7 +4,7 @@ ### Debian current: <%= codename=scope.lookupvar('::debian_codename') %> # basic -deb <%= debian_url=scope.lookupvar('apt::debian_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::real_repos') %> +deb <%= debian_url=scope.lookupvar('apt::debian_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::repos') %> <% if include_src=scope.lookupvar('apt::include_src') -%> deb-src <%= debian_url %> <%= codename %> <%= lrepos %> <% end -%> diff --git a/templates/Ubuntu/sources.list.erb b/templates/Ubuntu/sources.list.erb index e6d2f64..b90b8c8 100644 --- a/templates/Ubuntu/sources.list.erb +++ b/templates/Ubuntu/sources.list.erb @@ -1,8 +1,8 @@ # This file is managed by puppet # all local modifications will be overwritten -# basic <%= codename=scope.lookupvar('::ubuntu_codename') %> -deb <%= ubuntu_url=scope.lookupvar('apt::ubuntu_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::real_repos') %> +# basic <%= codename=scope.lookupvar('apt::codename') %> +deb <%= ubuntu_url=scope.lookupvar('apt::ubuntu_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::repos') %> <% if include_src=scope.lookupvar('apt::include_src') -%> deb-src <%= ubuntu_url %> <%= codename %> <%= lrepos %> <% end -%> -- cgit v1.2.3 From 8859eba152a5a504db9816b64fec6720f7ba5f14 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Wed, 29 Jun 2016 16:45:22 +0200 Subject: add an upgrade notice about the change of default value for $repos --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5f6a109..f6a0c4a 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ Ubuntu support is lagging behind but not absent either. ## Upgrade Notice + * The default value of the `$repos` parameter was removed since the logic is + now in the `apt::params` class. If you have explicitly set `$repos` to + 'auto' in your manifests, you should remove this. + * The `disable_update` parameter has been removed. The main apt class defaults to *not* run an `apt-get update` on every run anyway so this parameter seems useless. -- cgit v1.2.3