Skip to content

Commit

Permalink
Add 'samba::additional_config' option
Browse files Browse the repository at this point in the history
This allows the user of the module to specify arbitrary server
configuration options. For example, in hiera:

    samba::additional_config:
      server_multi_channel_support: yes
      aio_read_size: 1
      aio_write_size: 1
      min_receivefile_size: 16384

This would write the following to /etc/samba/smb.conf:

    server multi channel support = yes
    aio read size = 1
    aio write size = 1
    min receivefile size = 16384
  • Loading branch information
parkr committed Jun 21, 2024
1 parent 5abd508 commit 3169add
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ This module is designed to be as clean and compliant with latest puppet code gui
local_master => 'yes',
preferred_master => 'yes',
map_to_guest => 'Bad User',
additional_config => {
server_multi_channel_support => 'yes'
},
shares => {
'homes' => {
comment => 'Home Directories',
Expand Down Expand Up @@ -102,6 +105,8 @@ samba::local_master: 'yes'
samba::preferred_master: 'yes'
samba::map_to_guest: 'Bad User'
samba::firewall_manage: true
additional_config:
server_multi_channel_support: 'yes'
samba::shares:
'homes':
comment: 'Home Directories'
Expand Down
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The following parameters are available in the `samba` class:
* [`dedicated_keytab_file`](#-samba--dedicated_keytab_file)
* [`obey_pam_restrictions`](#-samba--obey_pam_restrictions)
* [`shares`](#-samba--shares)
* [`additional_config`](#-samba--additional_config)
* [`idmap_config`](#-samba--idmap_config)

##### <a name="-samba--packages"></a>`packages`
Expand Down Expand Up @@ -437,6 +438,14 @@ A hash of share names, their path(s) and other parameters.

Default value: `{}`

##### <a name="-samba--additional_config"></a>`additional_config`

Data type: `Variant[Undef, Hash]`

Additional configuration options to be added to the server smb.conf file.

Default value: `{}`

##### <a name="-samba--idmap_config"></a>`idmap_config`

Data type: `Variant[Undef, Hash]`
Expand Down
7 changes: 7 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
'obey pam restrictions': value => $samba::obey_pam_restrictions;
}

$samba::additional_config.each | $option, $value | {
$option_with_spaces = regsubst($option, /_/, ' ', 'G')
samba::option { $option_with_spaces:
value => $value,
}
}

$samba::idmap_config.each | $idmap_domain, $idmap_options | {
$idmap_options.each | $idmap_option, $idmap_value | {
samba::option { "idmap config ${idmap_domain} : ${idmap_option}":
Expand Down
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# This integer value controls what level Samba advertises itself as for browse elections.
#
# @param wins_support
# This boolean controls if the nmbd(8) process in Samba will act as a WINS server.
# This boolean controls if the nmbd(8) process in Samba will act as a WINS server.
#
# @param wins_server
# This specifies the IP address (or DNS name: IP address for preference) of the WINS server that nmbd(8) should register with.
Expand Down Expand Up @@ -142,6 +142,9 @@
# @param shares
# A hash of share names, their path(s) and other parameters.
#
# @param additional_config
# Additional configuration options to be added to the server smb.conf file.
#
# @param idmap_config
# The mapping between Windows SIDs and Unix user and group IDs.
#
Expand Down Expand Up @@ -203,6 +206,7 @@
Variant[Undef, String] $kerberos_method = 'default',
Variant[Undef, String] $dedicated_keytab_file = undef,
Variant[Undef, Boolean] $obey_pam_restrictions = false,
Variant[Undef, Hash] $additional_config = {},
Variant[Undef, Hash] $idmap_config = {},
Hash $shares = {},
) {
Expand Down
10 changes: 9 additions & 1 deletion spec/classes/samba_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
let(:params) do
{
netbios_name: 'foo',
additional_config: { server_multi_channel_support: 'yes',
aio_read_size: 1,
aio_write_size: 1,
min_receivefile_size: 16_384 },
idmap_config: { '*' => { backend: 'tbd', range: '400-999' },
'AD' => { unix_primary_group: 'Yes', unix_nss_info: 'Yes', schema_mode: 'rfc2307', range: '1000-2147483647', backend: 'ad' } }
}
Expand Down Expand Up @@ -95,6 +99,10 @@
is_expected.to contain_samba__option('kerberos method').with_value('default')
is_expected.to contain_samba__option('dedicated keytab file').with_value(nil)
is_expected.to contain_samba__option('obey pam restrictions').with_value(false)
is_expected.to contain_samba__option('server multi channel support').with_value('yes')
is_expected.to contain_samba__option('aio read size').with_value(1)
is_expected.to contain_samba__option('aio write size').with_value(1)
is_expected.to contain_samba__option('min receivefile size').with_value(16_384)
is_expected.to contain_samba__option('idmap config * : backend').with_value('tbd')
is_expected.to contain_samba__option('idmap config * : range').with_value('400-999')
is_expected.to contain_samba__option('idmap config AD : unix_primary_group').with_value('Yes')
Expand All @@ -105,7 +113,7 @@
}

it {
is_expected.to have_samba__option_resource_count(39)
is_expected.to have_samba__option_resource_count(43)
}
end

Expand Down

0 comments on commit 3169add

Please sign in to comment.