class Chef::Provider::Group::Usermod
Public Instance Methods
add_member(member)
click to toggle source
# File lib/chef/provider/group/usermod.rb, line 67 def add_member(member) shell_out!("usermod", append_flags, new_resource.group_name, member) end
append_flags()
click to toggle source
# File lib/chef/provider/group/usermod.rb, line 77 def append_flags case node[:platform] when "openbsd", "netbsd", "aix", "smartos", "omnios" "-G" end end
define_resource_requirements()
click to toggle source
Calls superclass method
Chef::Provider::Group::Groupadd#define_resource_requirements
# File lib/chef/provider/group/usermod.rb, line 32 def define_resource_requirements super requirements.assert(:all_actions) do |a| a.assertion { ::File.exist?("/usr/sbin/usermod") } a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/usermod for #{new_resource}" # No whyrun alternative: this component should be available in the base install of any given system that uses it end requirements.assert(:modify, :manage) do |a| a.assertion { new_resource.members.empty? || new_resource.append } a.failure_message Chef::Exceptions::Group, "setting group members directly is not supported by #{self}, must set append true in group" # No whyrun alternative - this action is simply not supported. end requirements.assert(:all_actions) do |a| a.assertion { new_resource.excluded_members.empty? } a.failure_message Chef::Exceptions::Group, "excluded_members is not supported by #{self}" # No whyrun alternative - this action is simply not supported. end end
load_current_resource()
click to toggle source
Calls superclass method
Chef::Provider::Group::Groupadd#load_current_resource
# File lib/chef/provider/group/usermod.rb, line 28 def load_current_resource super end
remove_member(member)
click to toggle source
# File lib/chef/provider/group/usermod.rb, line 71 def remove_member(member) # This provider only supports adding members with # append. This function should never be called. raise Chef::Exceptions::UnsupportedAction, "Removing members members is not supported by #{self}" end
set_members(members)
click to toggle source
# File lib/chef/provider/group/usermod.rb, line 54 def set_members(members) return if members.empty? # This provider only supports adding members with # append. Only if the action is create we will go # ahead and add members. unless new_resource.action.include?(:create) raise Chef::Exceptions::UnsupportedAction, "Setting members directly is not supported by #{self}" end members.each do |member| add_member(member) end end