From 96027ca58643be9c90e005056953da84899254c5 Mon Sep 17 00:00:00 2001
From: Chris Croome <chris@webarchitects.co.uk>
Date: Sat, 3 Jun 2023 13:32:10 +0100
Subject: [PATCH] Update linting

---
 .gitlab-ci.yml                | 18 ++++++++++++----
 .pre-commit-config.yaml       | 11 +++++++++-
 molecule/default/converge.yml | 39 +++++++++++++++++++++++++++++++++++
 molecule/default/molecule.yml | 19 ++++++++++-------
 tasks/main.yml                |  7 +++++++
 5 files changed, 81 insertions(+), 13 deletions(-)
 create mode 100644 molecule/default/converge.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f8765e8..ac95d62 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,8 +1,19 @@
+# Copyright 2018-2023 Chris Croome
+#
+# This file is part of the Webarchitects MariaDB Ansible role.
+#
+# The Webarchitects MariaDB Ansible role is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+#
+# The Webarchitects MariaDB Ansible role is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with the Webarchitects MariaDB Ansible role. If not, see <https://www.gnu.org/licenses/>.
 ---
-image: registry.git.coop/webarch/containers/images/ansible:0.23.0
+image: registry.git.coop/webarch/containers/images/ansible:0.24.0
 variables:
-  PY_COLORS: "1"
+  ANSIBLE_DEFAULT_VERBOSITY: "2"
+  ANSIBLE_DIFF_ALWAYS: "1"
   ANSIBLE_FORCE_COLOR: "1"
+  PY_COLORS: "1"
 before_script:
   - chmod 700 $(pwd)
 stages:
@@ -10,6 +21,5 @@ stages:
 lint:
   stage: lint
   script:
-    - molecule lint
-# vim: syntax=yaml
+    - molecule converge
 ...
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 60df15a..cae5906 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,9 +1,18 @@
+# Copyright 2018-2023 Chris Croome
+#
+# This file is part of the Webarchitects MariaDB Ansible role.
+#
+# The Webarchitects MariaDB Ansible role is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+#
+# The Webarchitects MariaDB Ansible role is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with the Webarchitects MariaDB Ansible role. If not, see <https://www.gnu.org/licenses/>.
 ---
 # https://yamllint.readthedocs.io/en/stable/integration.html
 # https://github.com/adrienverge/yamllint/tags
 repos:
   - repo: https://github.com/adrienverge/yamllint.git
-    rev: v1.31.0
+    rev: v1.32.0
     hooks:
       - id: yamllint
 ...
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml
new file mode 100644
index 0000000..37e48b7
--- /dev/null
+++ b/molecule/default/converge.yml
@@ -0,0 +1,39 @@
+# Copyright 2018-2023 Chris Croome
+#
+# This file is part of the Webarchitects MariaDB Ansible role.
+#
+# The Webarchitects MariaDB Ansible role is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+#
+# The Webarchitects MariaDB Ansible role is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with the Webarchitects MariaDB Ansible role. If not, see <https://www.gnu.org/licenses/>.
+---
+- name: Lint
+  become: false
+  connection: local
+  gather_facts: false
+  hosts:
+    - localhost
+  tasks:
+
+    - name: Check Jinja2 syntax
+      ansible.builtin.command: find -type f -name '*.j2' -exec ansiblej2lint.py {} +
+      check_mode: false
+      args:
+        chdir: ../..
+      changed_when: false
+
+    - name: YAML lint
+      ansible.builtin.command: yamllint -f colored -c .yamllint .
+      check_mode: false
+      args:
+        chdir: ../..
+      changed_when: false
+
+    - name: Ansible lint
+      ansible.builtin.command: ansible-lint -c .ansible-lint --force-color .
+      check_mode: false
+      args:
+        chdir: ../..
+      changed_when: false
+...
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
index ce086fb..e7f64a4 100644
--- a/molecule/default/molecule.yml
+++ b/molecule/default/molecule.yml
@@ -1,16 +1,19 @@
+# Copyright 2018-2023 Chris Croome
+#
+# This file is part of the Webarchitects MariaDB Ansible role.
+#
+# The Webarchitects MariaDB Ansible role is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+#
+# The Webarchitects MariaDB Ansible role is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with the Webarchitects MariaDB Ansible role. If not, see <https://www.gnu.org/licenses/>.
 ---
 dependency:
   name: galaxy
 platforms:
   - name: instance
-    image: registry.git.coop/webarch/containers/images/ansible:0.23.0
-    pre_build_image: true
 provisioner:
   name: ansible
-lint: |
-  set -e
-  find -type f -name '*.j2' -exec ansiblej2lint.py {} +
-  yamllint -f colored -c .yamllint .
-  ansible-lint -c .ansible-lint --force-color .
-# vim: syntax=yaml
+verifier:
+  name: ansible
 ...
diff --git a/tasks/main.yml b/tasks/main.yml
index e674f3b..462725f 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -8,6 +8,13 @@
 #
 # You should have received a copy of the GNU General Public License along with the Webarchitects MariaDB Ansible role. If not, see <https://www.gnu.org/licenses/>.
 ---
+- name: Skip the tasks in this role
+  ansible.builtin.debug:
+    msg: "The MariaDB role tasks are not being run since the mariadb variable is false."
+  when: not mariadb | bool
+  tags:
+    - mariadb
+
 - name: MariaDB
   block:
 
-- 
GitLab