From cb1ef5c5d98a4e9ea5f02c7d2e337809cb637ed9 Mon Sep 17 00:00:00 2001
From: Andreas Kempe <kempe@lysator.liu.se>
Date: Sat, 17 Oct 2020 14:16:38 +0200
Subject: [PATCH] workstation: factor out NIS to its own class

To prepare for LDAP support, NIS is factored out into its own class.
---
 files/{workstation => nis}/auto_master   |  0
 files/{workstation => nis}/include_yp    |  0
 files/{workstation => nis}/krb5.conf     |  0
 files/{workstation => nis}/nsswitch.conf |  0
 files/{workstation => nis}/pam.sshd      |  0
 files/{workstation => nis}/pam.su        |  0
 files/{workstation => nis}/pam.system    |  0
 manifests/nis.pp                         | 82 ++++++++++++++++++++++++
 manifests/workstation.pp                 | 81 -----------------------
 9 files changed, 82 insertions(+), 81 deletions(-)
 rename files/{workstation => nis}/auto_master (100%)
 rename files/{workstation => nis}/include_yp (100%)
 rename files/{workstation => nis}/krb5.conf (100%)
 rename files/{workstation => nis}/nsswitch.conf (100%)
 rename files/{workstation => nis}/pam.sshd (100%)
 rename files/{workstation => nis}/pam.su (100%)
 rename files/{workstation => nis}/pam.system (100%)
 create mode 100644 manifests/nis.pp

diff --git a/files/workstation/auto_master b/files/nis/auto_master
similarity index 100%
rename from files/workstation/auto_master
rename to files/nis/auto_master
diff --git a/files/workstation/include_yp b/files/nis/include_yp
similarity index 100%
rename from files/workstation/include_yp
rename to files/nis/include_yp
diff --git a/files/workstation/krb5.conf b/files/nis/krb5.conf
similarity index 100%
rename from files/workstation/krb5.conf
rename to files/nis/krb5.conf
diff --git a/files/workstation/nsswitch.conf b/files/nis/nsswitch.conf
similarity index 100%
rename from files/workstation/nsswitch.conf
rename to files/nis/nsswitch.conf
diff --git a/files/workstation/pam.sshd b/files/nis/pam.sshd
similarity index 100%
rename from files/workstation/pam.sshd
rename to files/nis/pam.sshd
diff --git a/files/workstation/pam.su b/files/nis/pam.su
similarity index 100%
rename from files/workstation/pam.su
rename to files/nis/pam.su
diff --git a/files/workstation/pam.system b/files/nis/pam.system
similarity index 100%
rename from files/workstation/pam.system
rename to files/nis/pam.system
diff --git a/manifests/nis.pp b/manifests/nis.pp
new file mode 100644
index 0000000..a5604b0
--- /dev/null
+++ b/manifests/nis.pp
@@ -0,0 +1,82 @@
+class freebsd::nis {
+  file { '/etc/auto_master':
+    ensure => file,
+    source => 'puppet:///modules/freebsd/nis/auto_master',
+    owner  => 'root',
+    group  => 'wheel',
+    mode   => '0644',
+  }
+
+  file { '/etc/nsswitch.conf':
+    ensure => file,
+    source => 'puppet:///modules/freebsd/nis/nsswitch.conf',
+    owner  => 'root',
+    group  => 'wheel',
+    mode   => '0644',
+  }
+
+  file { '/etc/krb5.conf':
+    ensure => file,
+    source => 'puppet:///modules/freebsd/nis/krb5.conf',
+    owner  => 'root',
+    group  => 'wheel',
+    mode   => '0644',
+  }
+
+  file { '/etc/pam.d/sshd':
+    ensure => file,
+    source => 'puppet:///modules/freebsd/nis/pam.sshd',
+    owner  => 'root',
+    group  => 'wheel',
+    mode   => '0644',
+  }
+
+  file { '/etc/pam.d/system':
+    ensure => file,
+    source => 'puppet:///modules/freebsd/nis/pam.system',
+    owner  => 'root',
+    group  => 'wheel',
+    mode   => '0644',
+  }
+
+  file { '/etc/pam.d/su':
+    ensure => file,
+    source => 'puppet:///modules/freebsd/nis/pam.su',
+    owner  => 'root',
+    group  => 'wheel',
+    mode   => '0644',
+  }
+
+  file_line { 'Set nisdomain':
+    path => '/etc/rc.conf',
+    line => 'nisdomainname="lysator"',
+  }
+
+  file_line { 'Enable nis client':
+    path => '/etc/rc.conf',
+    line => 'nis_client_enable="YES"',
+  }
+
+  file_line { 'Set nis flags':
+    path => '/etc/rc.conf',
+    line => 'nis_client_flags="-s -m -S lysator,nis.lysator.liu.se,nis-slave.lysator.liu.se"',
+  }
+
+  file_line { 'Enable autofs':
+    path => '/etc/rc.conf',
+    line => 'autofs_enable="YES"',
+  }
+
+  file { '/etc/autofs/include_yp':
+    ensure => file,
+    source => 'puppet:///modules/freebsd/nis/include_yp',
+    owner  => 'root',
+    group  => 'wheel',
+    mode   => '0744',
+  }
+
+  file { '/etc/autofs/include':
+    ensure => 'link',
+    target => '/etc/autofs/include_yp',
+  }
+}
diff --git a/manifests/workstation.pp b/manifests/workstation.pp
index 5e4a298..a90a366 100644
--- a/manifests/workstation.pp
+++ b/manifests/workstation.pp
@@ -174,54 +174,6 @@ class freebsd::workstation inherits freebsd::base {
       ensure => installed,
   }
 
-  file { '/etc/auto_master':
-    ensure => file,
-    source => 'puppet:///modules/freebsd/workstation/auto_master',
-    owner  => 'root',
-    group  => 'wheel',
-    mode   => '0644',
-  }
-
-  file { '/etc/nsswitch.conf':
-    ensure => file,
-    source => 'puppet:///modules/freebsd/workstation/nsswitch.conf',
-    owner  => 'root',
-    group  => 'wheel',
-    mode   => '0644',
-  }
-
-  file { '/etc/krb5.conf':
-    ensure => file,
-    source => 'puppet:///modules/freebsd/workstation/krb5.conf',
-    owner  => 'root',
-    group  => 'wheel',
-    mode   => '0644',
-  }
-
-  file { '/etc/pam.d/sshd':
-    ensure => file,
-    source => 'puppet:///modules/freebsd/workstation/pam.sshd',
-    owner  => 'root',
-    group  => 'wheel',
-    mode   => '0644',
-  }
-
-  file { '/etc/pam.d/system':
-    ensure => file,
-    source => 'puppet:///modules/freebsd/workstation/pam.system',
-    owner  => 'root',
-    group  => 'wheel',
-    mode   => '0644',
-  }
-
-  file { '/etc/pam.d/su':
-    ensure => file,
-    source => 'puppet:///modules/freebsd/workstation/pam.su',
-    owner  => 'root',
-    group  => 'wheel',
-    mode   => '0644',
-  }
-
   file { '/etc/ssh/ssh_config':
     ensure => file,
     source => 'puppet:///modules/freebsd/workstation/ssh_config',
@@ -260,44 +212,11 @@ class freebsd::workstation inherits freebsd::base {
     line => 'dbus_enable="YES"',
   }
 
-  file_line { 'Set nisdomain':
-    path => '/etc/rc.conf',
-    line => 'nisdomainname="lysator"',
-  }
-
-  file_line { 'Enable nis client':
-    path => '/etc/rc.conf',
-    line => 'nis_client_enable="YES"',
-  }
-
-  file_line { 'Set nis flags':
-    path => '/etc/rc.conf',
-    line => 'nis_client_flags="-s -m -S lysator,nis.lysator.liu.se,nis-slave.lysator.liu.se"',
-  }
-
-  file_line { 'Enable autofs':
-    path => '/etc/rc.conf',
-    line => 'autofs_enable="YES"',
-  }
-
   file_line { 'Enable slim login manager':
     path => '/etc/rc.conf',
     line => 'slim_enable="YES"',
   }
 
-  file { '/etc/autofs/include_yp':
-    ensure => file,
-    source => 'puppet:///modules/freebsd/workstation/include_yp',
-    owner  => 'root',
-    group  => 'wheel',
-    mode   => '0744',
-  }
-
-  file { '/etc/autofs/include':
-    ensure => 'link',
-    target => '/etc/autofs/include_yp',
-  }
-
   # Set default Xorg keyboard layout to Swedish.
   file { '/usr/local/etc/X11/xorg.conf.d/keyboard.conf':
     ensure => file,
-- 
GitLab