aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-09-13 16:25:21 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-09-13 16:25:21 +0200
commit29384509936abbd49cd0ff5af2350122cb3e1ec5 (patch)
tree3305af63355562d85a449582effd8f2527ca8ec3
parentapt: the extra packages are optional (diff)
downloadinfra-ansible-29384509936abbd49cd0ff5af2350122cb3e1ec5.tar.gz
infra-ansible-29384509936abbd49cd0ff5af2350122cb3e1ec5.zip
move rate_mirrors inside of pacman
-rw-r--r--roles/pacman/defaults/main.yml2
-rw-r--r--roles/pacman/tasks/main.yml19
-rw-r--r--roles/rate_mirrors/tasks/main.yml8
3 files changed, 21 insertions, 8 deletions
diff --git a/roles/pacman/defaults/main.yml b/roles/pacman/defaults/main.yml
index 85cf2fc..94033bb 100644
--- a/roles/pacman/defaults/main.yml
+++ b/roles/pacman/defaults/main.yml
@@ -1 +1,3 @@
+pacman_rate_mirrors: true
+
pacman_packages: []
diff --git a/roles/pacman/tasks/main.yml b/roles/pacman/tasks/main.yml
index dad1148..972fddf 100644
--- a/roles/pacman/tasks/main.yml
+++ b/roles/pacman/tasks/main.yml
@@ -1,3 +1,22 @@
+- name: Use rate-mirrors if available
+ when: pacman_rate_mirrors
+ block:
+ - name: Check for rate-mirrors
+ ansible.builtin.command: rate-mirrors --version
+ register: rate_mirrors_version
+ changed_when: false
+ failed_when: false
+
+ - name: Run rate-mirrors
+ when: rate_mirrors_version.rc == 0
+ become: true
+ ansible.builtin.shell: |
+ . /etc/os-release && rate-mirrors \
+ --allow-root \
+ --disable-comments \
+ --save /etc/pacman.d/mirrorlist \
+ "$ID"
+
- name: Upgrade packages
become: true
community.general.pacman:
diff --git a/roles/rate_mirrors/tasks/main.yml b/roles/rate_mirrors/tasks/main.yml
deleted file mode 100644
index 4d72a41..0000000
--- a/roles/rate_mirrors/tasks/main.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-- name: Rate pacman mirrors
- become: true
- ansible.builtin.shell: |
- . /etc/os-release && rate-mirrors \
- --allow-root \
- --disable-comments \
- --save /etc/pacman.d/mirrorlist \
- "$ID"