debian.yml 1.79 KB
Newer Older
Bengt Giger's avatar
Bengt Giger committed
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
- name: Read currently excluded packages
  command: apt-mark showhold
  register: showhold_output
  changed_when: false

- name: Store excluded packages
  set_fact:
    pkgs_excluded_current: "{{ showhold_output.stdout.split('\n') }} "

- name: Determine new packages
  set_fact:
    pkgs_excluded_new: "{{ system_update_manager_excluded | difference(pkgs_excluded_current) }}"

- name: Determine obsolete packages
  set_fact:
    pkgs_excluded_obsolete: "{{ pkgs_excluded_current | difference(system_update_manager_excluded) }}"

- name: Update excluded packages
  block:

    - name: Update apt cache
      apt:
        update_cache: true

    - name: Unhold all packages
      command: "apt-mark unhold {{ pkgs_excluded_current | join(' ') }}"
      when: pkgs_excluded_current != [""]

    - name: Exclude configured packages from updates
      command: "apt-mark hold {{ system_update_manager_excluded | join(' ') }}"
      when: system_update_manager_excluded != []

  when: pkgs_excluded_obsolete != [] or pkgs_excluded_new != []

- name: Run full update
  block:

    - name: Update apt cache
      apt:
        update_cache: true
        force_apt_get: true
        cache_valid_time: 60

    - name: Exclude Ansible from system update
      command: "apt-mark hold ansible"

    - name: Update system
      apt:
        upgrade: dist
        force_apt_get: true

    - name: Restore original excludes
      command: "apt-mark unhold ansible"

    - name: Check if reboot is required
      stat:
        path: /var/run/reboot-required
        get_md5: false
      register: reboot_required_file
      changed_when: false

Bengt Giger's avatar
Bengt Giger committed
63
64
    - name: Set flag if system needs a reboot
      set_fact:
Bengt Giger's avatar
Bengt Giger committed
65
        update_manager_reboot_required: true
66
      when: reboot_required_file.stat.exists
Bengt Giger's avatar
Bengt Giger committed
67

68
  when: system_update_manager_forceupdate