create_group
Create 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'])
host.su('root')
result = host.create_group('kanrisuru', gid: 1003)
result.success?
true
result.group
'kanrisuru'
result.gid
1003
Parameters
Field |
Type |
Description |
group |
string
|
Required name of the group to create. |
gid |
integer
|
The numerical value of the group's ID. This value must be unique unless the non_unique option is present. |
non_unique |
boolean
|
This option permits to add a group with a non-unique GID. |
system |
boolean
|
Create a system group. |
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. |
Return Example
host.su('root')
host.create_group('admin', gid: 55, system: true).data
#<Struct:Kanrisuru::Core::Group::Group:0x00000690
gid = 55,
name = "admin",
users = nil
>
Exit Status
Code |
Description |
0 |
Success |
2 |
Invalid command syntax |
3 |
Invalid argument to option |
4 |
GID is already used (when called without -o) |
9 |
Group name is already used |
10 |
Can't update group file |
Tested On
- Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES