configure-mirrors: fix stripped newline

I74b9de7092f182c942a58ac7a46b9fbd791889de hit a common ansible gotcha
where it likes to strip the trailing newline after a {% endif %}.
This has resulted in invalid lines in our sources.list.

Unfortunately we miss this because it still exits with 0.  Add a
simple test looking for warning output.

Change-Id: I46d393a5e67d10a52c4dcca803176ff368a4b5bd
This commit is contained in:
Ian Wienand 2022-03-01 10:51:15 +11:00
parent e160f59e0e
commit c20a2435a6
2 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,4 @@
#jinja2: trim_blocks:False
# {{ ansible_managed }}
deb {% if set_apt_mirrors_trusted %}[ trusted=yes ] {% endif %}{{ package_mirror }} {{ ansible_distribution_release }} main universe
deb {% if set_apt_mirrors_trusted %}[ trusted=yes ] {% endif %}{{ package_mirror }} {{ ansible_distribution_release }}-updates main universe

View File

@ -37,3 +37,19 @@
name: "{{ emacs_package | default('emacs') }}"
state: "present"
become: yes
- name: Ensure no apt warnings
hosts: all
tasks:
- name: Check apt output
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
block:
- name: Run apt-get update
command: 'apt-get update'
register: _apt_get_output
become: yes
- name: Check for warnings in output
fail:
msg: 'Warnings found in apt output'
when: _apt_get_output is regex('^W:.*$')