From c20a2435a618d004352f682e24ff888234fbfa99 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 1 Mar 2022 10:51:15 +1100 Subject: [PATCH] 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 --- .../templates/apt/etc/apt/sources.list.j2 | 1 + test-playbooks/base-roles/configure-mirrors.yaml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/roles/configure-mirrors/templates/apt/etc/apt/sources.list.j2 b/roles/configure-mirrors/templates/apt/etc/apt/sources.list.j2 index 2d6444aaa..de4073d58 100644 --- a/roles/configure-mirrors/templates/apt/etc/apt/sources.list.j2 +++ b/roles/configure-mirrors/templates/apt/etc/apt/sources.list.j2 @@ -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 diff --git a/test-playbooks/base-roles/configure-mirrors.yaml b/test-playbooks/base-roles/configure-mirrors.yaml index 114ad5a2d..cd26a9562 100644 --- a/test-playbooks/base-roles/configure-mirrors.yaml +++ b/test-playbooks/base-roles/configure-mirrors.yaml @@ -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:.*$')