Skip to content

Commit

Permalink
fix: add retry logic for installing nfs packages to handle potential …
Browse files Browse the repository at this point in the history
…lock issues during installation
  • Loading branch information
viniciusdc committed Mar 6, 2024
1 parent 6a32afb commit 759b921
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/kvm-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- name: Install system dependencies
# Running this to check if we could avoid /var/lib/dpkg/lock-frontend lock
run: |
sudo apt update && sudo apt upgrade
sudo apt update
sudo apt-get install net-tools -y
- name: Install dependencies
Expand Down
26 changes: 19 additions & 7 deletions roles/nfs/tasks/server.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
---
- name: Install nfs
- name: Install nfs with retry on lock
become: true
ansible.builtin.apt:
state: latest
cache_valid_time: 3600
name:
- nfs-common
- nfs-server
block:
- name: Install nfs packages
ansible.builtin.apt:
state: latest
cache_valid_time: 3600
name:
- nfs-common
- nfs-server
retries: 2
delay: 60
until: result is succeeded
rescue:
- name: Check for apt lock
ansible.builtin.command: ps aux | grep -i apt
register: grep_apt_output
- name: Show apt processes if lock encountered
ansible.builtin.debug:
msg: "{{ grep_apt_output.stdout_lines }}"

- name: Ensure nfs directory created
become: true
Expand Down

0 comments on commit 759b921

Please sign in to comment.