Skip to content

Commit 76c9300

Browse files
authored
Merge pull request #286 from Linuxfabrik/fix/apt-cache-refresh-before-upgrade
fix(roles): refresh apt cache before upgrade on Debian
2 parents 2316c19 + cb05c64 commit 76c9300

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4747

4848
### Fixed
4949

50+
* **role:php**: The `php:update` tag now refreshes the apt cache before the upgrade on Debian-family hosts, so it reliably installs the latest packages (e.g. to roll out security updates) instead of running against a stale cache. RHEL-family hosts are unaffected, since dnf refreshes its metadata on its own.
51+
* **role:monitoring_plugins**: The role now refreshes the apt cache before installing the monitoring-plugins package on Debian-family hosts, so it reliably installs the latest version (e.g. to roll out security updates) instead of running against a stale cache. RHEL-family hosts are unaffected, since dnf refreshes its metadata on its own.
52+
* **role:mariadb_server**: The `mariadb_server:upgrade` tag now refreshes the apt cache before the upgrade on Debian-family hosts, so it reliably installs the latest packages (e.g. to roll out security updates) instead of running against a stale cache. RHEL-family hosts are unaffected, since dnf refreshes its metadata on its own.
5053
* **role:system_update**: The update and security-update jobs no longer send a failure mail when a mirror hiccups briefly (e.g. Rocky's mirrorlist intermittently returning "No URLs in mirrorlist"). Repository metadata is now refreshed with a few retries before updates are applied, so short-lived upstream outages are ridden out instead of paging you.
5154
* **role:monitoring_plugins, role:mod_maxminddb**: The role no longer aborts at start with an `undefined` error demanding a variable that has an OS-specific default (`monitoring_plugins__icinga_user` respectively `mod_maxminddb__apache_conf_modules_d`). The role now derives the default on its own again, so there is no need to set the variable in the inventory.
5255
* **role:monitoring_plugins**: A source install no longer aborts on RHEL 8. The role used to fail because the system Python 3.6 is older than the required 3.9; it now installs and uses Python 3.9 automatically.

roles/mariadb_server/tasks/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@
4242
- 'mariadb-server'
4343
state: 'absent'
4444

45+
# refresh the apt cache so the following `state: latest` upgrade resolves
46+
# against current metadata, e.g. to roll out security updates. apt does not
47+
# auto-expire its cache the way dnf does, so without this the upgrade can
48+
# silently run against a stale cache and miss newer versions.
49+
- name: 'apt update # update the cache'
50+
ansible.builtin.apt:
51+
update_cache: true
52+
changed_when: false # refreshing the package cache is not a config change
53+
when: 'ansible_facts["os_family"] == "Debian"'
54+
4555
- name: 'Install latest mariadb-server' # noqa package-latest (latest is necessary for upgrade)
4656
ansible.builtin.package:
4757
name:

roles/monitoring_plugins/tasks/linux-package.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121

2222
- block:
2323

24+
# refresh the apt cache so the following `state: latest` upgrade resolves
25+
# against current metadata, e.g. to roll out security updates. apt does not
26+
# auto-expire its cache the way dnf does, so without this the upgrade can
27+
# silently run against a stale cache and miss newer versions.
28+
- name: 'apt update # update the cache'
29+
ansible.builtin.apt:
30+
update_cache: true
31+
changed_when: false # refreshing the package cache is not a config change
32+
when: 'ansible_facts["os_family"] == "Debian"'
33+
2434
- name: 'install linuxfabrik-monitoring-plugins{{ __monitoring_plugins__package_version_separator }}{{ monitoring_plugins__version }}*' # noqa package-latest
2535
ansible.builtin.package:
2636
name:

roles/php/tasks/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727

2828
- block:
2929

30+
# refresh the apt cache so the following `state: latest` upgrade resolves
31+
# against current metadata, e.g. to roll out security updates. apt does not
32+
# auto-expire its cache the way dnf does, so without this the upgrade can
33+
# silently run against a stale cache and miss newer versions.
34+
- name: 'apt update # update the cache'
35+
ansible.builtin.apt:
36+
update_cache: true
37+
changed_when: false # refreshing the package cache is not a config change
38+
when: 'ansible_facts["os_family"] == "Debian"'
39+
3040
- name: 'Update php php-fpm composer' # noqa package-latest (we explicitly want latest here)
3141
ansible.builtin.package:
3242
name:
@@ -88,6 +98,16 @@
8898
ansible.builtin.debug:
8999
var: 'php__modules__combined_var'
90100

101+
# refresh the apt cache so the following `state: latest` upgrade resolves
102+
# against current metadata, e.g. to roll out security updates. apt does not
103+
# auto-expire its cache the way dnf does, so without this the upgrade can
104+
# silently run against a stale cache and miss newer versions.
105+
- name: 'apt update # update the cache'
106+
ansible.builtin.apt:
107+
update_cache: true
108+
changed_when: false # refreshing the package cache is not a config change
109+
when: 'ansible_facts["os_family"] == "Debian"'
110+
91111
- name: 'Update PHP modules' # noqa package-latest (we explicitly want latest here)
92112
# providing the packages as a list is much more faster than looping for each
93113
ansible.builtin.package:

0 commit comments

Comments
 (0)