From 7355c1cdc2a16140d02d31c790dddfeba98f30b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= <valtri@civ.zcu.cz>
Date: Thu, 5 Jun 2025 00:19:31 +0000
Subject: [PATCH] Ansible linting

---
 common/playbooks/backup.yaml    |  1 +
 common/playbooks/k8s.yaml       | 16 ++++++++++++----
 common/playbooks/notebooks.yaml |  2 +-
 egi-devel/playbooks/binder.yaml |  1 +
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/common/playbooks/backup.yaml b/common/playbooks/backup.yaml
index c45869e..b5636e2 100644
--- a/common/playbooks/backup.yaml
+++ b/common/playbooks/backup.yaml
@@ -47,4 +47,5 @@
       environment:
         KUBECONFIG: /etc/kubernetes/admin.conf
         PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
+      changed_when: true
       when: true
diff --git a/common/playbooks/k8s.yaml b/common/playbooks/k8s.yaml
index b3c9de7..ad7c8d4 100644
--- a/common/playbooks/k8s.yaml
+++ b/common/playbooks/k8s.yaml
@@ -47,7 +47,11 @@
             dest: /etc/cron-apt/action.d/9-upgrade
             content: -q -q dist-upgrade
             mode: 0644
-    - name: Mails settings
+      rescue:
+        - name: Site install cron-apt fail
+          fail:
+            mag: "Site install cron-apt failed"
+    - name: Mail Settings
       vars:
         fip_hostname: "{{ lookup('dig', (groups['fip'][0], 'PTR') | join('/')) | regex_replace('\\.$', '') }}"
       block:
@@ -575,8 +579,7 @@
         name: ubuntu-drivers-common
         update_cache: true
     - name: Install Nvidia driver packages
-      shell: |-
-        ubuntu-drivers install
+      command: ubuntu-drivers install
       changed_when: true
     - name: Reboot GPU node
       reboot:
@@ -615,6 +618,7 @@
           when: true
         - name: Get GPU node hostnames
           shell: |-
+            set -o pipefail
             kubectl get nodes --no-headers -o custom-columns=NAME:.metadata.name | grep -- -gpu-
           register: gpu_nodes
           changed_when: false
@@ -626,8 +630,12 @@
         - name: Add required label to GPU nodes to create mig profiles
           vars:
             mig_profile: all-1g.12gb
-          shell: |-
+          command: |-
             kubectl label node {{ item }} nvidia.com/mig.config={{ mig_profile }} --overwrite
           loop: "{{ gpu_nodes.stdout_lines }}"
           changed_when: true
           when: true
+      rescue:
+        - name: GPU Setup Fail
+          fail:
+            msg: "GPU setup failed"
diff --git a/common/playbooks/notebooks.yaml b/common/playbooks/notebooks.yaml
index 5c49b60..2fa6a3d 100644
--- a/common/playbooks/notebooks.yaml
+++ b/common/playbooks/notebooks.yaml
@@ -11,7 +11,7 @@
       when: "'jupyterhub' not in ansible_local.helm_repos | map(attribute='name') | list or
             'eginotebooks' not in ansible_local.helm_repos | map(attribute='name') | list"
     - name: Get latest helm charts
-      shell: |-
+      command: |-
         helm repo update
       changed_when: true
     - name: Get Secrets from Vault for notebooks
diff --git a/egi-devel/playbooks/binder.yaml b/egi-devel/playbooks/binder.yaml
index 1127e09..d08ecce 100644
--- a/egi-devel/playbooks/binder.yaml
+++ b/egi-devel/playbooks/binder.yaml
@@ -212,6 +212,7 @@
       environment:
         KUBECONFIG: /etc/kubernetes/admin.conf
         PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
+      changed_when: true
       when: true
 
 - name: Workaround for binder socket and bind-mount race-condition
-- 
GitLab