From 0ad062b911bc1019a7a016682e2d9c7910f775de Mon Sep 17 00:00:00 2001 From: ilia Date: Fri, 29 Aug 2025 14:30:15 +0000 Subject: [PATCH] Enhance snap role tasks for Debian systems by adding checks for snap readiness and installation status. Introduce a wait command for snapd, validate snap functionality before installing applications, and provide debug output for installation status. This improves error handling and user feedback during setup. --- roles/snap/tasks/main.yml | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/roles/snap/tasks/main.yml b/roles/snap/tasks/main.yml index fe3047b..7d0465a 100644 --- a/roles/snap/tasks/main.yml +++ b/roles/snap/tasks/main.yml @@ -28,15 +28,49 @@ - name: Force Ansible to reload facts setup: +- name: Wait for snapd to be ready + command: snap wait system seed.loaded + register: snap_wait_result + until: snap_wait_result.rc == 0 + retries: 10 + delay: 5 + when: ansible_facts['os_family'] == "Debian" + ignore_errors: true + +- name: Check if snap is working + command: snap list + register: snap_check + when: ansible_facts['os_family'] == "Debian" + ignore_errors: true + - name: Install VSCode IDE (Snap, all distros) community.general.snap: name: code classic: true state: present - when: ansible_facts['os_family'] == "Debian" + when: + - ansible_facts['os_family'] == "Debian" + - snap_check is defined + - snap_check.rc == 0 + ignore_errors: true - name: Install Cursor (Snap, all distros) community.general.snap: name: cursor state: present - when: ansible_facts['os_family'] == "Debian" + when: + - ansible_facts['os_family'] == "Debian" + - snap_check is defined + - snap_check.rc == 0 + ignore_errors: true + +- name: Display snap installation status + debug: + msg: | + Snap check result: {{ snap_check.rc if snap_check is defined else 'not defined' }} + VSCode and Cursor installation may have failed if snap is not properly configured. + You may need to manually install these applications or troubleshoot snap on this host. + when: + - ansible_facts['os_family'] == "Debian" + - snap_check is defined + - snap_check.rc != 0