# class Chef::Provider::Group::Usermod

### Public Instance Methods

add_member(member) click to toggle source

    # File lib/chef/provider/group/usermod.rb, line 69
    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 79
    def append_flags
      case node[:platform]
      when "openbsd", "netbsd", "aix", "solaris2", "smartos"
        "-G"
      when "solaris", "suse", "opensuse"
        "-a -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 33
    def define_resource_requirements
      super

      requirements.assert(:all_actions) do |a|
        a.assertion { ::File.exists?("/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.to_s}, 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.to_s}"
        # 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 29
    def load_current_resource
      super
    end

remove_member(member) click to toggle source

    # File lib/chef/provider/group/usermod.rb, line 73
    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.to_s}"
    end

set_members(members) click to toggle source

    # File lib/chef/provider/group/usermod.rb, line 55
    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.
      if @new_resource.action == :create
        members.each do |member|
          add_member(member)
        end
      else
        raise Chef::Exceptions::UnsupportedAction, "Setting members directly is not supported by #{self.to_s}"
      end
    end