Class: Wright::Provider::Group::GnuPasswd

Inherits:
Wright::Provider::Group show all
Defined in:
lib/wright/provider/group/gnu_passwd.rb

Overview

GNU passwd group provider. Used as a provider for Resource::Group on GNU systems.

Constant Summary

Constants inherited from Wright::Provider

PROVIDER_DIR

Instance Method Summary collapse

Methods inherited from Wright::Provider::Group

#add_member, #create, #ensure_group_exists, #gid, #gid_uptodate?, #group_data, #group_exists?, #group_name, #members, #members_uptodate?, #remove, #remove_member, #system_group?, #uptodate?

Methods inherited from Wright::Provider

#env, #exec_or_fail, #initialize, #unless_dry_run, #unless_uptodate, #updated?

Constructor Details

This class inherits a constructor from Wright::Provider

Instance Method Details

#create_groupObject (private)


12
13
14
15
16
17
18
19
# File 'lib/wright/provider/group/gnu_passwd.rb', line 12

def create_group
  options = []
  options << '--system' if system_group?
  options += ['-g', gid.to_s] if gid
  cmd = 'groupadd'
  args = [*options, group_name]
  exec_or_fail(cmd, args, "cannot create group '#{group_name}'")
end

#remove_groupObject (private)


21
22
23
24
25
# File 'lib/wright/provider/group/gnu_passwd.rb', line 21

def remove_group
  cmd = 'groupdel'
  args = [group_name]
  exec_or_fail(cmd, args, "cannot remove group '#{group_name}'")
end

#set_gidObject (private)


33
34
35
36
37
# File 'lib/wright/provider/group/gnu_passwd.rb', line 33

def set_gid
  cmd = 'groupmod'
  args = ['-g', gid.to_s, group_name]
  exec_or_fail(cmd, args, "cannot create group '#{group_name}'")
end

#set_membersObject (private)


27
28
29
30
31
# File 'lib/wright/provider/group/gnu_passwd.rb', line 27

def set_members
  cmd = 'gpasswd'
  args = ['-M', members.join(','), group_name]
  exec_or_fail(cmd, args, "cannot create group '#{group_name}'")
end