92 lines
2.5 KiB
Puppet
92 lines
2.5 KiB
Puppet
# Install samba server.
|
|
#
|
|
class samba::server {
|
|
|
|
package { "samba":
|
|
ensure => installed,
|
|
}
|
|
|
|
case $operatingsystem {
|
|
openbsd: {
|
|
service { "nmbd":
|
|
ensure => running,
|
|
enable => true,
|
|
binary => "/usr/local/libexec/nmbd",
|
|
start => "/usr/local/libexec/nmbd -D",
|
|
require => File["/etc/samba/smb.conf"],
|
|
subscribe => File["/etc/samba/smb.conf"],
|
|
}
|
|
service { "smbd":
|
|
ensure => running,
|
|
enable => true,
|
|
binary => "/usr/local/libexec/smbd",
|
|
start => "/usr/local/libexec/smbd -D",
|
|
require => File["/etc/samba/smb.conf"],
|
|
subscribe => File["/etc/samba/smb.conf"],
|
|
}
|
|
}
|
|
default: {
|
|
service { "smb":
|
|
ensure => running,
|
|
enable => true,
|
|
hasstatus => true,
|
|
hasrestart => true,
|
|
require => File["/etc/samba/smb.conf"],
|
|
subscribe => File["/etc/samba/smb.conf"],
|
|
}
|
|
}
|
|
}
|
|
|
|
file { "/etc/samba/smb.conf":
|
|
ensure => present,
|
|
source => [ "puppet:///files/samba/smb.conf.${fqdn}",
|
|
"puppet:///files/samba/smb.conf", ],
|
|
mode => 0644,
|
|
owner => root,
|
|
group => $operatingsystem ? {
|
|
openbsd => wheel,
|
|
default => root,
|
|
},
|
|
require => Package["samba"],
|
|
}
|
|
|
|
file { "/etc/samba/lmhosts":
|
|
ensure => present,
|
|
source => [ "puppet:///files/samba/lmhosts.${fqdn}",
|
|
"puppet:///files/samba/lmhosts",
|
|
"puppet:///samba/lmhosts", ],
|
|
mode => 0644,
|
|
owner => root,
|
|
group => $operatingsystem ? {
|
|
openbsd => wheel,
|
|
default => root,
|
|
},
|
|
require => Package["samba"],
|
|
}
|
|
|
|
}
|
|
|
|
|
|
# Join samba server into domain.
|
|
#
|
|
# === Global variables
|
|
#
|
|
# $samba_join_user:
|
|
# Username to use when joining domain.
|
|
#
|
|
# $samba_join_pass:
|
|
# Password to use when joining domain.
|
|
#
|
|
class samba::domainmember {
|
|
|
|
include samba::server
|
|
|
|
exec { "net join":
|
|
command => "net join -U ${samba_join_user}%\"\${SECRET}\"",
|
|
environment => "SECRET=${samba_join_pass}",
|
|
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
|
onlyif => "rpcclient localhost -c 'srvinfo' -U root%'' 2>&1 | grep 'NT_STATUS_CANT_ACCESS_DOMAIN_INFO'",
|
|
require => Service["smb"],
|
|
}
|
|
|
|
}
|