From e710d4475093eea4e2f8c2e24b1c9812eb715965 Mon Sep 17 00:00:00 2001
From: Chris Croome <chris@webarchitects.co.uk>
Date: Tue, 1 Dec 2020 13:59:31 +0000
Subject: [PATCH] Ansible lint updates

---
 .ansible-lint                 | 11 +++++++++++
 .gitlab-ci.yml                | 12 +++++++-----
 .yamllint                     |  8 +++++++-
 molecule/default/molecule.yml | 17 +++++++++++++++++
 tasks/config.yml              |  2 +-
 tasks/main.yml                |  2 +-
 tasks/mc3.yml                 |  1 +
 tasks/mpm.yml                 |  4 ++--
 tasks/webarch.yml             |  1 +
 9 files changed, 48 insertions(+), 10 deletions(-)
 create mode 100644 .ansible-lint
 create mode 100644 molecule/default/molecule.yml

diff --git a/.ansible-lint b/.ansible-lint
new file mode 100644
index 0000000..6d84341
--- /dev/null
+++ b/.ansible-lint
@@ -0,0 +1,11 @@
+---
+# https://docs.ansible.com/ansible-lint/rules/default_rules.html
+skip_list:
+  # Lines should be no longer than 160 chars
+  - "204"
+  # rsync used in place of synchronize module
+  - "303"
+  # Package installs should not use latest
+  - "403"
+# vim: syntax=yaml
+...
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ee4ab5a..68f1e22 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,11 +1,13 @@
 ---
 image: registry.git.coop/webarch/containers/images/ansible:0.3
-
+before_script:
+  - chmod 700 $(pwd)
 stages:
-  - check
-
-ansible-lint:
-  stage: check
+  - lint
+lint:
+  stage: lint
   script:
     - yamllint .
+    - molecule lint
+# vim: syntax=yaml
 ...
diff --git a/.yamllint b/.yamllint
index a4d53d6..dd1565f 100644
--- a/.yamllint
+++ b/.yamllint
@@ -1,5 +1,8 @@
+---
 extends: default
-
+yaml-files:
+  - '*.yaml'
+  - '*.yml'
 rules:
   braces:
     max-spaces-inside: 1
@@ -8,3 +11,6 @@ rules:
     max-spaces-inside: 1
     level: error
   line-length: disable
+  comments-indentation: disable
+# vim: syntax=yaml
+...
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
new file mode 100644
index 0000000..f895196
--- /dev/null
+++ b/molecule/default/molecule.yml
@@ -0,0 +1,17 @@
+---
+dependency:
+  name: galaxy
+driver:
+  name: docker
+platforms:
+  - name: instance
+    image: registry.git.coop/webarch/containers/images/ansible:0.3
+    pre_build_image: true
+provisioner:
+  name: ansible
+lint: |
+ set -e
+  yamllint -c .yamllint .
+  ansible-lint -c .ansible-lint.yml .
+# vim: syntax=yaml
+...
diff --git a/tasks/config.yml b/tasks/config.yml
index ade0920..e941d6a 100644
--- a/tasks/config.yml
+++ b/tasks/config.yml
@@ -59,7 +59,7 @@
             common_name: "{{ inventory_hostname }}"
 
       when:
-        - ( apache_cert.stat.exists == False )
+        - ( not apache_cert.stat.exists )
         - ( "ssl" in apache_mods_enabled )
         - ( "le" in apache_conf_enabled )
         - ( common_name is defined ) and ( common_name == inventory_hostname )
diff --git a/tasks/main.yml b/tasks/main.yml
index 3019f62..5954587 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -46,7 +46,7 @@
 
     - name: Include MPM switching tasks
       include_tasks: mpm.yml
-      when: ( apache_mpm_loaded not in apache_mods_enabled ) or ( apache_mpm_loaded == "" )
+      when: ( apache_mpm_loaded not in apache_mods_enabled ) or ( apache_mpm_loaded | length == 0 )
 
     - name: Apache config available
       include_tasks: config.yml
diff --git a/tasks/mc3.yml b/tasks/mc3.yml
index 7f80672..8a73846 100644
--- a/tasks/mc3.yml
+++ b/tasks/mc3.yml
@@ -6,6 +6,7 @@
       git:
         repo: https://git.coop/mc3coop/ssh-templates.git
         dest: /var/www/mc3
+        version: master
         clone: true
         update: true
         force: true
diff --git a/tasks/mpm.yml b/tasks/mpm.yml
index b96f4ed..1090238 100644
--- a/tasks/mpm.yml
+++ b/tasks/mpm.yml
@@ -44,7 +44,7 @@
       when: apache_mpm_event_enabled.changed
 
   when:
-    - ( apache_mpm_loaded == "mpm_prefork" ) or ( apache_mpm_loaded | length <= 0 )
+    - ( apache_mpm_loaded == "mpm_prefork" ) or ( apache_mpm_loaded | length == 0 )
     - ( apache_mods_enabled is defined ) and ( "mpm_event" in apache_mods_enabled )
   tags:
     - apache
@@ -73,7 +73,7 @@
       when: apache_mpm_prefork_enabled.changed
 
   when:
-    - ( apache_mpm_loaded == "mpm_event" ) or ( apache_mpm_loaded == "" )
+    - ( apache_mpm_loaded == "mpm_event" ) or ( apache_mpm_loaded | length == 0 )
     - ( "mpm_prefork" in apache_mods_enabled )
   tags:
     - apache
diff --git a/tasks/webarch.yml b/tasks/webarch.yml
index 46601a4..c6d4731 100644
--- a/tasks/webarch.yml
+++ b/tasks/webarch.yml
@@ -6,6 +6,7 @@
       git:
         repo: https://git.coop/webarch/website-templates.git
         dest: /var/www/wsh
+        version: master
         clone: true
         update: true
         force: true
-- 
GitLab