geerlingguy.ntp
Ansible Role: NTP
This role installs NTP (Network Time Protocol) on Linux systems.
Requirements
No specific requirements.
Role Variables
Here are the available variables and their default values (found in defaults/main.yml
):
ntp_enabled:
true
Controls whether to start the NTP service and enable it to run at system startup. For many virtual machines (VMs) inside a container, it's better not to run the NTP service, as time synchronization should be handled by the host system.ntp_timezone:
Etc/UTC
Sets the timezone for your server.ntp_package:
ntp
The package to install that provides NTP functionality. The default isntp
for most systems orchrony
for RHEL/CentOS 7 and newer.ntp_daemon: [various]
The standard NTP daemon for your system. You might need to change this if usingntp
on newer RHEL/CentOS versions.ntp_config_file:
/etc/ntp.conf
The path for the NTP configuration file. This is usually/etc/ntp.conf
, or/etc/chrony.conf
for RHEL/CentOS 7 and newer.ntp_manage_config:
false
Set totrue
to allow this role to manage the NTP configuration file.ntp_driftfile: [various]
Default NTP driftfile path; you may need to change this for your system.ntp_area:
''
Set the NTP Pool Area. Defaults to none, which uses the global pool.ntp_servers:
"0{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst"
"1{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst"
"2{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst"
"3{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst"
Specify the NTP servers to use. Only works ifntp_manage_config
is set toTrue
.
ntp_restrict:
"127.0.0.1"
"::1"
Restricts NTP access to only these hosts (loopback).
ntp_cron_handler_enabled:
false
Indicates whether to restart the cron service after changing the timezone.ntp_tinker_panic:
true
Enables tinker panic, which is helpful for NTP in a VM.
Dependencies
None.
Example Playbook
- hosts: all
roles:
- geerlingguy.ntp
Inside vars/main.yml
:
ntp_timezone: America/Chicago
License
MIT / BSD
Author Information
This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.
NTP installation and configuration for Linux.
ansible-galaxy install geerlingguy.ntp