mirror of https://github.com/ansible/ansible
apt: recreate apt cache if /var/lib/apt/lists is missing (#86612)
* While creating bare minimum container images, sometimes /var/lib/apt/lists is removed. Recreate this directory in order to update cache successfully. Fixes: #61176 Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com> Co-authored-by: Sloane Hertel <19572925+shertel@users.noreply.github.com>pull/86595/head
parent
ca8444f238
commit
4da24b8128
@ -0,0 +1,3 @@
|
||||
---
|
||||
bugfixes:
|
||||
- apt - recreate the APT lists directory (/var/lib/apt/lists by default) if missing (https://github.com/ansible/ansible/issues/61176).
|
||||
@ -0,0 +1,24 @@
|
||||
- block:
|
||||
- name: Create a backup of the /var/lib/apt/lists/partial
|
||||
command: mv /var/lib/apt/lists/partial /var/lib/apt/lists/partial.backup
|
||||
|
||||
- name: Verify that apt update does not fail if the /var/lib/apt/lists/partial is not present
|
||||
apt:
|
||||
update_cache: yes
|
||||
|
||||
- name: Create a backup of the /var/lib/apt/lists
|
||||
command: mv /var/lib/apt/lists /var/lib/apt/lists.backup
|
||||
|
||||
- name: Verify that apt update does not fail if the /var/lib/apt/lists is not present
|
||||
apt:
|
||||
update_cache: yes
|
||||
|
||||
always:
|
||||
- name: Check if the /var/lib/apt/lists is present
|
||||
stat:
|
||||
path: /var/lib/apt/lists.backup
|
||||
register: apt_lists_backup_stat
|
||||
|
||||
- name: Restore the /var/lib/apt/lists
|
||||
shell: rsync -a --delete /var/lib/apt/lists.backup/ /var/lib/apt/lists/ && rm -rf /var/lib/apt/lists.backup
|
||||
when: apt_lists_backup_stat.stat.exists
|
||||
Loading…
Reference in new issue