Pool and server configuration may have different options but it's not currently possible. In order to solve that, the template is changed to accept pool or server specification as a dictionnary, specifying at least the pool/server name and if wanted the pool/server options. If no options are specified, it'll use chrony.options. In order to not break anything the template is checking if the server/pool specification is a dictionnary or not, and acts accordingly. Fixes: #27 Signed-off-by: Arnaud Patard <apatard@hupstream.com>tags/v1.3.0
{%- if chrony.ntpservers is defined %} | {%- if chrony.ntpservers is defined %} | ||||
{% for server in chrony.ntpservers -%} | {% for server in chrony.ntpservers -%} | ||||
{% if server is mapping %} | |||||
server {{ server.name }} {{ server.options | default(chrony.options) }} | |||||
{% else %} | |||||
server {{ server }} {{ chrony.options }} | server {{ server }} {{ chrony.options }} | ||||
{% endif %} | |||||
{% endfor %} | {% endfor %} | ||||
{%- endif %} | {%- endif %} | ||||
{%- if chrony.pool is defined %} | {%- if chrony.pool is defined %} | ||||
{% for pool in chrony.pool -%} | {% for pool in chrony.pool -%} | ||||
{% if pool is mapping %} | |||||
pool {{ pool.name }} {{ pool.options | default(chrony.options) }} | |||||
{% else %} | |||||
pool {{ pool }} {{ chrony.options }} | pool {{ pool }} {{ chrony.options }} | ||||
{% endif %} | |||||
{% endfor %} | {% endfor %} | ||||
{% endif %} | {% endif %} | ||||
--- | --- | ||||
chrony: | chrony: | ||||
ntpservers: | ntpservers: | ||||
- '0.debian.pool.ntp.org' | |||||
- '1.centos.pool.ntp.org' | |||||
- name: '0.debian.pool.ntp.org' | |||||
options: iburst | |||||
- name: '1.centos.pool.ntp.org' | |||||
- '2.arch.pool.ntp.org' | - '2.arch.pool.ntp.org' | ||||
- '3.gentoo.pool.ntp.org' | - '3.gentoo.pool.ntp.org' | ||||
pool: | pool: | ||||
- '0.debian.pool.ntp.org' | |||||
- '1.centos.pool.ntp.org' | |||||
- name: '0.debian.pool.ntp.org' | |||||
options: iburst | |||||
- name: '1.centos.pool.ntp.org' | |||||
- '2.arch.pool.ntp.org' | - '2.arch.pool.ntp.org' | ||||
- '3.gentoo.pool.ntp.org' | - '3.gentoo.pool.ntp.org' | ||||
allow: | allow: |
its('content') { should include keyfile } | its('content') { should include keyfile } | ||||
its('content') { should include driftfile } | its('content') { should include driftfile } | ||||
its('content') { should include logdir } | its('content') { should include logdir } | ||||
its('content') { should include 'server 0.debian.pool.ntp.org iburst' } | |||||
its('content') { should include 'server 1.centos.pool.ntp.org' } | |||||
its('content') { should include 'pool 0.debian.pool.ntp.org iburst' } | |||||
its('content') { should include 'pool 1.centos.pool.ntp.org' } | |||||
end | end | ||||
end | end |