inspec/docs/resources/systemd_service.md.erb

77 lines
1.6 KiB
Text
Raw Normal View History

2016-09-22 12:43:57 +00:00
---
title: About the systemd_service Resource
---
# systemd_service
Use the `systemd_service` InSpec audit resource to test a service using SystemD.
## Syntax
2016-09-22 12:43:57 +00:00
A `systemd_service` resource block declares the name of a service and then one (or more) matchers to test the state of the service:
describe systemd_service('service_name') do
it { should be_installed }
it { should be_enabled }
it { should be_running }
end
where
* `('service_name')` must specify a service name
* `be_installed`, `be_enabled`, and `be_running` are valid matchers for this resource; all matchers available to the `service` resource may be used
The path to the service manager's control may be specified for situations where the path isn't available in the current `PATH`. For example:
describe systemd_service('service_name', '/path/to/control') do
it { should be_enabled }
it { should be_installed }
it { should be_running }
end
## 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_enabled
2016-09-22 12:43:57 +00:00
The `be_enabled` matcher tests if the named service is enabled:
it { should be_enabled }
### be_installed
2016-09-22 12:43:57 +00:00
The `be_installed` matcher tests if the named service is installed:
it { should be_installed }
### be_running
2016-09-22 12:43:57 +00:00
The `be_running` matcher tests if the named service is running:
it { should be_running }
### 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" %>
### 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
None.