diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-04 23:51:08 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-04 23:51:08 +0200 |
commit | bd3c4b37d43d51ce5b6f979664f82804c8c75df1 (patch) | |
tree | f97692b0d767d073b792116363503bb0829cb863 | |
parent | rename tasks (diff) | |
download | maintenance-bd3c4b37d43d51ce5b6f979664f82804c8c75df1.tar.gz maintenance-bd3c4b37d43d51ce5b6f979664f82804c8c75df1.zip |
roles: add rate_mirrors
-rw-r--r-- | roles/pacman/meta/main.yml | 1 | ||||
-rw-r--r-- | roles/rate_mirrors/meta/main.yml | 2 | ||||
-rw-r--r-- | roles/rate_mirrors/tasks/main.yml | 44 |
3 files changed, 47 insertions, 0 deletions
diff --git a/roles/pacman/meta/main.yml b/roles/pacman/meta/main.yml index 3d3d0a1..3a79dd0 100644 --- a/roles/pacman/meta/main.yml +++ b/roles/pacman/meta/main.yml @@ -1,3 +1,4 @@ dependencies: - role: common - role: etckeeper + - role: rate_mirrors diff --git a/roles/rate_mirrors/meta/main.yml b/roles/rate_mirrors/meta/main.yml new file mode 100644 index 0000000..cc61eb8 --- /dev/null +++ b/roles/rate_mirrors/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - role: etckeeper diff --git a/roles/rate_mirrors/tasks/main.yml b/roles/rate_mirrors/tasks/main.yml new file mode 100644 index 0000000..3334483 --- /dev/null +++ b/roles/rate_mirrors/tasks/main.yml @@ -0,0 +1,44 @@ +- name: Check if rate-mirrors is installed + command: rate-mirrors --version + register: rate_mirrors_version + changed_when: false + failed_when: false + +- when: rate_mirrors_version.rc == 0 + become: true + block: + - when: etc_versioned + block: + - name: Check for changes in /etc + command: git status --porcelain=v1 + args: + chdir: /etc + register: git_status + changed_when: false + failed_when: false + + - fail: + msg: There are uncommitted changes in /etc + when: git_status.stdout + + - name: Rate pacman mirrors + shell: | + . /etc/os-release && rate-mirrors --allow-root --disable-comments --save=/etc/pacman.d/mirrorlist "$ID" + + - when: etc_versioned + block: + - name: Check for changes in /etc + command: git status --porcelain=v1 + args: + chdir: /etc + register: git_status + changed_when: false + failed_when: false + + - fail: + msg: How did this happen? + when: git_status.stdout != ' M pacman.d/mirrorlist' + + - name: Commit changes in /etc/pacman.d/mirrorlist + command: | + etckeeper commit 'rate-mirrors' |