Kanrisuru

get_group

Gets a group in ruby
linux manual

Basic Usage

require 'kanrisuru'
host = Kanrisuru::Remote::Host.new(host: '127.0.1.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])

result = host.get_group('ubuntu')
result.success?
true

result.gid
1000

result.name
'ubuntu'

Parameters

Field Type Description
group string
integer
Required name / gid of the group to get.

Result

Returns a single Group struct.

Group Fields

Field Type Description
gid integer The numerical value of the group's ID.
name string The name of the group.
users array Array of users that belong to the group.

Return Example

host.get_group(1000).data
#<Struct:Kanrisuru::Core::Group::Group:0x00000730
  gid = 1000,
  name = "ubuntu",
  users = [
    [0] #<Struct:Kanrisuru::Core::Group::GroupUser:0x000007a8
      name = 'ubuntu',
      uid = 1000
    >,
    [1] #<Struct:Kanrisuru::Core::Group::GroupUser:0x000007c8
      name = "www-data",
      uid = 33
    >,
    [2] #<Struct:Kanrisuru::Core::Group::GroupUser:0x000007f8
      name = "rails",
      uid = 1002
    >
  ]
>

Exit Status

Code Description
0 Success
1 Missing arguments, or database unknown.
2 One or more supplied key could not be found in the database.
3 Enumeration not supported on this database.

Tested On

  • Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES