geerlingguy.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: [各种]
默认的 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: [各种]
默认的 NTP driftfile 应该适合你的发行版,但在某些情况下,你可能想要覆盖默认设置。
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 服务器。仅在允许此角色管理 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:
- geerlingguy.ntp
在 vars/main.yml
中:
ntp_timezone: America/Chicago
许可证
MIT / BSD
作者信息
此角色由 Jeff Geerling 于 2014 年创建,他是 Ansible for DevOps 的作者。
关于项目
NTP installation and configuration for Linux.
安装
ansible-galaxy install geerlingguy.ntp
许可证
mit
下载
6.4M
拥有者
Father, author, developer, maker. Sometimes called "an inflammatory enigma". #stl #drupal #ansible #k8s #raspberrypi #crohns