From c73037ce5c57ed6d75c160ceea3fd0859744aa55 Mon Sep 17 00:00:00 2001 From: mg Date: Sat, 15 Jan 2022 11:18:56 +0100 Subject: [PATCH] apt_sources: check ob >0 in template statt Task (#300) Co-authored-by: Michael Grote Reviewed-on: https://git.mgrote.net/mg/ansible/pulls/300 Co-authored-by: mg Co-committed-by: mg --- roles/mgrote.apt_manage_sources/tasks/main.yml | 6 +++--- roles/mgrote.apt_manage_sources/templates/apt.conf | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/roles/mgrote.apt_manage_sources/tasks/main.yml b/roles/mgrote.apt_manage_sources/tasks/main.yml index 8d5272f3..494ac87e 100644 --- a/roles/mgrote.apt_manage_sources/tasks/main.yml +++ b/roles/mgrote.apt_manage_sources/tasks/main.yml @@ -3,16 +3,16 @@ include_tasks: ubuntu.yml when: - ansible_distribution == 'Ubuntu' - - manage_sources_apt_proxy | length > 0 + - manage_sources_apt_proxy is defined - name: include Linux Mint tasks (determined by "ansible_distribution") include_tasks: mint.yml when: - ansible_distribution == 'Linux Mint' - - manage_sources_apt_proxy | length > 0 + - manage_sources_apt_proxy is defined - name: include proxmox tasks (determined by group) include_tasks: proxmox.yml when: - "'proxmox' in group_names" - - manage_sources_apt_proxy | length > 0 + - manage_sources_apt_proxy is defined diff --git a/roles/mgrote.apt_manage_sources/templates/apt.conf b/roles/mgrote.apt_manage_sources/templates/apt.conf index 495e5e87..7c98d3a5 100644 --- a/roles/mgrote.apt_manage_sources/templates/apt.conf +++ b/roles/mgrote.apt_manage_sources/templates/apt.conf @@ -1,3 +1,5 @@ {{ file_header | default () }} +{% if manage_sources_apt_proxy | length > 0 %} Acquire::http::proxy "http://{{ manage_sources_apt_proxy | default() }}"; Acquire::https::proxy "http://{{ manage_sources_apt_proxy | default() }}"; +{% endif %}