From dd28c8e1a1a96a7d446d6f53b0a74b9169902fb5 Mon Sep 17 00:00:00 2001 From: Luhan Cheng <lche0021@student.monash.edu> Date: Thu, 30 Jan 2020 00:19:56 +1100 Subject: [PATCH] added ansible lint Former-commit-id: 0b874ca530fb39f44d192c0ff422fa34d0666262 --- CICD/ansiblelint/logdir/HIGH | 40 +++++ CICD/ansiblelint/logdir/INFO | 141 ++++++++++++++++++ CICD/ansiblelint/logdir/LOW | 6 + CICD/ansiblelint/logdir/MEDIUM | 35 +++++ CICD/ansiblelint/logdir/VERY_HIGH | 9 ++ CICD/ansiblelint/logdir/VERY_LOW | 9 ++ CICD/ansiblelint/logdir/logfile | 234 ++++++++++++++++++++++++++++++ CICD/ansiblelint/run_lint.py | 75 ++++++++++ CICD/ansiblelint/spec.yml | 37 +++++ 9 files changed, 586 insertions(+) create mode 100644 CICD/ansiblelint/logdir/HIGH create mode 100644 CICD/ansiblelint/logdir/INFO create mode 100644 CICD/ansiblelint/logdir/LOW create mode 100644 CICD/ansiblelint/logdir/MEDIUM create mode 100644 CICD/ansiblelint/logdir/VERY_HIGH create mode 100644 CICD/ansiblelint/logdir/VERY_LOW create mode 100644 CICD/ansiblelint/logdir/logfile create mode 100644 CICD/ansiblelint/run_lint.py create mode 100644 CICD/ansiblelint/spec.yml diff --git a/CICD/ansiblelint/logdir/HIGH b/CICD/ansiblelint/logdir/HIGH new file mode 100644 index 00000000..e71c428b --- /dev/null +++ b/CICD/ansiblelint/logdir/HIGH @@ -0,0 +1,40 @@ +filepath line rule serverity rule description +plays/roles/calculateEtcHosts/tasks/main.yml 8 E301 HIGH Commands should not change things if nothing needs doing +plays/roles/config_repos/tasks/main.yml 52 E301 HIGH Commands should not change things if nothing needs doing +plays/roles/config_repos/tasks/main.yml 52 E305 HIGH Use shell only when shell functionality is required +plays/roles/config_repos/tasks/main.yml 67 E305 HIGH Use shell only when shell functionality is required +plays/roles/config_repos/tasks/main.yml 72 E305 HIGH Use shell only when shell functionality is required +plays/roles/config_repos/tasks/main.yml 77 E305 HIGH Use shell only when shell functionality is required +plays/roles/etcHosts/tasks/main.yml 13 E305 HIGH Use shell only when shell functionality is required +plays/roles/etcHosts/tasks/main.yml 26 E305 HIGH Use shell only when shell functionality is required +plays/roles/gpu/tasks/main.yml 56 E305 HIGH Use shell only when shell functionality is required +plays/roles/gpu/tasks/main.yml 138 E301 HIGH Commands should not change things if nothing needs doing +plays/roles/gpu/tasks/main.yml 138 E305 HIGH Use shell only when shell functionality is required +plays/roles/gpu/tasks/main.yml 148 E305 HIGH Use shell only when shell functionality is required +plays/roles/move_homedir/tasks/main.yml 9 E305 HIGH Use shell only when shell functionality is required +plays/roles/nfs-client/meta/main.yml 2 E701 HIGH No 'galaxy_info' found +plays/roles/nfs-server/meta/main.yml 2 E701 HIGH No 'galaxy_info' found +plays/roles/slurm-common/tasks/installMungeFromSource.yml 22 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installMungeFromSource.yml 46 E303 HIGH systemctl used in place of systemd module +plays/roles/slurm-common/tasks/installMungeFromSource.yml 46 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 1 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 6 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 37 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 51 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 64 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 77 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 96 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 101 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/main.yml 81 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/main.yml 124 E601 HIGH Don't compare to literal True/False +plays/roles/slurm-common/tasks/main.yml 129 E601 HIGH Don't compare to literal True/False +plays/roles/slurm-common/tasks/main.yml 145 E601 HIGH Don't compare to literal True/False +plays/roles/slurm-start/tasks/main.yml 41 E303 HIGH systemctl used in place of systemd module +plays/roles/slurm-start/tasks/main.yml 41 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-start/tasks/main.yml 46 E303 HIGH systemctl used in place of systemd module +plays/roles/slurm-start/tasks/main.yml 46 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-start/tasks/main.yml 51 E303 HIGH systemctl used in place of systemd module +plays/roles/slurm-start/tasks/main.yml 51 E305 HIGH Use shell only when shell functionality is required +plays/roles/slurm-start/tasks/main.yml 66 E301 HIGH Commands should not change things if nothing needs doing +plays/roles/slurm-start/tasks/main.yml 66 E305 HIGH Use shell only when shell functionality is required +plays/roles/upgrade/tasks/main.yml 66 E305 HIGH Use shell only when shell functionality is required diff --git a/CICD/ansiblelint/logdir/INFO b/CICD/ansiblelint/logdir/INFO new file mode 100644 index 00000000..1b741f36 --- /dev/null +++ b/CICD/ansiblelint/logdir/INFO @@ -0,0 +1,141 @@ +filepath line rule serverity rule description +plays/allnodes.yml 2 E201 INFO Trailing whitespace +plays/allnodes.yml 3 E201 INFO Trailing whitespace +plays/allnodes.yml 6 E201 INFO Trailing whitespace +plays/allnodes.yml 7 E201 INFO Trailing whitespace +plays/allnodes.yml 8 E201 INFO Trailing whitespace +plays/allnodes.yml 15 E201 INFO Trailing whitespace +plays/allnodes.yml 16 E201 INFO Trailing whitespace +plays/allnodes.yml 19 E201 INFO Trailing whitespace +plays/allnodes.yml 20 E201 INFO Trailing whitespace +plays/allnodes.yml 21 E201 INFO Trailing whitespace +plays/allnodes.yml 32 E201 INFO Trailing whitespace +plays/allnodes.yml 33 E201 INFO Trailing whitespace +plays/allnodes.yml 36 E201 INFO Trailing whitespace +plays/allnodes.yml 37 E201 INFO Trailing whitespace +plays/allnodes.yml 38 E201 INFO Trailing whitespace +plays/computenodes.yml 3 E201 INFO Trailing whitespace +plays/computenodes.yml 4 E201 INFO Trailing whitespace +plays/computenodes.yml 7 E201 INFO Trailing whitespace +plays/computenodes.yml 8 E201 INFO Trailing whitespace +plays/computenodes.yml 9 E201 INFO Trailing whitespace +plays/computenodes.yml 15 E201 INFO Trailing whitespace +plays/computenodes.yml 16 E201 INFO Trailing whitespace +plays/computenodes.yml 19 E201 INFO Trailing whitespace +plays/computenodes.yml 20 E201 INFO Trailing whitespace +plays/computenodes.yml 21 E201 INFO Trailing whitespace +plays/init_slurmconf.yml 4 E201 INFO Trailing whitespace +plays/init_slurmconf.yml 7 E201 INFO Trailing whitespace +plays/init_slurmconf.yml 8 E201 INFO Trailing whitespace +plays/init_slurmconf.yml 9 E201 INFO Trailing whitespace +plays/make_files.yml 17 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 6 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 7 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 10 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 11 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 12 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 21 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 22 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 25 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 26 E201 INFO Trailing whitespace +plays/mgmtnodes.yml 27 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 9 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 14 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 17 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 18 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 19 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 23 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 25 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 26 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 29 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 30 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 31 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 37 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 38 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 41 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 42 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 43 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 52 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 54 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 55 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 58 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 59 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 60 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 74 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 75 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 78 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 79 E201 INFO Trailing whitespace +plays/nfssqlnodes.yml 80 E201 INFO Trailing whitespace +plays/roles/calculateEtcHosts/tasks/main.yml 11 E201 INFO Trailing whitespace +plays/roles/calculateKnownHosts/tasks/main.yml 4 E201 INFO Trailing whitespace +plays/roles/config_repos/tasks/main.yml 4 E201 INFO Trailing whitespace +plays/roles/config_repos/tasks/main.yml 5 E201 INFO Trailing whitespace +plays/roles/enable_modules/tasks/main.yml 4 E201 INFO Trailing whitespace +plays/roles/etcHosts/tasks/main.yml 29 E201 INFO Trailing whitespace +plays/roles/etcHosts/tasks/main.yml 42 E201 INFO Trailing whitespace +plays/roles/etcHosts/tasks/main.yml 44 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 2 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 11 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 53 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 69 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 80 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 84 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 88 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 93 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 115 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 133 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 152 E201 INFO Trailing whitespace +plays/roles/gpu/tasks/main.yml 168 E201 INFO Trailing whitespace +plays/roles/jasons_ssh_ca/tasks/main.yml 10 E201 INFO Trailing whitespace +plays/roles/ldapclient/handlers/main.yml 2 E201 INFO Trailing whitespace +plays/roles/ldapclient/tasks/installOpenLdap.yml 3 E201 INFO Trailing whitespace +plays/roles/ldapclient/tasks/installOpenLdap.yml 13 E201 INFO Trailing whitespace +plays/roles/ldapclient/tasks/installOpenLdap.yml 14 E201 INFO Trailing whitespace +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 35 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 +plays/roles/nfs-client/tasks/mountFileSystem.yml 6 E201 INFO Trailing whitespace +plays/roles/nfs-common/handlers/main.yml 1 E201 INFO Trailing whitespace +plays/roles/nfs-common/handlers/main.yml 2 E201 INFO Trailing whitespace +plays/roles/nfs-common/tasks/aptPackages.yml 2 E201 INFO Trailing whitespace +plays/roles/nfs-common/tasks/yumPackages.yml 1 E201 INFO Trailing whitespace +plays/roles/nfs-common/tasks/yumPackages.yml 2 E201 INFO Trailing whitespace +plays/roles/nfs-common/tasks/yumPackages.yml 4 E201 INFO Trailing whitespace +plays/roles/nfs-server/tasks/startServer.yml 1 E201 INFO Trailing whitespace +plays/roles/postfix/handlers/main.yml 2 E201 INFO Trailing whitespace +plays/roles/postfix/tasks/main.yml 12 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/createSlurmDirectories.yml 15 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/createSlurmDirectories.yml 25 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/createSlurmDirectories.yml 27 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/createSlurmDirectories.yml 59 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/installCgroup.yml 1 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/installCgroup.yml 9 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/installCgroup.yml 14 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/installCgroup.yml 15 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/installMungeFromSource.yml 31 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/installMungeFromSource.yml 33 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 3 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 8 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/main.yml 108 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/main.yml 124 E201 INFO Trailing whitespace +plays/roles/slurm-common/tasks/main.yml 136 E201 INFO Trailing whitespace +plays/roles/slurm-start/tasks/main.yml 3 E201 INFO Trailing whitespace +plays/roles/slurm-start/tasks/main.yml 6 E201 INFO Trailing whitespace +plays/roles/slurmdb-config/tasks/main.yml 33 E201 INFO Trailing whitespace +plays/roles/slurmdb-config/tasks/main.yml 34 E201 INFO Trailing whitespace +plays/roles/slurmdb-config/tasks/main.yml 44 E201 INFO Trailing whitespace +plays/roles/slurmdb-config/tasks/main.yml 45 E201 INFO Trailing whitespace +plays/roles/ssh-password-login/tasks/main.yml 6 E201 INFO Trailing whitespace +plays/roles/ssh-password-login/tasks/main.yml 9 E201 INFO Trailing whitespace +plays/roles/ssh-password-login/tasks/main.yml 21 E201 INFO Trailing whitespace +plays/roles/upgrade/tasks/main.yml 56 E201 INFO Trailing whitespace +plays/roles/upgrade/tasks/main.yml 58 E201 INFO Trailing whitespace +plays/roles/upgrade/tasks/main.yml 64 E201 INFO Trailing whitespace +plays/roles/upgrade/tasks/main.yml 70 E201 INFO Trailing whitespace +plays/roles/upgrade/tasks/main.yml 73 E201 INFO Trailing whitespace +plays/roles/upgrade/tasks/main.yml 90 E201 INFO Trailing whitespace diff --git a/CICD/ansiblelint/logdir/LOW b/CICD/ansiblelint/logdir/LOW new file mode 100644 index 00000000..b091ba7d --- /dev/null +++ b/CICD/ansiblelint/logdir/LOW @@ -0,0 +1,6 @@ +filepath line rule serverity rule description +plays/roles/config_repos/tasks/main.yml 54 E206 LOW Variables should have spaces before and after: {{ var_name }} +plays/roles/lmod/tasks/main.yml 39 E206 LOW Variables should have spaces before and after: {{ var_name }} +plays/roles/lmod/tasks/main.yml 48 E206 LOW Variables should have spaces before and after: {{ var_name }} +plays/roles/slurm-common/tasks/createSlurmDirectories.yml 43 E206 LOW Variables should have spaces before and after: {{ var_name }} +plays/roles/slurm-start/tasks/main.yml 67 E206 LOW Variables should have spaces before and after: {{ var_name }} diff --git a/CICD/ansiblelint/logdir/MEDIUM b/CICD/ansiblelint/logdir/MEDIUM new file mode 100644 index 00000000..2a344d6e --- /dev/null +++ b/CICD/ansiblelint/logdir/MEDIUM @@ -0,0 +1,35 @@ +filepath line rule serverity rule description +plays/init_slurmconf.yml 4 E502 MEDIUM All tasks should be named +plays/init_slurmconf.yml 5 E502 MEDIUM All tasks should be named +plays/init_slurmconf.yml 6 E502 MEDIUM All tasks should be named +plays/init_slurmconf.yml 7 E502 MEDIUM All tasks should be named +plays/init_slurmconf.yml 8 E502 MEDIUM All tasks should be named +plays/init_slurmconf.yml 9 E502 MEDIUM All tasks should be named +plays/make_files.yml 5 E502 MEDIUM All tasks should be named +plays/make_files.yml 6 E502 MEDIUM All tasks should be named +plays/make_files.yml 7 E502 MEDIUM All tasks should be named +plays/make_files.yml 8 E502 MEDIUM All tasks should be named +plays/make_files.yml 9 E502 MEDIUM All tasks should be named +plays/make_files.yml 10 E502 MEDIUM All tasks should be named +plays/nfssqlnodes.yml 14 E502 MEDIUM All tasks should be named +plays/nfssqlnodes.yml 15 E502 MEDIUM All tasks should be named +plays/nfssqlnodes.yml 16 E502 MEDIUM All tasks should be named +plays/nfssqlnodes.yml 17 E502 MEDIUM All tasks should be named +plays/nfssqlnodes.yml 18 E502 MEDIUM All tasks should be named +plays/nfssqlnodes.yml 19 E502 MEDIUM All tasks should be named +plays/roles/config_repos/tasks/main.yml 43 E306 MEDIUM Shells that use pipes should set the pipefail option +plays/roles/etcHosts/tasks/main.yml 5 E306 MEDIUM Shells that use pipes should set the pipefail option +plays/roles/etcHosts/tasks/main.yml 18 E306 MEDIUM Shells that use pipes should set the pipefail option +plays/roles/gpu/tasks/main.yml 72 E306 MEDIUM Shells that use pipes should set the pipefail option +plays/roles/gpu/tasks/main.yml 109 E306 MEDIUM Shells that use pipes should set the pipefail option +plays/roles/jasons_ssh_ca/handlers/main.yml 2 E502 MEDIUM All tasks should be named +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/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 +plays/roles/slurm-start/tasks/main.yml 46 E503 MEDIUM Tasks that run when changed should likely be handlers +plays/roles/slurm-start/tasks/main.yml 51 E503 MEDIUM Tasks that run when changed should likely be handlers +plays/roles/upgrade/tasks/main.yml 50 E306 MEDIUM Shells that use pipes should set the pipefail option +plays/roles/upgrade/tasks/main.yml 59 E306 MEDIUM Shells that use pipes should set the pipefail option diff --git a/CICD/ansiblelint/logdir/VERY_HIGH b/CICD/ansiblelint/logdir/VERY_HIGH new file mode 100644 index 00000000..4e0ae716 --- /dev/null +++ b/CICD/ansiblelint/logdir/VERY_HIGH @@ -0,0 +1,9 @@ +filepath line rule serverity rule description +plays/roles/gpu/tasks/main.yml 133 E302 VERY_HIGH chmod used in place of argument mode to file module +plays/roles/slurm-common/tasks/createSlurmDirectories.yml 38 E103 VERY_HIGH Deprecated sudo feature +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 1 E302 VERY_HIGH rm used in place of argument state=absent to file module +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 6 E302 VERY_HIGH rm used in place of argument state=absent to file module +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 96 E302 VERY_HIGH rm used in place of argument state=absent to file module +plays/roles/slurm-common/tasks/installSlurmFromSource.yml 101 E302 VERY_HIGH ln used in place of argument state=link to file module +plays/roles/slurmdb-config/tasks/main.yml 24 E103 VERY_HIGH Deprecated sudo feature +plays/roles/slurmdb-config/tasks/main.yml 28 E103 VERY_HIGH Deprecated sudo feature diff --git a/CICD/ansiblelint/logdir/VERY_LOW b/CICD/ansiblelint/logdir/VERY_LOW new file mode 100644 index 00000000..5e1812c8 --- /dev/null +++ b/CICD/ansiblelint/logdir/VERY_LOW @@ -0,0 +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/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 +plays/roles/upgrade/tasks/main.yml 44 E403 VERY_LOW Package installs should not use latest diff --git a/CICD/ansiblelint/logdir/logfile b/CICD/ansiblelint/logdir/logfile new file mode 100644 index 00000000..0afa53d4 --- /dev/null +++ b/CICD/ansiblelint/logdir/logfile @@ -0,0 +1,234 @@ +plays/allnodes.yml:2: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:3: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:6: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:7: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:8: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:15: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:16: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:19: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:20: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:21: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:32: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:33: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:36: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:37: [E201] [INFO] Trailing whitespace +plays/allnodes.yml:38: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:3: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:4: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:7: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:8: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:9: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:15: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:16: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:19: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:20: [E201] [INFO] Trailing whitespace +plays/computenodes.yml:21: [E201] [INFO] Trailing whitespace +plays/init_slurmconf.yml:4: [E201] [INFO] Trailing whitespace +plays/init_slurmconf.yml:4: [E502] [MEDIUM] All tasks should be named +plays/init_slurmconf.yml:5: [E502] [MEDIUM] All tasks should be named +plays/init_slurmconf.yml:6: [E502] [MEDIUM] All tasks should be named +plays/init_slurmconf.yml:7: [E201] [INFO] Trailing whitespace +plays/init_slurmconf.yml:7: [E502] [MEDIUM] All tasks should be named +plays/init_slurmconf.yml:8: [E201] [INFO] Trailing whitespace +plays/init_slurmconf.yml:8: [E502] [MEDIUM] All tasks should be named +plays/init_slurmconf.yml:9: [E201] [INFO] Trailing whitespace +plays/init_slurmconf.yml:9: [E502] [MEDIUM] All tasks should be named +plays/make_files.yml:5: [E502] [MEDIUM] All tasks should be named +plays/make_files.yml:6: [E502] [MEDIUM] All tasks should be named +plays/make_files.yml:7: [E502] [MEDIUM] All tasks should be named +plays/make_files.yml:8: [E502] [MEDIUM] All tasks should be named +plays/make_files.yml:9: [E502] [MEDIUM] All tasks should be named +plays/make_files.yml:10: [E502] [MEDIUM] All tasks should be named +plays/make_files.yml:17: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:6: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:7: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:10: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:11: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:12: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:21: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:22: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:25: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:26: [E201] [INFO] Trailing whitespace +plays/mgmtnodes.yml:27: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:9: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:14: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:14: [E502] [MEDIUM] All tasks should be named +plays/nfssqlnodes.yml:15: [E502] [MEDIUM] All tasks should be named +plays/nfssqlnodes.yml:16: [E502] [MEDIUM] All tasks should be named +plays/nfssqlnodes.yml:17: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:17: [E502] [MEDIUM] All tasks should be named +plays/nfssqlnodes.yml:18: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:18: [E502] [MEDIUM] All tasks should be named +plays/nfssqlnodes.yml:19: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:19: [E502] [MEDIUM] All tasks should be named +plays/nfssqlnodes.yml:23: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:25: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:26: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:29: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:30: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:31: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:37: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:38: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:41: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:42: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:43: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:49: [E204] [VERY_LOW] Lines should be no longer than 160 chars +plays/nfssqlnodes.yml:52: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:54: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:55: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:58: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:59: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:60: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:74: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:75: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:78: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:79: [E201] [INFO] Trailing whitespace +plays/nfssqlnodes.yml:80: [E201] [INFO] Trailing whitespace +plays/roles/calculateEtcHosts/tasks/main.yml:8: [E301] [HIGH] Commands should not change things if nothing needs doing +plays/roles/calculateEtcHosts/tasks/main.yml:11: [E201] [INFO] Trailing whitespace +plays/roles/calculateKnownHosts/tasks/main.yml:4: [E201] [INFO] Trailing whitespace +plays/roles/config_repos/tasks/main.yml:4: [E201] [INFO] Trailing whitespace +plays/roles/config_repos/tasks/main.yml:5: [E201] [INFO] Trailing whitespace +plays/roles/config_repos/tasks/main.yml:43: [E306] [MEDIUM] Shells that use pipes should set the pipefail option +plays/roles/config_repos/tasks/main.yml:52: [E301] [HIGH] Commands should not change things if nothing needs doing +plays/roles/config_repos/tasks/main.yml:52: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/config_repos/tasks/main.yml:54: [E206] [LOW] Variables should have spaces before and after: {{ var_name }} +plays/roles/config_repos/tasks/main.yml:67: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/config_repos/tasks/main.yml:72: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/config_repos/tasks/main.yml:77: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/enable_modules/tasks/main.yml:4: [E201] [INFO] Trailing whitespace +plays/roles/etcHosts/tasks/main.yml:5: [E306] [MEDIUM] Shells that use pipes should set the pipefail option +plays/roles/etcHosts/tasks/main.yml:13: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/etcHosts/tasks/main.yml:18: [E306] [MEDIUM] Shells that use pipes should set the pipefail option +plays/roles/etcHosts/tasks/main.yml:26: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/etcHosts/tasks/main.yml:29: [E201] [INFO] Trailing whitespace +plays/roles/etcHosts/tasks/main.yml:42: [E201] [INFO] Trailing whitespace +plays/roles/etcHosts/tasks/main.yml:44: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:2: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:11: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:53: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:56: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/gpu/tasks/main.yml:69: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:72: [E306] [MEDIUM] Shells that use pipes should set the pipefail option +plays/roles/gpu/tasks/main.yml:80: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:84: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:88: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:93: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:109: [E306] [MEDIUM] Shells that use pipes should set the pipefail option +plays/roles/gpu/tasks/main.yml:115: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:133: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:133: [E302] [VERY_HIGH] chmod used in place of argument mode to file module +plays/roles/gpu/tasks/main.yml:138: [E301] [HIGH] Commands should not change things if nothing needs doing +plays/roles/gpu/tasks/main.yml:138: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/gpu/tasks/main.yml:148: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/gpu/tasks/main.yml:152: [E201] [INFO] Trailing whitespace +plays/roles/gpu/tasks/main.yml:168: [E201] [INFO] Trailing whitespace +plays/roles/jasons_ssh_ca/handlers/main.yml:2: [E502] [MEDIUM] All tasks should be named +plays/roles/jasons_ssh_ca/tasks/main.yml:2: [E502] [MEDIUM] All tasks should be named +plays/roles/jasons_ssh_ca/tasks/main.yml:10: [E201] [INFO] Trailing whitespace +plays/roles/ldapclient/handlers/main.yml:2: [E201] [INFO] Trailing whitespace +plays/roles/ldapclient/tasks/installOpenLdap.yml:3: [E201] [INFO] Trailing whitespace +plays/roles/ldapclient/tasks/installOpenLdap.yml:13: [E201] [INFO] Trailing whitespace +plays/roles/ldapclient/tasks/installOpenLdap.yml:14: [E201] [INFO] Trailing whitespace +plays/roles/ldapclient/tasks/main.yml:3: [E201] [INFO] Trailing whitespace +plays/roles/ldapclient/tasks/main.yml:5: [E201] [INFO] Trailing whitespace +plays/roles/lmod/tasks/main.yml:2: [E502] [MEDIUM] All tasks should be named +plays/roles/lmod/tasks/main.yml:39: [E206] [LOW] Variables should have spaces before and after: {{ var_name }} +plays/roles/lmod/tasks/main.yml:48: [E206] [LOW] Variables should have spaces before and after: {{ var_name }} +plays/roles/lmod/tasks/main.yml:52: [E204] [VERY_LOW] Lines should be no longer than 160 chars +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: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/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 +plays/roles/nfs-client/tasks/mountFileSystem.yml:1: [E201] [INFO] Trailing whitespace +plays/roles/nfs-client/tasks/mountFileSystem.yml:6: [E201] [INFO] Trailing whitespace +plays/roles/nfs-common/handlers/main.yml:1: [E201] [INFO] Trailing whitespace +plays/roles/nfs-common/handlers/main.yml:2: [E201] [INFO] Trailing whitespace +plays/roles/nfs-common/tasks/aptPackages.yml:2: [E201] [INFO] Trailing whitespace +plays/roles/nfs-common/tasks/yumPackages.yml:1: [E201] [INFO] Trailing whitespace +plays/roles/nfs-common/tasks/yumPackages.yml:2: [E201] [INFO] Trailing whitespace +plays/roles/nfs-common/tasks/yumPackages.yml:4: [E201] [INFO] Trailing whitespace +plays/roles/nfs-server/meta/main.yml:2: [E701] [HIGH] No 'galaxy_info' found +plays/roles/nfs-server/tasks/startServer.yml:1: [E201] [INFO] Trailing whitespace +plays/roles/postfix/handlers/main.yml:2: [E201] [INFO] Trailing whitespace +plays/roles/postfix/tasks/main.yml:12: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/createSlurmDirectories.yml:15: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/createSlurmDirectories.yml:25: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/createSlurmDirectories.yml:27: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/createSlurmDirectories.yml:38: [E103] [VERY_HIGH] Deprecated sudo feature +plays/roles/slurm-common/tasks/createSlurmDirectories.yml:43: [E206] [LOW] Variables should have spaces before and after: {{ var_name }} +plays/roles/slurm-common/tasks/createSlurmDirectories.yml:59: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installCgroup.yml:1: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installCgroup.yml:9: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installCgroup.yml:14: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installCgroup.yml:15: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installMungeFromSource.yml:22: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installMungeFromSource.yml:31: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installMungeFromSource.yml:33: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installMungeFromSource.yml:46: [E303] [HIGH] systemctl used in place of systemd module +plays/roles/slurm-common/tasks/installMungeFromSource.yml:46: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installMungeFromSource.yml:46: [E503] [MEDIUM] Tasks that run when changed should likely be handlers +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:1: [E302] [VERY_HIGH] rm used in place of argument state=absent to file module +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:1: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:3: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:6: [E302] [VERY_HIGH] rm used in place of argument state=absent to file module +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:6: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:8: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:37: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:51: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:64: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:77: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:96: [E302] [VERY_HIGH] rm used in place of argument state=absent to file module +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:96: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:101: [E302] [VERY_HIGH] ln used in place of argument state=link to file module +plays/roles/slurm-common/tasks/installSlurmFromSource.yml:101: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/main.yml:81: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-common/tasks/main.yml:95: [E306] [MEDIUM] Shells that use pipes should set the pipefail option +plays/roles/slurm-common/tasks/main.yml:108: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/main.yml:124: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/main.yml:124: [E601] [HIGH] Don't compare to literal True/False +plays/roles/slurm-common/tasks/main.yml:129: [E601] [HIGH] Don't compare to literal True/False +plays/roles/slurm-common/tasks/main.yml:136: [E201] [INFO] Trailing whitespace +plays/roles/slurm-common/tasks/main.yml:145: [E601] [HIGH] Don't compare to literal True/False +plays/roles/slurm-start/tasks/main.yml:3: [E201] [INFO] Trailing whitespace +plays/roles/slurm-start/tasks/main.yml:6: [E201] [INFO] Trailing whitespace +plays/roles/slurm-start/tasks/main.yml:41: [E303] [HIGH] systemctl used in place of systemd module +plays/roles/slurm-start/tasks/main.yml:41: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-start/tasks/main.yml:41: [E503] [MEDIUM] Tasks that run when changed should likely be handlers +plays/roles/slurm-start/tasks/main.yml:46: [E303] [HIGH] systemctl used in place of systemd module +plays/roles/slurm-start/tasks/main.yml:46: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-start/tasks/main.yml:46: [E503] [MEDIUM] Tasks that run when changed should likely be handlers +plays/roles/slurm-start/tasks/main.yml:51: [E303] [HIGH] systemctl used in place of systemd module +plays/roles/slurm-start/tasks/main.yml:51: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-start/tasks/main.yml:51: [E503] [MEDIUM] Tasks that run when changed should likely be handlers +plays/roles/slurm-start/tasks/main.yml:66: [E301] [HIGH] Commands should not change things if nothing needs doing +plays/roles/slurm-start/tasks/main.yml:66: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/slurm-start/tasks/main.yml:67: [E206] [LOW] Variables should have spaces before and after: {{ var_name }} +plays/roles/slurmdb-config/tasks/main.yml:24: [E103] [VERY_HIGH] Deprecated sudo feature +plays/roles/slurmdb-config/tasks/main.yml:28: [E103] [VERY_HIGH] Deprecated sudo feature +plays/roles/slurmdb-config/tasks/main.yml:33: [E201] [INFO] Trailing whitespace +plays/roles/slurmdb-config/tasks/main.yml:34: [E201] [INFO] Trailing whitespace +plays/roles/slurmdb-config/tasks/main.yml:44: [E201] [INFO] Trailing whitespace +plays/roles/slurmdb-config/tasks/main.yml:45: [E201] [INFO] Trailing whitespace +plays/roles/ssh-password-login/tasks/main.yml:6: [E201] [INFO] Trailing whitespace +plays/roles/ssh-password-login/tasks/main.yml:9: [E201] [INFO] Trailing whitespace +plays/roles/ssh-password-login/tasks/main.yml:21: [E201] [INFO] Trailing whitespace +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 +plays/roles/upgrade/tasks/main.yml:44: [E403] [VERY_LOW] Package installs should not use latest +plays/roles/upgrade/tasks/main.yml:50: [E306] [MEDIUM] Shells that use pipes should set the pipefail option +plays/roles/upgrade/tasks/main.yml:56: [E201] [INFO] Trailing whitespace +plays/roles/upgrade/tasks/main.yml:58: [E201] [INFO] Trailing whitespace +plays/roles/upgrade/tasks/main.yml:59: [E306] [MEDIUM] Shells that use pipes should set the pipefail option +plays/roles/upgrade/tasks/main.yml:64: [E201] [INFO] Trailing whitespace +plays/roles/upgrade/tasks/main.yml:66: [E305] [HIGH] Use shell only when shell functionality is required +plays/roles/upgrade/tasks/main.yml:70: [E201] [INFO] Trailing whitespace +plays/roles/upgrade/tasks/main.yml:73: [E201] [INFO] Trailing whitespace +plays/roles/upgrade/tasks/main.yml:90: [E201] [INFO] Trailing whitespace diff --git a/CICD/ansiblelint/run_lint.py b/CICD/ansiblelint/run_lint.py new file mode 100644 index 00000000..50490689 --- /dev/null +++ b/CICD/ansiblelint/run_lint.py @@ -0,0 +1,75 @@ +import yaml +from argparse import ArgumentParser +import subprocess +from pathlib import Path +import re +import sys +from collections import defaultdict +def parse_argument(): + parser = ArgumentParser("ansible lint runner with customized spec") + parser.add_argument('--spec', type=str, nargs='?', help="yaml file which defines warning and error rules") + parser.add_argument('targets', type=str, nargs='+', help="role or task to lint") + parser.add_argument('--logdir', type=Path, default=Path('./ansiblelint/logdir'), help='log directory default to ./ansiblelint/logdir') + + args = parser.parse_args() + + args.logdir.mkdir(exist_ok=True) + return args +def parse_rule_output(line): + # (filepath, line, rule, severity, rule_desc) + expression = '(.*\.yml):([0-9]+): \[(.*)\] \[(.*)\] (.*$)' + matched = re.match(expression, line) + matched_groups = matched.groups() + return matched_groups +def group_by(output, idx): + res = defaultdict(list) + for i in output: + # print(i) + res[i[idx]].append(i) + return res +cmd_template = "ansible-lint --parseable-severity --nocolor " +outputs = defaultdict() +def main(): + exit_code = 0 + args = parse_argument() + if args.spec is not None: + with open(args.spec, 'r') as f: + spec = yaml.load(f) + for k,v in spec.items(): + cmd = cmd_template + ' '.join(['-t ' + str(tag) for tag in v]) + cmd += ' ' + ' '.join(args.targets) + logfile = args.logdir.joinpath(k) + cmd += ' 2>&1 | tee {}'.format(str(logfile.resolve())) + output = subprocess.check_output(cmd, shell=True) + output = output.decode().splitlines() + output = [parse_rule_output(line) for line in output] + outputs[k] = output + # outputs.append(output) + else: + cmd = cmd_template + cmd += ' ' + ' '.join(args.targets) + logfile = args.logdir.joinpath('logfile') + cmd += ' 2>&1 | tee {}'.format(str(logfile.resolve())) + # print(cmd) + output = subprocess.check_output(cmd, shell=True) + output = output.decode().splitlines() + output = [parse_rule_output(line) for line in output] + + # group by serverity + output = group_by(output, 3) + # print(output.keys()) + + for k,v in output.items(): + if (k == 'HIGH' or k=='VERY_HIGH') and len(v) != 0: + exit_code = 1 + current_log = args.logdir.joinpath(k).resolve() + + 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 +if __name__ == "__main__": + main() diff --git a/CICD/ansiblelint/spec.yml b/CICD/ansiblelint/spec.yml new file mode 100644 index 00000000..53ee4a04 --- /dev/null +++ b/CICD/ansiblelint/spec.yml @@ -0,0 +1,37 @@ +--- +# https://docs.ansibl.com/ansibl-lint/ruls/dfault_ruls.html +error: + - 101 + - 102 + - 103 + - 104 + - 202 + - 304 + - 306 + - 401 + - 402 + - 403 + - 404 + - 501 + - 502 + - 701 + +warning: + - 105 + - 201 + - 203 + - 204 + - 205 + - 206 + - 301 + - 302 + - 303 + - 305 + - 503 + - 504 + - 601 + - 602 + - 702 + - 703 + - 704 + -- GitLab