jnv / ansible-role-unattended-upgrades

[DEPRECATED] Setup unattended-upgrades on Debian-based systems
https://github.com/jnv/ansible-role-unattended-upgrades/issues/98
GNU General Public License v2.0
272 stars 94 forks source link

Suppress blank template lines #83

Closed kousu closed 2 years ago

kousu commented 3 years ago

My /etc/apt/apt.conf.d/50unattended-upgrades are coming out with an extra 5 trailing lines that are distracting.

Maybe this is better handled with https://jinja.palletsprojects.com/en/master/templates/#whitespace-control but I don't understand how to use that.

jnv commented 3 years ago

Hi @kousu, thanks for the suggestion but I wouldn't like to sacrifice readability for such (in my opinion) minor aesthetic issue. However, I think using an explicit whitespace control you mentioned could be a good way to approach it. Perhaps something like that:

{%- if unattended_download_upgradeable is defined -%}
APT::Periodic::Download-Upgradeable-Packages "{{unattended_download_upgradeable}}";
{%- endif %}

According to this answer templates also accept special control statements like: #jinja2: lstrip_blocks: True, so try if that works for you.

I will turn this PR into a draft, feel free to republish it once you make adjustments.

jnv commented 2 years ago

I am closing this PR since this role has been deprecated. Feel free to suggest alternatives in #98.