Skip to content

enabling more variable overwriting #43

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 41 additions & 31 deletions manifests/classic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,36 @@
#

class samba::classic(
$smbname = undef,
$domain = undef,
$realm = undef,
$strictrealm = true,
$adminuser = 'administrator',
$adminpassword = undef,
$security = 'ads',
$sambaloglevel = 1,
$join_domain = true,
$manage_winbind = true,
$krbconf = true,
$nsswitch = true,
$pam = false,
$sambaclassloglevel = undef,
$logtosyslog = false,
$globaloptions = {},
$globalabsentoptions = [],
$joinou = undef,
$default_realm = undef,
$additional_realms = [],
$smbname = undef,
$domain = undef,
$realm = undef,
$strictrealm = true,
$adminuser = 'administrator',
$adminpassword = undef,
$security = 'ads',
$sambaloglevel = 1,
$join_domain = true,
$manage_winbind = true,
$krbconf = true,
$nsswitch = true,
$pam = false,
$sambaclassloglevel = undef,
$logtosyslog = false,
$globaloptions = {},
$globalabsentoptions = [],
$joinou = undef,
$default_realm = undef,
$additional_realms = [],
$packagesambaclassic = $::samba::params::packagesambaclassic,
$packagesambawinbind = $::samba::params::packagesambawinbind,
$packagesambansswinbind = $::samba::params::packagesambansswinbind,
$packagesambapamwinbind = $::samba::params::packagesambapamwinbind,
$servivesmb = $::samba::params::servivesmb,
$servivewinbind = $::samba::params::servivewinbind,
$sambaoptsfile = $::samba::params::sambaoptsfile,
$sambaoptstmpl = $::samba::params::sambaoptstmpl,
$smbconffile = $::samba::params::smbconffile,
$krbconffile = $::samba::params::krbconffile,
) inherits ::samba::params{


Expand Down Expand Up @@ -109,13 +119,13 @@

file { '/etc/samba/smb_path':
ensure => 'present',
content => $::samba::params::smbconffile,
content => $smbconffile,
require => File['/etc/samba/'],
}

if $join_domain {
if $krbconf {
file {$::samba::params::krbconffile:
file {$krbconffile:
ensure => present,
mode => '0644',
content => template("${module_name}/krb5.conf.erb"),
Expand All @@ -126,7 +136,7 @@
if $nsswitch {
package{ 'SambaNssWinbind':
ensure => 'installed',
name => $::samba::params::packagesambansswinbind
name => $packagesambansswinbind
}

augeas{'samba nsswitch group':
Expand Down Expand Up @@ -154,11 +164,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 @@ -211,38 +221,38 @@

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']
}

service{ 'SambaSmb':
ensure => 'running',
name => $::samba::params::servivesmb,
name => $servivesmb,
require => [ Package['SambaClassic'], File['SambaOptsFile'] ],
enable => true,
}

if $manage_winbind {
service{ 'SambaWinBind':
ensure => 'running',
name => $::samba::params::servivewinbind,
name => $servivewinbind,
require => [ Package['SambaClassic'], File['SambaOptsFile'] ],
enable => true,
}
}
$sambamode = 'classic'
# Deploy /etc/sysconfig/|/etc/defaut/ file (startup options)
file{ 'SambaOptsFile':
path => $::samba::params::sambaoptsfile,
content => template($::samba::params::sambaoptstmpl),
path => $sambaoptsfile,
content => template($sambaoptstmpl),
require => Package['SambaClassic'],
}

Expand Down
51 changes: 31 additions & 20 deletions manifests/dc.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@
$globalabsentoptions = [],
$netlogonabsentoptions = [],
$sysvolabsentoptions = [],
$packagesambadc = $::samba::params::packagesambadc,
$packagesambaclient = $::samba::params::packagesambaclient,
$packagesambawinbind = $::samba::params::packagesambawinbind,
$servivesambadc = $::samba::params::servivesambadc,
$servivesmb = $::samba::params::servivesmb,
$sambacmd = $::samba::params::sambacmd,
$sambaclientcmd = $::samba::params::sambaclientcmd,
$sambaoptsfile = $::samba::params::sambaoptsfile,
$sambaoptstmpl = $::samba::params::sambaoptstmpl,
$smbconffile = $::samba::params::smbconffile,
$packagepyyaml = $::samba::params::packagepyyaml,
) inherits ::samba::params{

case $dnsbackend {
Expand Down Expand Up @@ -151,31 +162,31 @@

file { '/etc/samba/smb_path':
ensure => 'present',
content => $::samba::params::smbconffile,
content => $smbconffile,
require => File['/etc/samba/'],
}

package{ 'SambaWinBind':
ensure => 'installed',
name => $::samba::params::packagesambawinbind,
name => $packagesambawinbind,
require => File['/etc/samba/smb_path'],
}

package{ 'SambaClient':
ensure => 'installed',
name => $::samba::params::packagesambaclient,
name => $packagesambaclient,
require => File['/etc/samba/smb_path'],
}

package{ 'SambaDC':
ensure => 'installed',
name => $::samba::params::packagesambadc,
name => $packagesambadc,
require => Package['SambaClient', 'SambaWinBind'],
}

service{ 'SambaClassic':
ensure => 'stopped',
name => $::samba::params::servivesmb,
name => $servivesmb,
enable => false,
require => Package['SambaDC'],
notify => Service['SambaDC'],
Expand Down Expand Up @@ -211,35 +222,35 @@
exec{ 'provisionAD':
path => '/bin:/sbin:/usr/bin:/usr/sbin',
unless => "test -d '${targetdir}/state/sysvol/${realmdowncase}/'",
command => "printf '' > '${::samba::params::smbconffile}' && \
${::samba::params::sambacmd} domain provision ${hostip} \
command => "printf '' > '${smbconffile}' && \
${sambacmd} domain provision ${hostip} \
--domain='${domain}' --realm='${realm}' --dns-backend='${sambadns}' \
--targetdir='${targetdir}' --use-rfc2307 \
--configfile='${::samba::params::smbconffile}' --server-role='${role}' ${domainprovargs} -d 1 && \
mv '${targetdir}/etc/smb.conf' '${::samba::params::smbconffile}'",
--configfile='${smbconffile}' --server-role='${role}' ${domainprovargs} -d 1 && \
mv '${targetdir}/etc/smb.conf' '${smbconffile}'",
require => Exec['CleanService'],
notify => Service['SambaDC'],
}

service{ 'SambaDC':
ensure => 'running',
name => $::samba::params::servivesambadc,
name => $servivesambadc,
require => [ Exec['provisionAD'], File['SambaOptsFile'] ],
enable => true,
}

$sambamode = 'ad'
# Deploy /etc/sysconfig/|/etc/defaut/ file (startup options)
file{ 'SambaOptsFile':
path => $::samba::params::sambaoptsfile,
content => template($::samba::params::sambaoptstmpl),
path => $sambaoptsfile,
content => template($sambaoptstmpl),
require => Package['SambaDC'],
notify => Service['SambaDC'],
}

package{ 'PyYaml':
ensure => 'installed',
name => $::samba::params::packagepyyaml,
name => $packagepyyaml,
}

file{ 'SambaOptsAdditionnalTool':
Expand All @@ -265,7 +276,7 @@
if $dnsforwarder != undef {
smb_setting { 'global/dns forwarder':
ensure => present,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => 'global',
setting => 'dns forwarder',
value => $dnsforwarder,
Expand All @@ -284,9 +295,9 @@
# Check and set administrator password
unless $adminpassword == undef {
exec{ 'setAdminPassword':
unless => "${::samba::params::sambaclientcmd} \
unless => "${sambaclientcmd} \
//localhost/netlogon ${adminpassword} -Uadministrator -c 'ls'",
command => "${::samba::params::sambacmd} user setpassword \
command => "${sambacmd} user setpassword \
Administrator --newpassword=${adminpassword} -d 1",
require => Service['SambaDC'],
}
Expand All @@ -295,19 +306,19 @@
# Configure Domain function level
exec{ 'setDomainFunctionLevel':
path => '/bin:/sbin:/usr/bin:/usr/sbin',
unless => "${::samba::params::sambacmd} domain level show -d 1\
unless => "${sambacmd} domain level show -d 1\
| grep 'Domain function level' | grep -q \"${domainlevel}$\"",
command => "${::samba::params::sambacmd} domain \
command => "${sambacmd} domain \
level raise --domain-level='${strdomainlevel}' -d 1",
require => Service['SambaDC'],
}

# Configure Forest function level
exec{ 'setForestFunctionLevel':
path => '/bin:/sbin:/usr/bin:/usr/sbin',
unless => "${::samba::params::sambacmd} domain level show -d 1\
unless => "${sambacmd} domain level show -d 1\
| grep 'Forest function level' | grep -q '${domainlevel}$'",
command => "${::samba::params::sambacmd} domain \
command => "${sambacmd} domain \
level raise --forest-level='${strdomainlevel}' -d 1",
require => Exec['setDomainFunctionLevel'],
}
Expand Down
5 changes: 3 additions & 2 deletions manifests/dc/ppolicy_param.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$option,
$show_string,
$value,
$sambacmd = $::samba::params::sambacmd,
){

validate_re(
Expand All @@ -29,10 +30,10 @@
path => '/bin:/sbin:/usr/bin:/usr/sbin',
require => Service['SambaDC'],
unless => "[ \
\"\$( ${::samba::params::sambacmd} domain passwordsettings show -d 1 | \
\"\$( ${sambacmd} domain passwordsettings show -d 1 | \
sed 's/${show_string} *//p;d' )\" = \
'${value}' ]",
command => "${::samba::params::sambacmd} domain passwordsettings set -d 1 \
command => "${sambacmd} domain passwordsettings set -d 1 \
${option}='${value}'",
}
}
Expand Down
15 changes: 8 additions & 7 deletions manifests/log.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$logtosyslog,
$settingsignored,
$sambaclassloglevel = undef,
$smbconffile = $::samba::params::smbconffile,
) {

unless is_integer($sambaloglevel)
Expand Down Expand Up @@ -40,7 +41,7 @@
unless member($settingsignored, 'log level'){
smb_setting { 'global/log level':
ensure => present,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => 'global',
setting => 'log level',
value => "${sambaloglevel}${logadditional}",
Expand All @@ -53,7 +54,7 @@
unless member($settingsignored, 'syslog'){
smb_setting { 'global/syslog':
ensure => present,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => 'global',
setting => 'syslog',
value => "${sambaloglevel}${logadditional}",
Expand All @@ -63,7 +64,7 @@
unless member($settingsignored, 'syslog only'){
smb_setting { 'global/syslog only':
ensure => present,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => 'global',
setting => 'syslog only',
value => 'yes',
Expand All @@ -73,7 +74,7 @@
unless member($settingsignored, 'logging'){
smb_setting { 'global/logging':
ensure => present,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => 'global',
setting => 'logging',
value => $syslog_loglevel,
Expand All @@ -87,7 +88,7 @@
unless member($settingsignored, 'syslog only'){
smb_setting { 'global/syslog only':
ensure => present,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => 'global',
setting => 'syslog only',
value => 'no',
Expand All @@ -97,7 +98,7 @@
unless member($settingsignored, 'syslog'){
smb_setting { 'global/syslog':
ensure => absent,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => 'global',
setting => 'syslog',
}
Expand All @@ -106,7 +107,7 @@
unless member($settingsignored, 'logging'){
smb_setting { 'global/logging':
ensure => absent,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => 'global',
setting => 'logging',
}
Expand Down
3 changes: 2 additions & 1 deletion manifests/option.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
$options,
$section,
$settingsignored = [],
$smbconffile = $::samba::params::smbconffile,
){
$optionssetting = regsubst($title, '^\[.*\](.*)$', '\1')
$optionsvalue = $options[$optionssetting]

unless member($settingsignored, $optionssetting){
smb_setting { "${section}/${optionssetting}":
ensure => present,
path => $::samba::params::smbconffile,
path => $smbconffile,
section => $section,
setting => $optionssetting,
value => $optionsvalue,
Expand Down
Loading