From: Peter Palfrader Date: Sat, 7 Sep 2019 17:23:03 +0000 (+0200) Subject: Try to retire the site module: move site::aptrepo to base X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=9c6e5abb124b6664dea47f2637e431286433b677;p=mirror%2Fdsa-puppet.git Try to retire the site module: move site::aptrepo to base --- diff --git a/modules/base/manifests/aptrepo.pp b/modules/base/manifests/aptrepo.pp new file mode 100644 index 000000000..f7c81fc2b --- /dev/null +++ b/modules/base/manifests/aptrepo.pp @@ -0,0 +1,42 @@ +define base::aptrepo ( + $url='', + $suite='', + $components=[], + $key = undef, + $ensure = present +) { + + case $ensure { + present: { + if $key { + file { "/etc/apt/trusted.gpg.d/${name}.gpg": + source => $key, + mode => '0664', + } + } + } + absent: { + if $key { + file { "/etc/apt/trusted.gpg.d/${name}.gpg": + ensure => absent, + } + } + } + default: { fail ( "Unknown ensure value: '$ensure'" ) } + } + + case $ensure { + present: { + if !($url and $suite) { + fail ( "Need both url and suite for $name" ) + } + } + default: {} + } + + file { "/etc/apt/sources.list.d/${name}.list": + ensure => $ensure, + content => template('base/aptrepo.erb'), + notify => Exec['apt-get update'], + } +} diff --git a/modules/base/templates/aptrepo.erb b/modules/base/templates/aptrepo.erb new file mode 100644 index 000000000..33d4c69b8 --- /dev/null +++ b/modules/base/templates/aptrepo.erb @@ -0,0 +1,18 @@ +## +### THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. +### USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git +### + +<%= + url = [scope.lookupvar('url') ].flatten + suite = [scope.lookupvar('suite')].flatten + components = [scope.lookupvar('components')].flatten.join(' ') + + lines = [] + url.each do |u| + suite.each do |s| + lines << "deb #{u} #{s} #{components}" + end + end + lines.join("\n") +%> diff --git a/modules/debian_org/manifests/apt.pp b/modules/debian_org/manifests/apt.pp index d52005f80..8ff087746 100644 --- a/modules/debian_org/manifests/apt.pp +++ b/modules/debian_org/manifests/apt.pp @@ -17,14 +17,14 @@ class debian_org::apt { # jessie if versioncmp($::lsbmajdistrelease, '8') <= 0 { - site::aptrepo { 'debian': + base::aptrepo { 'debian': url => $mirror, suite => [ $::lsbdistcodename ], components => ['main','contrib','non-free'] } # stretch or buster } else { - site::aptrepo { 'debian': + base::aptrepo { 'debian': url => $mirror, suite => [ $::lsbdistcodename, "${::lsbdistcodename}-backports", "${::lsbdistcodename}-updates" ], components => ['main','contrib','non-free'] @@ -32,13 +32,13 @@ class debian_org::apt { } if versioncmp($::lsbmajdistrelease, '8') <= 0 { - site::aptrepo { 'security': + base::aptrepo { 'security': url => [ 'http://security-cdn.debian.org/', 'http://security.debian.org/' ], suite => "${::lsbdistcodename}/updates", components => ['main','contrib','non-free'] } } else { - site::aptrepo { 'security': + base::aptrepo { 'security': url => [ 'http://security.debian.org/' ], suite => "${::lsbdistcodename}/updates", components => ['main','contrib','non-free'] @@ -57,7 +57,7 @@ class debian_org::apt { } } $dbdosuites = [ 'debian-all', $::lsbdistcodename ] - site::aptrepo { 'db.debian.org': + base::aptrepo { 'db.debian.org': url => 'https://db.debian.org/debian-admin', suite => $dbdosuites, components => 'main', @@ -65,39 +65,39 @@ class debian_org::apt { } if ($::hostname in []) { - site::aptrepo { 'proposed-updates': + base::aptrepo { 'proposed-updates': url => $mirror, suite => "${::lsbdistcodename}-proposed-updates", components => ['main','contrib','non-free'] } } else { - site::aptrepo { 'proposed-updates': + base::aptrepo { 'proposed-updates': ensure => absent, } } - site::aptrepo { 'debian-cdn': + base::aptrepo { 'debian-cdn': ensure => absent, } - site::aptrepo { 'debian.org': + base::aptrepo { 'debian.org': ensure => absent, } - site::aptrepo { 'debian2': + base::aptrepo { 'debian2': ensure => absent, } - site::aptrepo { 'backports2.debian.org': + base::aptrepo { 'backports2.debian.org': ensure => absent, } - site::aptrepo { 'backports.debian.org': + base::aptrepo { 'backports.debian.org': ensure => absent, } - site::aptrepo { 'volatile': + base::aptrepo { 'volatile': ensure => absent, } - site::aptrepo { 'db.debian.org-suite': + base::aptrepo { 'db.debian.org-suite': ensure => absent, } - site::aptrepo { 'debian-lts': + base::aptrepo { 'debian-lts': ensure => absent, } diff --git a/modules/debian_org/manifests/apt_restricted.pp b/modules/debian_org/manifests/apt_restricted.pp index 9b1126e14..b76d5b094 100644 --- a/modules/debian_org/manifests/apt_restricted.pp +++ b/modules/debian_org/manifests/apt_restricted.pp @@ -1,5 +1,5 @@ class debian_org::apt_restricted { - site::aptrepo { 'db.debian.org.restricted': + base::aptrepo { 'db.debian.org.restricted': url => 'https://db.debian.org/debian-admin', suite => "${::lsbdistcodename}-restricted", components => 'non-free', diff --git a/modules/hardware/manifests/raid/dell.pp b/modules/hardware/manifests/raid/dell.pp index c654f4745..277fa2d85 100644 --- a/modules/hardware/manifests/raid/dell.pp +++ b/modules/hardware/manifests/raid/dell.pp @@ -22,10 +22,10 @@ class hardware::raid::dell { ensure => installed, } } - site::aptrepo { 'jessie.dell': + base::aptrepo { 'jessie.dell': ensure => absent, } - site::aptrepo { 'debian.restricted.dell': + base::aptrepo { 'debian.restricted.dell': ensure => absent, } } diff --git a/modules/hardware/manifests/raid/megaraid_sas.pp b/modules/hardware/manifests/raid/megaraid_sas.pp index bb5172e9b..f208682cc 100644 --- a/modules/hardware/manifests/raid/megaraid_sas.pp +++ b/modules/hardware/manifests/raid/megaraid_sas.pp @@ -18,7 +18,7 @@ class hardware::raid::megaraid_sas { ensure => 'absent', } } - site::aptrepo { 'debian.restricted.megaraid_sas': + base::aptrepo { 'debian.restricted.megaraid_sas': ensure => absent, } } diff --git a/modules/hardware/manifests/raid/proliant.pp b/modules/hardware/manifests/raid/proliant.pp index afc709138..305cfc4ae 100644 --- a/modules/hardware/manifests/raid/proliant.pp +++ b/modules/hardware/manifests/raid/proliant.pp @@ -1,6 +1,6 @@ class hardware::raid::proliant { if $::smartarraycontroller_hpsa or $::smartarraycontroller_cciss { - site::aptrepo { 'debian.restricted': + base::aptrepo { 'debian.restricted': ensure => absent, } include debian_org::apt_restricted @@ -44,7 +44,7 @@ class hardware::raid::proliant { } file { '/etc/cron.d/puppet-nagios-hpsa': ensure => absent, } } else { - site::aptrepo { 'debian.restricted': + base::aptrepo { 'debian.restricted': ensure => absent, } } diff --git a/modules/site/manifests/aptrepo.pp b/modules/site/manifests/aptrepo.pp deleted file mode 100644 index 148f9cf0b..000000000 --- a/modules/site/manifests/aptrepo.pp +++ /dev/null @@ -1,42 +0,0 @@ -define site::aptrepo ( - $url='', - $suite='', - $components=[], - $key = undef, - $ensure = present -) { - - case $ensure { - present: { - if $key { - file { "/etc/apt/trusted.gpg.d/${name}.gpg": - source => $key, - mode => '0664', - } - } - } - absent: { - if $key { - file { "/etc/apt/trusted.gpg.d/${name}.gpg": - ensure => absent, - } - } - } - default: { fail ( "Unknown ensure value: '$ensure'" ) } - } - - case $ensure { - present: { - if !($url and $suite) { - fail ( "Need both url and suite for $name" ) - } - } - default: {} - } - - file { "/etc/apt/sources.list.d/${name}.list": - ensure => $ensure, - content => template('site/aptrepo.erb'), - notify => Exec['apt-get update'], - } -} diff --git a/modules/site/templates/aptrepo.erb b/modules/site/templates/aptrepo.erb deleted file mode 100644 index 33d4c69b8..000000000 --- a/modules/site/templates/aptrepo.erb +++ /dev/null @@ -1,18 +0,0 @@ -## -### THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. -### USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git -### - -<%= - url = [scope.lookupvar('url') ].flatten - suite = [scope.lookupvar('suite')].flatten - components = [scope.lookupvar('components')].flatten.join(' ') - - lines = [] - url.each do |u| - suite.each do |s| - lines << "deb #{u} #{s} #{components}" - end - end - lines.join("\n") -%>