From 1cb141c796c63ac95d6b8dac83a7180ed9302a7d Mon Sep 17 00:00:00 2001 From: "Adrien \"ze\" Urban" Date: Wed, 27 Oct 2021 12:49:51 +0000 Subject: [PATCH] refactor: config file formating Refactored space removal in configuration file. Now each block has: * starts with an empty line **IF** it has anything to state * no empty line within a block (of servers, pools, otherparams) --- chrony/files/default/chrony.conf.jinja | 36 ++++++++++++++------------ 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/chrony/files/default/chrony.conf.jinja b/chrony/files/default/chrony.conf.jinja index 8b34285..c0b1187 100644 --- a/chrony/files/default/chrony.conf.jinja +++ b/chrony/files/default/chrony.conf.jinja @@ -3,38 +3,40 @@ # Your changes will be overwritten. ######################################################################## -{%- if chrony.ntpservers is defined %} -{% for server in chrony.ntpservers -%} -{% if server is mapping %} +{%- if chrony.ntpservers is defined and chrony.ntpservers %} +{% for server in chrony.ntpservers %} +{%- if server is mapping %} server {{ server.name }} {{ server.options | default(chrony.options) }} -{% else %} +{%- else %} server {{ server }} {{ chrony.options }} -{% endif %} -{% endfor %} +{%- endif %} +{%- endfor %} {%- endif %} {%- if chrony.pool is defined %} -{% for pool in chrony.pool -%} -{% if pool is mapping %} +{% for pool in chrony.pool %} +{%- if pool is mapping %} pool {{ pool.name }} {{ pool.options | default(chrony.options) }} -{% else %} +{%- else %} pool {{ pool }} {{ chrony.options }} -{% endif %} -{% endfor %} -{% endif %} +{%- endif %} +{%- endfor %} +{%- endif %} keyfile {{ chrony.keyfile }} driftfile {{ chrony.driftfile }} -{% if chrony.allow is defined %} -{% for allowed in chrony.get('allow', {}) -%} +{%- if chrony.allow is defined %} +{% for allowed in chrony.get('allow', {}) %} allow {{ allowed }} -{% endfor %} +{%- endfor %} {%- endif %} logdir {{ chrony.logdir }} -{% for param in chrony.get('otherparams', {}) -%} +{%- if chrony.get('otherparams', {}) %} +{% for param in chrony.get('otherparams', {}) %} {{ param }} -{% endfor %} +{%- endfor %} +{%- endif %}