diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b5b5b73148c9286c71537e094a68ba675f9a16eb..48993503ea087b304d8d3ef8fc8b86ac0c4240a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,13 +62,14 @@ yamllint: - yamllint -c ./.yamllintheat.yaml ./heat ansiblelint: + allow_failure: true stage: lint tags: - ansiblelint script: - echo "stage ansiblelint" - cd CICD - - python ansiblelint/run_lint.py master_playbook.yml + - python3 ansiblelint/run_lint.py --targets master_playbook.yml build_cluster_cicd: diff --git a/CICD/ansiblelint/.gitignore b/CICD/ansiblelint/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..460d28f826de5b20b152849a5081d67dc92b8eb8 --- /dev/null +++ b/CICD/ansiblelint/.gitignore @@ -0,0 +1 @@ +logdir diff --git a/CICD/ansiblelint/logdir/INFO b/CICD/ansiblelint/logdir/INFO index 226d1d3de3edb9ba2c670483ac96caf08efe05b8..1519bf640c83c3dce1664ca934fe641de12c8977 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 2a344d6e5128b0c0f2e4d3254625f528ef21b279..cb20dc3308393603fd83acc6fb220a9f730a5f3c 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 5e1812c810b3e362cb9d431ea8054b183654b5f7..853e813c3d1abd41558f4210239548af8713be6d 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 26b9120652685066b934f4a7044ba8b8c87821d2..45ddc7a9ea11a76ca0929310ea21577b61ea74db 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 872f2cbb68428dae1cbb1f4d478953a110ac152f..cea3e7d6ae52e212c3ee0b151e58b0cdf361af1f 100644 --- a/CICD/ansiblelint/run_lint.py +++ b/CICD/ansiblelint/run_lint.py @@ -13,7 +13,6 @@ def parse_argument(): parser.add_argument('--logdir', type=Path, default=Path( __file__ + '/../logdir').resolve(), nargs='?', help='log directory default to ./ansiblelint/logdir') args = parser.parse_args() - args.logdir.mkdir(exist_ok=True) return args def parse_rule_output(line): @@ -49,6 +48,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 +65,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