From 56760345ff392f2626a93136b809f266f8c07a59 Mon Sep 17 00:00:00 2001
From: Baptiste DE RENZO <baptiste.derenzo@ubicast.eu>
Date: Wed, 15 Feb 2023 16:14:25 +0000
Subject: [PATCH] Fix lint, Refs #37443

---
 playbooks/mediavault/add_backup.yml           |  3 ++-
 .../mediavault/ressources/add_backup_task.yml |  6 ++---
 playbooks/tests/data-partition.yml            | 12 ++++++----
 playbooks/tests/firewall-rules.yml            | 11 +++++----
 .../tests/ressources/firewall/listen.yml      |  6 +++--
 .../tests/ressources/firewall/test-rule.yml   | 24 ++++++++++++-------
 roles/sysconfig/tasks/main.yml                |  2 +-
 7 files changed, 40 insertions(+), 24 deletions(-)

diff --git a/playbooks/mediavault/add_backup.yml b/playbooks/mediavault/add_backup.yml
index 7aba5266..d7416602 100755
--- a/playbooks/mediavault/add_backup.yml
+++ b/playbooks/mediavault/add_backup.yml
@@ -4,5 +4,6 @@
   hosts: mediavault
   tags: mediavault
   tasks:
-    - include_tasks: ressources/add_backup_task.yml
+    - name: Add backup
+      ansible.builtin.include_tasks: ressources/add_backup_task.yml
       loop: "{{ mvt_backups }}"
diff --git a/playbooks/mediavault/ressources/add_backup_task.yml b/playbooks/mediavault/ressources/add_backup_task.yml
index 3c930f62..0e27fd3c 100644
--- a/playbooks/mediavault/ressources/add_backup_task.yml
+++ b/playbooks/mediavault/ressources/add_backup_task.yml
@@ -1,8 +1,8 @@
 ---
-- name: get {{ item.name  }} backup information
-  stat: path={{ item.dest }}/backup.marker
+- name: get {{ item.name }} backup information
+  ansible.builtin.stat: path={{ item.dest }}/backup.marker
   register: backup_marker
 
 - name: create {{ item.name }} backup
-  ansible.builtin.shell: mediavaultctl add --backup-name "{{ item.name }}" --source-folder "{{ item.source  }}" --dest-folder "{{ item.dest }}"
+  ansible.builtin.command: mediavaultctl add --backup-name "{{ item.name }}" --source-folder "{{ item.source }}" --dest-folder "{{ item.dest }}"
   when: not backup_marker.stat.exists
diff --git a/playbooks/tests/data-partition.yml b/playbooks/tests/data-partition.yml
index b6e47986..03804bf1 100755
--- a/playbooks/tests/data-partition.yml
+++ b/playbooks/tests/data-partition.yml
@@ -5,15 +5,16 @@
   gather_facts: false
   tasks:
     - name: verify /data partition existence
-      ansible.builtin.shell: findmnt /data
+      ansible.builtin.command: findmnt /data
       register: data_exist
       failed_when: false
       changed_when: false
 
     # /data exist
-    - block:
+    - name: Verify if /data exist
+      block:
         - name: get /data size
-          ansible.builtin.shell: df -BG /data --output=size | tail -n1 | grep -o '[0-9]*'
+          ansible.builtin.command: df -BG /data --output=size | tail -n1 | grep -o '[0-9]*'
           register: data_size
           failed_when: false
           changed_when: false
@@ -48,9 +49,10 @@
       when: data_exist.rc == 0
 
     # /data missing
-    - block:
+    - name: Verify if /home is big enough
+      block:
         - name: get /home size
-          ansible.builtin.shell: df -BG /home --output=size | tail -n1 | grep -o '[0-9]*'
+          ansible.builtin.command: df -BG /home --output=size | tail -n1 | grep -o '[0-9]*'
           register: home_size
           failed_when: false
           changed_when: false
diff --git a/playbooks/tests/firewall-rules.yml b/playbooks/tests/firewall-rules.yml
index b22cfaf0..1cc5e095 100755
--- a/playbooks/tests/firewall-rules.yml
+++ b/playbooks/tests/firewall-rules.yml
@@ -13,10 +13,12 @@
   hosts: all
   gather_facts: false
   tasks:
-    - include_vars:
+    - name: Set vars
+      ansible.builtin.include_vars:
         file: ressources/firewall/rules.yml
 
-    - include_tasks: ressources/firewall/listen.yml
+    - name: listen ports
+      ansible.builtin.include_tasks: ressources/firewall/listen.yml
       # loop over listen vars (named outer_item) and call firewall-listen
       loop: "{{ listen }}"
       loop_control:
@@ -28,11 +30,12 @@
   hosts: all
   gather_facts: false
   tasks:
-    - include_vars:
+    - name: Set vars
+      ansible.builtin.include_vars:
         file: ressources/firewall/rules.yml
 
     - name: test rules
-      include_tasks: ressources/firewall/test-rule.yml
+      ansible.builtin.include_tasks: ressources/firewall/test-rule.yml
       # loop over listen vars (named outer_item) and call firewall-listen
       loop: "{{ test }}"
       loop_control:
diff --git a/playbooks/tests/ressources/firewall/listen.yml b/playbooks/tests/ressources/firewall/listen.yml
index 3094bcb1..1b89b977 100644
--- a/playbooks/tests/ressources/firewall/listen.yml
+++ b/playbooks/tests/ressources/firewall/listen.yml
@@ -1,8 +1,10 @@
 ---
-- debug:
+- name: Print debug
+  ansible.builtin.debug:
     msg: On {{ outer_item.groupname }} server(s) put {{ outer_item.ports }} port(s) in listen mode
 
-- ansible.builtin.shell: nohup timeout 300 nc -lp {{ item }} >/dev/null 2>&1 &
+- name: put port {{ item }} in listen mode
+  ansible.builtin.shell: nohup timeout 300 nc -lp {{ item }} >/dev/null 2>&1 &
   ignore_errors: true
   loop: "{{ outer_item.ports }}"
   changed_when: false
diff --git a/playbooks/tests/ressources/firewall/test-rule.yml b/playbooks/tests/ressources/firewall/test-rule.yml
index 3b4edefb..6634956f 100644
--- a/playbooks/tests/ressources/firewall/test-rule.yml
+++ b/playbooks/tests/ressources/firewall/test-rule.yml
@@ -1,16 +1,20 @@
 ---
 # test rules with direct hosts destination
-- block:
-    - debug:
+- name: Test host rules
+  block:
+    - name: Print debug
+      ansible.builtin.debug:
         msg: Test rule from {{ outer_item.groupname_src }} to {{ outer_item.hosts_dst }} on {{ outer_item.ports }} port(s)
 
-    - shell: nc -zv {{ item.0 }} {{ item.1 }}
+    - name: Test port
+      ansible.builtin.command: nc -zv {{ item.0 }} {{ item.1 }}
       ignore_errors: true
       loop: "{{ outer_item.hosts_dst | product(outer_item.ports) | list }}"
       when: proxy is not defined
       changed_when: false
 
-    - shell: nc -x {{ proxy }} -X Connect -zv {{ item.0 }} {{ item.1 }}
+    - name: Test port with proxy
+      ansible.builtin.command: nc -x {{ proxy }} -X Connect -zv {{ item.0 }} {{ item.1 }}
       ignore_errors: true
       loop: "{{ outer_item.hosts_dst | product(outer_item.ports) | list }}"
       when: proxy is defined
@@ -18,17 +22,21 @@
   when: outer_item.hosts_dst is defined
 
 # test rules with ansible group destination
-- block:
-    - debug:
+- name: Test host group rules
+  block:
+    - name: Print debug
+      ansible.builtin.debug:
         msg: Test rule from {{ outer_item.groupname_src }} to {{ outer_item.groupname_dst }} on {{ outer_item.ports }} port(s)
 
-    - shell: nc -zv {{ item.0 }} {{ item.1 }}
+    - name: Test port
+      ansible.builtin.command: nc -zv {{ item.0 }} {{ item.1 }}
       ignore_errors: true
       loop: "{{ groups[outer_item.groupname_dst] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | list | product(outer_item.ports) | list }}"
       when: proxy is not defined
       changed_when: false
 
-    - shell: nc -x {{ proxy }} -X Connect -zv {{ item.0 }} {{ item.1 }}
+    - name: Test port with proxy
+      ansible.builtin.command: nc -x {{ proxy }} -X Connect -zv {{ item.0 }} {{ item.1 }}
       ignore_errors: true
       loop: "{{ groups[outer_item.groupname_dst] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | list | product(outer_item.ports) | list }}"
       when: proxy is defined
diff --git a/roles/sysconfig/tasks/main.yml b/roles/sysconfig/tasks/main.yml
index ff01b52f..69182767 100644
--- a/roles/sysconfig/tasks/main.yml
+++ b/roles/sysconfig/tasks/main.yml
@@ -115,7 +115,7 @@
   ansible.builtin.copy:
     content: |
       \e{lightblue} © UBICAST\e{reset}
-      
+
       IP Address:
       \e{bold}\4\e{reset}
 
-- 
GitLab