From b3fc136cc3249078ed1ea23582d6a21b88fe0718 Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Wed, 3 Sep 2025 11:45:10 +0200 Subject: [PATCH 1/2] Added support for server directives Signed-off-by: Martin Pecka --- README.md | 5 +++++ defaults/main.yml | 3 +++ templates/chrony.conf.j2 | 3 +++ templates/ntp.conf.j2 | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 60ed8d3..720556d 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,11 @@ Set the [NTP Pool Area](http://support.ntp.org/bin/view/Servers/NTPPoolServers) - "2{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst" - "3{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst" +Set the non-pool NTP servers to use. Defaults to none. + + ntp_servers_no_pool: + - "ntp.ubuntu.com" + Specify the NTP servers you'd like to use. Only takes effect if you allow this role to manage NTP's configuration, by setting `ntp_manage_config` to `True`. ntp_restrict: diff --git a/defaults/main.yml b/defaults/main.yml index 4c1fd82..7952cd3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,6 +18,9 @@ ntp_servers: - "2{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst" - "3{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst" +# Single (non-pooled) NTP servers +ntp_servers_no_pool: [] + ntp_restrict: - "127.0.0.1" - "::1" diff --git a/templates/chrony.conf.j2 b/templates/chrony.conf.j2 index 4d80b94..5b83f60 100644 --- a/templates/chrony.conf.j2 +++ b/templates/chrony.conf.j2 @@ -4,6 +4,9 @@ {% for server in ntp_servers %} server {{ server }} {% endfor %} +{% for server in ntp_servers_non_pool %} +server {{ server }} +{% endfor %} # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). diff --git a/templates/ntp.conf.j2 b/templates/ntp.conf.j2 index ddaa6f3..5d61e3b 100644 --- a/templates/ntp.conf.j2 +++ b/templates/ntp.conf.j2 @@ -26,6 +26,10 @@ tinker panic 0 pool {{ item }} {% endfor %} +{% for item in ntp_servers_non_pool %} +server {{ item }} +{% endfor %} + # Permit time synchronization with our time source, but do not # permit the source to query or modify the service on this system. restrict default nomodify notrap nopeer noquery From 1c79d8e65def8343d996b3616178279e66a3fab7 Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Wed, 3 Sep 2025 11:47:46 +0200 Subject: [PATCH 2/2] Fixed typos. Signed-off-by: Martin Pecka --- README.md | 2 +- defaults/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 720556d..583e9ce 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Set the [NTP Pool Area](http://support.ntp.org/bin/view/Servers/NTPPoolServers) Set the non-pool NTP servers to use. Defaults to none. - ntp_servers_no_pool: + ntp_servers_non_pool: - "ntp.ubuntu.com" Specify the NTP servers you'd like to use. Only takes effect if you allow this role to manage NTP's configuration, by setting `ntp_manage_config` to `True`. diff --git a/defaults/main.yml b/defaults/main.yml index 7952cd3..02dbe21 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,7 +19,7 @@ ntp_servers: - "3{{ '.' + ntp_area if ntp_area else '' }}.pool.ntp.org iburst" # Single (non-pooled) NTP servers -ntp_servers_no_pool: [] +ntp_servers_non_pool: [] ntp_restrict: - "127.0.0.1"