Fix merge conflict in README

This commit is contained in:
Jerome Charaoui 2015-10-09 12:08:26 -04:00
commit e4d777e5ec
28 changed files with 229 additions and 102 deletions

23
README
View file

@ -17,9 +17,11 @@ Ubuntu support is lagging behind but not absent either.
! Upgrade Notice !
* Several parser functions have been updated: you need to restart your puppet
master, otherwise some nodes may keep on using an old, cached version!
(https://docs.puppetlabs.com/guides/custom_functions.html#gotchas)
* The apt::codename parameter has been removed. In its place, the
debian_codename fact may be overridden via an environment variable. This
will affect all other debian_* facts, and achieve the same result.
FACTER_debian_codename=jessie puppet agent -t
* If you were using custom 50unattended-upgrades.${::lsbdistcodename} in your
site_apt, these are no longer supported. You should migrate to passing
@ -97,9 +99,9 @@ Requirements
This module needs:
- the lsb module: git://labs.riseup.net/shared-lsb
- the common module: git://labs.riseup.net/shared-common
- the stdlib module: https://forge.puppetlabs.com/puppetlabs/stdlib
- the common module: https://gitlab.com/shared-puppet-modules-group/common
- the lsb module: https://gitlab.com/shared-puppet-modules-group/lsb
(optional but recommended, required on Ubuntu)
By default, on normal hosts, this module sets the configuration option
DSelect::Clean to 'auto'. On virtual servers, the value is set by default to
@ -226,15 +228,6 @@ Class parameters:
class { 'apt': custom_sources_list => template('site_apt/sources.list') }
* codename
Contains the codename ("squeeze", "wheezy", ...) of the client's release. While
these values come from lsb-release by default, this parameter can be set
manually, e.g. to enable forced upgrades. For example:
include apt::dist_upgrade
class { 'apt': codename => 'wheezy', notify => Exec['apt_dist-upgrade'] }
* custom_key_dir
If you have different apt-key files that you want to get added to your

View file

@ -0,0 +1,40 @@
begin
require 'facter/util/debian'
end
def version_to_codename(version)
if Facter::Util::Debian::CODENAMES.has_key?(version)
return Facter::Util::Debian::CODENAMES[version]
else
Facter.warn("Could not determine codename from version '#{version}'")
end
end
Facter.add(:debian_codename) do
has_weight 99
confine :operatingsystem => 'Debian'
setcode do
Facter.value('lsbdistcodename')
end
end
Facter.add(:debian_codename) do
has_weight 66
confine :operatingsystem => 'Debian'
setcode do
version_to_codename(Facter.value('operatingsystemmajrelease'))
end
end
Facter.add(:debian_codename) do
has_weight 33
confine :operatingsystem => 'Debian'
setcode do
debian_version = File.open('/etc/debian_version', &:readline)
if debian_version.match(/^\d+/)
version_to_codename(version_to_codename.scan(/^(\d+)/)[0][0])
elsif debian_version.match(/^[a-z]+\/(sid|unstable)/)
debian_version.scan(/^([a-z]+)\//)[0][0]
end
end
end

14
lib/facter/debian_lts.rb Normal file
View file

@ -0,0 +1,14 @@
begin
require 'facter/util/debian'
end
Facter.add(:debian_lts) do
confine :operatingsystem => 'Debian'
setcode do
if Facter::Util::Debian::LTS.include? Facter.value('debian_codename')
true
else
false
end
end
end

View file

@ -0,0 +1,22 @@
begin
require 'facter/util/debian'
end
def debian_codename_to_next(codename)
if codename == "sid"
return "experimental"
else
codenames = Facter::Util::Debian::CODENAMES.values
i = codenames.index(codename)
if i and i+1 < codenames.count
return codenames[i+1]
end
end
end
Facter.add(:debian_nextcodename) do
confine :operatingsystem => 'Debian'
setcode do
debian_codename_to_next(Facter.value('debian_codename'))
end
end

View file

@ -0,0 +1,23 @@
def debian_release_to_next(release)
releases = [
'oldoldoldstable',
'oldoldstable',
'oldstable',
'stable',
'testing',
'unstable',
'experimental',
]
if releases.include? release
if releases.index(release)+1 < releases.count
return releases[releases.index(release)+1]
end
end
end
Facter.add(:debian_nextrelease) do
confine :operatingsystem => 'Debian'
setcode do
debian_release_to_next(Facter.value('debian_release'))
end
end

View file

@ -0,0 +1,36 @@
begin
require 'facter/util/debian'
end
def debian_codename_to_release(codename)
stable = Facter::Util::Debian::STABLE
versions = Facter::Util::Debian::CODENAMES.invert
release = nil
if codename == "sid"
release = "unstable"
elsif versions.has_key? codename
version = versions[codename].to_i
if version == stable
release = "stable"
elsif version < stable
release = "stable"
for i in version..stable - 1
release = "old" + release
end
elsif version == stable + 1
release = "testing"
end
end
if release.nil?
Facter.warn("Could not determine release from codename #{codename}!")
end
return release
end
Facter.add(:debian_release) do
has_weight 99
confine :operatingsystem => 'Debian'
setcode do
debian_codename_to_release(Facter.value('debian_codename'))
end
end

View file

@ -0,0 +1,8 @@
Facter.add(:ubuntu_codename) do
confine :operatingsystem => 'Ubuntu'
setcode do
Facter.value('lsbdistcodename')
end
end

View file

@ -0,0 +1,18 @@
begin
require 'facter/util/ubuntu'
end
def ubuntu_codename_to_next(codename)
codenames = Facter::Util::Ubuntu::CODENAMES
i = codenames.index(codename)
if i and i+1 < codenames.count
return codenames[i+1]
end
end
Facter.add(:ubuntu_nextcodename) do
confine :operatingsystem => 'Ubuntu'
setcode do
ubuntu_codename_to_next(Facter.value('ubuntu_codename'))
end
end

18
lib/facter/util/debian.rb Normal file
View file

@ -0,0 +1,18 @@
module Facter
module Util
module Debian
STABLE = 8
CODENAMES = {
"5" => "lenny",
"6" => "squeeze",
"7" => "wheezy",
"8" => "jessie",
"9" => "stretch",
"10" => "buster",
}
LTS = [
"squeeze",
]
end
end
end

20
lib/facter/util/ubuntu.rb Normal file
View file

@ -0,0 +1,20 @@
module Facter
module Util
module Ubuntu
CODENAMES = [
"lucid",
"maverick",
"natty",
"oneiric",
"precise",
"quantal",
"raring",
"saucy",
"trusty",
"utopic",
"vivid",
"wily",
]
end
end
end

View file

@ -1,12 +0,0 @@
module Puppet::Parser::Functions
newfunction(:debian_nextcodename, :type => :rvalue) do |args|
case args[0]
when "squeeze" then "wheezy"
when "wheezy" then "jessie"
when "jessie" then "stretch"
when "stretch" then "sid"
when "sid" then "experimental"
else "sid"
end
end
end

View file

@ -1,11 +0,0 @@
module Puppet::Parser::Functions
newfunction(:debian_nextrelease, :type => :rvalue) do |args|
case args[0]
when 'oldstable' then 'stable'
when 'stable' then 'testing'
when 'testing' then 'unstable'
when 'unstable' then 'experimental'
else 'unstable'
end
end
end

View file

@ -1,13 +0,0 @@
module Puppet::Parser::Functions
newfunction(:debian_release, :type => :rvalue) do |args|
case args[0]
when 'squeeze' then 'oldoldstable'
when 'wheezy' then 'oldstable'
when 'jessie' then 'stable'
when 'stretch' then 'testing'
when 'sid' then 'unstable'
when 'experimental' then 'experimental'
else 'testing'
end
end
end

View file

@ -1,12 +0,0 @@
module Puppet::Parser::Functions
newfunction(:debian_release_version, :type => :rvalue) do |args|
case args[0]
when 'squeeze' then '6.0'
when 'wheezy' then '7.0'
when 'jessie' then '8.0'
when 'stretch' then '9.0'
when 'buster' then '10.0'
else ''
end
end
end

View file

@ -1,6 +1,6 @@
class apt::apticron(
$ensure_version = 'installed',
$config = "apt/${::operatingsystem}/apticron_${::lsbdistcodename}.erb",
$config = "apt/${::operatingsystem}/apticron_${::debian_codename}.erb",
$email = 'root',
$diff_only = '1',
$listchanges_profile = 'apticron',

View file

@ -4,7 +4,6 @@
# See LICENSE for the full license granted to you.
class apt(
$codename = $apt::params::codename,
$use_lts = $apt::params::use_lts,
$use_volatile = $apt::params::use_volatile,
$use_backports = $apt::params::use_backports,
@ -42,21 +41,6 @@ class apt(
require => undef,
}
include lsb
# init $release, $next_release, $next_codename, $release_version
case $codename {
'n/a': {
fail("Unknown lsbdistcodename reported by facter: '$::lsbdistcodename', please fix this by setting this variable in your manifest.")
}
default: {
$release = debian_release($codename)
}
}
$release_version = debian_release_version($codename)
$next_codename = debian_nextcodename($codename)
$next_release = debian_nextrelease($release)
$sources_content = $custom_sources_list ? {
'' => template( "apt/${::operatingsystem}/sources.list.erb"),
default => $custom_sources_list

View file

@ -1,6 +1,6 @@
class apt::listchanges(
$ensure_version = 'installed',
$config = "apt/${::operatingsystem}/listchanges_${::lsbdistcodename}.erb",
$config = "apt/${::operatingsystem}/listchanges_${::debian_codename}.erb",
$frontend = 'mail',
$email = 'root',
$confirm = '0',

View file

@ -1,5 +1,4 @@
class apt::params () {
$codename = $::lsbdistcodename
$use_lts = false
$use_volatile = false
$use_backports = true
@ -7,7 +6,7 @@ class apt::params () {
$use_next_release = false
$debian_url = 'http://httpredir.debian.org/debian/'
$security_url = 'http://security.debian.org/'
$backports_url = $::lsbdistcodename ? {
$backports_url = $::debian_codename ? {
'squeeze' => 'http://backports.debian.org/debian-backports/',
default => $debian_url
}

View file

@ -2,8 +2,8 @@ class apt::preferences {
$pref_contents = $apt::custom_preferences ? {
'' => $::operatingsystem ? {
'debian' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"),
'ubuntu' => template("apt/${::operatingsystem}/preferences_${apt::codename}.erb"),
'debian' => template("apt/${::operatingsystem}/preferences_${::debian_codename}.erb"),
'ubuntu' => template("apt/${::operatingsystem}/preferences_${::ubuntu_codename}.erb"),
},
default => $apt::custom_preferences
}

View file

@ -4,7 +4,7 @@ define apt::preseeded_package (
) {
$seedfile = "/var/cache/local/preseeding/${name}.seeds"
$real_content = $content ? {
'' => template ( "site_apt/${::lsbdistcodename}/${name}.seeds" ),
'' => template ( "site_apt/${::debian_codename}/${name}.seeds" ),
default => $content
}

View file

@ -5,13 +5,13 @@ Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";
"${distro_id}:${distro_codename}-backports";
<% elsif scope.lookupvar('::operatingsystem') == 'Debian' and scope.lookupvar('::operatingsystemmajrelease') == 6 -%>
<% elsif scope.lookupvar('::operatingsystem') == 'Debian' and scope.lookupvar('::debian_codename') == 'squeeze' -%>
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:oldoldstable";
"${distro_id}:squeeze-lts";
<% else -%>
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,archive=<%= scope.lookupvar('::apt::release') %>,label=Debian-Security";
"origin=Debian,archive=<%= scope.lookupvar('::debian_release') %>,label=Debian-Security";
"origin=Debian,archive=${distro_codename}-lts";
<% end -%>
};

View file

@ -1,4 +1,4 @@
Explanation: Debian <%= codename=scope.lookupvar('apt::codename') %>
Explanation: Debian <%= codename=scope.lookupvar('::debian_codename') %>
Package: *
Pin: release o=Debian,n=<%= codename %>
Pin-Priority: 990

View file

@ -1,6 +1,6 @@
Explanation: Debian <%= codename=scope.lookupvar('apt::codename') %>
Explanation: Debian <%= codename=scope.lookupvar('::debian_codename') %>
Package: *
Pin: release o=Debian,a=<%= scope.lookupvar('apt::release') %>,v=<%= scope.lookupvar('apt::release_version') %>*
Pin: release o=Debian,a=<%= scope.lookupvar('::debian_release') %>,v=5*
Pin-Priority: 990
Explanation: Debian backports
@ -8,7 +8,7 @@ Package: *
Pin: origin backports.debian.org
Pin-Priority: 200
Explanation: Debian <%= next_release=scope.lookupvar('apt::next_release') %>
Explanation: Debian <%= next_release=scope.lookupvar('::debian_nextrelease') %>
Package: *
Pin: release o=Debian,a=<%= next_release %>
Pin-Priority: 2

View file

@ -1,4 +1,4 @@
Explanation: Debian <%= codename=scope.lookupvar('apt::codename') %>
Explanation: Debian <%= codename=scope.lookupvar('::debian_codename') %>
Package: *
Pin: release o=Debian,n=<%= codename %>
Pin-Priority: 990
@ -13,7 +13,7 @@ Package: *
Pin: release o=Debian,n=<%= codename %>-lts
Pin-Priority: 990
Explanation: Debian <%= next_codename=scope.lookupvar('apt::next_codename') %>
Explanation: Debian <%= next_codename=scope.lookupvar('::debian_nextcodename') %>
Package: *
Pin: release o=Debian,n=<%= next_codename %>
Pin-Priority: 2

View file

@ -1,4 +1,4 @@
Explanation: Debian <%= codename=scope.lookupvar('apt::codename') %>
Explanation: Debian <%= codename=scope.lookupvar('::debian_codename') %>
Package: *
Pin: release o=Debian,n=<%= codename %>
Pin-Priority: 990

View file

@ -1,7 +1,7 @@
# This file is managed by puppet
# all local modifications will be overwritten
### Debian current: <%= codename=scope.lookupvar('apt::codename') %>
### Debian current: <%= codename=scope.lookupvar('::debian_codename') %>
# basic
deb <%= debian_url=scope.lookupvar('apt::debian_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::real_repos') %>
@ -10,7 +10,7 @@ deb-src <%= debian_url %> <%= codename %> <%= lrepos %>
<% end -%>
# security
<% if ((release=scope.lookupvar('apt::release')) == "stable" || release == "oldstable") -%>
<% if ((release=scope.lookupvar('::debian_release')) == "stable" || release == "oldstable") -%>
deb <%= security_url=scope.lookupvar('apt::security_url') %> <%= codename %>/updates <%= lrepos %>
<% if include_src -%>
deb-src <%= security_url %> <%= codename %>/updates <%= lrepos %>
@ -45,7 +45,7 @@ deb-src <%= debian_url %> <%= codename %>-updates <%= lrepos %>
<% if use_lts=scope.lookupvar('apt::use_lts') -%>
# LTS
<% if release != "oldoldstable" -%>
<% if release_lts=scope.lookupvar('::debian_lts') == "false" -%>
# There is no LTS archive for <%= release %>
<% else -%>
deb <%= debian_url %> <%= codename %>-lts <%= lrepos %>
@ -56,7 +56,7 @@ deb-src <%= debian_url %> <%= codename %>-lts <%= lrepos %>
<% end -%>
<% if next_release=scope.lookupvar('apt::use_next_release') -%>
### Debian next: <%= next_release=scope.lookupvar('apt::next_release') ; next_codename=scope.lookupvar('apt::next_codename') %>
### Debian next: <%= next_release=scope.lookupvar('::debian_nextrelease') ; next_codename=scope.lookupvar('::debian_nextcodename') %>
# basic
deb <%= debian_url %> <%= next_codename %> <%= lrepos %>

View file

@ -1,4 +1,4 @@
Explanation: Ubuntu <%= codename=scope.lookupvar('apt::codename') %> security
Explanation: Ubuntu <%= codename=scope.lookupvar('::ubuntu_codename') %> security
Package: *
Pin: release o=Ubuntu,a=<%= codename %>-security
Pin-Priority: 990
@ -18,7 +18,7 @@ Package: *
Pin: release a=<%= codename %>-backports
Pin-Priority: 200
Explanation: Ubuntu <%= next_release=scope.lookupvar('apt::next_release') %>
Explanation: Ubuntu <%= next_release=scope.lookupvar('::ubuntu_nextcodename') %>
Package: *
Pin: release o=Ubuntu,a=<%= next_release %>
Pin-Priority: 2

View file

@ -1,7 +1,7 @@
# This file is managed by puppet
# all local modifications will be overwritten
# basic <%= codename=scope.lookupvar('apt::codename') %>
# basic <%= codename=scope.lookupvar('::ubuntu_codename') %>
deb <%= ubuntu_url=scope.lookupvar('apt::ubuntu_url') %> <%= codename %> <%= lrepos=scope.lookupvar('apt::real_repos') %>
<% if include_src=scope.lookupvar('apt::include_src') -%>
deb-src <%= ubuntu_url %> <%= codename %> <%= lrepos %>