diff --git a/defaults/main.yml b/defaults/main.yml index d4696e6fabdddd40945925bedda99bd0474d82bf..f2510d4f802c517d8af45687d5b99a1c67b706c8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,6 +3,5 @@ paas_ci_orchestrator_url: https://paas.cloud.infn.it/orchestrator paas_ci_iam_group: admins/cicd paas_ci_workdir: "{{ lookup('env','WORKSPACE') }}" -paas_ci_scan_script_path: "{{ paas_ci_workdir }}/scan.py" n_timeout_ticks: 60 endpoints_to_scan: None \ No newline at end of file diff --git a/files/scan.py b/files/scan.py index e3f1f10146b4348109c9b1cfcf3ea55c51407113..ae3744a3abdd2a20e241f092845f09026b547b0a 100644 --- a/files/scan.py +++ b/files/scan.py @@ -4,8 +4,8 @@ import logging import json from sys import argv, exit import os -import gvm_library -import utilities +import scan_gvm_library as gvm_library +import scan_utilities as utilities import argparse ### GVM Options ### diff --git a/files/gvm_library.py b/files/scan_gvm_library.py similarity index 100% rename from files/gvm_library.py rename to files/scan_gvm_library.py diff --git a/files/utilities.py b/files/scan_utilities.py similarity index 100% rename from files/utilities.py rename to files/scan_utilities.py diff --git a/tasks/2-scan.yml b/tasks/2-scan.yml index 585ee0d925bacd14b7c35068c0c1609297b124ba..1448c93cab52d38b5c1032a9b6f99fee6d41ca27 100644 --- a/tasks/2-scan.yml +++ b/tasks/2-scan.yml @@ -9,35 +9,60 @@ - name: Copy scan script copy: src: files/scan.py - dest: "{{ paas_ci_scan_script_path }}" + dest: "{{ paas_ci_workdir + '/scan.py' }}" - name: Copy utilities module copy: src: files/utilities.py - dest: "{{ paas_ci_scan_script_path }}" + dest: "{{ paas_ci_workdir + '/scan_utilities.py' }}" - name: Copy gvm_library module copy: src: files/gvm_library.py - dest: "{{ paas_ci_scan_script_path }}" + dest: "{{ paas_ci_workdir + '/scan_gvm_library.py' }}" - name: Adding execution permission to scan script file: - dest: "{{ paas_ci_scan_script_path + '/scan.py' }} " + dest: "{{ paas_ci_workdir + '/scan.py' }}" mode: a+x - name: Show dep json file debug: - msg: "{{lookup('file', item.path)}}" - with_items: "{{ paas_ci_workdir + '/dep.json'}}" + msg: "{{ lookup('file', item.path) }}" + with_items: "{{ paas_ci_workdir + '/dep.json' }}" + +- name: Load depdep log + command: cat "{{ paas_ci_workdir + '/dep.json' }}" + register: dep_json + +- name: import depdep_log + set_fact: + imported_depdep_log: "{{ dep_json.stdout }}" + +- name: Show depdep log + debug: + var: imported_depdep_log + +- name: Show BEFORE paas_ci_test.endpoints_to_scan log + debug: + var: paas_ci_test.endpoints_to_scan + +- name: Fail if "bar" is undefined + set_fact: + paas_ci_test.endpoints_to_scan: "None" + when: paas_ci_test.endpoints_to_scan is undefined + +- name: Show AFTER paas_ci_test.endpoints_to_scan log + debug: + var: paas_ci_test.endpoints_to_scan - name: Run scan - command: "{{ paas_ci_scan_script_path }}/scan.py --endpoint-keys {{ paas_ci_test.endpoints_to_scan }} --dep-json {{ paas_ci_workdir + '/dep.json'}} --output-dir {{ paas_ci_workdir }}" + command: "{{ paas_ci_workdir + '/scan.py' }} --endpoint-keys {{ paas_ci_test.endpoints_to_scan }} --dep-json {{ paas_ci_workdir + '/dep.json'}} --output-dir {{ paas_ci_workdir }}" register: scan_output - name: Scan logs debug: - msg: "{{lookup('file', item.path)}}" + msg: "{{ lookup('file', item.path) }}" with_items: "{{ paas_ci_workdir + 'scan.log' }}" - name: Show scan output @@ -46,12 +71,12 @@ - name: Find report files find: - paths: "{{paas_ci_workdir}}" + paths: "{{ paas_ci_workdir }}" patterns: '*infn.it-report.txt' register: report_files - name: read summary report file - shell: cat "{{ paas_ci_workdir + '/summary-report.json'}}" + shell: cat "{{ paas_ci_workdir + '/summary-report.json' }}" register: summary_report - name: import summary_report @@ -60,12 +85,12 @@ - name: Show reports debug: - msg: "{{lookup('file', item.path)}}" - with_items: "{{report_files.files}}" + msg: "{{ lookup('file', item.path) }}" + with_items: "{{ report_files.files }}" when: summary_report_json.global == 'NOK' - name: Load scans log - command: cat "{{ paas_ci_workdir + '/scans.log'}}" + command: cat "{{ paas_ci_workdir + '/scan.log' }}" register: scans_log when: summary_report_json.global == 'NOK'