ricsanfre.ntp

Ansible 角色:NTP

CI

在 Linux 上安装和配置 NTP(chrony)。

要求

无。

角色变量

可用的变量如下所列,以及默认值(请参见 defaults\main.yaml

ntp_timezone: Europe/Madrid

设置服务器的时区。

ntp_daemon: chrony
ntp_package: chrony

NTP 包名称和守护进程。Ubuntu 的默认包是 chrony,ntp 已被弃用。

ntp_config_file: /etc/chrony/chrony.conf

NTP 服务配置文件的路径。

ntp_servers:

要使用的 NTP 服务器或池。

格式为字典列表,包含以下键:

  • server: 主机或池
  • type: (可选)默认为 server。映射到配置文件中的时间源。可以是 server、peer、pool 之一。
  • options: (可选)依赖于类型的选项列表,详情请参阅 Chrony 文档
ntp_servers:
  - server: ntp.ubuntu.org
    type: pool
    options:
      - option: iburst
      - option: maxsources
        val: 4
  - server: 0.ubuntu.pool.ntp.org
    type: pool
    options:
      - option: iburst
      - option: maxsources
        val: 1
  - server: 1.ubuntu.pool.ntp.org
    type: pool
    options:
      - option: iburst
      - option: maxsources
        val: 1
  - server: 2.ubuntu.pool.ntp.org
    type: pool
    options:
      - option: iburst
      - option: maxsources
        val: 2

ntp_allow_hosts: []

可选地指定允许连接到作为 NTP 服务器的机器的主机、子网或网络。

ntp_allow_hosts:
  - 10.0.0.0/24

依赖项

示例剧本

对于 NTP 服务器

- hosts: ntp-server
  roles:
    - role: ricsanfre.ntp
      ntp_servers:
        - server: ntp.ubuntu.org
          type: pool
          options:
            - option: iburst
            - option: maxsources
          val: 4
        - server: 0.ubuntu.pool.ntp.org
          type: pool
          options:
            - option: iburst
            - option: maxsources
          val: 1
        - server: 1.ubuntu.pool.ntp.org
          type: pool
          options:
            - option: iburst
            - option: maxsources
          val: 1
        - server: 2.ubuntu.pool.ntp.org
          type: pool
          options:
            - option: iburst
            - option: maxsources
          val: 2
      ntp_allow_hosts:
        - 10.0.0.0/24

对于 NTP 客户端

- hosts: ntp-client
  roles:
    - role: ricsanfre.ntp
      ntp_servers:
        - server: 10.0.0.1
          type: server
      ntp_allow_hosts: []

包含 vars/main.yaml

ntp_time_zone: Europe/Madrid

许可证

MIT/BSD

作者信息

Ricardo Sanchez (ricsanfre)

关于项目

NTP (chrony) installation and configuration role

安装
ansible-galaxy install ricsanfre.ntp
许可证
mit
下载
16.1k
拥有者
Telecom engineer.