Class: Chef::Provider::Group::Aix

Inherits:
Usermod show all
Defined in:
lib/chef/provider/group/aix.rb

Instance Attribute Summary

Attributes inherited from Chef::Provider::Group

#group_exists

Attributes inherited from Chef::Provider

#current_resource, #new_resource, #run_context

Instance Method Summary collapse

Methods inherited from Usermod

#load_current_resource, #modify_group_members

Methods inherited from Groupadd

#groupadd_options, #load_current_resource, #modify_group_members

Methods inherited from Chef::Provider::Group

#action_create, #action_manage, #action_modify, #action_remove, #compare_group, #initialize, #load_current_resource

Methods included from Mixin::Command

#chdir_or_tmpdir, #handle_command_failures, #output_of_command, #run_command, #run_command_with_systems_locale

Methods included from Mixin::Command::Windows

#popen4

Methods included from Mixin::Command::Unix

#popen4

Methods inherited from Chef::Provider

#action_nothing, build_from_file, #cookbook_name, #initialize, #load_current_resource, #node, #resource_collection

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename

Methods included from Mixin::RecipeDefinitionDSLCore

#method_missing

Methods included from Mixin::Language

#data_bag, #data_bag_item, #platform?, #search, #value_for_platform

Constructor Details

This class inherits a constructor from Chef::Provider::Group

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore

Instance Method Details

#create_groupObject



32
33
34
35
36
37
# File 'lib/chef/provider/group/aix.rb', line 32

def create_group
  command = "mkgroup"
  command << set_options << " #{@new_resource.group_name}"
  run_command(:command => command)
  modify_group_members
end

#manage_groupObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/chef/provider/group/aix.rb', line 39

def manage_group
  command = "chgroup"
  options = set_options
  #Usage: chgroup [-R load_module] "attr=value" ... group
  if options.size > 0
    command << options << " #{@new_resource.group_name}"
    run_command(:command => command)
  end
  modify_group_members
end

#remove_groupObject



50
51
52
# File 'lib/chef/provider/group/aix.rb', line 50

def remove_group
  run_command(:command => "rmgroup #{@new_resource.group_name}")
end

#required_binariesObject



26
27
28
29
30
# File 'lib/chef/provider/group/aix.rb', line 26

def required_binaries
  [ "/usr/bin/mkgroup",
    "/usr/bin/chgroup",
    "/usr/sbin/rmgroup" ]
end

#set_optionsObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/chef/provider/group/aix.rb', line 54

def set_options
  opts = ""
  { :gid => "id" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
    if @current_resource.send(field) != @new_resource.send(field)
      if @new_resource.send(field)
        Chef::Log.debug("#{@new_resource} setting #{field.to_s} to #{@new_resource.send(field)}")
        opts << " '#{option}=#{@new_resource.send(field)}'"
      end
    end
  end
  opts
end