ricsanfre.ntp

Ansible Role: NTP

CI

This role installs and sets up NTP (chrony) on Linux.

Requirements

None.

Role Variables

Below are the available variables with their default values (check defaults\main.yaml):

  • ntp_timezone: Europe/Madrid
    This sets the server's timezone.

  • ntp_daemon: chrony

    • ntp_package: chrony
      This specifies the NTP package and daemon. For Ubuntu, the default package is chrony because ntp is outdated.
  • ntp_config_file: /etc/chrony/chrony.conf
    This is the path to the NTP service configuration file.

  • ntp_servers:
    This defines the NTP servers or pools to be used. Use this format, which is a list of dictionaries:

    • server: the host or pool name
    • type: (Optional) Defaults to server. It refers to a time source in the config file. Possible values: server, peer, pool.
    • options: (Optional) A list of options based on the type. Check the Chrony documentation for more details.

    Example:

    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: []
    This is an optional list where you can specify a host, subnet, or network allowed to connect to the NTP server.

    Example:

    ntp_allow_hosts:
      - 10.0.0.0/24
    

Dependencies

None.

Example Playbook

For NTP server:

- 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

For NTP Client:

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

Include vars/main.yaml:

ntp_time_zone: Europe/Madrid

License

MIT/BSD

Author Information

Ricardo Sanchez (ricsanfre)

Informazioni sul progetto

NTP (chrony) installation and configuration role

Installa
ansible-galaxy install ricsanfre.ntp
Licenza
mit
Download
16.7k
Proprietario
Telecom engineer.