aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.rspec2
-rw-r--r--[-rwxr-xr-x]Gemfile2
-rw-r--r--manifests/server/ads.pp47
-rw-r--r--[-rwxr-xr-x]manifests/server/share.pp66
-rw-r--r--metadata.json2
-rw-r--r--spec/acceptance/basic_samba_spec.rb1
-rw-r--r--spec/classes/samba__server__ads_spec.rb19
-rw-r--r--spec/classes/samba__server_spec.rb4
-rw-r--r--spec/defines/samba__server__share_spec.rb687
-rw-r--r--spec/spec.opts6
-rw-r--r--spec/spec_helper.rb7
-rw-r--r--spec/support/augeas.rb69
-rw-r--r--templates/configure_active_directory.erb2
-rw-r--r--templates/verify_active_directory.erb2
15 files changed, 889 insertions, 28 deletions
diff --git a/.gitignore b/.gitignore
index 7ff6674..49f2ba2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ pkg/
log/
Gemfile.lock
spec/fixtures/
+.vagrant/
diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..8c18f1a
--- /dev/null
+++ b/.rspec
@@ -0,0 +1,2 @@
+--format documentation
+--color
diff --git a/Gemfile b/Gemfile
index a89c9e6..598a68f 100755..100644
--- a/Gemfile
+++ b/Gemfile
@@ -20,7 +20,9 @@ group :test do
gem "rspec", '< 3.2.0'
gem "rspec-core", "3.1.7"
gem "rspec-puppet", "~> 2.1"
+ gem "json_pure", "< 2.0.0"
gem "puppet-syntax"
gem "puppetlabs_spec_helper"
+ gem 'rspec-puppet-facts'
end
diff --git a/manifests/server/ads.pp b/manifests/server/ads.pp
index 757d091..7e2ffe0 100644
--- a/manifests/server/ads.pp
+++ b/manifests/server/ads.pp
@@ -21,7 +21,8 @@ class samba::server::ads($ensure = present,
$map_system = 'no',
$map_archive = 'no',
$map_readonly = 'no',
- $target_ou = 'Nix_Mashine') {
+ $target_ou = 'Nix_Mashine',
+ $perform_join = true) {
$krb5_user_package = $::osfamily ? {
'RedHat' => 'krb5-workstation',
@@ -38,7 +39,7 @@ class samba::server::ads($ensure = present,
$winbind_package = 'winbind'
}
- package{
+ package {
$krb5_user_package: ensure => installed;
$winbind_package: ensure => installed;
'expect': ensure => installed;
@@ -49,18 +50,24 @@ class samba::server::ads($ensure = present,
# notify winbind
samba::server::option {
- 'realm': value => $realm,
- notify => Class['Samba::Server::Winbind'];
- 'winbind uid': value => $winbind_uid,
- notify => Class['Samba::Server::Winbind'];
- 'winbind gid': value => $winbind_gid,
- notify => Class['Samba::Server::Winbind'];
- 'winbind enum groups': value => $winbind_enum_groups,
- notify => Class['Samba::Server::Winbind'];
- 'winbind enum users': value => $winbind_enum_users,
- notify => Class['Samba::Server::Winbind'];
- 'winbind use default domain': value => $winbind_use_default_domain,
- notify => Class['Samba::Server::Winbind'];
+ 'realm':
+ value => $realm,
+ notify => Class['Samba::Server::Winbind'];
+ 'winbind uid':
+ value => $winbind_uid,
+ notify => Class['Samba::Server::Winbind'];
+ 'winbind gid':
+ value => $winbind_gid,
+ notify => Class['Samba::Server::Winbind'];
+ 'winbind enum groups':
+ value => $winbind_enum_groups,
+ notify => Class['Samba::Server::Winbind'];
+ 'winbind enum users':
+ value => $winbind_enum_users,
+ notify => Class['Samba::Server::Winbind'];
+ 'winbind use default domain':
+ value => $winbind_use_default_domain,
+ notify => Class['Samba::Server::Winbind'];
}
samba::server::option {
@@ -122,10 +129,12 @@ class samba::server::ads($ensure = present,
'samba-winbind use default domain'], Service['winbind'] ],
}
- exec {'join-active-directory':
- # join the domain configured in samba.conf
- command => '/sbin/configure_active_directory -j',
- unless => '/sbin/verify_active_directory',
- require => [ File['configure_active_directory', 'verify_active_directory'], Service['winbind'] ],
+ if ($perform_join) {
+ exec {'join-active-directory':
+ # join the domain configured in samba.conf
+ command => '/sbin/configure_active_directory -j',
+ unless => '/sbin/verify_active_directory',
+ require => [ File['configure_active_directory', 'verify_active_directory'], Service['winbind'] ],
+ }
}
}
diff --git a/manifests/server/share.pp b/manifests/server/share.pp
index b0690bb..5544caf 100755..100644
--- a/manifests/server/share.pp
+++ b/manifests/server/share.pp
@@ -20,16 +20,26 @@ define samba::server::share($ensure = present,
$veto_oplock_files = '',
$read_only = '',
$public = '',
+ $read_list = '',
$write_list = '',
$writable = '',
$printable = '',
$valid_users = '',
$follow_symlinks = '',
$wide_links = '',
+ $acl_group_control = '',
$map_acl_inherit = '',
+ $profile_acls = '',
$store_dos_attributes = '',
$strict_allocate = '',
$hide_dot_files = '',
+ $root_preexec = '',
+ $inherit_permissions = '',
+ $inherit_acls = '',
+ $delete_readonly = '',
+ $printer_name = '',
+ $msdfs_root = '',
+ $guest_account = '',
) {
$incl = $samba::server::incl
@@ -143,11 +153,21 @@ define samba::server::share($ensure = present,
false => "set \"${target}/wide links\" no",
default => "rm \"${target}/wide links\"",
},
+ $acl_group_control ? {
+ true => "set \"${target}/acl group control\" yes",
+ false => "set \"${target}/acl group control\" no",
+ default => "rm \"${target}/acl group control\"",
+ },
$map_acl_inherit ? {
true => "set \"${target}/map acl inherit\" yes",
false => "set \"${target}/map acl inherit\" no",
default => "rm \"${target}/map acl inherit\"",
},
+ $profile_acls ? {
+ true => "set \"${target}/profile acls\" yes",
+ false => "set \"${target}/profile acls\" no",
+ default => "rm \"${target}/profile acls\"",
+ },
$store_dos_attributes ? {
true => "set \"${target}/store dos attributes\" yes",
false => "set \"${target}/store dos attributes\" no",
@@ -159,23 +179,27 @@ define samba::server::share($ensure = present,
default => "rm \"${target}/strict allocate\"",
},
$valid_users ? {
- '' => "rm \"${target}/valid users\"",
+ '' => "rm \"${target}/valid users\"",
default => "set \"${target}/valid users\" '${valid_users}'",
},
$op_locks ? {
- '' => "rm \"${target}/oplocks\"",
+ '' => "rm \"${target}/oplocks\"",
default => "set \"${target}/oplocks\" '${op_locks}'",
},
$level2_oplocks ? {
- '' => "rm \"${target}/level2 oplocks\"",
+ '' => "rm \"${target}/level2 oplocks\"",
default => "set \"${target}/level2 oplocks\" '${level2_oplocks}'",
},
$veto_oplock_files ? {
- '' => "rm \"${target}/veto oplock files\"",
+ '' => "rm \"${target}/veto oplock files\"",
default => "set \"${target}/veto oplock files\" '${veto_oplock_files}'",
},
+ $read_list ? {
+ '' => "rm \"${target}/read list\"",
+ default => "set \"${target}/read list\" '${read_list}'",
+ },
$write_list ? {
- '' => "rm \"${target}/write list\"",
+ '' => "rm \"${target}/write list\"",
default => "set \"${target}/write list\" '${write_list}'",
},
$hide_dot_files ? {
@@ -183,6 +207,38 @@ define samba::server::share($ensure = present,
false => "set \"${target}/hide dot files\" no",
default => "rm \"${target}/hide dot files\"",
},
+ $root_preexec ? {
+ '' => "rm \"${target}/root preexec\"",
+ default => "set \"${target}/root preexec\" '${root_preexec}'",
+ },
+ $inherit_permissions ? {
+ true => "set \"${target}/inherit permissions\" yes",
+ false => "set \"${target}/inherit permissions\" no",
+ default => "rm \"${target}/inherit permissions\"",
+ },
+ $inherit_acls ? {
+ true => "set \"${target}/inherit acls\" yes",
+ false => "set \"${target}/inherit acls\" no",
+ default => "rm \"${target}/inherit acls\"",
+ },
+ $delete_readonly ? {
+ true => "set \"${target}/delete readonly\" yes",
+ false => "set \"${target}/delete readonly\" no",
+ default => "rm \"${target}/delete readonly\"",
+ },
+ $printer_name ? {
+ '' => "rm \"${target}/printer name\"",
+ default => "set \"${target}/printer name\" '${printer_name}'",
+ },
+ $msdfs_root ? {
+ true => "set \"${target}/msdfs root\" yes",
+ false => "set \"${target}/msdfs root\" no",
+ default => "rm \"${target}/msdfs root\"",
+ },
+ $guest_account ? {
+ '' => "rm \"${target}/guest account\"",
+ default => "set \"${target}/guest account\" '${guest_account}'",
+ },
]
augeas { "${name}-changes":
diff --git a/metadata.json b/metadata.json
index 173933f..5e3d84b 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,6 +1,6 @@
{
"name": "ajjahn-samba",
- "version": "0.4.1",
+ "version": "0.5.1",
"author": "Adam Jahn",
"summary": "Module for provisioning Samba",
"license": "Apache-2.0",
diff --git a/spec/acceptance/basic_samba_spec.rb b/spec/acceptance/basic_samba_spec.rb
index 8a9e363..e50cb2a 100644
--- a/spec/acceptance/basic_samba_spec.rb
+++ b/spec/acceptance/basic_samba_spec.rb
@@ -22,6 +22,7 @@ describe 'basic samba' do
force_group => 'group',
force_user => 'user',
hide_dot_files => false,
+ msdfs_root => true,
}
"}
diff --git a/spec/classes/samba__server__ads_spec.rb b/spec/classes/samba__server__ads_spec.rb
new file mode 100644
index 0000000..a174bef
--- /dev/null
+++ b/spec/classes/samba__server__ads_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe 'samba::server::ads', :type => :class do
+ let( :facts ) { { :osfamily => 'Debian' } }
+ context "Default config" do
+ it { should contain_exec('join-active-directory') }
+ end
+
+ context "No join" do
+ let ( :params ) { { 'perform_join' => false }}
+ it { should_not contain_exec('join-active-directory') }
+ end
+
+ context "Join 'forced'" do
+ let ( :params ) { { 'perform_join' => true }}
+ it { should contain_exec('join-active-directory') }
+ end
+end
+
diff --git a/spec/classes/samba__server_spec.rb b/spec/classes/samba__server_spec.rb
index 46c5b15..37d5aa8 100644
--- a/spec/classes/samba__server_spec.rb
+++ b/spec/classes/samba__server_spec.rb
@@ -30,19 +30,21 @@ describe 'samba::server' do
'writable' => true,
'guest_ok' => true,
'guest_only' => true,
+ 'msdfs_root' => true,
},
'testShare2' => {
'path' => '/some/other/path'
}
}
}}
- it {
+ it {
should contain_samba__server__share( 'testShare' ).with({
'path' => '/path/to/some/share',
'browsable' => true,
'writable' => true,
'guest_ok' => true,
'guest_only' => true,
+ 'msdfs_root' => true,
})
}
it { should contain_samba__server__share( 'testShare2' ).with_path('/some/other/path') }
diff --git a/spec/defines/samba__server__share_spec.rb b/spec/defines/samba__server__share_spec.rb
new file mode 100644
index 0000000..894f334
--- /dev/null
+++ b/spec/defines/samba__server__share_spec.rb
@@ -0,0 +1,687 @@
+require 'spec_helper'
+
+shared_examples "default share" do
+ let(:title) { "test_share" }
+ let(:params) {{ :ensure => 'present' }}
+ let(:default_changes) do
+ set = Augeas::TargetedChangeSet.new(title)
+ set.with("available")
+ set.with("browsable")
+ set.with("comment")
+ set.with("copy")
+ set.with("create mask")
+ set.with("directory mask")
+ set.with("force create mask")
+ set.with("force directory mode")
+ set.with("force group")
+ set.with("force user")
+ set.with("guest ok")
+ set.with("guest only")
+ set.with("hide unreadable")
+ set.with("path", nil, nil)
+ set.with("read only")
+ set.with("public")
+ set.with("writable")
+ set.with("printable")
+ set.with("follow symlinks")
+ set.with("wide links")
+ set.with("acl group control")
+ set.with("map acl inherit")
+ set.with("profile acls")
+ set.with("store dos attributes")
+ set.with("strict allocate")
+ set.with("valid users")
+ set.with("oplocks")
+ set.with("level2 oplocks")
+ set.with("veto oplock files")
+ set.with("read list")
+ set.with("write list")
+ set.with("hide dot files")
+ set.with("root preexec")
+ set.with("inherit permissions")
+ set.with("inherit acls")
+ set.with("delete readonly")
+ set.with("printer name")
+ set.with("msdfs root")
+ set.with("guest account")
+ end
+ let(:change_set) { default_changes }
+ let(:changes) { change_set.to_a }
+
+ it { is_expected.to contain_samba__server__share(title) }
+ it { is_expected.to contain_augeas("#{title}-section").with(
+ :incl => '/etc/samba/smb.conf',
+ :lens => 'Samba.lns',
+ :context => '/files/etc/samba/smb.conf',
+ :changes => ["set target[. = '#{title}'] '#{title}'"],
+ :require => 'Class[Samba::Server::Config]',
+ :notify => 'Class[Samba::Server::Service]')
+ }
+ it { is_expected.to contain_augeas("#{title}-changes").with(
+ :incl => '/etc/samba/smb.conf',
+ :lens => 'Samba.lns',
+ :context => '/files/etc/samba/smb.conf',
+ :changes => changes,
+ :require => 'Augeas[test_share-section]',
+ :notify => 'Class[Samba::Server::Service]')
+ }
+end
+
+describe 'samba::server::share', :type => :define do
+ let(:pre_condition){ 'class{"samba::server":}'}
+ on_supported_os({
+ :hardwaremodels => ['x86_64'],
+ :supported_os => [
+ {
+ "operatingsystem" => "Ubuntu",
+ "operatingsystemrelease" => [
+ "14.04"
+ ]
+ },
+ {
+ "operatingsystem" => "CentOS",
+ "operatingsystemrelease" => [
+ "7"
+ ]
+ }
+ ],
+ }).each do |os, facts|
+ context "for #{os}" do
+ let(:facts) do
+ facts.merge({
+ :concat_basedir => '/tmp',
+ :domain => 'domain.com'
+ })
+ end
+
+ context 'with base options' do
+ let(:title) { 'test_share' }
+ let(:params) {{
+ :ensure => 'present'
+ }}
+
+ it { is_expected.to contain_samba__server__share('test_share') }
+ it { is_expected.to contain_augeas('test_share-section').with(
+ :incl => '/etc/samba/smb.conf',
+ :lens => 'Samba.lns',
+ :context => '/files/etc/samba/smb.conf',
+ :changes => ["set target[. = 'test_share'] 'test_share'"],
+ :require => 'Class[Samba::Server::Config]',
+ :notify => 'Class[Samba::Server::Service]')
+ }
+ it { is_expected.to contain_augeas('test_share-changes').with(
+ :incl => '/etc/samba/smb.conf',
+ :lens => 'Samba.lns',
+ :context => '/files/etc/samba/smb.conf',
+ :require => 'Augeas[test_share-section]',
+ :notify => 'Class[Samba::Server::Service]')
+ }
+ end
+
+ context 'with ensure set to absent' do
+ let(:title) { 'test_share' }
+ let(:params) {{
+ :ensure => 'absent'
+ }}
+
+ it { is_expected.to contain_augeas('test_share-section').with(
+ :incl => '/etc/samba/smb.conf',
+ :lens => 'Samba.lns',
+ :context => '/files/etc/samba/smb.conf',
+ :changes => ["rm target[. = 'test_share'] 'test_share'"],
+ :require => 'Class[Samba::Server::Config]',
+ :notify => 'Class[Samba::Server::Service]')
+ }
+ end
+
+ context 'with available set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :available => true,
+ }}
+ let(:change_set) { default_changes.with("available", "yes") }
+ end
+
+ context 'with available set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :available => false,
+ }}
+ let(:change_set) { default_changes.with("available", "no") }
+ end
+
+ context 'with browsable set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :browsable => true,
+ }}
+ let(:change_set) { default_changes.with("browsable", "yes") }
+ end
+
+ context 'with browsable set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :browsable => false,
+ }}
+ let(:change_set) { default_changes.with("browsable", "no") }
+ end
+
+ context 'with root_preexec set to /bin/true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :root_preexec => '/bin/true',
+ }}
+ let(:change_set) { default_changes.with("root preexec", "'/bin/true'") }
+ end
+
+ context 'with comment set to "testing testing"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :comment => 'testing testing',
+ }}
+ let(:change_set) { default_changes.with("comment", "'testing testing'") }
+ end
+
+ context 'with copy set to "testing testing"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :copy => 'testing testing',
+ }}
+ let(:change_set) { default_changes.with("copy", "'testing testing'") }
+ end
+
+ context 'with create_mask set to "755"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :create_mask => '755',
+ }}
+ let(:change_set) { default_changes.with("create mask", "'755'") }
+ end
+
+ context 'with directory_mask set to "755"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :directory_mask => '755',
+ }}
+ let(:change_set) { default_changes.with("directory mask", "'755'") }
+ end
+
+ context 'with force_create_mask set to "755"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :force_create_mask => '755',
+ }}
+ let(:change_set) { default_changes.with("force create mask", "'755'") }
+ end
+
+ context 'with force_directory_mode set to "755"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :force_directory_mode => '755',
+ }}
+ let(:change_set) { default_changes.with("force directory mode", "'755'") }
+ end
+
+ context 'with force_group set to "nogroup"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :force_group => 'nogroup',
+ }}
+ let(:change_set) { default_changes.with("force group", "'nogroup'") }
+ end
+
+ context 'with force_user set to "nobody"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :force_user => 'nobody',
+ }}
+ let(:change_set) { default_changes.with("force user", "'nobody'") }
+ end
+
+ context 'with guest_ok set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :guest_ok => true,
+ }}
+ let(:change_set) { default_changes.with("guest ok", "yes") }
+ end
+
+ context 'with guest_ok set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :guest_ok => false,
+ }}
+ let(:change_set) { default_changes.with("guest ok", "no") }
+ end
+
+ context 'with guest_only set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :guest_only => true,
+ }}
+ let(:change_set) { default_changes.with("guest only", "yes") }
+ end
+
+ context 'with guest_only set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :guest_only => false,
+ }}
+ let(:change_set) { default_changes.with("guest only", "no") }
+ end
+
+ context 'with hide_unreadable set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :hide_unreadable => true,
+ }}
+ let(:change_set) { default_changes.with("hide unreadable", "yes") }
+ end
+
+ context 'with hide_unreadable set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :hide_unreadable => false,
+ }}
+ let(:change_set) { default_changes.with("hide unreadable", "no") }
+ end
+
+ context 'with path set to /tmp' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :path => '/tmp',
+ }}
+ let(:change_set) { default_changes.with("path", "'/tmp'", nil) }
+ end
+
+ context 'with read_only set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :read_only => true,
+ }}
+ let(:change_set) { default_changes.with("read only", "yes") }
+ end
+
+ context 'with read_only set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :read_only => false,
+ }}
+ let(:change_set) { default_changes.with("read only", "no") }
+ end
+
+ context 'with public set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :public => true,
+ }}
+ let(:change_set) { default_changes.with("public", "yes") }
+ end
+
+ context 'with public set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :public => false,
+ }}
+ let(:change_set) { default_changes.with("public", "no") }
+ end
+
+ context 'with writable set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :writable => true,
+ }}
+ let(:change_set) { default_changes.with("writable", "yes") }
+ end
+
+ context 'with writable set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :writable => false,
+ }}
+ let(:change_set) { default_changes.with("writable", "no") }
+ end
+
+ context 'with printable set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :printable => true,
+ }}
+ let(:change_set) { default_changes.with("printable", "yes") }
+ end
+
+ context 'with printable set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :printable => false,
+ }}
+ let(:change_set) { default_changes.with("printable", "no") }
+ end
+
+ context 'with follow_symlinks set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :follow_symlinks => true,
+ }}
+ let(:change_set) { default_changes.with("follow symlinks", "yes") }
+ end
+
+ context 'with follow_symlinks set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :follow_symlinks => false,
+ }}
+ let(:change_set) { default_changes.with("follow symlinks", "no") }
+ end
+
+ context 'with wide_links set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :wide_links => true,
+ }}
+ let(:change_set) { default_changes.with("wide links", "yes") }
+ end
+
+ context 'with wide_links set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :wide_links => false,
+ }}
+ let(:change_set) { default_changes.with("wide links", "no") }
+ end
+
+ context 'with acl_group_control set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :acl_group_control => true,
+ }}
+ let(:change_set) { default_changes.with("acl group control", "yes") }
+ end
+
+ context 'with acl_group_control set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :acl_group_control => false,
+ }}
+ let(:change_set) { default_changes.with("acl group control", "no") }
+ end
+
+ context 'with map_acl_inherit set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :map_acl_inherit => true,
+ }}
+ let(:change_set) { default_changes.with("map acl inherit", "yes") }
+ end
+
+ context 'with map_acl_inherit set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :map_acl_inherit => false,
+ }}
+ let(:change_set) { default_changes.with("map acl inherit", "no") }
+ end
+
+ context 'with profile_acls set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :profile_acls => true,
+ }}
+ let(:change_set) { default_changes.with("profile acls", "yes") }
+ end
+
+ context 'with profile_acls set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :profile_acls => false,
+ }}
+ let(:change_set) { default_changes.with("profile acls", "no") }
+ end
+
+ context 'with store_dos_attributes set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :store_dos_attributes => true,
+ }}
+ let(:change_set) { default_changes.with("store dos attributes", "yes") }
+ end
+
+ context 'with store_dos_attributes set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :store_dos_attributes => false,
+ }}
+ let(:change_set) { default_changes.with("store dos attributes", "no") }
+ end
+
+ context 'with strict_allocate set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :strict_allocate => true,
+ }}
+ let(:change_set) { default_changes.with("strict allocate", "yes") }
+ end
+
+ context 'with strict_allocate set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :strict_allocate => false,
+ }}
+ let(:change_set) { default_changes.with("strict allocate", "no") }
+ end
+
+ context 'with valid_users set to "bill,ben"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :valid_users => 'bill,ben',
+ }}
+ let(:change_set) { default_changes.with("valid users", "'bill,ben'") }
+ end
+
+ context 'with op_locks set to "testing"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :op_locks => 'testing',
+ }}
+ let(:change_set) { default_changes.with("oplocks", "'testing'") }
+ end
+
+ context 'with level2_oplocks set to "testing"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :level2_oplocks => 'testing',
+ }}
+ let(:change_set) { default_changes.with("level2 oplocks", "'testing'") }
+ end
+
+ context 'with veto_oplock_files set to "testing"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :veto_oplock_files => 'testing',
+ }}
+ let(:change_set) { default_changes.with("veto oplock files", "'testing'") }
+ end
+
+ context 'with read_list set to "bill,ben"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :read_list => 'bill,ben',
+ }}
+ let(:change_set) { default_changes.with("read list", "'bill,ben'") }
+ end
+
+ context 'with write_list set to "bill,ben"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :write_list => 'bill,ben',
+ }}
+ let(:change_set) { default_changes.with("write list", "'bill,ben'") }
+ end
+
+ context 'with hide_dot_files set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :hide_dot_files => true,
+ }}
+ let(:change_set) { default_changes.with("hide dot files", "yes") }
+ end
+
+ context 'with hide_dot_files set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :hide_dot_files => false,
+ }}
+ let(:change_set) { default_changes.with("hide dot files", "no") }
+ end
+
+ context 'with root_preexec set to "/bin/test"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :root_preexec => '/bin/test',
+ }}
+ let(:change_set) { default_changes.with("root preexec", "'/bin/test'") }
+ end
+
+ context 'with inherit_permissions set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :inherit_permissions => true,
+ }}
+ let(:change_set) { default_changes.with("inherit permissions", "yes") }
+ end
+
+ context 'with inherit_permissions set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :inherit_permissions => false,
+ }}
+ let(:change_set) { default_changes.with("inherit permissions", "no") }
+ end
+
+ context 'with inherit_acls set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :inherit_acls => true,
+ }}
+ let(:change_set) { default_changes.with("inherit acls", "yes") }
+ end
+
+ context 'with inherit_acls set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :inherit_acls => false,
+ }}
+ let(:change_set) { default_changes.with("inherit acls", "no") }
+ end
+
+ context 'with delete_readonly set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :delete_readonly => true,
+ }}
+ let(:change_set) { default_changes.with("delete readonly", "yes") }
+ end
+
+ context 'with delete_readonly set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :delete_readonly => false,
+ }}
+ let(:change_set) { default_changes.with("delete readonly", "no") }
+ end
+
+ context 'with printer_name set to "killing trees"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :printer_name => 'killing trees',
+ }}
+ let(:change_set) { default_changes.with("printer name", "'killing trees'") }
+ end
+
+ context 'with msdfs_root set to true' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :msdfs_root => true,
+ }}
+ let(:change_set) { default_changes.with("msdfs root", "yes") }
+ end
+
+ context 'with msdfs_root set to false' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :msdfs_root => false,
+ }}
+ let(:change_set) { default_changes.with("msdfs root", "no") }
+ end
+
+ context 'with guest_account set to "killing trees"' do
+ include_examples "default share"
+ let(:params) {{
+ :ensure => 'present',
+ :guest_account => 'someone',
+ }}
+ let(:change_set) { default_changes.with("guest account", "'someone'") }
+ end
+ end
+ end
+end
diff --git a/spec/spec.opts b/spec/spec.opts
new file mode 100644
index 0000000..91cd642
--- /dev/null
+++ b/spec/spec.opts
@@ -0,0 +1,6 @@
+--format
+s
+--colour
+--loadby
+mtime
+--backtrace
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 81f98ac..51ef6aa 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,4 +1,9 @@
require 'puppetlabs_spec_helper/module_spec_helper'
+require 'rspec-puppet-facts'
+
+Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
+
+include RspecPuppetFacts
RSpec.configure do |c|
c.before do
@@ -6,3 +11,5 @@ RSpec.configure do |c|
Puppet.features.stubs(:root? => true)
end
end
+
+at_exit { RSpec::Puppet::Coverage.report! }
diff --git a/spec/support/augeas.rb b/spec/support/augeas.rb
new file mode 100644
index 0000000..7548684
--- /dev/null
+++ b/spec/support/augeas.rb
@@ -0,0 +1,69 @@
+require "delegate"
+
+module Augeas
+ class Change
+ attr_reader :target, :name, :delimiter
+
+ def initialize(target, name, value = nil, delimiter = "\"")
+ @target = target
+ @name = name
+ @value = value
+ @delimiter = delimiter
+ end
+
+ def to_s
+ "#{action} #{delimiter}target[. = '#{target}']/#{name}#{delimiter}#{value}"
+ end
+
+ def hash
+ [target, name, Change].hash
+ end
+
+ def ==(other)
+ other.is_a?(self.class) && [other.target, other.name] == [target, name]
+ end
+ alias_method :eql?, :==
+
+ private
+
+ def action
+ return "set" unless @value.nil?
+ "rm "
+ end
+
+ def value
+ " #{@value}" if @value
+ end
+ end
+
+ class ChangeSet
+ def initialize
+ @set = []
+ end
+
+ def <<(change)
+ index = @set.index(change) || @set.length
+ @set[index] = change
+ end
+
+ def to_a
+ changes
+ end
+
+ def changes
+ @set.map(&:to_s)
+ end
+ end
+
+ class TargetedChangeSet < DelegateClass(ChangeSet)
+ def initialize(target)
+ @target = target
+ super(ChangeSet.new)
+ end
+
+ def with(*args)
+ self << Change.new(@target, *args)
+ self
+ end
+ end
+end
diff --git a/templates/configure_active_directory.erb b/templates/configure_active_directory.erb
index 4f9b6e0..1e74560 100644
--- a/templates/configure_active_directory.erb
+++ b/templates/configure_active_directory.erb
@@ -57,7 +57,7 @@ done
password='<%= scope.lookupvar('samba::server::ads::winbind_pass') -%>'
# short hostname from facter
-my_hostname="<%= hostname -%>"
+my_hostname="<%= @hostname -%>"
# what account do we use for net ads commands?
winbind_acct="<%= scope.lookupvar('samba::server::ads::winbind_acct') -%>"
diff --git a/templates/verify_active_directory.erb b/templates/verify_active_directory.erb
index 0917c49..c88d6a4 100644
--- a/templates/verify_active_directory.erb
+++ b/templates/verify_active_directory.erb
@@ -24,7 +24,7 @@ fi
password='<%= scope.lookupvar('samba::server::ads::winbind_pass') -%>'
# short hostname from facter
-my_hostname="<%= hostname -%>"
+my_hostname="<%= @hostname -%>"
winbind_acct="<%= scope.lookupvar('samba::server::ads::winbind_acct') -%>"