From 7dfbb6defb6517e2202c379aff991bc2a0269192 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de>
Date: Tue, 21 Feb 2023 16:32:43 +0100
Subject: [PATCH] style: satisfy ansible-lint

---
 .ansible-lint                            | 1 +
 ci-playbook.yml                          | 3 ++-
 handlers/main.yml                        | 4 ++--
 meta/main.yml                            | 2 ++
 molecule/resources/playbooks/prepare.yml | 4 ++--
 molecule/resources/playbooks/verify.yml  | 6 +++---
 site.yml                                 | 5 +++--
 tasks/configure-nfs-mounts.yml           | 2 +-
 tasks/install-repair-tools.yml           | 2 +-
 tasks/main.yml                           | 4 ++--
 tests/local/docker-playbook.yml          | 3 ++-
 11 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/.ansible-lint b/.ansible-lint
index f18a647..5620f63 100644
--- a/.ansible-lint
+++ b/.ansible-lint
@@ -37,6 +37,7 @@ use_default_rules: true
 skip_list:
   - skip_this_tag
   - git-latest
+  - name[casing]
 
 # Any rule that has the 'opt-in' tag will not be loaded unless its 'id' is
 # mentioned in the enable_list:
diff --git a/ci-playbook.yml b/ci-playbook.yml
index 2a7bc19..70cc648 100644
--- a/ci-playbook.yml
+++ b/ci-playbook.yml
@@ -12,7 +12,8 @@
 #
 ######
 
-- hosts: "localhost"
+- name: CI run
+  hosts: "localhost"
   connection: local
   # Collect facts from remote system? Possible values: true, false
   gather_facts: true
diff --git a/handlers/main.yml b/handlers/main.yml
index 974b01a..06afe22 100644
--- a/handlers/main.yml
+++ b/handlers/main.yml
@@ -16,6 +16,7 @@
   loop: "{{ vault_service_files.keys() | list }}"
 
 - name: save iptables rules (Debian)
+  when: ansible_os_family == "Debian"
   block:
     - name: Ordner für iptables-Config erstellen
       ansible.builtin.file:
@@ -34,9 +35,9 @@
     - name: save iptables rules
       ansible.builtin.command: 'netfilter-persistent save'      # noqa no-changed-when
       listen: "save iptables rules"
-  when: ansible_os_family == "Debian"
 
 - name: save iptables rules (RedHat)
+  when: ansible_os_family == "RedHat"
   block:
     - name: make sure iptables config file exists
       ansible.builtin.file:
@@ -50,4 +51,3 @@
     - name: save rules
       ansible.builtin.command: /usr/sbin/iptables-save        # noqa no-changed-when
       listen: "save iptables rules"
-  when: ansible_os_family == "RedHat"
diff --git a/meta/main.yml b/meta/main.yml
index 374bb35..4e9ec98 100644
--- a/meta/main.yml
+++ b/meta/main.yml
@@ -1,5 +1,7 @@
 ---
 galaxy_info:
+  role_name: ansible_lza_repair
+  namespace: slub
   author: Jörg Sachse
   description: role to install repair server for the SLUBarchiv digital preservation repository
   company: SLUB Dresden
diff --git a/molecule/resources/playbooks/prepare.yml b/molecule/resources/playbooks/prepare.yml
index f03054f..4e63bee 100644
--- a/molecule/resources/playbooks/prepare.yml
+++ b/molecule/resources/playbooks/prepare.yml
@@ -7,6 +7,7 @@
         name: "lza"
       become: true
     - name: configure additional package repositories for Debian
+      when: ansible_os_family == "Debian"
       block:
         - name: install GPG
           ansible.builtin.apt:
@@ -26,7 +27,6 @@
             update_cache: true
             mode: "0644"
           become: true
-      when: ansible_os_family == "Debian"
     - name: install tooling before running the actual tests, so we're not bound by the fixed versions
       ansible.builtin.apt:
         name: [
@@ -38,6 +38,7 @@
       become: true
 
     - name: configure additional package repositories for RedHat
+      when: ansible_os_family == "RedHat"
       block:
         - name: add custom repositories
           ansible.builtin.yum_repository:
@@ -59,4 +60,3 @@
           ansible.builtin.file:
             path: "/etc/yum.repos.d/SLUB.repo"
             state: absent
-      when: ansible_os_family == "RedHat"
diff --git a/molecule/resources/playbooks/verify.yml b/molecule/resources/playbooks/verify.yml
index e707420..a5cfa75 100644
--- a/molecule/resources/playbooks/verify.yml
+++ b/molecule/resources/playbooks/verify.yml
@@ -5,6 +5,6 @@
   hosts: all
   gather_facts: false
   tasks:
-  - name: Example assertion
-    ansible.builtin.assert:
-      that: true
+    - name: Example assertion
+      ansible.builtin.assert:
+        that: true
diff --git a/site.yml b/site.yml
index 4b4bbcb..e6956ba 100644
--- a/site.yml
+++ b/site.yml
@@ -1,8 +1,9 @@
 ---
-- hosts: "*"
+- name: install repairserver
+  hosts: "*"
   pre_tasks:
     - name: Verify that the installed version of Ansible meets this playbook's version requirements.
-      assert:
+      ansible.builtin.assert:
         that: "ansible_version.full is version_compare('2.5', '>=')"
         msg: >
           "You must update Ansible to at least 2.5 to use this playbook."
diff --git a/tasks/configure-nfs-mounts.yml b/tasks/configure-nfs-mounts.yml
index dfb4208..217fbc5 100644
--- a/tasks/configure-nfs-mounts.yml
+++ b/tasks/configure-nfs-mounts.yml
@@ -38,6 +38,6 @@
     path: "{{ item[0] }}/{{ item[1] }}"
     state: directory
     mode: "0777"    # it's a mixed mode share, so actual mode is 0777 anyway
-  loop: "{{ vault_nfs_mounts | map(attribute='name') | product( ['unprocessed', 'processed', 'workdir']) }}"
+  loop: "{{ vault_nfs_mounts | map(attribute='name') | product(['unprocessed', 'processed', 'workdir']) }}"
   when: '"/var/log/" not in item[0]'
   tags: [ci]
diff --git a/tasks/install-repair-tools.yml b/tasks/install-repair-tools.yml
index 67975bd..2fb838f 100644
--- a/tasks/install-repair-tools.yml
+++ b/tasks/install-repair-tools.yml
@@ -1,5 +1,6 @@
 ---
 - name: configure Debian repositories
+  when: "ansible_facts['distribution'] == 'Debian'"
   block:
     - name: öffentlichen Schlüssel hinzufügen (sonst muss bei jeder Installation eine Warnmeldung bestätigt werden)
       ansible.builtin.apt_key:
@@ -15,7 +16,6 @@
         mode: "0644"
       when: ansible_distribution_major_version == '11'
       tags: [apt]
-  when: "ansible_facts['distribution'] == 'Debian'"
 
 - name: install repairtool dependencies from local Debian repo server (if we're running in prod)
   ansible.builtin.apt:
diff --git a/tasks/main.yml b/tasks/main.yml
index de0d353..d29799d 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -26,8 +26,8 @@
 
 ### CONFIG LOGROTATE
 - name: config logrotate
-  import_tasks: configure-logrotate.yml
-  tags: [log]
+  ansible.builtin.import_tasks: "configure_logrotate.yml"
+  tags: [log, logrotate]
 
 ### INSTALLATION REPARATURTOOLS ###
 - name: install repairtools
diff --git a/tests/local/docker-playbook.yml b/tests/local/docker-playbook.yml
index 797ef6c..cbe5806 100644
--- a/tests/local/docker-playbook.yml
+++ b/tests/local/docker-playbook.yml
@@ -1,5 +1,6 @@
 ---
-- hosts: "local"
+- name: CI testrun in Docker
+  hosts: "local"
   connection: docker
   # Collect facts from remote system? Possible values: true, false
   gather_facts: true
-- 
GitLab