aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roles/pacman/tasks/main.yml
blob: 972fddfab9455637d84d02c29cbcb0e593067b87 (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
- 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:
    update_cache: true
    upgrade: true
  register: pacman_result
  notify: pacman_upgraded

- name: Reboot if necessary
  ansible.builtin.meta: flush_handlers

- name: Install packages
  become: true
  community.general.pacman:
    name: '{{ pacman_packages }}'
    state: present
  when: pacman_packages | length > 0