softbauware.ntp
Ansible 角色:NTP
在Linux上安装NTP。
需求
无。
角色变量
可用变量如下所列,并附有默认值(见defaults/main.yml
):
ntp_enabled: true
决定是否启动ntpd服务并在系统启动时启用。在许多运行在容器内的虚拟机(如OpenVZ或VirtualBox)上,建议不运行NTP守护进程,因为主机应该设置为为所有子虚拟机同步时间。
ntp_timezone: Etc/UTC
设置服务器的时区。
ntp_package: ntp
提供NTP功能的安装包。大多数平台的默认值是ntp
,对于RHEL/CentOS 7及更高版本则是chrony
。
ntp_daemon: [various]
默认的NTP守护进程应适合您的发行版,但有些情况下您可能想要覆盖默认设置,例如在更新版本的RHEL/CentOS上运行ntp
。
ntp_config_file: /etc/ntp.conf
NTP配置文件的路径。大多数平台的默认值是/etc/ntp.conf
,而在RHEL/CentOS 7及更高版本上则是/etc/chrony.conf
。
ntp_manage_config: false
设置为true以允许此角色管理NTP配置文件(/etc/ntp.conf
)。
ntp_driftfile: [various]
默认的NTP漂移文件应适合您的发行版,但有些情况下您可能想要覆盖默认设置。
ntp_area: ""
设置要使用的NTP池区域。默认为无,使用全球池。
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"
设置NTP配置文件中用于服务器的关键字。当DNS解析可用时,使用“pool”是个不错的选择,否则应使用“server”。
ntp_server_keyword: "pool"
指定您想要使用的NTP服务器。只有在将ntp_manage_config
设置为True
时,此设置才会生效。
ntp_restrict:
- "127.0.0.1"
- "::1"
限制NTP访问这些主机;默认为仅环回。
ntp_cron_handler_enabled: false
在时区更改后是否重启cron守护进程。
ntp_tinker_panic: true
启用tinker panic,这在虚拟机中运行NTP时非常有用。
依赖
无。
示例剧本
- hosts: all
roles:
- softbauware.ntp
_在vars/main.yml
中_:
ntp_timezone: America/Chicago
许可证
MIT / BSD
作者信息
此角色由Jeff Geerling于2014年创建,他是Ansible for DevOps的作者。