Initial Chef repository
This commit is contained in:
29
cookbooks/users/libraries/helpers.rb
Normal file
29
cookbooks/users/libraries/helpers.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
require 'mixlib/shellout'
|
||||
|
||||
module Users
|
||||
# Helpers for Users
|
||||
module Helpers
|
||||
# Checks fs type.
|
||||
#
|
||||
# @return [String]
|
||||
def fs_type(mount)
|
||||
begin
|
||||
# Doesn't support macosx
|
||||
stat = Mixlib::ShellOut.new("stat -f -L -c %T #{mount} 2>&1").run_command
|
||||
stat.stdout.chomp
|
||||
rescue
|
||||
'none'
|
||||
end
|
||||
end
|
||||
|
||||
# Determines if provided mount point is remote.
|
||||
#
|
||||
# @return [Boolean]
|
||||
def fs_remote?(mount)
|
||||
fs_type(mount) == 'nfs' ? true : false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Chef::Resource.send(:include, ::Users::Helpers)
|
||||
Chef::Provider.send(:include, ::Users::Helpers)
|
||||
15
cookbooks/users/libraries/matchers.rb
Normal file
15
cookbooks/users/libraries/matchers.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# Matchers for chefspec 3
|
||||
|
||||
if defined?(ChefSpec)
|
||||
def create_users_manage(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:users_manage,
|
||||
:create,
|
||||
resource_name)
|
||||
end
|
||||
|
||||
def remove_users_manage(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:users_manage,
|
||||
:remove,
|
||||
resource_name)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user