From 955ee2210ae77852009bd93e5bfa5e828292b190 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Mon, 10 Jun 2024 09:38:28 +0200 Subject: [PATCH] lint auto fix --- manifests/client.pp | 13 +- manifests/client/config.pp | 64 +++++---- manifests/client/mount.pp | 23 ++-- manifests/client/package.pp | 25 ++-- manifests/client/service.pp | 45 +++---- manifests/functions/create_export.pp | 2 +- manifests/functions/mkdir.pp | 2 +- manifests/init.pp | 72 +++++------ manifests/params.pp | 187 +++++++++++++-------------- manifests/server.pp | 31 +++-- manifests/server/config.pp | 60 +++++---- manifests/server/export.pp | 19 +-- manifests/server/package.pp | 13 +- manifests/server/service.pp | 54 ++++---- 14 files changed, 284 insertions(+), 326 deletions(-) diff --git a/manifests/client.pp b/manifests/client.pp index df5a7569..e171d752 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -16,14 +16,13 @@ # class nfs::client ( - $ensure = $::nfs::ensure, - $nfs_v4 = $::nfs::nfs_v4_client, - $nfs_v4_mount_root = $::nfs::nfs_v4_mount_root, - $nfs_v4_idmap_domain = $::nfs::nfs_v4_idmap_domain, + $ensure = $nfs::ensure, + $nfs_v4 = $nfs::nfs_v4_client, + $nfs_v4_mount_root = $nfs::nfs_v4_mount_root, + $nfs_v4_idmap_domain = $nfs::nfs_v4_idmap_domain, ) { - - anchor {'nfs::client::begin': } - anchor {'nfs::client::end': } + anchor { 'nfs::client::begin': } + anchor { 'nfs::client::end': } # package(s) class { 'nfs::client::package': } diff --git a/manifests/client/config.pp b/manifests/client/config.pp index bf43f53c..6c4e92b3 100644 --- a/manifests/client/config.pp +++ b/manifests/client/config.pp @@ -15,40 +15,37 @@ # class nfs::client::config { - - if $::nfs::client::nfs_v4 { - - if $::nfs::defaults_file != undef { - if $::nfs::client_gssd_options != '' { - $_gssd1_aug = ["set ${::nfs::client_gssdopt_name} \"'${::nfs::client_gssd_options}'\""] + if $nfs::client::nfs_v4 { + if $nfs::defaults_file != undef { + if $nfs::client_gssd_options != '' { + $_gssd1_aug = ["set ${nfs::client_gssdopt_name} \"'${nfs::client_gssd_options}'\""] } else { $_gssd1_aug = undef } - - if $::nfs::client_need_gssd { + if $nfs::client_need_gssd { $_gssd2_aug = ['set NEED_GSSD yes'] } else { $_gssd2_aug = undef } - augeas { $::nfs::defaults_file: - context => "/files/${::nfs::defaults_file}", - changes => delete_undef_values(concat($::nfs::client_idmapd_setting, $_gssd1_aug, $_gssd2_aug)), + augeas { $nfs::defaults_file: + context => "/files/${nfs::defaults_file}", + changes => delete_undef_values(concat($nfs::client_idmapd_setting, $_gssd1_aug, $_gssd2_aug)), } } - if ($::nfs::client_rpcbind_config != undef) and ($::nfs::client_rpcbind_optname != undef) and ($::nfs::client_rpcbind_opts != undef){ - augeas { $::nfs::client_rpcbind_config: - incl => $::nfs::client_rpcbind_config, + if ($nfs::client_rpcbind_config != undef) and ($nfs::client_rpcbind_optname != undef) and ($nfs::client_rpcbind_opts != undef) { + augeas { $nfs::client_rpcbind_config: + incl => $nfs::client_rpcbind_config, lens => 'Shellvars.lns', - context => "/files/${::nfs::client_rpcbind_config}", - changes => "set ${::nfs::client_rpcbind_optname} \"'${::nfs::client_rpcbind_opts}'\"", + context => "/files/${nfs::client_rpcbind_config}", + changes => "set ${nfs::client_rpcbind_optname} \"'${nfs::client_rpcbind_opts}'\"", } } - if $::nfs::client_d9_gssdopt_workaround and $::nfs::client_gssd_service { - file_line{ 'rpc-gssd.service': + if $nfs::client_d9_gssdopt_workaround and $nfs::client_gssd_service { + file_line { 'rpc-gssd.service': path => '/lib/systemd/system/rpc-gssd.service', match => 'EnvironmentFile', line => 'EnvironmentFile=-/etc/default/nfs-common', @@ -59,41 +56,40 @@ } ~> Service['rpc-gssd'] } - if ( $::nfs::server_enabled == false ) or ( $::nfs::server_enabled == true and $::nfs::nfs_v4 == false ) { - if $::nfs::idmapd_file != undef { - - if $::nfs::nfs_v4_idmap_localrealms != '' { - if $::nfs::nfs_v4_idmap_localrealms =~ String { - $_localrealms = $::nfs::nfs_v4_idmap_localrealms + if ( $nfs::server_enabled == false ) or ( $nfs::server_enabled == true and $nfs::nfs_v4 == false ) { + if $nfs::idmapd_file != undef { + if $nfs::nfs_v4_idmap_localrealms != '' { + if $nfs::nfs_v4_idmap_localrealms =~ String { + $_localrealms = $nfs::nfs_v4_idmap_localrealms } else { - $_localrealms = join($::nfs::nfs_v4_idmap_localrealms, ',') + $_localrealms = join($nfs::nfs_v4_idmap_localrealms, ',') } $_aug_localrealm = "set General/Local-Realms ${_localrealms}" } else { $_aug_localrealm = undef } - if $::nfs::nfs_v4_idmap_cache != 0 { - $_cache = "set General/Cache-Expiration ${::nfs::nfs_v4_idmap_cache}" + if $nfs::nfs_v4_idmap_cache != 0 { + $_cache = "set General/Cache-Expiration ${nfs::nfs_v4_idmap_cache}" } else { $_cache = undef } - if $::nfs::manage_nfs_v4_idmap_nobody_mapping { - $_user = "set Mapping/Nobody-User ${::nfs::nfs_v4_idmap_nobody_user}" - $_group = "set Mapping/Nobody-Group ${::nfs::nfs_v4_idmap_nobody_group}" + if $nfs::manage_nfs_v4_idmap_nobody_mapping { + $_user = "set Mapping/Nobody-User ${nfs::nfs_v4_idmap_nobody_user}" + $_group = "set Mapping/Nobody-Group ${nfs::nfs_v4_idmap_nobody_group}" } else { $_user = undef $_group = undef } - $changes = ["set General/Domain ${::nfs::nfs_v4_idmap_domain}", $_aug_localrealm, $_cache, $_user, $_group] + $changes = ["set General/Domain ${nfs::nfs_v4_idmap_domain}", $_aug_localrealm, $_cache, $_user, $_group] $filtered_changes = filter($changes) |$val| { $val =~ NotUndef } - augeas { $::nfs::idmapd_file: - context => "/files/${::nfs::idmapd_file}", + augeas { $nfs::idmapd_file: + context => "/files/${nfs::idmapd_file}", lens => 'Puppet.lns', - incl => $::nfs::idmapd_file, + incl => $nfs::idmapd_file, changes => $filtered_changes, } } diff --git a/manifests/client/mount.pp b/manifests/client/mount.pp index 0ebce331..9101abf0 100644 --- a/manifests/client/mount.pp +++ b/manifests/client/mount.pp @@ -49,7 +49,6 @@ # String. Overwrite mount root if differs from server config # - # === Examples # # class { '::nfs': @@ -77,27 +76,25 @@ $mount = $title, $remounts = false, $atboot = false, - $options_nfsv4 = $::nfs::client_nfsv4_options, - $options_nfs = $::nfs::client_nfs_options, + $options_nfsv4 = $nfs::client_nfsv4_options, + $options_nfs = $nfs::client_nfs_options, $bindmount = undef, $nfstag = undef, - $nfs_v4 = $::nfs::client::nfs_v4, + $nfs_v4 = $nfs::client::nfs_v4, $owner = undef, $group = undef, $mode = undef, $mount_root = undef, - $manage_packages = $::nfs::manage_packages, - $client_packages = $::nfs::effective_client_packages, + $manage_packages = $nfs::manage_packages, + $client_packages = $nfs::effective_client_packages, ) { - if $manage_packages and $client_packages != undef { - $mount_require = [ Nfs::Functions::Mkdir[$mount], Package[$client_packages] ] + $mount_require = [Nfs::Functions::Mkdir[$mount], Package[$client_packages]] } else { - $mount_require = [ Nfs::Functions::Mkdir[$mount] ] + $mount_require = [Nfs::Functions::Mkdir[$mount]] } if $nfs_v4 == true { - if $mount_root == undef { $root = '' } else { @@ -117,7 +114,7 @@ mount { "shared ${sharename} by ${server} on ${mount}": ensure => $ensure, device => "${server}:${sharename}", - fstype => $::nfs::client_nfsv4_fstype, + fstype => $nfs::client_nfsv4_fstype, name => $mount, options => $options_nfsv4, remounts => $remounts, @@ -131,9 +128,7 @@ mount_name => $bindmount, } } - } else { - if $share != undef { $sharename = $share } else { @@ -146,7 +141,7 @@ mount { "shared ${sharename} by ${server} on ${mount}": ensure => $ensure, device => "${server}:${sharename}", - fstype => $::nfs::client_nfs_fstype, + fstype => $nfs::client_nfs_fstype, name => $mount, options => $options_nfs, remounts => $remounts, diff --git a/manifests/client/package.pp b/manifests/client/package.pp index 7e284f22..1a01b27e 100644 --- a/manifests/client/package.pp +++ b/manifests/client/package.pp @@ -15,33 +15,26 @@ # class nfs::client::package { - - if $::nfs::manage_packages { - - if $::nfs::client::nfs_v4 { - - if $::nfs::effective_nfsv4_client_services != undef and $::nfs::manage_client_service { - $notify_services = Service[keys($::nfs::effective_nfsv4_client_services)] + if $nfs::manage_packages { + if $nfs::client::nfs_v4 { + if $nfs::effective_nfsv4_client_services != undef and $nfs::manage_client_service { + $notify_services = Service[keys($nfs::effective_nfsv4_client_services)] } else { $notify_services = undef } - } else { - - if $::nfs::effective_client_services != undef and $::nfs::manage_client_service { - $notify_services = Service[keys($::nfs::effective_client_services)] + if $nfs::effective_client_services != undef and $nfs::manage_client_service { + $notify_services = Service[keys($nfs::effective_client_services)] } else { $notify_services = undef } - } - if $::nfs::effective_client_packages != undef { - package { $::nfs::effective_client_packages: - ensure => $::nfs::client_package_ensure, + if $nfs::effective_client_packages != undef { + package { $nfs::effective_client_packages: + ensure => $nfs::client_package_ensure, notify => $notify_services, } } - } } diff --git a/manifests/client/service.pp b/manifests/client/service.pp index 2eb67eb9..0a9a5b33 100644 --- a/manifests/client/service.pp +++ b/manifests/client/service.pp @@ -15,58 +15,53 @@ # class nfs::client::service { + if $nfs::client::nfs_v4 { + $create_services = $nfs::effective_nfsv4_client_services - if $::nfs::client::nfs_v4 { - - $create_services = $::nfs::effective_nfsv4_client_services - - if $::nfs::server_enabled { - $subscription = [ Concat[$::nfs::exports_file], Augeas[$::nfs::idmapd_file] ] + if $nfs::server_enabled { + $subscription = [Concat[$nfs::exports_file], Augeas[$nfs::idmapd_file]] } else { - if ($::nfs::client_rpcbind_config != undef) - and ($::nfs::client_rpcbind_optname != undef) - and ($::nfs::client_rpcbind_opts != undef) { + if ($nfs::client_rpcbind_config != undef) + and ($nfs::client_rpcbind_optname != undef) + and ($nfs::client_rpcbind_opts != undef) { $subscription = [ - Augeas[$::nfs::idmapd_file], - Augeas[$::nfs::defaults_file], - Augeas[$::nfs::client_rpcbind_config] + Augeas[$nfs::idmapd_file], + Augeas[$nfs::defaults_file], + Augeas[$nfs::client_rpcbind_config] ] } else { $subscription = [ - Augeas[$::nfs::idmapd_file], - Augeas[$::nfs::defaults_file] + Augeas[$nfs::idmapd_file], + Augeas[$nfs::defaults_file] ] } } - } else { + $create_services = $nfs::effective_client_services - $create_services = $::nfs::effective_client_services - - if $::nfs::server_enabled { - $subscription = [ Concat[$::nfs::exports_file] ] + if $nfs::server_enabled { + $subscription = [Concat[$nfs::exports_file]] } else { $subscription = undef } - } $service_defaults = { ensure => running, - enable => $::nfs::client_services_enable, - hasrestart => $::nfs::client_services_hasrestart, - hasstatus => $::nfs::client_services_hasstatus, + enable => $nfs::client_services_enable, + hasrestart => $nfs::client_services_hasrestart, + hasstatus => $nfs::client_services_hasstatus, subscribe => $subscription, } - if $create_services != undef and $::nfs::manage_client_service { + if $create_services != undef and $nfs::manage_client_service { create_resources('service', $create_services, $service_defaults ) } # Redhat ~7.5 workaround (See issue https://github.com/derdanne/puppet-nfs/issues/82) if $facts['os']['family'] == 'RedHat' and $facts['os']['release']['major'] == '7' and versioncmp($facts['os']['release']['full'], '7.5') < 0 { - transition {'stop-rpcbind.service-service': + transition { 'stop-rpcbind.service-service': resource => Service['rpcbind.service'], prior_to => Service['rpcbind.socket'], attributes => { diff --git a/manifests/functions/create_export.pp b/manifests/functions/create_export.pp index a36cb76d..f3f42ffe 100644 --- a/manifests/functions/create_export.pp +++ b/manifests/functions/create_export.pp @@ -45,7 +45,7 @@ $line = "${name} ${join(any2array($clients),' ')}\n" concat::fragment { $name: - target => $::nfs::exports_file, + target => $nfs::exports_file, content => $line, } diff --git a/manifests/functions/mkdir.pp b/manifests/functions/mkdir.pp index 0469c3c5..9fe16844 100644 --- a/manifests/functions/mkdir.pp +++ b/manifests/functions/mkdir.pp @@ -22,7 +22,7 @@ # define nfs::functions::mkdir ( - $ensure = 'present', + $ensure = 'present', ) { if $ensure != 'absent' { exec { "mkdir_recurse_${name}": diff --git a/manifests/init.pp b/manifests/init.pp index ed56423c..b5a62b3a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -209,56 +209,56 @@ # * Daniel Klockenkaemper # -class nfs( +class nfs ( Enum['present', 'absent', 'running', 'stopped', 'disabled'] $ensure = 'present', Boolean $server_enabled = false, Boolean $client_enabled = false, Boolean $storeconfigs_enabled = true, - Boolean $nfs_v4 = $::nfs::params::nfs_v4, - Boolean $nfs_v4_client = $::nfs::params::nfs_v4, - Stdlib::Absolutepath $exports_file = $::nfs::params::exports_file, - Stdlib::Absolutepath $idmapd_file = $::nfs::params::idmapd_file, - Optional[Stdlib::Absolutepath] $defaults_file = $::nfs::params::defaults_file, + Boolean $nfs_v4 = $nfs::params::nfs_v4, + Boolean $nfs_v4_client = $nfs::params::nfs_v4, + Stdlib::Absolutepath $exports_file = $nfs::params::exports_file, + Stdlib::Absolutepath $idmapd_file = $nfs::params::idmapd_file, + Optional[Stdlib::Absolutepath] $defaults_file = $nfs::params::defaults_file, Boolean $manage_packages = true, - Array $server_packages = $::nfs::params::server_packages, + Array $server_packages = $nfs::params::server_packages, String $server_package_ensure = 'installed', - Array $client_packages = $::nfs::params::client_packages, + Array $client_packages = $nfs::params::client_packages, String $client_package_ensure = 'installed', Boolean $manage_server_service = true, Boolean $manage_server_servicehelper = true, Boolean $manage_client_service = true, - String $server_service_name = $::nfs::params::server_service_name, + String $server_service_name = $nfs::params::server_service_name, Enum['present', 'absent', 'running', 'stopped', 'disabled'] $server_service_ensure = 'running', Boolean $server_service_enable = true, - Boolean $server_service_hasrestart = $::nfs::params::server_service_hasrestart, - Boolean $server_service_hasstatus = $::nfs::params::server_service_hasstatus, - Optional[String] $server_service_restart_cmd = $::nfs::params::server_service_restart_cmd, - Optional[Array] $server_nfsv4_servicehelper = $::nfs::params::server_nfsv4_servicehelper, - $client_services = $::nfs::params::client_services, - $client_nfsv4_services = $::nfs::params::client_nfsv4_services, - Boolean $client_services_enable = $::nfs::params::client_services_enable, - Boolean $client_services_hasrestart = $::nfs::params::client_services_hasrestart, - Boolean $client_services_hasstatus = $::nfs::params::client_services_hasstatus, - Array[String] $client_idmapd_setting = $::nfs::params::client_idmapd_setting, - String $client_nfs_fstype = $::nfs::params::client_nfs_fstype, - String $client_nfs_options = $::nfs::params::client_nfs_options, - String $client_nfsv4_fstype = $::nfs::params::client_nfsv4_fstype, - String $client_nfsv4_options = $::nfs::params::client_nfsv4_options, + Boolean $server_service_hasrestart = $nfs::params::server_service_hasrestart, + Boolean $server_service_hasstatus = $nfs::params::server_service_hasstatus, + Optional[String] $server_service_restart_cmd = $nfs::params::server_service_restart_cmd, + Optional[Array] $server_nfsv4_servicehelper = $nfs::params::server_nfsv4_servicehelper, + $client_services = $nfs::params::client_services, + $client_nfsv4_services = $nfs::params::client_nfsv4_services, + Boolean $client_services_enable = $nfs::params::client_services_enable, + Boolean $client_services_hasrestart = $nfs::params::client_services_hasrestart, + Boolean $client_services_hasstatus = $nfs::params::client_services_hasstatus, + Array[String] $client_idmapd_setting = $nfs::params::client_idmapd_setting, + String $client_nfs_fstype = $nfs::params::client_nfs_fstype, + String $client_nfs_options = $nfs::params::client_nfs_options, + String $client_nfsv4_fstype = $nfs::params::client_nfsv4_fstype, + String $client_nfsv4_options = $nfs::params::client_nfsv4_options, Boolean $client_need_gssd = false, Boolean $client_gssd_service = false, - $client_gssd_service_name = $::nfs::params::client_gssd_service_name, - String $client_gssd_options = $::nfs::params::client_gssd_options, - String $client_gssdopt_name = $::nfs::params::client_gssdopt_name, + $client_gssd_service_name = $nfs::params::client_gssd_service_name, + String $client_gssd_options = $nfs::params::client_gssd_options, + String $client_gssdopt_name = $nfs::params::client_gssdopt_name, Boolean $client_d9_gssdopt_workaround = false, - String $nfs_v4_export_root = $::nfs::params::nfs_v4_export_root, - String $nfs_v4_export_root_clients = $::nfs::params::nfs_v4_export_root_clients, - String $nfs_v4_mount_root = $::nfs::params::nfs_v4_mount_root, - String $nfs_v4_idmap_domain = $::nfs::params::nfs_v4_idmap_domain, + String $nfs_v4_export_root = $nfs::params::nfs_v4_export_root, + String $nfs_v4_export_root_clients = $nfs::params::nfs_v4_export_root_clients, + String $nfs_v4_mount_root = $nfs::params::nfs_v4_mount_root, + String $nfs_v4_idmap_domain = $nfs::params::nfs_v4_idmap_domain, Variant[String, Array] $nfs_v4_idmap_localrealms = '', Integer $nfs_v4_idmap_cache = 0, Boolean $manage_nfs_v4_idmap_nobody_mapping = false, - String $nfs_v4_idmap_nobody_user = $::nfs::params::nfs_v4_idmap_nobody_user, - String $nfs_v4_idmap_nobody_group = $::nfs::params::nfs_v4_idmap_nobody_group, + String $nfs_v4_idmap_nobody_user = $nfs::params::nfs_v4_idmap_nobody_user, + String $nfs_v4_idmap_nobody_group = $nfs::params::nfs_v4_idmap_nobody_group, String $nfs_v4_root_export_ensure = 'mounted', Optional[String] $nfs_v4_root_export_mount = undef, Boolean $nfs_v4_root_export_remounts = false, @@ -267,13 +267,11 @@ Optional[String] $nfs_v4_root_export_bindmount = undef, Optional[String] $nfs_v4_root_export_tag = undef, Boolean $nfsv4_bindmount_enable = true, - Optional[Stdlib::Absolutepath] $client_rpcbind_config = $::nfs::params::client_rpcbind_config, - Optional[String] $client_rpcbind_optname = $::nfs::params::client_rpcbind_optname, + Optional[Stdlib::Absolutepath] $client_rpcbind_config = $nfs::params::client_rpcbind_config, + Optional[String] $client_rpcbind_optname = $nfs::params::client_rpcbind_optname, Optional[String] $client_rpcbind_opts = undef, ) inherits nfs::params { - if $server_enabled { - if $server_nfsv4_servicehelper != undef { $effective_nfsv4_client_services = delete($client_nfsv4_services, $server_nfsv4_servicehelper) } else { @@ -282,7 +280,6 @@ $effective_client_services = $client_services $effective_client_packages = difference($client_packages, $server_packages) - } else { if $client_gssd_service and $client_gssd_service_name != undef { $effective_nfsv4_client_services = $client_nfsv4_services + $client_gssd_service_name @@ -292,7 +289,6 @@ $effective_client_services = $client_services $effective_client_packages = $client_packages - } if $server_enabled { diff --git a/manifests/params.pp b/manifests/params.pp index d6eba161..646559f8 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -48,39 +48,39 @@ $exports_file = '/etc/exports' $idmapd_file = '/etc/idmapd.conf' $defaults_file = '/etc/default/nfs-common' - $server_packages = [ 'nfs-common', 'nfs-kernel-server', 'nfs4-acl-tools', 'rpcbind' ] - $client_packages = [ 'nfs-common', 'nfs4-acl-tools', 'rpcbind' ] + $server_packages = ['nfs-common', 'nfs-kernel-server', 'nfs4-acl-tools', 'rpcbind'] + $client_packages = ['nfs-common', 'nfs4-acl-tools', 'rpcbind'] $client_rpcbind_config = '/etc/default/rpcbind' } 'RedHat': { $exports_file = '/etc/exports' $idmapd_file = '/etc/idmapd.conf' $defaults_file = '/etc/sysconfig/nfs' - $server_packages = [ 'nfs-utils', 'nfs4-acl-tools', 'rpcbind' ] - $client_packages = [ 'nfs-utils', 'nfs4-acl-tools', 'rpcbind' ] + $server_packages = ['nfs-utils', 'nfs4-acl-tools', 'rpcbind'] + $client_packages = ['nfs-utils', 'nfs4-acl-tools', 'rpcbind'] $client_rpcbind_config = '/etc/sysconfig/rpcbind' } 'Gentoo': { $exports_file = '/etc/exports' $idmapd_file = '/etc/idmapd.conf' $defaults_file = '/etc/conf.d/nfs' - $server_packages = [ 'net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap' ] - $client_packages = [ 'net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap' ] + $server_packages = ['net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap'] + $client_packages = ['net-nds/rpcbind', 'net-fs/nfs-utils', 'net-libs/libnfsidmap'] $client_rpcbind_config = undef } 'Suse': { $exports_file = '/etc/exports' $idmapd_file = '/etc/idmapd.conf' - $server_packages = [ 'nfs-kernel-server' ] - $client_packages = [ 'nfsidmap', 'nfs-client', 'rpcbind' ] + $server_packages = ['nfs-kernel-server'] + $client_packages = ['nfsidmap', 'nfs-client', 'rpcbind'] $defaults_file = undef $client_rpcbind_config = undef } 'Archlinux': { $exports_file = '/etc/exports' $idmapd_file = '/etc/idmapd.conf' - $server_packages = [ 'nfs-utils' ] - $client_packages = [ 'nfs-utils', 'nfsidmap', 'rpcbind' ] + $server_packages = ['nfs-utils'] + $client_packages = ['nfs-utils', 'nfsidmap', 'rpcbind'] $defaults_file = undef $client_rpcbind_config = undef } @@ -95,7 +95,6 @@ } } - # service parameters # params that are the same on all (known) OSes. $client_nfs_fstype = 'nfs' @@ -119,62 +118,62 @@ case $facts['os']['distro']['codename'] { 'trusty': { - $client_services = {'rpcbind' => {}} - $client_nfsv4_services = {'rpcbind' => {}, 'nfs-common' => { require => Service['rpcbind'] }} + $client_services = { 'rpcbind' => {} } + $client_nfsv4_services = { 'rpcbind' => {}, 'nfs-common' => { require => Service['rpcbind'] } } $client_gssd_service_name = undef $server_nfsv4_servicehelper = undef $server_service_name = 'nfs-kernel-server' $client_gssdopt_name = 'RPCGSSDOPTS' } 'jessie', 'wheezy': { - $client_services = {'rpcbind' => {}} - $client_nfsv4_services = {'rpcbind' => {}, 'nfs-common' => { require => Service['rpcbind'] }} + $client_services = { 'rpcbind' => {} } + $client_nfsv4_services = { 'rpcbind' => {}, 'nfs-common' => { require => Service['rpcbind'] } } $client_gssd_service_name = undef - $server_nfsv4_servicehelper = [ 'nfs-common' ] + $server_nfsv4_servicehelper = ['nfs-common'] $server_service_name = 'nfs-kernel-server' $client_gssdopt_name = 'RPCGSSDOPTS' } 'bullseye', 'buster', 'stretch', 'xenial', 'yakkety', 'zesty': { $client_services = { 'rpcbind' => { - ensure => 'running', - enable => false, - }, - } + ensure => 'running', + enable => false, + }, + } $client_gssd_service_name = { 'rpc-gssd' => { - ensure => 'running', - enable => true, - }, - } + ensure => 'running', + enable => true, + }, + } $client_nfsv4_services = { 'rpcbind' => { - ensure => 'running', - enable => false, - }, - } - $server_nfsv4_servicehelper = [ 'nfs-idmapd' ] + ensure => 'running', + enable => false, + }, + } + $server_nfsv4_servicehelper = ['nfs-idmapd'] $server_service_name = 'nfs-kernel-server' $client_gssdopt_name = 'GSSDARGS' } 'bionic', 'focal', 'jammy', 'kinetic': { - $client_services = {'rpcbind' => {}} + $client_services = { 'rpcbind' => {} } $client_gssd_service_name = { 'rpc-gssd' => { - ensure => 'running', - enable => true, - }, - } - $client_nfsv4_services = {'rpcbind' => {}} + ensure => 'running', + enable => true, + }, + } + $client_nfsv4_services = { 'rpcbind' => {} } $server_nfsv4_servicehelper = undef $server_service_name = 'nfs-kernel-server' $client_gssdopt_name = 'GSSDARGS' } default: { - $client_services = {'rpcbind' => {}} + $client_services = { 'rpcbind' => {} } $client_gssd_service_name = { 'rpc-gssd' => { - ensure => 'running', - enable => true, - }, - } - $client_nfsv4_services = {'rpcbind' => {}} - $server_nfsv4_servicehelper = [ 'idmapd' ] + ensure => 'running', + enable => true, + }, + } + $client_nfsv4_services = { 'rpcbind' => {} } + $server_nfsv4_servicehelper = ['idmapd'] $server_service_name = 'nfs-kernel-server' $client_gssdopt_name = 'GSSDARGS' } @@ -192,40 +191,40 @@ $client_gssdopt_name = 'RPCGSSDARGS' if versioncmp($facts['os']['release']['full'], '7.5') < 0 { $client_services = { 'rpcbind.service' => { - ensure => 'running', - enable => false, - }, - 'rpcbind.socket' => { - ensure => 'running', - enable => true, - }, - } + ensure => 'running', + enable => false, + }, + 'rpcbind.socket' => { + ensure => 'running', + enable => true, + }, + } } else { - $client_services = {'rpcbind.service' => {}} + $client_services = { 'rpcbind.service' => {} } } $client_gssd_service_name = { 'rpc-gssd' => { - ensure => 'running', - enable => true, - }, - } + ensure => 'running', + enable => true, + }, + } $client_nfsv4_fstype = 'nfs4' $client_nfsv4_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3' if versioncmp($facts['os']['release']['full'], '7.5') < 0 { $client_nfsv4_services = { 'rpcbind.service' => { - ensure => 'running', - enable => false, - }, - 'rpcbind.socket' => { - ensure => 'running', - enable => true, - }, - } + ensure => 'running', + enable => false, + }, + 'rpcbind.socket' => { + ensure => 'running', + enable => true, + }, + } } else { - $client_nfsv4_services = {'rpcbind' => {}} + $client_nfsv4_services = { 'rpcbind' => {} } } - $server_nfsv4_servicehelper = [ 'nfs-idmap.service' ] + $server_nfsv4_servicehelper = ['nfs-idmap.service'] $server_service_name = 'nfs-server.service' } '8': { @@ -233,16 +232,16 @@ $client_nfs_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3' $client_services_enable = true $client_gssdopt_name = 'RPCGSSDARGS' - $client_services = {'rpcbind.service' => {}} + $client_services = { 'rpcbind.service' => {} } $client_gssd_service_name = { 'rpc-gssd' => { - ensure => 'running', - enable => true, - }, - } + ensure => 'running', + enable => true, + }, + } $client_nfsv4_fstype = 'nfs4' $client_nfsv4_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3' - $client_nfsv4_services = {'rpcbind' => {}} - $server_nfsv4_servicehelper = [ 'nfs-idmapd.service' ] + $client_nfsv4_services = { 'rpcbind' => {} } + $server_nfsv4_servicehelper = ['nfs-idmapd.service'] $server_service_name = 'nfs-server.service' } '9': { @@ -250,16 +249,16 @@ $client_nfs_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3' $client_services_enable = true $client_gssdopt_name = 'RPCGSSDARGS' - $client_services = {'rpcbind.service' => {}} + $client_services = { 'rpcbind.service' => {} } $client_gssd_service_name = { 'rpc-gssd' => { - ensure => 'running', - enable => true, - }, - } + ensure => 'running', + enable => true, + }, + } $client_nfsv4_fstype = 'nfs4' $client_nfsv4_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3' - $client_nfsv4_services = {'rpcbind' => {}} - $server_nfsv4_servicehelper = [ 'nfs-idmapd.service' ] + $client_nfsv4_services = { 'rpcbind' => {} } + $server_nfsv4_servicehelper = ['nfs-idmapd.service'] $server_service_name = 'nfs-server.service' } default: { @@ -267,16 +266,16 @@ $client_idmapd_setting = [''] $client_nfs_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3' $client_services_enable = true - $client_services = {'rpcbind' => {}} + $client_services = { 'rpcbind' => {} } $client_gssd_service_name = { 'rpc-gssd' => { - ensure => 'running', - enable => true, - }, - } + ensure => 'running', + enable => true, + }, + } $client_nfsv4_fstype = 'nfs4' $client_nfsv4_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,actimeo=3' - $client_nfsv4_services = {'rpcbind' => {}, 'rpcidmapd' => {}} - $server_nfsv4_servicehelper = [ 'rpcidmapd', 'rpcbind' ] + $client_nfsv4_services = { 'rpcbind' => {}, 'rpcidmapd' => {} } + $server_nfsv4_servicehelper = ['rpcidmapd', 'rpcbind'] $server_service_name = 'nfs' } } @@ -289,12 +288,12 @@ $client_idmapd_setting = ['set NFS_NEEDED_SERVICES rpc.idmapd'] $client_nfs_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=3,actimeo=3' $client_services_enable = true - $client_services = {'rpcbind' => {} } + $client_services = { 'rpcbind' => {} } $client_gssd_service_name = undef $client_nfsv4_fstype = 'nfs4' $client_nfsv4_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=4,actimeo=3' - $client_nfsv4_services = {'rpcbind' => {}, 'rpc.idmapd' => {}} - $server_nfsv4_servicehelper = [ 'rpc.idmapd' ] + $client_nfsv4_services = { 'rpcbind' => {}, 'rpc.idmapd' => {} } + $server_nfsv4_servicehelper = ['rpc.idmapd'] $server_service_name = 'nfs' } 'Suse': { @@ -305,11 +304,11 @@ $client_idmapd_setting = [''] $client_nfs_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=3,actimeo=3' $client_services_enable = true - $client_services = {'rpcbind' => { before => Service['nfs'] }, 'nfs' => {}} + $client_services = { 'rpcbind' => { before => Service['nfs'] }, 'nfs' => {} } $client_gssd_service_name = undef $client_nfsv4_fstype = 'nfs4' $client_nfsv4_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=4,actimeo=3' - $client_nfsv4_services = {'rpcbind' => { before => Service['nfs'] }, 'nfs' => {}} + $client_nfsv4_services = { 'rpcbind' => { before => Service['nfs'] }, 'nfs' => {} } $server_nfsv4_servicehelper = undef $server_service_name = 'nfsserver' } @@ -321,12 +320,12 @@ $client_idmapd_setting = [''] $client_nfs_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=3,actimeo=3' $client_services_enable = true - $client_services = {'rpcbind' => {}} + $client_services = { 'rpcbind' => {} } $client_gssd_service_name = undef $client_nfsv4_fstype = 'nfs4' $client_nfsv4_options = 'tcp,nolock,rsize=32768,wsize=32768,intr,noatime,nfsvers=4,actimeo=3' - $client_nfsv4_services = {'rpcbind' => {}} - $server_nfsv4_servicehelper = [ 'nfs-idmapd' ] + $client_nfsv4_services = { 'rpcbind' => {} } + $server_nfsv4_servicehelper = ['nfs-idmapd'] $server_service_name = 'nfs-server.service' } default: { diff --git a/manifests/server.pp b/manifests/server.pp index cb8601f2..68c0b5bf 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -15,22 +15,21 @@ # class nfs::server ( - $ensure = $::nfs::ensure, - $nfs_v4 = $::nfs::nfs_v4, - $nfs_v4_export_root = $::nfs::nfs_v4_export_root, - $nfs_v4_export_root_clients = $::nfs::nfs_v4_export_root_clients, - $nfs_v4_idmap_domain = $::nfs::nfs_v4_idmap_domain, - $nfs_v4_root_export_ensure = $::nfs::nfs_v4_root_export_ensure, - $nfs_v4_root_export_mount = $::nfs::nfs_v4_root_export_mount, - $nfs_v4_root_export_remounts = $::nfs::nfs_v4_root_export_remounts, - $nfs_v4_root_export_atboot = $::nfs::nfs_v4_root_export_atboot , - $nfs_v4_root_export_options = $::nfs::nfs_v4_root_export_options, - $nfs_v4_root_export_bindmount = $::nfs::nfs_v4_root_export_bindmount, - $nfs_v4_root_export_tag = $::nfs::nfs_v4_root_export_tag, -){ - - anchor {'nfs::server::begin': } - anchor {'nfs::server::end': } + $ensure = $nfs::ensure, + $nfs_v4 = $nfs::nfs_v4, + $nfs_v4_export_root = $nfs::nfs_v4_export_root, + $nfs_v4_export_root_clients = $nfs::nfs_v4_export_root_clients, + $nfs_v4_idmap_domain = $nfs::nfs_v4_idmap_domain, + $nfs_v4_root_export_ensure = $nfs::nfs_v4_root_export_ensure, + $nfs_v4_root_export_mount = $nfs::nfs_v4_root_export_mount, + $nfs_v4_root_export_remounts = $nfs::nfs_v4_root_export_remounts, + $nfs_v4_root_export_atboot = $nfs::nfs_v4_root_export_atboot , + $nfs_v4_root_export_options = $nfs::nfs_v4_root_export_options, + $nfs_v4_root_export_bindmount = $nfs::nfs_v4_root_export_bindmount, + $nfs_v4_root_export_tag = $nfs::nfs_v4_root_export_tag, +) { + anchor { 'nfs::server::begin': } + anchor { 'nfs::server::end': } # package(s) class { 'nfs::server::package': } diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 91d3fbb7..cc2c2dea 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -15,77 +15,75 @@ # class nfs::server::config { - - concat { $::nfs::exports_file: + concat { $nfs::exports_file: ensure => present, } concat::fragment { 'nfs_exports_header': - target => $::nfs::exports_file, + target => $nfs::exports_file, content => "# This file is configured through the nfs::server puppet module\n", order => 1; } - if $::nfs::nfs_v4 { - - if $::nfs::nfsv4_bindmount_enable { + if $nfs::nfs_v4 { + if $nfs::nfsv4_bindmount_enable { concat::fragment { 'nfs_exports_root': - target => $::nfs::exports_file, - content => "${::nfs::server::nfs_v4_export_root} ${::nfs::server::nfs_v4_export_root_clients}\n", + target => $nfs::exports_file, + content => "${nfs::server::nfs_v4_export_root} ${nfs::server::nfs_v4_export_root_clients}\n", order => 2, } } - if ! defined(File[$::nfs::server::nfs_v4_export_root]) { - file { $::nfs::server::nfs_v4_export_root: + if ! defined(File[$nfs::server::nfs_v4_export_root]) { + file { $nfs::server::nfs_v4_export_root: ensure => directory, } } - if $::nfs::nfs_v4_idmap_localrealms != '' { - if $::nfs::nfs_v4_idmap_localrealms =~ String { - $_localrealms = $::nfs::nfs_v4_idmap_localrealms + if $nfs::nfs_v4_idmap_localrealms != '' { + if $nfs::nfs_v4_idmap_localrealms =~ String { + $_localrealms = $nfs::nfs_v4_idmap_localrealms } else { - $_localrealms = join($::nfs::nfs_v4_idmap_localrealms, ',') + $_localrealms = join($nfs::nfs_v4_idmap_localrealms, ',') } $_aug_localrealm = "set General/Local-Realms ${_localrealms}" } else { $_aug_localrealm = undef } - if $::nfs::nfs_v4_idmap_cache != 0 { - $_cache = "set General/Cache-Expiration ${::nfs::nfs_v4_idmap_cache}" + if $nfs::nfs_v4_idmap_cache != 0 { + $_cache = "set General/Cache-Expiration ${nfs::nfs_v4_idmap_cache}" } else { $_cache = undef } - if $::nfs::manage_nfs_v4_idmap_nobody_mapping { - $_user = "set Mapping/Nobody-User ${::nfs::nfs_v4_idmap_nobody_user}" - $_group = "set Mapping/Nobody-Group ${::nfs::nfs_v4_idmap_nobody_group}" + if $nfs::manage_nfs_v4_idmap_nobody_mapping { + $_user = "set Mapping/Nobody-User ${nfs::nfs_v4_idmap_nobody_user}" + $_group = "set Mapping/Nobody-Group ${nfs::nfs_v4_idmap_nobody_group}" } else { $_user = undef $_group = undef } - $changes = ["set General/Domain ${::nfs::server::nfs_v4_idmap_domain}", $_aug_localrealm, $_cache, $_user, $_group] + $changes = ["set General/Domain ${nfs::server::nfs_v4_idmap_domain}", $_aug_localrealm, $_cache, $_user, $_group] $filtered_changes = filter($changes) |$val| { $val =~ NotUndef } - augeas { $::nfs::idmapd_file: - context => "/files/${::nfs::idmapd_file}", + augeas { $nfs::idmapd_file: + context => "/files/${nfs::idmapd_file}", lens => 'Puppet.lns', - incl => $::nfs::idmapd_file, + incl => $nfs::idmapd_file, changes => $filtered_changes, } if $nfs::storeconfigs_enabled { - @@nfs::client::mount { $::nfs::nfs_v4_mount_root: - ensure => $::nfs::server::nfs_v4_root_export_ensure, - server => $::clientcert, - remounts => $::nfs::server::nfs_v4_root_export_remounts, - atboot => $::nfs::server::nfs_v4_root_export_atboot, - options_nfsv4 => $::nfs::server::nfs_v4_root_export_options, - bindmount => $::nfs::server::nfs_v4_root_export_bindmount, - nfstag => $::nfs::server::nfs_v4_root_export_tag, + @@nfs::client::mount { $nfs::nfs_v4_mount_root: + ensure => $nfs::server::nfs_v4_root_export_ensure, + server => $facts['clientcert'], + remounts => $nfs::server::nfs_v4_root_export_remounts, + atboot => $nfs::server::nfs_v4_root_export_atboot, + options_nfsv4 => $nfs::server::nfs_v4_root_export_options, + bindmount => $nfs::server::nfs_v4_root_export_bindmount, + nfstag => $nfs::server::nfs_v4_root_export_tag, } } } diff --git a/manifests/server/export.pp b/manifests/server/export.pp index 84d653d2..82830807 100644 --- a/manifests/server/export.pp +++ b/manifests/server/export.pp @@ -76,7 +76,7 @@ # * Daniel Klockenkaemper # -define nfs::server::export( +define nfs::server::export ( $v3_export_name = $name, $v4_export_name = regsubst($name, '.*/(.*)', '\1' ), $clients = 'localhost(ro)', @@ -87,30 +87,27 @@ $mount = undef, $remounts = false, $atboot = false, - $options_nfsv4 = $::nfs::client_nfsv4_options, - $options_nfs = $::nfs::client_nfs_options, + $options_nfsv4 = $nfs::client_nfsv4_options, + $options_nfs = $nfs::client_nfs_options, $bindmount = undef, $nfstag = undef, $owner = undef, $group = undef, $mode = undef, - $server = $::clientcert, - $nfsv4_bindmount_enable = $::nfs::nfsv4_bindmount_enable, + $server = $facts['clientcert'], + $nfsv4_bindmount_enable = $nfs::nfsv4_bindmount_enable, ) { - if $nfs::server::nfs_v4 { - if $nfsv4_bindmount_enable { $export_name = $v4_export_name - $export_title = "${::nfs::server::nfs_v4_export_root}/${export_name}" - $create_export_require = [ Nfs::Functions::Nfsv4_bindmount[$name] ] + $export_title = "${nfs::server::nfs_v4_export_root}/${export_name}" + $create_export_require = [Nfs::Functions::Nfsv4_bindmount[$name]] nfs::functions::nfsv4_bindmount { $name: ensure => $ensure, v4_export_name => $export_name, bind => $bind, } - } else { $export_name = $name $export_title = $name @@ -145,7 +142,6 @@ } } } else { - if $mount != undef { $mount_name = $mount } else { @@ -171,6 +167,5 @@ server => $server, } } - } } diff --git a/manifests/server/package.pp b/manifests/server/package.pp index 392c9384..19e1290d 100644 --- a/manifests/server/package.pp +++ b/manifests/server/package.pp @@ -15,19 +15,16 @@ # class nfs::server::package { - - if $::nfs::manage_packages { - - if $::nfs::manage_server_service { - $notify_services = Service[$::nfs::server_service_name] + if $nfs::manage_packages { + if $nfs::manage_server_service { + $notify_services = Service[$nfs::server_service_name] } else { $notify_services = undef } - package { $::nfs::server_packages: - ensure => $::nfs::server_package_ensure, + package { $nfs::server_packages: + ensure => $nfs::server_package_ensure, notify => $notify_services, } - } } diff --git a/manifests/server/service.pp b/manifests/server/service.pp index f8eb4898..3bc44009 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -15,47 +15,43 @@ # class nfs::server::service { - - if $::nfs::nfs_v4 == true { - - if $::nfs::server_nfsv4_servicehelper != undef and $::nfs::manage_server_servicehelper { - $server_service_require = Service[$::nfs::server_nfsv4_servicehelper] - $::nfs::server_nfsv4_servicehelper.each |$service_name| { + if $nfs::nfs_v4 == true { + if $nfs::server_nfsv4_servicehelper != undef and $nfs::manage_server_servicehelper { + $server_service_require = Service[$nfs::server_nfsv4_servicehelper] + $nfs::server_nfsv4_servicehelper.each |$service_name| { service { $service_name: - ensure => $::nfs::server_service_ensure, - enable => $::nfs::server_service_enable, - hasrestart => $::nfs::server_service_hasrestart, - hasstatus => $::nfs::server_service_hasstatus, - subscribe => [ Concat[$::nfs::exports_file], Augeas[$::nfs::idmapd_file] ], + ensure => $nfs::server_service_ensure, + enable => $nfs::server_service_enable, + hasrestart => $nfs::server_service_hasrestart, + hasstatus => $nfs::server_service_hasstatus, + subscribe => [Concat[$nfs::exports_file], Augeas[$nfs::idmapd_file]], } } } else { $server_service_require = undef } - if $::nfs::manage_server_service { - service { $::nfs::server_service_name: - ensure => $::nfs::server_service_ensure, - enable => $::nfs::server_service_enable, - hasrestart => $::nfs::server_service_hasrestart, - hasstatus => $::nfs::server_service_hasstatus, - restart => $::nfs::server_service_restart_cmd, - subscribe => [ Concat[$::nfs::exports_file], Augeas[$::nfs::idmapd_file] ], + if $nfs::manage_server_service { + service { $nfs::server_service_name: + ensure => $nfs::server_service_ensure, + enable => $nfs::server_service_enable, + hasrestart => $nfs::server_service_hasrestart, + hasstatus => $nfs::server_service_hasstatus, + restart => $nfs::server_service_restart_cmd, + subscribe => [Concat[$nfs::exports_file], Augeas[$nfs::idmapd_file]], require => $server_service_require, } } } else { - - if $::nfs::manage_server_service { - service { $::nfs::server_service_name: - ensure => $::nfs::server_service_ensure, - enable => $::nfs::server_service_enable, - hasrestart => $::nfs::server_service_hasrestart, - hasstatus => $::nfs::server_service_hasstatus, - restart => $::nfs::server_service_restart_cmd, - subscribe => Concat[$::nfs::exports_file], + if $nfs::manage_server_service { + service { $nfs::server_service_name: + ensure => $nfs::server_service_ensure, + enable => $nfs::server_service_enable, + hasrestart => $nfs::server_service_hasrestart, + hasstatus => $nfs::server_service_hasstatus, + restart => $nfs::server_service_restart_cmd, + subscribe => Concat[$nfs::exports_file], } } - } }