Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Assert systemd-timesyncd status" task fails #5

Open
jantari opened this issue Dec 22, 2021 · 1 comment
Open

"Assert systemd-timesyncd status" task fails #5

jantari opened this issue Dec 22, 2021 · 1 comment

Comments

@jantari
Copy link

jantari commented Dec 22, 2021

I have noticed that the task "timesyncd : Assert systemd-timesyncd status" from

- name: Assert systemd-timesyncd status
fails on one of my hosts with the following error:

failed: [machine] (item={'regex': 'Started Network Time Synchronization', 'fail_msg': 'systemd-timesyncd does not appear to have started NTP Synchronization'}) => changed=false 
  ansible_loop_var: item
  assertion: timesyncd_status.stdout | regex_search("Started Network Time Synchronization")
  evaluated_to: false
  item:
    fail_msg: systemd-timesyncd does not appear to have started NTP Synchronization
    regex: Started Network Time Synchronization
  msg: systemd-timesyncd does not appear to have started NTP Synchronization

The output of sudo systemctl status systemd-timesyncd on the machine is:

● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-11-30 00:13:23 CET; 3 weeks 1 days ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 420 (systemd-timesyn)
     Status: "Initial synchronization to time server INTERNAL_IP:123 (INTERNAL_IP)."
      Tasks: 2 (limit: 4557)
     Memory: 1.3M
     CGroup: /system.slice/systemd-timesyncd.service
             └─420 /lib/systemd/systemd-timesyncd

Warning: journal has been rotated since unit was started, output may be incomplete.

everything is operating fine and yet the task asserts a failure. Perhaps it is not the most robust technique to try and regex-scrape the output of a shell command to try and look for logs of a service? I personally think this test can be removed.

@ArturFormella
Copy link

My workaround:

  pre_tasks:
    # https://github.com/shalomb/ansible-systemd-timesyncd/issues/5
    - name: Repair ansible-systemd-timesyncd
      ignore_errors: yes
      become: yes
      ansible.builtin.shell: |
        timedatectl set-ntp false
        timedatectl set-ntp true

 roles:
    - role: ansible-systemd-timesyncd
      become: yes
      config:
        ntp_servers:
          - ...
        timezone: '...'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants