linux-system-roles / timesync

An ansible role which configures time synchronization
https://linux-system-roles.github.io/timesync/
MIT License
67 stars 43 forks source link

chrony.conf ubuntu crash #162

Closed MrOffline77 closed 4 months ago

MrOffline77 commented 1 year ago

The timesync role places the chrony.conf into /etc for each OS. Ubuntu (DEBIAN) expects the config in the /etc/chrony/ directory. Should be handled inside /tasks/main.yml as os specific variable.

- name: Generate chrony.conf file
  template:
    src: chrony.conf.j2
    dest: /etc/chrony.conf
    backup: true
    mode: 0644
  notify: restart {{ 'chronyd' if timesync_mode == 1 else 'timemaster' }}
  when:
    - timesync_mode != 2
    - timesync_ntp_provider == 'chrony'
    - "'chrony' in ansible_facts.packages"
richm commented 1 year ago

The directory should be set in a file in vars/ - we have a Debian file - https://github.com/linux-system-roles/timesync/blob/master/vars/Debian.yml - is it different than Ubuntu?

MrOffline77 commented 1 year ago

Ubuntu expects the chrony.conf as describe above in a different directory. The Path is hardcoded in the main.yml see template copy process I quoted above. Would be great if we could introduce an option to change the target path for the template within the debian vars file as you mentioned.

richm commented 1 year ago

Rather than add a "one-off" setting specifically for Ubuntu to tasks/main.yml, I would like to refactor the code to handle this case better:

We can then use this same approach for /etc/ntp.conf, /etc/ptp4l.conf, /etc/sysconfig/phc2sys, /etc/sysconfig/network, and any other platform differences.

One problem is that even though the code "supports" Debian, Ubuntu, etc., we have no CI testing on anything except RedHat os_family platforms, so we would have no way of knowing if the refactoring introduced any regressions.

Thulium-Drake commented 1 year ago

I have made a PR addressing the location #187 as the role didn't crash on Debian, but the configuration wasn't effectuated after running the role :sweat_smile:

That should fix this issue as well, as Ubuntu should match with os_family.