2016-09-22 12:43:57 +00:00
---
title: About the ntp_conf Resource
2018-02-16 00:28:15 +00:00
platform: linux
2016-09-22 12:43:57 +00:00
---
# ntp_conf
Use the `ntp_conf` InSpec audit resource to test the synchronization settings defined in the `ntp.conf` file. This file is typically located at `/etc/ntp.conf`.
2017-10-03 21:35:10 +00:00
<br>
2016-09-22 12:43:57 +00:00
2018-08-09 12:34:49 +00:00
## Availability
### Installation
This resource is distributed along with InSpec itself. You can use it automatically.
### Version
This resource first became available in v1.0.0 of InSpec.
2016-09-27 19:03:23 +00:00
## Syntax
2016-09-22 12:43:57 +00:00
An `ntp_conf` resource block declares the synchronization settings that should be tested:
describe ntp_conf('path') do
its('setting_name') { should eq 'value' }
end
where
* `'setting_name'` is a synchronization setting defined in the `ntp.conf` file
* `('path')` is the non-default path to the `ntp.conf` file
* `{ should eq 'value' }` is the value that is expected
2017-10-03 21:35:10 +00:00
<br>
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
## Examples
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
The following examples show how to use this InSpec audit resource.
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### Test for clock drift against named servers
2016-09-22 12:43:57 +00:00
describe ntp_conf do
2017-10-03 21:35:10 +00:00
its('driftfile') { should eq '/var/lib/ntp/ntp.drift' }
its('server') { should eq [
0.ubuntu.pool.ntp.org,
1.ubuntu.pool.ntp.org,
2.ubuntu.pool.ntp.org
] }
2016-09-22 12:43:57 +00:00
end
2017-10-03 21:35:10 +00:00
<br>
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
## Matchers
2016-09-22 12:43:57 +00:00
2018-02-16 03:07:18 +00:00
This resource matches any service that is listed in the `ntp.conf` file. For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
its('server') { should_not eq nil }
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
or:
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
its('restrict') { should include '-4 default kod notrap nomodify nopeer noquery'}
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
For example:
2016-09-22 12:43:57 +00:00
describe ntp_conf do
2017-10-03 21:35:10 +00:00
its('server') { should_not eq nil }
its('restrict') { should include '-4 default kod notrap nomodify nopeer noquery'}
2016-09-22 12:43:57 +00:00
end