aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.fixtures.yml4
-rw-r--r--.travis.yml42
-rw-r--r--Gemfile18
-rw-r--r--Gemfile.lock67
-rw-r--r--Modulefile6
-rw-r--r--README.md36
-rw-r--r--Rakefile45
-rw-r--r--manifests/init.pp4
-rw-r--r--manifests/server.pp28
-rw-r--r--manifests/server/ads.pp18
-rw-r--r--manifests/server/config.pp2
-rw-r--r--manifests/server/install.pp4
-rw-r--r--manifests/server/option.pp8
-rw-r--r--manifests/server/params.pp32
-rw-r--r--manifests/server/service.pp44
-rw-r--r--manifests/server/share.pp38
-rw-r--r--manifests/server/user.pp24
-rw-r--r--manifests/server/winbind.pp2
-rw-r--r--metadata.json28
-rw-r--r--spec/classes/samba__server__config_spec.rb10
-rw-r--r--spec/classes/samba__server__install_spec.rb9
-rw-r--r--spec/classes/samba__server__service_spec.rb44
-rw-r--r--spec/classes/samba__server_spec.rb26
-rw-r--r--spec/fixtures/manifests/init.pp7
-rw-r--r--spec/spec_helper.rb8
-rw-r--r--templates/add_samba_user2
-rw-r--r--templates/check_samba_user2
-rw-r--r--tests/init.pp3
28 files changed, 454 insertions, 107 deletions
diff --git a/.fixtures.yml b/.fixtures.yml
new file mode 100644
index 0000000..112077f
--- /dev/null
+++ b/.fixtures.yml
@@ -0,0 +1,4 @@
+fixtures:
+ repositories:
+ symlinks:
+ samba: "#{source_dir}"
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..625faa3
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,42 @@
+---
+language: ruby
+bundler_args: --without development --jobs=3 --retry=3
+
+sudo: false
+
+rvm:
+ - 1.8.7
+ - 1.9.3
+ - 2.0.0
+ - 2.1
+
+env:
+ - PUPPET_VERSION="~> 2.7.0"
+ - PUPPET_VERSION="~> 3.1.0"
+ - PUPPET_VERSION="~> 3.2.0"
+ - PUPPET_VERSION="~> 3.3.0"
+ - PUPPET_VERSION="~> 3.4.0"
+ - PUPPET_VERSION="~> 3.5.0"
+
+before_install: rm Gemfile.lock || true
+
+script: bundle exec rake test
+
+matrix:
+ exclude:
+ - rvm: 1.9.3
+ env: PUPPET_VERSION="~> 2.7.0"
+ - rvm: 2.0.0
+ env: PUPPET_VERSION="~> 2.7.0"
+ - rvm: 2.0.0
+ env: PUPPET_VERSION="~> 3.1.0"
+ - rvm: 2.1
+ env: PUPPET_VERSION="~> 2.7.0"
+ - rvm: 2.1
+ env: PUPPET_VERSION="~> 3.1.0"
+ - rvm: 2.1
+ env: PUPPET_VERSION="~> 3.2.0"
+ - rvm: 2.1
+ env: PUPPET_VERSION="~> 3.3.0"
+ - rvm: 2.1
+ env: PUPPET_VERSION="~> 3.4.0"
diff --git a/Gemfile b/Gemfile
index 0b9fdc5..5abd8e3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,5 +1,15 @@
-source "http://rubygems.org"
+source "https://rubygems.org"
-gem "rake"
-gem "puppet-lint"
-gem "puppet" \ No newline at end of file
+group :development do
+ gem "puppet-blacksmith"
+end
+
+group :test do
+ gem "rake"
+ gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.7.0'
+ gem "puppet-lint"
+ gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git'
+ gem "puppet-syntax"
+ gem "puppetlabs_spec_helper"
+ gem 'rspec', '< 2.99'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
index 6b9032d..3fbd85d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,18 +1,71 @@
+GIT
+ remote: https://github.com/rodjek/rspec-puppet.git
+ revision: a9a837669cf6955279f02d1d9b524dc140b9d3e8
+ specs:
+ rspec-puppet (2.0.1)
+ rspec
+
GEM
- remote: http://rubygems.org/
+ remote: https://rubygems.org/
specs:
- facter (1.6.13)
- hiera (1.0.0)
- puppet (3.0.1)
- facter (~> 1.6.11)
- hiera (~> 1.0.0)
+ CFPropertyList (2.2.8)
+ diff-lcs (1.2.5)
+ domain_name (0.5.23)
+ unf (>= 0.0.5, < 1.0.0)
+ facter (2.4.3)
+ CFPropertyList (~> 2.2.6)
+ hiera (1.3.4)
+ json_pure
+ http-cookie (1.0.2)
+ domain_name (~> 0.5)
+ json_pure (1.8.2)
+ metaclass (0.0.4)
+ mime-types (2.4.3)
+ mocha (1.1.0)
+ metaclass (~> 0.0.1)
+ netrc (0.10.3)
+ puppet (3.7.5)
+ facter (> 1.6, < 3)
+ hiera (~> 1.0)
+ json_pure
+ puppet-blacksmith (3.3.1)
+ puppet (>= 2.7.16)
+ rest-client
puppet-lint (0.3.2)
+ puppet-syntax (2.0.0)
+ rake
+ puppetlabs_spec_helper (0.10.1)
+ mocha
+ puppet-lint
+ puppet-syntax
+ rake
+ rspec-puppet
rake (0.9.2.2)
+ rest-client (1.8.0)
+ http-cookie (>= 1.0.2, < 2.0)
+ mime-types (>= 1.16, < 3.0)
+ netrc (~> 0.7)
+ rspec (2.14.1)
+ rspec-core (~> 2.14.0)
+ rspec-expectations (~> 2.14.0)
+ rspec-mocks (~> 2.14.0)
+ rspec-core (2.14.8)
+ rspec-expectations (2.14.5)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rspec-mocks (2.14.6)
+ unf (0.1.4)
+ unf_ext
+ unf_ext (0.0.6)
PLATFORMS
ruby
DEPENDENCIES
- puppet
+ puppet (~> 3.7.0)
+ puppet-blacksmith
puppet-lint
+ puppet-syntax
+ puppetlabs_spec_helper
rake
+ rspec (< 2.99)
+ rspec-puppet!
diff --git a/Modulefile b/Modulefile
deleted file mode 100644
index 6a6e472..0000000
--- a/Modulefile
+++ /dev/null
@@ -1,6 +0,0 @@
-name 'ajjahn-samba'
-version '0.2.0'
-summary "Module for provisioning Samba"
-description "Module for provisioning Samba"
-author 'Adam Jahn'
-project_page 'https://github.com/ajjahn/puppet-samba' \ No newline at end of file
diff --git a/README.md b/README.md
index 6bb9a79..238d0d2 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# Puppet Samba Module
+[![Build Status](https://travis-ci.org/ajjahn/puppet-samba.png?branch=master)](https://travis-ci.org/ajjahn/puppet-samba)
+
Module for provisioning Samba
Tested on Ubuntu 12.04, CentOS 6.3, patches to support other operating systems are welcome.
@@ -20,26 +22,26 @@ Tweak and add the following to your site manifest:
node 'server.example.com' {
class {'samba::server':
- workgroup => 'example',
+ workgroup => 'example',
server_string => "Example Samba Server",
- interfaces => "eth0 lo",
- security => 'share'
+ interfaces => "eth0 lo",
+ security => 'share'
}
samba::server::share {'example-share':
- comment => 'Example Share',
- path => '/path/to/share',
- guest_only => true,
- guest_ok => true,
- guest_account => "guest",
- browsable => false,
- create_mask => 0777,
- force_create_mask => 0777,
- directory_mask => 0777,
+ comment => 'Example Share',
+ path => '/path/to/share',
+ guest_only => true,
+ guest_ok => true,
+ guest_account => "guest",
+ browsable => false,
+ create_mask => 0777,
+ force_create_mask => 0777,
+ directory_mask => 0777,
force_directory_mask => 0777,
- force_group => 'group',
- force_user => 'user',
- copy => 'some-other-share',
+ force_group => 'group',
+ force_user => 'user',
+ copy => 'some-other-share',
}
}
@@ -81,6 +83,10 @@ Most configuration options are optional.
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
+## Module modified
+
+Added "map to guest" in samba::server
+
## License
This module is released under the MIT license:
diff --git a/Rakefile b/Rakefile
index 8e7269f..69fed1b 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,16 +1,41 @@
-require 'puppet'
-require 'rake'
+require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
+require 'puppet-syntax/tasks/puppet-syntax'
-# Leave this in until we're ready to write documentation
-PuppetLint.configuration.send("disable_documentation")
+# These two gems aren't always present, for instance
+# on Travis with --without development
+begin
+ require 'puppetlabs_spec_helper/rake_tasks'
+ require 'puppet_blacksmith/rake_tasks'
+rescue LoadError
+end
-# Ruby's version of true does not equate to puppet's version of true
-PuppetLint.configuration.send("disable_quoted_booleans")
-PuppetLint.configuration.send("disable_selector_inside_resource")
-PuppetLint.configuration.send("disable_autoloader_layout")
PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"
-desc "Run puppet-lint"
-task :default => [:lint]
+# Forsake support for Puppet 2.6.2 for the benefit of cleaner code.
+# http://puppet-lint.com/checks/class_parameter_defaults/
+PuppetLint.configuration.send('disable_80chars')
+PuppetLint.configuration.send('disable_class_parameter_defaults')
+# http://puppet-lint.com/checks/class_inherits_from_params_class/
+PuppetLint.configuration.send('disable_class_inherits_from_params_class')
+
+exclude_paths = [
+ "pkg/**/*",
+ "vendor/**/*",
+ "spec/**/*",
+]
+PuppetLint.configuration.ignore_paths = exclude_paths
+PuppetSyntax.exclude_paths = exclude_paths
+
+desc "Run acceptance tests"
+RSpec::Core::RakeTask.new(:acceptance) do |t|
+ t.pattern = 'spec/acceptance'
+end
+
+desc "Run syntax, lint, and spec tests."
+task :test => [
+ :syntax,
+# :lint,
+ :spec,
+]
diff --git a/manifests/init.pp b/manifests/init.pp
index 8a914a4..4fbac9a 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,7 +1,9 @@
+# == Class samba
+#
class samba {
include samba::server
if samba::server::security == 'ads' {
include samba::server::ads
}
-} \ No newline at end of file
+}
diff --git a/manifests/server.pp b/manifests/server.pp
index 31589e0..4120154 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -1,7 +1,10 @@
+# == Class samba::server
+#
class samba::server($interfaces = '',
$security = '',
$server_string = '',
$unix_password_sync = '',
+ $netbios_name = '',
$workgroup = '',
$socket_options = '',
$deadtime = '',
@@ -9,7 +12,12 @@ class samba::server($interfaces = '',
$load_printers = '',
$printing = '',
$printcap_name = '',
+ $map_to_guest = '',
$disable_spoolss = '',
+ $kernel_oplocks = '',
+ $pam_password_change = '',
+ $os_level = '',
+ $preferred_master = '',
$bind_interfaces_only = 'yes',) {
include samba::server::install
@@ -17,8 +25,8 @@ class samba::server($interfaces = '',
include samba::server::service
$incl = '/etc/samba/smb.conf'
- $context = "/files/etc/samba/smb.conf"
- $target = "target[. = 'global']"
+ $context = '/files/etc/samba/smb.conf'
+ $target = 'target[. = "global"]'
augeas { 'global-section':
incl => $incl,
@@ -35,6 +43,7 @@ class samba::server($interfaces = '',
'security': value => $security;
'server string': value => $server_string;
'unix password sync': value => $unix_password_sync;
+ 'netbios name': value => $netbios_name;
'workgroup': value => $workgroup;
'socket_options': value => $socket_options;
'deadtime': value => $deadtime;
@@ -42,24 +51,27 @@ class samba::server($interfaces = '',
'load_printers': value => $load_printers;
'printing': value => $printing;
'printcap_name': value => $printcap_name;
+ 'map to guest': value => $map_to_guest;
'disable_spoolss': value => $disable_spoolss;
+ 'kernel oplocks': value => $kernel_oplocks;
+ 'pam password change': value => $pam_password_change;
+ 'os level': value => $os_level;
+ 'preferred master': value => $preferred_master;
}
- file {'check_samba_user':
+ file {'/sbin/check_samba_user':
# script checks to see if a samba account exists for a given user
- path => '/sbin/check_samba_user',
owner => root,
group => root,
- mode => "0755",
+ mode => '0755',
content => template("${module_name}/check_samba_user"),
}
- file {'add_samba_user':
+ file {'/sbin/add_samba_user':
# script creates a new samba account for a given user and password
- path => '/sbin/add_samba_user',
owner => root,
group => root,
- mode => "0755",
+ mode => '0755',
content => template("${module_name}/add_samba_user"),
}
diff --git a/manifests/server/ads.pp b/manifests/server/ads.pp
index 3d44af6..1260fd1 100644
--- a/manifests/server/ads.pp
+++ b/manifests/server/ads.pp
@@ -1,8 +1,6 @@
+# == Class samba::server::ads
# This module join samba server to Active Dirctory
#
-# Copyright (c) 2013 Lebedev Vadim, abraham1901 at g mail dot c o m
-# Licensed under the MIT License, http://opensource.org/licenses/MIT
-
class samba::server::ads($ensure = present,
$winbind_acct = 'admin',
$winbind_pass = 'SecretPass',
@@ -30,7 +28,7 @@ class samba::server::ads($ensure = present,
default => 'krb5-user',
}
- if $osfamily == "RedHat" {
+ if $osfamily == 'RedHat' {
if $operatingsystemrelease =~ /^6\./ {
$winbind_package = 'samba-winbind'
} else {
@@ -82,10 +80,10 @@ class samba::server::ads($ensure = present,
$changes=$nsswitch ? {
true => [
- "set database[. = 'passwd']/service[1] compat",
- "set database[. = 'passwd']/service[2] winbind",
- "set database[. = 'group']/service[1] compat",
- "set database[. = 'group']/service[2] winbind",
+ 'set database[. = "passwd"]/service[1] compat',
+ 'set database[. = "passwd"]/service[2] winbind',
+ 'set database[. = "group"]/service[1] compat',
+ 'set database[. = "group"]/service[2] winbind',
],
false => [
"rm /files/${nss_file}/database[. = 'passwd']/service[. = 'winbind']",
@@ -103,7 +101,7 @@ class samba::server::ads($ensure = present,
path => '/sbin/verify_active_directory',
owner => root,
group => root,
- mode => "0755",
+ mode => '0755',
content => template("${module_name}/verify_active_directory.erb"),
require => [ Package[$krb5_user_package, $winbind_package, 'expect'],
Augeas['samba-realm', 'samba-security', 'samba-winbind enum users',
@@ -116,7 +114,7 @@ class samba::server::ads($ensure = present,
path => '/sbin/configure_active_directory',
owner => root,
group => root,
- mode => "0755",
+ mode => '0755',
content => template("${module_name}/configure_active_directory.erb"),
require => [ Package[$krb5_user_package, $winbind_package, 'expect'],
Augeas['samba-realm', 'samba-security', 'samba-winbind enum users',
diff --git a/manifests/server/config.pp b/manifests/server/config.pp
index d51e432..1ecb490 100644
--- a/manifests/server/config.pp
+++ b/manifests/server/config.pp
@@ -1,3 +1,5 @@
+# == Class samba::server::config
+#
class samba::server::config {
file { '/etc/samba':
diff --git a/manifests/server/install.pp b/manifests/server/install.pp
index 1454bfe..ec98a49 100644
--- a/manifests/server/install.pp
+++ b/manifests/server/install.pp
@@ -1,5 +1,7 @@
+# == Class samba::server::install
+#
class samba::server::install {
package { 'samba':
ensure => installed
}
-} \ No newline at end of file
+}
diff --git a/manifests/server/option.pp b/manifests/server/option.pp
index 699985d..bf491e8 100644
--- a/manifests/server/option.pp
+++ b/manifests/server/option.pp
@@ -1,14 +1,16 @@
+# == Define samba::server::option
+#
define samba::server::option ( $value = '' ) {
$incl = $samba::server::incl
$context = $samba::server::context
$target = $samba::server::target
$changes = $value ? {
- '' => "rm ${target}/$name",
- default => "set \"${target}/$name\" \"$value\"",
+ '' => "rm ${target}/${name}",
+ default => "set \"${target}/${name}\" \"${value}\"",
}
- augeas { "samba-$name":
+ augeas { "samba-${name}":
incl => $incl,
lens => 'Samba.lns',
context => $context,
diff --git a/manifests/server/params.pp b/manifests/server/params.pp
new file mode 100644
index 0000000..5f2fc3e
--- /dev/null
+++ b/manifests/server/params.pp
@@ -0,0 +1,32 @@
+# == Class samba::server::params
+#
+class samba::server::params {
+ case $::osfamily {
+ 'Redhat': { $service_name = 'smb' }
+
+ #On Debian family: Debian 7 => samba , Ubuntu => smbd
+ #Others, I don't know, hope 'samba' will works
+ 'Debian': {
+ case $::operatingsystem{
+ 'Debian': { $service_name = 'samba' }
+ 'Ubuntu': { $service_name = 'smbd'
+ $nmbd_name = 'nmbd' }
+ default: { $service_name = 'samba' }
+ }
+ }
+ 'Gentoo': { $service_name = 'samba' }
+ 'Archlinux': { $service_name = 'smbd'
+ $nmbd_name = 'nmbd' }
+
+ # Currently Gentoo has $::osfamily = "Linux". This should change in
+ # Factor 1.7.0 <http://projects.puppetlabs.com/issues/17029>, so
+ # adding workaround.
+ 'Linux': {
+ case $::operatingsystem {
+ 'Gentoo': { $service_name = 'samba' }
+ default: { fail("${::operatingsystem} is not supported by this module.") }
+ }
+ }
+ default: { fail("${::osfamily} is not supported by this module.") }
+ }
+}
diff --git a/manifests/server/service.pp b/manifests/server/service.pp
index 9ad5fb0..1a9fbe7 100644
--- a/manifests/server/service.pp
+++ b/manifests/server/service.pp
@@ -1,32 +1,11 @@
-class samba::server::service ($ensure = running, $enable = true) {
- case $::osfamily {
- 'Redhat': { $service_name = 'smb' }
+# == Class samba::server::server
+#
+class samba::server::service (
+ $ensure = running,
+ $enable = true
+) inherits samba::server::params {
- #On Debian family: Debian 7 => samba , Ubuntu => smbd
- #Others, I don't know, hope 'samba' will works
- 'Debian': {
- case $::operatingsystem{
- 'Debian': { $service_name = 'samba' }
- 'Ubuntu': { $service_name = 'smbd'}
- default: { $service_name='samba'}
- }
- }
- 'Gentoo': { $service_name = 'samba' }
- 'Archlinux': { $service_name = 'smbd' }
-
- # Currently Gentoo has $::osfamily = "Linux". This should change in
- # Factor 1.7.0 <http://projects.puppetlabs.com/issues/17029>, so
- # adding workaround.
- 'Linux': {
- case $::operatingsystem {
- 'Gentoo': { $service_name = 'samba' }
- default: { fail("$::operatingsystem is not supported by this module.") }
- }
- }
- default: { fail("$::osfamily is not supported by this module.") }
- }
-
- service { "$service_name" :
+ service { $service_name :
ensure => $ensure,
hasstatus => true,
hasrestart => true,
@@ -34,4 +13,13 @@ class samba::server::service ($ensure = running, $enable = true) {
require => Class['samba::server::config']
}
+ if $nmbd_name != undef {
+ service { $nmbd_name :
+ ensure => $ensure,
+ hasrestart => false,
+ enable => $enable,
+ require => Class['samba::server::config'],
+ }
+ }
+
}
diff --git a/manifests/server/share.pp b/manifests/server/share.pp
index b228818..5a6667c 100644
--- a/manifests/server/share.pp
+++ b/manifests/server/share.pp
@@ -1,3 +1,5 @@
+# == Define samba::server::share
+#
define samba::server::share($ensure = present,
$available = '',
$browsable = '',
@@ -12,6 +14,7 @@ define samba::server::share($ensure = present,
$guest_account = '',
$guest_ok = '',
$guest_only = '',
+ $hide_unreadable = '',
$path = '',
$op_locks = '',
$level2_oplocks = '',
@@ -22,6 +25,11 @@ define samba::server::share($ensure = present,
$writable = '',
$printable = '',
$valid_users = '',
+ $follow_symlinks = '',
+ $wide_links = '',
+ $map_acl_inherit = '',
+ $store_dos_attributes = '',
+ $strict_allocate = '',
) {
$incl = $samba::server::incl
@@ -98,6 +106,11 @@ define samba::server::share($ensure = present,
false => "set \"${target}/guest only\" no",
default => "rm \"${target}/guest only\"",
},
+ $hide_unreadable ? {
+ true => "set \"${target}/hide unreadable\" yes",
+ false => "set \"${target}/hide unreadable\" no",
+ default => "rm \"${target}/hide unreadable\"",
+ },
$path ? {
default => "set ${target}/path '${path}'",
'' => "rm ${target}/path",
@@ -122,6 +135,31 @@ define samba::server::share($ensure = present,
false => "set \"${target}/printable\" no",
default => "rm \"${target}/printable\"",
},
+ $follow_symlinks ? {
+ true => "set \"${target}/follow symlinks\" yes",
+ false => "set \"${target}/follow symlinks\" no",
+ default => "rm \"${target}/follow symlinks\"",
+ },
+ $wide_links ? {
+ true => "set \"${target}/wide links\" yes",
+ false => "set \"${target}/wide links\" no",
+ default => "rm \"${target}/wide links\"",
+ },
+ $map_acl_inherit ? {
+ true => "set \"${target}/map acl inherit\" yes",
+ false => "set \"${target}/map acl inherit\" no",
+ default => "rm \"${target}/map acl inherit\"",
+ },
+ $store_dos_attributes ? {
+ true => "set \"${target}/store dos attributes\" yes",
+ false => "set \"${target}/store dos attributes\" no",
+ default => "rm \"${target}/store dos attributes\"",
+ },
+ $strict_allocate ? {
+ true => "set \"${target}/strict allocate\" yes",
+ false => "set \"${target}/strict allocate\" no",
+ default => "rm \"${target}/strict allocate\"",
+ },
]
augeas { "${name}-changes":
diff --git a/manifests/server/user.pp b/manifests/server/user.pp
index 2cffe3b..b8f2e61 100644
--- a/manifests/server/user.pp
+++ b/manifests/server/user.pp
@@ -1,13 +1,13 @@
-define samba::server::user(
- $user_name = $name ,
- $password ,
- ) {
- exec { "add smb account for ${user_name}":
- command => "/sbin/add_samba_user '${user_name}' '${password}'" ,
- unless => "/sbin/check_samba_user '${user_name}'" ,
- require => [
- User["${user_name}"]
- ] ,
- notify => Class['samba::server::service']
- }
+# == Class samba::server::user
+#
+define samba::server::user (
+ $password,
+ $user_name = $name,
+) {
+ exec { "add smb account for ${user_name}":
+ command => "/sbin/add_samba_user '${user_name}' '${password}'" ,
+ unless => "/sbin/check_samba_user '${user_name}'" ,
+ require => [ User[$user_name] ],
+ notify => Class['samba::server::service']
+ }
}
diff --git a/manifests/server/winbind.pp b/manifests/server/winbind.pp
index b3fe1a9..376fed6 100644
--- a/manifests/server/winbind.pp
+++ b/manifests/server/winbind.pp
@@ -1,3 +1,5 @@
+# == Class samba::server::winbind
+#
class samba::server::winbind ($ensure = running, $enable = true) {
$service_name = 'winbind'
diff --git a/metadata.json b/metadata.json
new file mode 100644
index 0000000..1b2021a
--- /dev/null
+++ b/metadata.json
@@ -0,0 +1,28 @@
+{
+ "name": "ajjahn-samba",
+ "version": "0.3.2",
+ "author": "Adam Jahn",
+ "summary": "Module for provisioning Samba",
+ "license": "Apache-2.0",
+ "source": "https://github.com/ajjahn/puppet-samba",
+ "project_page": "https://github.com/ajjahn/puppet-samba",
+ "issues_url": "https://github.com/ajjahn/puppet-samba/issues",
+ "description": "Module for provisioning Samba",
+ "operatingsystem_support": [
+ {
+ "operatingsystem": "RedHat",
+ "operatingsystemrelease": [
+ "6.0"
+ ]
+ },
+ {
+ "operatingsystem": "Ubuntu",
+ "operatingsystemrelease": [
+ "12.04"
+ ]
+ }
+ ],
+ "dependencies": [
+
+ ]
+}
diff --git a/spec/classes/samba__server__config_spec.rb b/spec/classes/samba__server__config_spec.rb
new file mode 100644
index 0000000..5f13aa4
--- /dev/null
+++ b/spec/classes/samba__server__config_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe 'samba::server::config', :type => :class do
+ context "on a Debian OS" do
+ let( :facts ) { { :osfamily => 'Debian' } }
+
+ it { should contain_file('/etc/samba/smb.conf').with_owner('root') }
+ end
+end
+
diff --git a/spec/classes/samba__server__install_spec.rb b/spec/classes/samba__server__install_spec.rb
new file mode 100644
index 0000000..9764687
--- /dev/null
+++ b/spec/classes/samba__server__install_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe 'samba::server::install', :type => :class do
+ context "on a Debian OS" do
+ let(:facts) {{ :osfamily => 'Debian' }}
+ it { should contain_package('samba') }
+ end
+end
+
diff --git a/spec/classes/samba__server__service_spec.rb b/spec/classes/samba__server__service_spec.rb
new file mode 100644
index 0000000..ada7f21
--- /dev/null
+++ b/spec/classes/samba__server__service_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+describe 'samba::server::service' do
+ context 'on a Debian os family' do
+ let(:facts) {{ :osfamily => 'Debian' }}
+
+ it { should contain_service('samba').with_require('Class[Samba::Server::Config]') }
+
+ context 'Debian' do
+ let(:facts) {{ :osfamily => 'Debian', :operatingsystem => 'Debian' }}
+ it { should contain_service('samba') }
+ end
+
+ context 'Ubuntu' do
+ let(:facts) {{ :osfamily => 'Debian', :operatingsystem => 'Ubuntu' }}
+ it { should contain_service('smbd') }
+ end
+ end
+
+ context 'on a Redhat os family' do
+ let(:facts) {{ :osfamily => 'Redhat' }}
+ it { should contain_service('smb') }
+ end
+
+ context 'on a Archlinux os family' do
+ let(:facts) {{ :osfamily => 'Archlinux' }}
+ it { should contain_service('smbd') }
+ end
+
+ context 'on Linux os family' do
+ let(:facts) {{ :osfamily => 'Linux' }}
+ it { should raise_error(/is not supported by this module./) }
+
+ context 'Gentoo' do
+ let(:facts) {{ :osfamily => 'Linux', :operatingsystem => 'Gentoo' }}
+ it { should contain_service('samba') }
+ end
+ end
+
+ context 'on an unsupported OS' do
+ let(:facts) {{ :osfamily => 'Solaris' }}
+ it { should raise_error(/Solaris is not supported by this module./) }
+ end
+end
diff --git a/spec/classes/samba__server_spec.rb b/spec/classes/samba__server_spec.rb
new file mode 100644
index 0000000..fce10bb
--- /dev/null
+++ b/spec/classes/samba__server_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+describe 'samba::server' do
+ let(:facts) {{ :osfamily => 'Debian' }}
+
+ it { should contain_class('samba::server::install') }
+ it { should contain_class('samba::server::config') }
+ it { should contain_class('samba::server::service') }
+
+ it { should contain_samba__server__option('interfaces') }
+ it { should contain_samba__server__option('bind interfaces only') }
+ it { should contain_samba__server__option('security') }
+ it { should contain_samba__server__option('server string') }
+ it { should contain_samba__server__option('unix password sync') }
+ it { should contain_samba__server__option('workgroup') }
+ it { should contain_samba__server__option('socket_options') }
+ it { should contain_samba__server__option('deadtime') }
+ it { should contain_samba__server__option('keepalive') }
+ it { should contain_samba__server__option('load_printers') }
+ it { should contain_samba__server__option('printing') }
+ it { should contain_samba__server__option('printcap_name') }
+ it { should contain_samba__server__option('disable_spoolss') }
+
+ it { should contain_file('/sbin/check_samba_user').with_owner('root') }
+ it { should contain_file('/sbin/add_samba_user').with_owner('root') }
+end
diff --git a/spec/fixtures/manifests/init.pp b/spec/fixtures/manifests/init.pp
new file mode 100644
index 0000000..0f64360
--- /dev/null
+++ b/spec/fixtures/manifests/init.pp
@@ -0,0 +1,7 @@
+node 'testhost.example.com' {
+
+ include samba::server
+
+}
+
+node default {}
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..81f98ac
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,8 @@
+require 'puppetlabs_spec_helper/module_spec_helper'
+
+RSpec.configure do |c|
+ c.before do
+ # avoid "Only root can execute commands as other users"
+ Puppet.features.stubs(:root? => true)
+ end
+end
diff --git a/templates/add_samba_user b/templates/add_samba_user
index 1385d4e..cc1d56b 100644
--- a/templates/add_samba_user
+++ b/templates/add_samba_user
@@ -8,7 +8,7 @@
results=$?
if [ $results = 0 ]; then
- echo "added samba account for '$1'"
+ echo "added samba account for '$1'"
else
echo "could not add samba account for '$1'"
fi
diff --git a/templates/check_samba_user b/templates/check_samba_user
index 75cb4b5..431c3c4 100644
--- a/templates/check_samba_user
+++ b/templates/check_samba_user
@@ -8,7 +8,7 @@ sudo /usr/bin/pdbedit -L | egrep -q "^$1:"
exists=$?
if [ $exists = 0 ]; then
- echo "'$1' is a samba user"
+ echo "'$1' is a samba user"
else
echo "no samba account matching '$1'"
fi
diff --git a/tests/init.pp b/tests/init.pp
new file mode 100644
index 0000000..e1dd99d
--- /dev/null
+++ b/tests/init.pp
@@ -0,0 +1,3 @@
+# Smoketest.
+
+class {'samba::server': }