aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jahn <ajjahn@gmail.com>2016-01-22 12:03:55 -0500
committerAdam Jahn <ajjahn@gmail.com>2016-01-22 12:03:55 -0500
commit6b84cf51c863034c2dbba12f380bf8e82a529abb (patch)
tree17641909f729f4980bc5ff10f241f032f98dfa4f
parent6d835c44da343f84472f1da2627b350da173050e (diff)
parent9d63c7be3fa57e4af93c787f8b740658ec14f1f6 (diff)
downloadpuppet-samba-6b84cf51c863034c2dbba12f380bf8e82a529abb.tar.gz
puppet-samba-6b84cf51c863034c2dbba12f380bf8e82a529abb.tar.bz2
Merge pull request #49 from alexjfisher/remove_add_check_user_scripts
Remove add/check user scripts
-rw-r--r--.gitignore2
-rw-r--r--Gemfile.lock324
-rw-r--r--manifests/server.pp16
-rw-r--r--manifests/server/user.pp8
-rw-r--r--spec/classes/samba__server_spec.rb3
-rw-r--r--spec/defines/samba__server__user_spec.rb14
-rw-r--r--spec/fixtures/manifests/init.pp5
-rw-r--r--templates/add_samba_user16
-rw-r--r--templates/check_samba_user16
9 files changed, 21 insertions, 383 deletions
diff --git a/.gitignore b/.gitignore
index fc0ca69..7ff6674 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
.DS_Store
pkg/
log/
+Gemfile.lock
+spec/fixtures/
diff --git a/Gemfile.lock b/Gemfile.lock
deleted file mode 100644
index 1cd94b1..0000000
--- a/Gemfile.lock
+++ /dev/null
@@ -1,324 +0,0 @@
-GIT
- remote: git://github.com/rodjek/puppet-lint.git
- revision: 2546fed6be894bbcff15c3f48d4b6f6bc15d94d1
- ref: 2546fed6be894bbcff15c3f48d4b6f6bc15d94d1
- specs:
- puppet-lint (1.1.0)
-
-GEM
- remote: https://rubygems.org/
- specs:
- CFPropertyList (2.2.8)
- activesupport (4.2.5)
- i18n (~> 0.7)
- json (~> 1.7, >= 1.7.7)
- minitest (~> 5.1)
- thread_safe (~> 0.3, >= 0.3.4)
- tzinfo (~> 1.1)
- addressable (2.4.0)
- autoparse (0.3.3)
- addressable (>= 2.3.1)
- extlib (>= 0.9.15)
- multi_json (>= 1.0.0)
- aws-sdk (1.66.0)
- aws-sdk-v1 (= 1.66.0)
- aws-sdk-v1 (1.66.0)
- json (~> 1.4)
- nokogiri (>= 1.4.4)
- beaker (2.30.1)
- aws-sdk (~> 1.57)
- beaker-answers (~> 0.0)
- beaker-hiera (~> 0.0)
- docker-api
- fission (~> 0.4)
- fog (~> 1.25, < 1.35.0)
- fog-google (~> 0.0.9)
- google-api-client (~> 0.8)
- hocon (~> 0.1)
- inifile (~> 2.0)
- json (~> 1.8)
- mime-types (~> 2.99)
- minitest (~> 5.4)
- net-scp (~> 1.2)
- net-ssh (~> 2.9)
- open_uri_redirections (~> 0.2.1)
- rbvmomi (~> 1.8)
- rsync (~> 1.0.9)
- stringify-hash (~> 0.0)
- unf (~> 0.1)
- beaker-answers (0.3.2)
- require_all (~> 1.3.2)
- stringify-hash (~> 0.0.0)
- beaker-hiera (0.1.1)
- stringify-hash (~> 0.0.0)
- beaker-rspec (5.3.0)
- beaker (~> 2.0)
- rspec
- serverspec (~> 2)
- specinfra (~> 2)
- builder (3.2.2)
- coderay (1.1.0)
- diff-lcs (1.2.5)
- docker-api (1.24.1)
- excon (>= 0.38.0)
- json
- domain_name (0.5.25)
- unf (>= 0.0.5, < 1.0.0)
- excon (0.45.4)
- extlib (0.9.16)
- facter (2.4.4)
- CFPropertyList (~> 2.2.6)
- faraday (0.9.2)
- multipart-post (>= 1.2, < 3)
- fission (0.5.0)
- CFPropertyList (~> 2.2)
- fog (1.34.0)
- fog-atmos
- fog-aws (>= 0.6.0)
- fog-brightbox (~> 0.4)
- fog-core (~> 1.32)
- fog-dynect (~> 0.0.2)
- fog-ecloud (~> 0.1)
- fog-google (>= 0.0.2)
- fog-json
- fog-local
- fog-powerdns (>= 0.1.1)
- fog-profitbricks
- fog-radosgw (>= 0.0.2)
- fog-riakcs
- fog-sakuracloud (>= 0.0.4)
- fog-serverlove
- fog-softlayer
- fog-storm_on_demand
- fog-terremark
- fog-vmfusion
- fog-voxel
- fog-xml (~> 0.1.1)
- ipaddress (~> 0.5)
- nokogiri (~> 1.5, >= 1.5.11)
- fog-atmos (0.1.0)
- fog-core
- fog-xml
- fog-aws (0.7.6)
- fog-core (~> 1.27)
- fog-json (~> 1.0)
- fog-xml (~> 0.1)
- ipaddress (~> 0.8)
- fog-brightbox (0.10.1)
- fog-core (~> 1.22)
- fog-json
- inflecto (~> 0.0.2)
- fog-core (1.35.0)
- builder
- excon (~> 0.45)
- formatador (~> 0.2)
- fog-dynect (0.0.2)
- fog-core
- fog-json
- fog-xml
- fog-ecloud (0.3.0)
- fog-core
- fog-xml
- fog-google (0.0.9)
- fog-core
- fog-json
- fog-xml
- fog-json (1.0.2)
- fog-core (~> 1.0)
- multi_json (~> 1.10)
- fog-local (0.2.1)
- fog-core (~> 1.27)
- fog-powerdns (0.1.1)
- fog-core (~> 1.27)
- fog-json (~> 1.0)
- fog-xml (~> 0.1)
- fog-profitbricks (0.0.5)
- fog-core
- fog-xml
- nokogiri
- fog-radosgw (0.0.4)
- fog-core (>= 1.21.0)
- fog-json
- fog-xml (>= 0.0.1)
- fog-riakcs (0.1.0)
- fog-core
- fog-json
- fog-xml
- fog-sakuracloud (1.4.0)
- fog-core
- fog-json
- fog-serverlove (0.1.2)
- fog-core
- fog-json
- fog-softlayer (1.0.2)
- fog-core
- fog-json
- fog-storm_on_demand (0.1.1)
- fog-core
- fog-json
- fog-terremark (0.1.0)
- fog-core
- fog-xml
- fog-vmfusion (0.1.0)
- fission
- fog-core
- fog-voxel (0.1.0)
- fog-core
- fog-xml
- fog-xml (0.1.2)
- fog-core
- nokogiri (~> 1.5, >= 1.5.11)
- formatador (0.2.5)
- google-api-client (0.8.6)
- activesupport (>= 3.2)
- addressable (~> 2.3)
- autoparse (~> 0.3)
- extlib (~> 0.9)
- faraday (~> 0.9)
- googleauth (~> 0.3)
- launchy (~> 2.4)
- multi_json (~> 1.10)
- retriable (~> 1.4)
- signet (~> 0.6)
- googleauth (0.4.2)
- faraday (~> 0.9)
- jwt (~> 1.4)
- logging (~> 2.0)
- memoist (~> 0.12)
- multi_json (~> 1.11)
- signet (~> 0.6)
- hiera (1.3.4)
- json_pure
- hocon (0.9.3)
- http-cookie (1.0.2)
- domain_name (~> 0.5)
- i18n (0.7.0)
- inflecto (0.0.2)
- inifile (2.0.2)
- ipaddress (0.8.0)
- json (1.8.3)
- json_pure (1.8.3)
- jwt (1.5.2)
- launchy (2.4.3)
- addressable (~> 2.3)
- little-plugger (1.1.4)
- logging (2.0.0)
- little-plugger (~> 1.1)
- multi_json (~> 1.10)
- memoist (0.13.0)
- metaclass (0.0.4)
- metadata-json-lint (0.0.11)
- json
- spdx-licenses (~> 1.0)
- method_source (0.8.2)
- mime-types (2.99)
- mini_portile2 (2.0.0)
- minitest (5.8.3)
- mocha (1.1.0)
- metaclass (~> 0.0.1)
- multi_json (1.11.2)
- multipart-post (2.0.0)
- net-scp (1.2.1)
- net-ssh (>= 2.6.5)
- net-ssh (2.9.2)
- net-telnet (0.1.1)
- netrc (0.11.0)
- nokogiri (1.6.7)
- mini_portile2 (~> 2.0.0.rc2)
- open_uri_redirections (0.2.1)
- pry (0.10.3)
- coderay (~> 1.1.0)
- method_source (~> 0.8.1)
- slop (~> 3.4)
- 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-syntax (2.0.0)
- rake
- puppetlabs_spec_helper (1.0.1)
- mocha
- puppet-lint
- puppet-syntax
- rake
- rspec-puppet
- rake (10.4.2)
- rbvmomi (1.8.2)
- builder
- nokogiri (>= 1.4.1)
- trollop
- require_all (1.3.3)
- rest-client (1.8.0)
- http-cookie (>= 1.0.2, < 2.0)
- mime-types (>= 1.16, < 3.0)
- netrc (~> 0.7)
- retriable (1.4.1)
- rspec (3.1.0)
- rspec-core (~> 3.1.0)
- rspec-expectations (~> 3.1.0)
- rspec-mocks (~> 3.1.0)
- rspec-core (3.1.7)
- rspec-support (~> 3.1.0)
- rspec-expectations (3.1.2)
- diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.1.0)
- rspec-its (1.2.0)
- rspec-core (>= 3.0.0)
- rspec-expectations (>= 3.0.0)
- rspec-mocks (3.1.3)
- rspec-support (~> 3.1.0)
- rspec-puppet (2.2.0)
- rspec
- rspec-support (3.1.2)
- rsync (1.0.9)
- serverspec (2.24.3)
- multi_json
- rspec (~> 3.0)
- rspec-its
- specinfra (~> 2.43)
- sfl (2.2)
- signet (0.7.0)
- addressable (~> 2.3)
- faraday (~> 0.9)
- jwt (~> 1.5)
- multi_json (~> 1.10)
- slop (3.6.0)
- spdx-licenses (1.0.0)
- json
- specinfra (2.44.6)
- net-scp
- net-ssh (~> 2.7)
- net-telnet
- sfl
- stringify-hash (0.0.2)
- thread_safe (0.3.5)
- trollop (2.1.2)
- tzinfo (1.2.2)
- thread_safe (~> 0.1)
- unf (0.1.4)
- unf_ext
- unf_ext (0.0.7.1)
- vagrant-wrapper (2.0.3)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- beaker (> 2.0.0)
- beaker-rspec (>= 5.1.0)
- metadata-json-lint
- pry
- puppet (~> 3.7.0)
- puppet-blacksmith
- puppet-lint!
- puppet-syntax
- puppetlabs_spec_helper
- rake
- rspec (< 3.2.0)
- rspec-core (= 3.1.7)
- rspec-puppet (~> 2.1)
- serverspec
- vagrant-wrapper
diff --git a/manifests/server.pp b/manifests/server.pp
index 550659c..8a5853c 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -58,20 +58,4 @@ class samba::server($interfaces = '',
'os level': value => $os_level;
'preferred master': value => $preferred_master;
}
-
- file {'/sbin/check_samba_user':
- # script checks to see if a samba account exists for a given user
- owner => root,
- group => root,
- mode => '0755',
- content => template("${module_name}/check_samba_user"),
- }
-
- file {'/sbin/add_samba_user':
- # script creates a new samba account for a given user and password
- owner => root,
- group => root,
- mode => '0755',
- content => template("${module_name}/add_samba_user"),
- }
}
diff --git a/manifests/server/user.pp b/manifests/server/user.pp
index b8f2e61..d10a602 100644
--- a/manifests/server/user.pp
+++ b/manifests/server/user.pp
@@ -4,10 +4,12 @@ define samba::server::user (
$password,
$user_name = $name,
) {
+ require ::samba::server::install
+
exec { "add smb account for ${user_name}":
- command => "/sbin/add_samba_user '${user_name}' '${password}'" ,
- unless => "/sbin/check_samba_user '${user_name}'" ,
+ command => "/bin/echo -e '${password}\\n${password}\\n' | /usr/bin/pdbedit --password-from-stdin -a '${user_name}'",
+ unless => "/usr/bin/pdbedit '${user_name}'",
require => [ User[$user_name] ],
- notify => Class['samba::server::service']
+ notify => Class['samba::server::service'] #TODO: Is this really required??
}
}
diff --git a/spec/classes/samba__server_spec.rb b/spec/classes/samba__server_spec.rb
index 69fa0ec..dbf840a 100644
--- a/spec/classes/samba__server_spec.rb
+++ b/spec/classes/samba__server_spec.rb
@@ -20,7 +20,4 @@ describe 'samba::server' do
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/defines/samba__server__user_spec.rb b/spec/defines/samba__server__user_spec.rb
new file mode 100644
index 0000000..c7ae00c
--- /dev/null
+++ b/spec/defines/samba__server__user_spec.rb
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe 'samba::server::user', :type => :define do
+ let(:title) { 'test_user' }
+ let(:params) {{ :password => 'secret' }}
+
+ it { is_expected.to contain_samba__server__user('test_user') }
+ it { is_expected.to contain_exec('add smb account for test_user').with(
+ :command => '/bin/echo -e \'secret\nsecret\n\' | /usr/bin/pdbedit --password-from-stdin -a \'test_user\'',
+ :unless => '/usr/bin/pdbedit \'test_user\'',
+ :require => 'User[test_user]',
+ :notify => 'Class[Samba::Server::Service]'
+ ) }
+end
diff --git a/spec/fixtures/manifests/init.pp b/spec/fixtures/manifests/init.pp
deleted file mode 100644
index 94005cd..0000000
--- a/spec/fixtures/manifests/init.pp
+++ /dev/null
@@ -1,5 +0,0 @@
-node 'testhost.example.com' {
- include samba::server
-}
-
-node default {}
diff --git a/templates/add_samba_user b/templates/add_samba_user
deleted file mode 100644
index cc1d56b..0000000
--- a/templates/add_samba_user
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-# This script adds a samba account for a given user and password
-# call as:
-# > add_samba_user "USERNAME" "PASSWORD"
-
-/bin/echo -e "$2\n$2\n" | sudo /usr/bin/pdbedit -a "$1" -t 1>/dev/null
-results=$?
-
-if [ $results = 0 ]; then
- echo "added samba account for '$1'"
-else
- echo "could not add samba account for '$1'"
-fi
-
-exit $results
diff --git a/templates/check_samba_user b/templates/check_samba_user
deleted file mode 100644
index 431c3c4..0000000
--- a/templates/check_samba_user
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-# This script checks to see if a given user account exists on samba
-# if so, it returns 0
-# otherwise it returns 1
-
-sudo /usr/bin/pdbedit -L | egrep -q "^$1:"
-exists=$?
-
-if [ $exists = 0 ]; then
- echo "'$1' is a samba user"
-else
- echo "no samba account matching '$1'"
-fi
-
-exit $exists