inspec/docs/resources/group.md.erb

75 lines
1.3 KiB
Text
Raw Normal View History

2016-09-22 12:43:57 +00:00
---
title: About the group Resource
---
# group
Use the `group` InSpec audit resource to test groups on the system.
## Syntax
2016-09-22 12:43:57 +00:00
A `group` resource block declares a group, and then the details to be tested, such as if the group is a local group, the group identifier, or if the group exists:
describe group('group_name') do
it { should exist }
its('gid') { should eq 0 }
end
where
* `'group_name'` must specify the name of a group on the system
* `exist` and `'gid'` are valid matchers for this resource
## Matchers
2016-09-22 12:43:57 +00:00
This InSpec audit resource has the following matchers:
### be
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_be" %>
### be_local
2016-09-22 12:43:57 +00:00
The `be_local` matcher tests if the group is a local group:
it { should be_local }
### cmp
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_cmp" %>
### eq
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_eq" %>
### exist
2016-09-22 12:43:57 +00:00
The `exist` matcher tests if the named user exists:
it { should exist }
### gid
2016-09-22 12:43:57 +00:00
The `gid` matcher tests the named group identifier:
its('gid') { should eq 1234 }
### include
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_include" %>
### match
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_match" %>
## Examples
2016-09-22 12:43:57 +00:00
The following examples show how to use this InSpec audit resource.
### Test the group identifier for the root group
2016-09-22 12:43:57 +00:00
describe group('root') do
it { should exist }
its('gid') { should eq 0 }
end