aboutsummaryrefslogtreecommitdiff
path: root/roles/host/tasks/patching.yml
blob: 90f8e33e504e4d86bc27652a4b33cd759bb9f490 (plain)
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
42
43
44
- name: Block for dnf
  block:
    - name: Install dnf-automatic
      ansible.builtin.package:
        name: "dnf-automatic"
        state: "present"

    - name: Configure /etc/dnf/automatic.conf for reboot
      ansible.builtin.lineinfile:
        path: "/etc/dnf/automatic.conf"
        search_string: "reboot = "
        line: "reboot = {{ host_patching_reboot }}"

    - name: Enable and start dnf-automatic-install.timer
      ansible.builtin.systemd:
        name: "dnf-automatic-install.timer"
        enabled: true
        state: "started"
  when:
    - ansible_pkg_mgr == "dnf"

- name: Block for dnf5
  block:
    - name: Install dnf5-plugin-automatic
      ansible.builtin.package:
        name: "dnf5-plugin-automatic"
        state: "present"

    - name: Configure /etc/dnf/automatic.conf for reboot
      ansible.builtin.blockinfile:
        path: "/etc/dnf/automatic.conf"
        create: true
        block: |
          [commands]
          apply_updates = yes
          reboot = {{ host_patching_reboot }}

    - name: Enable and start dnf5-automatic.timer
      ansible.builtin.systemd:
        name: "dnf5-automatic.timer"
        enabled: true
        state: "started"
  when:
     - ansible_pkg_mgr == "dnf5"