Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit override of package names #59

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1648ce3
Allow override of samba package names, and set them to samba4 version…
legooolas Jul 11, 2018
6192371
Put back to default samba packages, as these can be overridden via th…
legooolas Jul 11, 2018
6fd4c18
Fix scoping on default values to grab from params class.
legooolas Jul 11, 2018
63633b1
Try removing dependency on samba service as workaround for samba bug.
legooolas Aug 24, 2018
d81abed
Add back dependency on samba package, but not service.
legooolas Aug 24, 2018
44e46a3
Add dependency for all options to be set before running domain join.
legooolas Oct 2, 2018
5484a36
Add --no-dns-updates option for join, and hide join pass from process…
legooolas Oct 2, 2018
250951c
Add missing trailing comma.
legooolas Oct 2, 2018
5d3332f
Add optional machinepass setting when performing domain-join.
legooolas Dec 13, 2018
e4ea873
Allow unset machinepass to skip environment variable addition.
legooolas Dec 13, 2018
76a26c1
Add debug output for domain join with password.
legooolas Dec 13, 2018
ea37ce3
Try using empty array for adding to environment settings.
legooolas Dec 13, 2018
b887bde
Remove debug output, add force_join option, and try using machinepass…
legooolas Aug 23, 2019
26b5941
Remove force_join option again now as we're not using this, and want …
legooolas Aug 23, 2019
667cc44
Re-add force-join option but don't change machine password env setup …
legooolas Aug 23, 2019
c4b2dac
Require winbindd to be running before smbd starts.
legooolas Sep 25, 2019
61947b2
Merge branch 'master' of github.com:kakwa/puppet-samba into master
legooolas Dec 9, 2020
5918f38
Resolve "Update for Puppet 8 and stdlib new version compatibility"
legooolas Jan 16, 2025
85e2a2a
Merge branch '1-update-for-puppet-8-and-stdlib-new-version-compatibil…
legooolas Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/facter/samba_version.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

case distid
when /RedHatEnterprise|CentOS|Fedora|RHEL/
if FileTest.exists?("/usr/bin/yum")
if FileTest.exist?("/usr/bin/yum")
version = Facter::Util::Resolution.exec('/usr/bin/yum info samba | sed \'s/Version *: \([0-9\.]\+\)/\1/gp;d\' | head -n 1')
end
when /Ubuntu|Debian/
if FileTest.exists?("/usr/bin/apt-cache")
if FileTest.exist?("/usr/bin/apt-cache")
version = Facter::Util::Resolution.exec('apt-cache show samba | sed \'s/Version:.*:\([0-9\.]\+\).*/\1/gp;d\' | head -n 1')
end
when 'Archlinux'
Expand Down
67 changes: 50 additions & 17 deletions manifests/classic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
$security = 'ads',
$sambaloglevel = 1,
$join_domain = true,
Boolean $force_join = false,
$join_dns_update = true,
$manage_winbind = true,
$krbconf = true,
$nsswitch = true,
Expand All @@ -55,21 +57,24 @@
$globaloptions = {},
$globalabsentoptions = [],
$joinou = undef,
Optional[String] $machinepass = undef,
Optional[String] $default_realm = undef,
Array $additional_realms = [],
$packagesambadc = $::samba::params::packagesambadc,
$packagesambaclassic = $::samba::params::packagesambaclassic,
$packagesambawinbind = $::samba::params::packagesambawinbind,
$packagesambansswinbind = $::samba::params::packagesambansswinbind,
$packagesambapamwinbind = $::samba::params::packagesambapamwinbind,
$packagesambaclient = $::samba::params::packagesambaclient,
) inherits samba::params{


unless is_domain_name($realm){
unless $realm =~ Stdlib::Host {
fail('realm must be a valid domain')
}

unless is_domain_name($realm){
fail('realm must be a valid domain')
}

validate_slength($smbname, 15)
unless is_domain_name("${smbname}.${realm}"){
assert_type(String[1, 15], $smbname)
unless "${smbname}.${realm}" =~ Stdlib::Host {
fail('smbname must be a valid domain')
}

Expand Down Expand Up @@ -118,7 +123,7 @@
if $nsswitch {
package{ 'SambaNssWinbind':
ensure => 'installed',
name => $samba::params::packagesambansswinbind
name => $packagesambansswinbind
}

augeas{'samba nsswitch group':
Expand Down Expand Up @@ -146,11 +151,11 @@
if $pam {
# Only add package here if different to the nss-winbind package,
# or nss and pam aren't both enabled, to avoid duplicate definition.
if ($samba::params::packagesambapamwinbind != $samba::params::packagesambansswinbind)
if ($packagesambapamwinbind != $packagesambansswinbind)
or !$nsswitch {
package{ 'SambaPamWinbind':
ensure => 'installed',
name => $::samba::params::packagesambapamwinbind
name => $packagesambapamwinbind
}
}

Expand Down Expand Up @@ -203,13 +208,13 @@

package{ 'SambaClassic':
ensure => 'installed',
name => $samba::params::packagesambaclassic,
name => $packagesambaclassic,
}

if $manage_winbind {
package{ 'SambaClassicWinBind':
ensure => 'installed',
name => $samba::params::packagesambawinbind,
name => $packagesambawinbind,
require => File['/etc/samba/smb_path'],
}
Package['SambaClassicWinBind'] -> Package['SambaClassic']
Expand All @@ -227,6 +232,7 @@
ensure => 'running',
name => $samba::params::servivewinbind,
require => [ Package['SambaClassic'], File['SambaOptsFile'] ],
before => [ Service['SambaSmb'] ], # required for smbd to run now
enable => true,
}
}
Expand Down Expand Up @@ -331,13 +337,40 @@
default => "createcomputer=\"${joinou}\"",
undef => '',
}
$no_dns_updates = $join_dns_update ? {
false => '--no-dns-updates',
default => '',
}
if $machinepass {
# Debug output -- put pass on command-line :)
#$pass = "machinepass=\"\${MACHINE_PASSWORD}\""
#$machinepass_env = [ "MACHINE_PASSWORD=${machinepass}", ]
#notify { "samba domain join being attempted with machinepass=${machinepass}": }
$pass = "machinepass=${machinepass}"
$machinepass_env = [ ]
} else {
$pass = ''
$machinepass_env = [ ]
}

if $force_join {
$unlesstest = 'false'
} else {
$unlesstest = 'net ads testjoin'
}

exec{ 'Join Domain':
path => '/bin:/sbin:/usr/sbin:/usr/bin/',
unless => 'net ads testjoin',
command => "echo '${adminpassword}'| net ads join -U '${adminuser}' ${ou}",
notify => Service['SambaWinBind'],
require => [ Package['SambaClassic'], Service['SambaSmb'] ],
path => '/bin:/sbin:/usr/sbin:/usr/bin/',
unless => $unlesstest,
#unless => 'net ads testjoin',
environment => [ "NET_PASSWORD=${adminpassword}", ] + $machinepass_env,
command => "echo \$NET_PASSWORD | net ads join -U '${adminuser}' ${no_dns_updates} ${ou} ${pass}",
notify => Service['SambaWinBind'],
require => Package['SambaClassic'],
}

# Add dependency for domain join to require all config options applied
Samba::Option <| |> -> Exec['Join Domain']
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions manifests/dc.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
$netlogonabsentoptions = [],
$sysvolabsentoptions = [],
Optional[String] $cleanup = undef,
$packagesambawinbind = $::samba::params::packagesambawinbind,
$packagesambaclient = $::samba::params::packagesambaclient,
$packagesambadc = $::samba::params::packagesambadc,
) inherits ::samba::params{

case $dnsbackend {
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
case $facts['os']['family'] {
'redhat': {
$cleanup = undef
# for now, this is not supported by RedHat
$packagesambadc = 'samba-dc'
$packagesambaclassic = 'samba'
$packagesambawinbind = 'samba-winbind'
$packagesambansswinbind = 'samba-winbind-clients'
$packagesambapamwinbind = 'samba-winbind-clients'
$packagesambaclient = 'samba-client'
# for now, this is not supported by Debian
$servivesambadc = undef
$servivesmb = 'smb'
$servivewinbind = 'winbind'
Expand Down
26 changes: 11 additions & 15 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kakwa-samba",
"version": "2.0.0",
"version": "2.1.0",
"author": "kakwa",
"summary": "Module managing Samba, including Samba as a AD Domain Controller",
"license": "MIT",
Expand All @@ -11,7 +11,7 @@
"dependencies": [
{
"name": "puppetlabs-stdlib",
"version_requirement": ">= 3.0.0 < 5.0.0"
"version_requirement": ">= 9.0.0 < 10.0.0"
},
{
"name": "herculesteam-augeasproviders_pam",
Expand All @@ -22,39 +22,35 @@
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6",
"7"
"8"
]
},
{
"operatingsystem": "CentOS",
"operatingsystem": "Rocky",
"operatingsystemrelease": [
"6",
"7"
"8"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"7",
"8"
"11",
"12"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04",
"16.04"
"20.04",
"22.04",
"24.04"
]
},
{
"operatingsystem": "Archlinux"
}
],
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.10.0 < 6.0.0"
"version_requirement": ">= 6.0.0 < 9.0.0"
}
]
}