aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roles/rate_mirrors/tasks/main.yml
blob: 8777fbd7649101a8d0fd8c10950dafbf6e798f5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
- 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'