diff --git a/tasks/main.yaml b/tasks/main.yaml index 2cb78c2e6b9703595e5d3e27c2b372d0c042f3d7..c3c6348780c0c310bdb49673ec0ae31f7467c01f 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -29,6 +29,15 @@ register: _ntp__installed become: true +- name: Get version of the installed NTP package + shell: "ntpd --version 2>&1 | head -n 1 | cut -d' ' -f2 | cut -d'@' -f1" + register: _ntp__version + changed_when: false +- set_fact: + _ntp__version: '{{ _ntp__version.stdout }}' +#- debug: +# var: _ntp__version + - name: Generate the NTP configuration file template: src: '{{ role_path }}/templates/ntp.conf.j2' diff --git a/templates/ntp.conf.j2 b/templates/ntp.conf.j2 index 647215084d77ecd71fc17c952ecb9e81a26b3cb0..5bb649445c8f74989df54f03c366d24766ec796f 100644 --- a/templates/ntp.conf.j2 +++ b/templates/ntp.conf.j2 @@ -31,8 +31,10 @@ restrict -6 default ignore restrict {{ restriction }} {% endfor %} +{% if _ntp__version is version_compare('4.2.7p22', '>=') %} # Needed for adding pool entries restrict source notrap nomodify noquery +{% endif %} # Add the ntp servers. You generally don't need these if you're using a pool. # server 0.pool.ntp.org iburst