Try to retire the site module: move site::aptrepo to base
authorPeter Palfrader <peter@palfrader.org>
Sat, 7 Sep 2019 17:23:03 +0000 (19:23 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sat, 7 Sep 2019 17:23:03 +0000 (19:23 +0200)
modules/base/manifests/aptrepo.pp [new file with mode: 0644]
modules/base/templates/aptrepo.erb [new file with mode: 0644]
modules/debian_org/manifests/apt.pp
modules/debian_org/manifests/apt_restricted.pp
modules/hardware/manifests/raid/dell.pp
modules/hardware/manifests/raid/megaraid_sas.pp
modules/hardware/manifests/raid/proliant.pp
modules/site/manifests/aptrepo.pp [deleted file]
modules/site/templates/aptrepo.erb [deleted file]

diff --git a/modules/base/manifests/aptrepo.pp b/modules/base/manifests/aptrepo.pp
new file mode 100644 (file)
index 0000000..f7c81fc
--- /dev/null
@@ -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 (file)
index 0000000..33d4c69
--- /dev/null
@@ -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")
+%>
index d52005f..8ff0877 100644 (file)
@@ -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,
        }
 
index 9b1126e..b76d5b0 100644 (file)
@@ -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',
index c654f47..277fa2d 100644 (file)
@@ -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,
        }
 }
index bb5172e..f208682 100644 (file)
@@ -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,
        }
 }
index afc7091..305cfc4 100644 (file)
@@ -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 (file)
index 148f9cf..0000000
+++ /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 (file)
index 33d4c69..0000000
+++ /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")
-%>