This module manages Samba installation, including samba as an Active Directory Domain Controler.
Any parameter in smb.conf can be added/modified/removed, keeping you free to customize the installation to your specific needs.
This module is licensed MIT.
The script additional-samba-tool is licensed GPLv3 (depends on python-samba which is GPLv3).
This module will install the samba packages and setup smb.conf.
In 'classic':
In 'dc':
This module requires puppetlabs-stdlib module.
Look at the examples directory.
To provision the domain controller use the samba::dc class:
class { ::samba::dc:
# Mandatory parameters
domain => 'ad', # * AD domain name
realm => 'ad.example.org', # * Realm name (must match domain)
# Optionnal parameters
dnsbackend => 'internal', # * DNS backend ('internal',
# 'bindFlat' or 'bindDLZ')
# default: internal
adminpassword => 'P455WordS', # * Administrator password
# (default: undef)
dnsforwarder => '8.8.8.8', # * Dns forwarder IP (default: undef)
ip => '192.168.1.1' # * DC listening IP (default undef)
targetdir => '/var/lib/samba/', # * Deployment directory
# (default: '/var/lib/samba/')
domainlevel => '2003', # * Functionality level ('2003',
# '2008' or '2008 R2') (default 2003).
# Can be upgraded, but not downgraded
domainprovargs => '', # * Additionnal arguments for domain
# provision (ex: --domain-sid)
sambaloglevel => 3, # * Log level (from 1 to 10) (default: 1)
logtosyslog => false, # * Log not to file but to syslog
# (default: false)
sambaclassloglevel => { # * Set log level by log classes
'printdrivers' => 1, # (default: undef)
'idmap' => 5,
'winbind' => 3,
},
globaloptions => { # * Custom options in section [global]
# Takes precedence.
# (default: {})
'custom setting 1' => 'custom value 1',
'custom setting 2' => 'custom value 2',
},
netlogonoptions => {}, # * Custom options in section [netlogon]
sysvoloptions => {}, # * Custom options in section [sysvol]
globalabsentoptions => ['idmap_ldb:use'], # * Remove default settings put
# by this class in [global]
# (default: [])
sysvolabsentoptions => [], # * remove default settings in [sysvol]
netlogonabsentoptions => [], # * Remove default settings in [netlogon]
}
Configuring password Policy:
class { ::samba::dc::ppolicy:
ppolicycomplexity => 'on', # * Enable password policy (default: on)
ppolicyplaintext => 'off', # * Store password in plain text
# (default: off)
ppolicyhistorylength => 24, # * Password history length (default: 24)
ppolicyminpwdlength => 7, # * Minimum password length (default: 7)
ppolicyminpwdage => 1, # * Minimum password age (default: 1)
ppolicymaxpwdage => 42, # * Maximum password age (default: 42)
}
If this class is not specified, default from samba-tool provisioning will be kept.
Password Policy parameters can be set individually:
samba::dc::ppolicy_param{'account-lockout-duration':
option => '--account-lockout-duration', # option name in samba-tool
show_string => 'Account lockout duration (mins):', # string name in show
value => '45', # value
}
Use the following commands to list available options for your samba version
# List available options:
$ samba-tool domain passwordsettings --help
# List available string_show:
$ samba-tool domain passwordsettings show
Adding logon scripts:
::samba::dc::script { 'login1.cmd': # * name of the script
content => 'echo login script 1 # * content of the script
ping -n 11 127.0.0.1 > nul # will automaticaly be converted
', # to CRLF End of Line.
}
Adding users:
smb_user { 'test user': # * user name
ensure => present, # * absent | present
password => 'QwertyP455aaa', # * user password (default: random)
force_password => true, # * force password value, if false
# only set at creation (default: true)
groups => ['domain users', # * list of groups (default: [])
'administrators'],
given_name => 'test user gn', # * user given name (default: '')
use_username_as_cn => true, # * use username as cn (default: false)
attributes => { # * hash of attributes
uidNumber => '15222', # use list for multivalued attributes
gidNumber => '10001', # (default: {} (no attributes))
msSFU30NisDomain => 'dc',
mail => ['test@toto.fr'],
},
}
Adding groups:
smb_group { 'mygroup':
ensure => present, # * group name
scope => 'Domain', # * group scope
type => 'Security', # * group type
attributes => { # * attributes
gidNumber => '15220', # use list for multivalued attributes
msSFU30NisDomain => 'dc',
},
groups => ['domain users', # * list of groups
'administrators'],
}
class { '::samba::classic':
# Mandatory parameters
domain => 'DC', # * Domain to authentify against
realm => 'dc.kakwa.fr', # * Realm to authentify against
smbname => 'SMB', # * Share name
sambaloglevel => 3, # * Samba log level
logtosyslog => true, # * Log to Syslog
# Optionnal parameters
strictrealm => true, # * Check for Strict Realm (default: true)
security => 'ADS', # * security mode.
# in ['ADS', 'AUTO', 'USER', 'DOMAIN']
# default: 'ADS'
manage_winbind => true # * Manage the winbind service (default: true)
krbconf => true, # * Deploy krb5.conf file (default: true)
nsswitch => true, # * Add winbind to nsswitch,
# (default: true)
pam => false, # * Add winbind to pam (default: false)
join_domain => true, # * Flag to enable domain join (default: true)
adminuser => 'custadmin' # * Domain Administrator login
# (default: 'administrator')
adminpassword => 'P455WordS', # * Domain Administrator
# password (for joining)
# (default: undef, no join)
joinou => 'Computer/Samba', # * OU to Join
sambaclassloglevel => { # * Set log level by log classes
'printdrivers' => 1, # (default: undef)
'idmap' => 5,
'winbind' => 3,
},
globaloptions => {}, # * Custom options in section [global]
globalabsentoptions => [], # * Remove default settings put
}
Idmap is to map user ids to unix uid/uid numbers, it supports several back-ends which can be configured with the following resources.
Note that configuring a '*' domain seems necessary for Idmap to properly work.
::samba::idmap { 'Domain *':
domain => '*', # * name of the Domain or '*'
idrangemin => 10000, # * Min uid for Domain users
idrangemax => 19999, # * Max uid for Domain users
backend => 'tdb', # * idmap backend
# in [nss, tdb or rid]
}
::samba::idmap { 'Domain DC':
domain => 'DC', # * name of the Domain or '*'
idrangemin => 10000, # * Min uid for Domain users
idrangemax => 19999, # * Max uid for Domain users
backend => 'ad', # * idmap backend
schema_mode => 'rfc2307', # * Schema mode
# in [rfc2307, sfu, sfu20]
}
::samba::idmap { 'Domain DC':
domain => 'DC', # * name of the Domain or '*'
idrangemin => 10000, # * Min uid for Domain users
idrangemax => 19999, # * Max uid for Domain users
backend => 'autorid', # * idmap backend
# Optionnal parameters
rangesize => 100000, # * number of uid per domain
# default: 100000
read_only => 'yes', # * Read only mappint
# Default no
ignore_builtin => 'yes', # * Ignore any mapping requests
# for the BUILTIN domain
}
::samba::idmap { 'Domain DC':
domain => 'DC', # * name of the Domain or '*'
idrangemin => 10000, # * Min uid for Domain users
idrangemax => 19999, # * Max uid for Domain users
backend => 'hash', # * idmap backend
name_map => '/etc/samba/name_map.cfg' # * mapping file
}
::samba::idmap { 'Domain DC':
domain => 'DC', # * name of the Domain or '*'
idrangemin => 10000, # * Min uid for Domain users
idrangemax => 19999, # * Max uid for Domain users
backend => 'ldap', # * idmap backend
ldap_base_dn => 'ou=users,dc=example,dc=com', # * users mapping ou
ldap_user_dn => 'cn=smb,dc=example,dc=com', # * bind account
ldap_passwd => 'password', # * bind password
ldap_url => 'ldap://ldap.example.com', # * ldap url
}
::samba::idmap { 'Domain DC':
domain => 'DC', # * name of the Domain or '*'
idrangemin => 10000, # * Min uid for Domain users
idrangemax => 19999, # * Max uid for Domain users
backend => 'tdb2', # * idmap backend
script => '/etc/samba/map.sh', # * mapping sid/uid script
}
To add multiple realms in krb5.conf, use the following syntax:
class { '::samba::classic':
default_realm => 'FOREST.EXAMPLE.COM'
additional_realms => [
'FOREST2.EXAMPLE.ORG'
]
}
::samba::share { 'Test Share':
# Mandatory parameters
path => '/srv/test/',
# Optionnal parameters
manage_directory => true, # * let the resource handle the shared
# directory creation (default: true)
owner => 'root', # * owner of the share directory
# (default: root)
group => 'root', # * group of the share directory
# (default: root)
mode => '0775', # * mode of the share directory
# (default: 0777)
acl => [], # * list of posix acls (default: undef)
options => { # * Custom options in section [Test Share]
'browsable' => 'Yes',
'root preexec' => 'mkdir -p \'/home/home_%U\'',
},
absentoptions => ['path'], # * Remove default settings put by this resource
# default?: []
}
If you want to create subdirectory in a share with specific permissions/acls:
::samba::dir { 'Sub Dir':
# Mandatory parameters
path => '/srv/test/sub',
# Optionnal parameters
owner => 'root', # * owner of the directory
# (default: root)
group => 'root', # * group of the directory
# (default: root)
mode => '0775', # * mode of the directory
# (default: 770)
acl => [], # * list of posix acls (default: undef)
}
If you want to create a DNS zone (most useful for creating the reverse zone after DC creation):
::samba::dc::dnszone { 'Reverse Zone':
# Mandatory parameters
zone => '0.168.192.in-addr.arpa'
}
If you want to create a DNS entry (most useful for creating the reverse DNS entries):
::samba::dc::dnsentry { 'Reverse Entry':
# Mandatory parameters
zone => '0.168.192.in-addr.arpa'
host => '1'
type => 'PTR'
record => 'dc.samdom.example.com.'
}
class samba::dc (deploy Samba as a Domain Controller) needs Samba in version 4.0.0 or above.
This version is available in Debian Jessie and above, or in Wheezy using Debian backports.
As of May 2017, CentOS/RedHat doesn't support Samba 4 AD DC due to choices in kerberos implementations.
If you plan to deploy Samba as a DC on CentOS/RedHat you will need to build samba yourself. Another possibility is to use the Samba+ Sernet Packages which requires a paid subscription.
Formerly, this Puppet module handled installing Samba from the free packages Sernet packages, these packages are EOL and are no longer available. For security reasons please be advised to migrate to a properly maintained solution (samba+ subscription, Debian/Ubuntu, self-maintained samba package).
Any form of contribution (bug reports, feature requests...) is welcomed. Pull requests will be merged after review.
If you have questions regarding how to use this module, don't hesitate to fill a bug.
Contribution must not raise errors from puppet-lint.
2.0.0:
1.0.0:
0.9.0:
0.8.1:
0.8.0:
0.7.5:
0.7.4:
0.7.3:
force_password
parameter to smb_user
resource to only set password at creation and not touch it after0.7.2:
0.7.1:
0.7.0:
0.6.2:
0.6.1:
0.6.0:
0.5.0:
0.4.0:
0.3.1:
0.3.0:
0.2.0:
0.1.2:
0.1.1:
0.1.0:
This module includes portions of code derived from: