From a7f94e1060ddd48504b091b99bef3da0c965c53f Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Mon, 21 Oct 2013 11:28:11 +0300 Subject: [PATCH] apt: Parameterize apt::sources --- apt/manifests/init.pp | 34 +++++++++++-------- apt/templates/sources.list.erb | 62 +++++----------------------------- 2 files changed, 28 insertions(+), 68 deletions(-) diff --git a/apt/manifests/init.pp b/apt/manifests/init.pp index eae862d..76b8869 100644 --- a/apt/manifests/init.pp +++ b/apt/manifests/init.pp @@ -75,31 +75,35 @@ define apt::ppa($ensure = "present") { # Configure /etc/apt/sources.list # -# === Global variables +# === Parameters # -# $apt_archive_url: -# Base URL of archive repository. Defaults to http://archive.ubuntu.com/ubuntu/. -# $apt_security_url: -# Base URL of security repository. Defaults to http://security.ubuntu.com/ubuntu/. +# $archive_url: +# Base URL of archive repository. +# Defaults to "mirror://mirrors.ubuntu.com/mirrors.txt". # -class apt::sources { +# $security_url: +# Base URL of security repository. +# Defaults to "mirror://mirrors.ubuntu.com/mirrors.txt". +# +# $backports: +# Boolean for enabling the backports repositories. +# Defaults to true. +# +class apt::sources( + $archive_url="mirror://mirrors.ubuntu.com/mirrors.txt", + $security_url="mirror://mirrors.ubuntu.com/mirrors.txt", + $backports=true +) { tag("bootstrap") include apt - if !$apt_archive_url { - $apt_archive_url = "http://archive.ubuntu.com/ubuntu/" - } - if !$apt_security_url { - $apt_security_url = "http://security.ubuntu.com/ubuntu/" - } - file { "/etc/apt/sources.list": ensure => present, mode => "0644", - owner => root, - group => root, + owner => "root", + group => "root", content => template("apt/sources.list.erb"), notify => Exec["apt-get-update"], } diff --git a/apt/templates/sources.list.erb b/apt/templates/sources.list.erb index 6ed7ac7..68ace46 100644 --- a/apt/templates/sources.list.erb +++ b/apt/templates/sources.list.erb @@ -1,57 +1,13 @@ -# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to -# newer versions of the distribution. +deb <%= @archive_url %> <%= @lsbdistcodename %> main restricted universe multiverse +deb-src <%= @archive_url %> <%= @lsbdistcodename %> main restricted universe multiverse -deb <%= @apt_archive_url %> <%= @lsbdistcodename %> main restricted -deb-src <%= @apt_archive_url %> <%= @lsbdistcodename %> main restricted +deb <%= @archive_url %> <%= @lsbdistcodename %>-updates main restricted universe multiverse +deb-src <%= @archive_url %> <%= @lsbdistcodename %>-updates main restricted universe multiverse -## Major bug fix updates produced after the final release of the -## distribution. -deb <%= @apt_archive_url %> <%= @lsbdistcodename %>-updates main restricted -deb-src <%= @apt_archive_url %> <%= @lsbdistcodename %>-updates main restricted +deb <%= @security_url %> <%= @lsbdistcodename %>-security main restricted universe multiverse +deb-src <%= @security_url %> <%= @lsbdistcodename %>-security main restricted universe multiverse +<% if @backports == true -%> -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team. Also, please note that software in universe WILL NOT receive any -## review or updates from the Ubuntu security team. -deb <%= @apt_archive_url %> <%= @lsbdistcodename %> universe -deb-src <%= @apt_archive_url %> <%= @lsbdistcodename %> universe -deb <%= @apt_archive_url %> <%= @lsbdistcodename %>-updates universe -deb-src <%= @apt_archive_url %> <%= @lsbdistcodename %>-updates universe - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb <%= @apt_archive_url %> <%= @lsbdistcodename %> multiverse -deb-src <%= @apt_archive_url %> <%= @lsbdistcodename %> multiverse -deb <%= @apt_archive_url %> <%= @lsbdistcodename %>-updates multiverse -deb-src <%= @apt_archive_url %> <%= @lsbdistcodename %>-updates multiverse - -## Uncomment the following two lines to add software from the 'backports' -## repository. -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -<% if @apt_backports -%> -deb <%= @apt_archive_url %> <%= @lsbdistcodename %>-backports main restricted universe multiverse -deb-src <%= @apt_archive_url %> <%= @lsbdistcodename %>-backports main restricted universe multiverse -<% else -%> -# deb <%= @apt_archive_url %> <%= @lsbdistcodename %>-backports main restricted universe multiverse -# deb-src <%= @apt_archive_url %> <%= @lsbdistcodename %>-backports main restricted universe multiverse +deb <%= @archive_url %> <%= @lsbdistcodename %>-backports main restricted universe multiverse +deb-src <%= @archive_url %> <%= @lsbdistcodename %>-backports main restricted universe multiverse <% end -%> - -## Uncomment the following two lines to add software from Canonical's -## 'partner' repository. -## This software is not part of Ubuntu, but is offered by Canonical and the -## respective vendors as a service to Ubuntu users. -# deb http://archive.canonical.com/ubuntu <%= @lsbdistcodename %> partner -# deb-src http://archive.canonical.com/ubuntu <%= @lsbdistcodename %> partner - -deb <%= @apt_security_url %> <%= @lsbdistcodename %>-security main restricted -deb-src <%= @apt_security_url %> <%= @lsbdistcodename %>-security main restricted -deb <%= @apt_security_url %> <%= @lsbdistcodename %>-security universe -deb-src <%= @apt_security_url %> <%= @lsbdistcodename %>-security universe -deb <%= @apt_security_url %> <%= @lsbdistcodename %>-security multiverse -deb-src <%= @apt_security_url %> <%= @lsbdistcodename %>-security multiverse