From 16813d8e24f90f1e86fb0cb3cf3a63574beea99d Mon Sep 17 00:00:00 2001 From: Brett Eisenberg Date: Tue, 17 Sep 2024 13:06:02 -0700 Subject: [PATCH] allow mirror update to optionally limit sources by country --- group_vars/all | 1 + roles/mirrorlist/tasks/main.yml | 4 ++-- .../reflector-update.sh => templates/reflector-update.sh.j2} | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) rename roles/mirrorlist/{files/reflector-update.sh => templates/reflector-update.sh.j2} (66%) diff --git a/group_vars/all b/group_vars/all index c9c1d07..e7ed863 100644 --- a/group_vars/all +++ b/group_vars/all @@ -323,6 +323,7 @@ kdeconnect: mirrorlist: run_on: trusted + country: US units: run_on: trusted diff --git a/roles/mirrorlist/tasks/main.yml b/roles/mirrorlist/tasks/main.yml index b13de23..3b863c8 100644 --- a/roles/mirrorlist/tasks/main.yml +++ b/roles/mirrorlist/tasks/main.yml @@ -5,8 +5,8 @@ state: present - name: Push reflector update script - copy: - src: reflector-update.sh + template: + src: reflector-update.sh.j2 dest: /usr/local/bin/reflector-update mode: 0755 diff --git a/roles/mirrorlist/files/reflector-update.sh b/roles/mirrorlist/templates/reflector-update.sh.j2 similarity index 66% rename from roles/mirrorlist/files/reflector-update.sh rename to roles/mirrorlist/templates/reflector-update.sh.j2 index 7d0be48..99a6654 100644 --- a/roles/mirrorlist/files/reflector-update.sh +++ b/roles/mirrorlist/templates/reflector-update.sh.j2 @@ -1,6 +1,9 @@ #!/bin/bash - +# {{ ansible_managed} +# /usr/bin/reflector --latest 20 \ + {% if mirrorlist.country %}--country {{ mirrorlist.country }} \ + {% endif %} --sort rate \ --protocol https \ --save /etc/pacman.d/mirrorlist