From 2962d656599beb0fecb1977be9b902022aecc606 Mon Sep 17 00:00:00 2001
From: Luhan Cheng <lche0021@student.monash.edu>
Date: Thu, 30 Jan 2020 15:30:10 +1100
Subject: [PATCH] removed log file, print log to stdout, added allow fail to
 ansible lint for now

---
 .gitlab-ci.yml                   | 3 ++-
 CICD/ansiblelint/.gitignore      | 1 +
 CICD/ansiblelint/logdir/INFO     | 2 ++
 CICD/ansiblelint/logdir/MEDIUM   | 1 +
 CICD/ansiblelint/logdir/VERY_LOW | 5 +++--
 CICD/ansiblelint/logdir/logfile  | 8 ++++++--
 CICD/ansiblelint/run_lint.py     | 3 +--
 7 files changed, 16 insertions(+), 7 deletions(-)
 create mode 100644 CICD/ansiblelint/.gitignore

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b5b5b731..bab05f37 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -68,7 +68,7 @@ ansiblelint:
   script:
     - echo "stage ansiblelint"
     - cd CICD
-    - python ansiblelint/run_lint.py master_playbook.yml
+    - python ansiblelint/run_lint.py --targets master_playbook.yml
     
 
 build_cluster_cicd:
@@ -95,6 +95,7 @@ build_cluster_cicd:
 
 ansible_create_cluster_stage:
   stage: ansible_create_cluster_stage
+  allow_failure: false
   tags: 
   - ansible
   before_script:
diff --git a/CICD/ansiblelint/.gitignore b/CICD/ansiblelint/.gitignore
new file mode 100644
index 00000000..460d28f8
--- /dev/null
+++ b/CICD/ansiblelint/.gitignore
@@ -0,0 +1 @@
+logdir
diff --git a/CICD/ansiblelint/logdir/INFO b/CICD/ansiblelint/logdir/INFO
index 226d1d3d..1519bf64 100644
--- a/CICD/ansiblelint/logdir/INFO
+++ b/CICD/ansiblelint/logdir/INFO
@@ -94,7 +94,9 @@ plays/roles/ldapclient/tasks/main.yml	3	E201	INFO	Trailing whitespace
 plays/roles/ldapclient/tasks/main.yml	5	E201	INFO	Trailing whitespace
 plays/roles/move_homedir/tasks/main.yml	3	E201	INFO	Trailing whitespace
 plays/roles/mysql/handlers/main.yml	2	E201	INFO	Trailing whitespace
+plays/roles/mysql/tasks/mysql_server.yml	13	E201	INFO	Trailing whitespace
 plays/roles/mysql/tasks/mysql_server.yml	35	E201	INFO	Trailing whitespace
+plays/roles/mysql/tasks/mysql_server.yml	37	E201	INFO	Trailing whitespace
 plays/roles/nfs-client/handlers/main.yml	6	E201	INFO	Trailing whitespace
 plays/roles/nfs-client/tasks/main.yml	6	E201	INFO	Trailing whitespace
 plays/roles/nfs-client/tasks/mountFileSystem.yml	1	E201	INFO	Trailing whitespace
diff --git a/CICD/ansiblelint/logdir/MEDIUM b/CICD/ansiblelint/logdir/MEDIUM
index 2a344d6e..cb20dc33 100644
--- a/CICD/ansiblelint/logdir/MEDIUM
+++ b/CICD/ansiblelint/logdir/MEDIUM
@@ -26,6 +26,7 @@ plays/roles/jasons_ssh_ca/handlers/main.yml	2	E502	MEDIUM	All tasks should be na
 plays/roles/jasons_ssh_ca/tasks/main.yml	2	E502	MEDIUM	All tasks should be named
 plays/roles/lmod/tasks/main.yml	2	E502	MEDIUM	All tasks should be named
 plays/roles/mysql/tasks/main.yml	2	E502	MEDIUM	All tasks should be named
+plays/roles/mysql/tasks/mysql_server.yml	32	E503	MEDIUM	Tasks that run when changed should likely be handlers
 plays/roles/slurm-common/tasks/installMungeFromSource.yml	46	E503	MEDIUM	Tasks that run when changed should likely be handlers
 plays/roles/slurm-common/tasks/main.yml	95	E306	MEDIUM	Shells that use pipes should set the pipefail option
 plays/roles/slurm-start/tasks/main.yml	41	E503	MEDIUM	Tasks that run when changed should likely be handlers
diff --git a/CICD/ansiblelint/logdir/VERY_LOW b/CICD/ansiblelint/logdir/VERY_LOW
index 5e1812c8..853e813c 100644
--- a/CICD/ansiblelint/logdir/VERY_LOW
+++ b/CICD/ansiblelint/logdir/VERY_LOW
@@ -1,8 +1,9 @@
 filepath	line	rule	serverity	rule description
 plays/nfssqlnodes.yml	49	E204	VERY_LOW	Lines should be no longer than 160 chars
 plays/roles/lmod/tasks/main.yml	52	E204	VERY_LOW	Lines should be no longer than 160 chars
-plays/roles/mysql/tasks/mysql_server.yml	38	E204	VERY_LOW	Lines should be no longer than 160 chars
-plays/roles/mysql/tasks/mysql_server.yml	42	E204	VERY_LOW	Lines should be no longer than 160 chars
+plays/roles/mysql/tasks/mysql_server.yml	32	E204	VERY_LOW	Lines should be no longer than 160 chars
+plays/roles/mysql/tasks/mysql_server.yml	40	E204	VERY_LOW	Lines should be no longer than 160 chars
+plays/roles/mysql/tasks/mysql_server.yml	44	E204	VERY_LOW	Lines should be no longer than 160 chars
 plays/roles/upgrade/tasks/main.yml	20	E403	VERY_LOW	Package installs should not use latest
 plays/roles/upgrade/tasks/main.yml	32	E403	VERY_LOW	Package installs should not use latest
 plays/roles/upgrade/tasks/main.yml	38	E403	VERY_LOW	Package installs should not use latest
diff --git a/CICD/ansiblelint/logdir/logfile b/CICD/ansiblelint/logdir/logfile
index 26b91206..45ddc7a9 100644
--- a/CICD/ansiblelint/logdir/logfile
+++ b/CICD/ansiblelint/logdir/logfile
@@ -139,9 +139,13 @@ plays/roles/move_homedir/tasks/main.yml:3: [E201] [INFO] Trailing whitespace
 plays/roles/move_homedir/tasks/main.yml:9: [E305] [HIGH] Use shell only when shell functionality is required
 plays/roles/mysql/handlers/main.yml:2: [E201] [INFO] Trailing whitespace
 plays/roles/mysql/tasks/main.yml:2: [E502] [MEDIUM] All tasks should be named
+plays/roles/mysql/tasks/mysql_server.yml:13: [E201] [INFO] Trailing whitespace
+plays/roles/mysql/tasks/mysql_server.yml:32: [E204] [VERY_LOW] Lines should be no longer than 160 chars
+plays/roles/mysql/tasks/mysql_server.yml:32: [E503] [MEDIUM] Tasks that run when changed should likely be handlers
 plays/roles/mysql/tasks/mysql_server.yml:35: [E201] [INFO] Trailing whitespace
-plays/roles/mysql/tasks/mysql_server.yml:38: [E204] [VERY_LOW] Lines should be no longer than 160 chars
-plays/roles/mysql/tasks/mysql_server.yml:42: [E204] [VERY_LOW] Lines should be no longer than 160 chars
+plays/roles/mysql/tasks/mysql_server.yml:37: [E201] [INFO] Trailing whitespace
+plays/roles/mysql/tasks/mysql_server.yml:40: [E204] [VERY_LOW] Lines should be no longer than 160 chars
+plays/roles/mysql/tasks/mysql_server.yml:44: [E204] [VERY_LOW] Lines should be no longer than 160 chars
 plays/roles/nfs-client/handlers/main.yml:6: [E201] [INFO] Trailing whitespace
 plays/roles/nfs-client/meta/main.yml:2: [E701] [HIGH] No 'galaxy_info' found
 plays/roles/nfs-client/tasks/main.yml:6: [E201] [INFO] Trailing whitespace
diff --git a/CICD/ansiblelint/run_lint.py b/CICD/ansiblelint/run_lint.py
index 872f2cbb..fb0e8c9a 100644
--- a/CICD/ansiblelint/run_lint.py
+++ b/CICD/ansiblelint/run_lint.py
@@ -49,6 +49,7 @@ def main():
     cmd += ' 2>&1 | tee {}'.format(str(logfile.resolve()))
     # print(cmd)
     output = subprocess.check_output(cmd, shell=True)
+    print(output.decode())
     output = output.decode().splitlines()
     # print(output)
     output = [parse_rule_output(line) for line in output]
@@ -65,8 +66,6 @@ def main():
 
         with current_log.open(mode='w') as f:
             f.writelines(['filepath\tline\trule\tserverity\trule description\n'])
-            # print(v[-1])
-            # return
             f.writelines(['\t'.join(list(i)) + '\n' for i in v])
     sys.exit(exit_code)
     # return
-- 
GitLab