From 5c6cf6764eba44c95244df037d8cae2e3ff6e6cd Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sun, 10 Apr 2022 17:38:37 +0200 Subject: [PATCH] cleanup --- defaults/main.yml | 2 +- handlers/main.yml | 2 +- molecule/rocky8/tests/test_default.py | 9 +++------ tasks/setup.yml | 1 + templates/etc/chrony.conf.j2 | 27 ++------------------------- 5 files changed, 8 insertions(+), 33 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index bd73f94..7f01ab6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,7 +7,7 @@ chrony_conf_file: /etc/chrony/chrony.conf chrony_key_file: /etc/chrony/chrony.keys chrony_drift_file: /var/lib/chrony/drift -# chrony_pool: $ "_unset_" +# @var chrony_pool:default: $ "_unset_" chrony_server: "169.254.169.123 prefer iburst" chrony_log: "tracking measurements statistics" diff --git a/handlers/main.yml b/handlers/main.yml index 3d3285b..7e8890d 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,7 +1,7 @@ --- - name: Restart service systemd: - name: chrony.service + name: chronyd.service state: restarted daemon_reload: True enabled: True diff --git a/molecule/rocky8/tests/test_default.py b/molecule/rocky8/tests/test_default.py index eb51688..baabcf8 100644 --- a/molecule/rocky8/tests/test_default.py +++ b/molecule/rocky8/tests/test_default.py @@ -8,9 +8,6 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( def test_chrony_running_and_enabled(host): - command = "XDG_RUNTIME_DIR=/run/user/$(id -u) systemctl --user is-enabled chrony.service" - - with host.sudo(user="chrony"): - status = host.check_output(command) - - assert status == "enabled" + chrony = host.service("chronyd") + assert chrony.is_running + assert chrony.is_enabled diff --git a/tasks/setup.yml b/tasks/setup.yml index bf4bed7..a93bfe9 100644 --- a/tasks/setup.yml +++ b/tasks/setup.yml @@ -9,6 +9,7 @@ template: src: etc/chrony.conf.j2 dest: /etc/chrony.conf + mode: 0644 notify: __chrony_restart - name: Ensure service is up and running diff --git a/templates/etc/chrony.conf.j2 b/templates/etc/chrony.conf.j2 index 4659af6..30bd0d1 100644 --- a/templates/etc/chrony.conf.j2 +++ b/templates/etc/chrony.conf.j2 @@ -2,7 +2,9 @@ port {{ chrony_port }} acquisitionport {{ chrony_acquisitionport }} +{% if chrony_pool is defined %} pool {{ chrony_pool }} +{% endif %} server {{ chrony_server }} keyfile {{ chrony_key_file }} @@ -13,44 +15,19 @@ log {{ chrony_log }} logdir {{ chrony_log_dir }} maxupdateskew {{ chrony_maxupdateskew }} dumponexit -# Specify directory for dumping measurements. - dumpdir {{ chrony_dump_dir }} {% if chrony_initstepslew_enabled | bool %} initstepslew {{ chrony_initstepslew_threshold }} {{ chrony_initstepslew_servers }} {% endif %} -# This directive lets 'chronyd' to serve time even if unsynchronised to any -# NTP server. - -#local stratum 10 - {% if chrony_allow | length > 0 %} -# This directive designates subnets (or nodes) from which NTP clients are allowed -# to access to 'chronyd'. {% for block in chrony_allow %} allow {{ block }} {% endfor %} {% endif %} -# This directive forces `chronyd' to send a message to syslog if it -# makes a system clock adjustment larger than a threshold value in seconds. - logchange 0.5 -# This directive defines an email address to which mail should be sent -# if chronyd applies a correction exceeding a particular threshold to the -# system clock. - -# mailonchange root@localhost 0.5 - -# This directive tells 'chronyd' to parse the 'adjtime' file to find out if the -# real-time clock keeps local time or UTC. It overrides the 'rtconutc' directive. - hwclockfile /etc/adjtime - -# This directive enables kernel synchronisation (every 11 minutes) of the -# real-time clock. Note that it can't be used along with the 'rtcfile' directive. - rtcsync