Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Paas CI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
INFN Cloud
Paas CI
Commits
ba1e0564
Commit
ba1e0564
authored
2 years ago
by
qweqweasdasd
Browse files
Options
Downloads
Patches
Plain Diff
Splitted the main in subfiles
parent
ea5fd3fa
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tasks/1-create-deployment.yml
+49
-0
49 additions, 0 deletions
tasks/1-create-deployment.yml
tasks/2-scan.yml
+41
-0
41 additions, 0 deletions
tasks/2-scan.yml
tasks/3-clean.yml
+7
-0
7 additions, 0 deletions
tasks/3-clean.yml
tasks/main.yml
+4
-103
4 additions, 103 deletions
tasks/main.yml
with
101 additions
and
103 deletions
tasks/1-create-deployment.yml
0 → 100644
+
49
−
0
View file @
ba1e0564
-
name
:
Get template
get_url
:
url
:
"
{{
paas_ci_test.template_url
}}"
dest
:
"
{{
paas_ci_workdir
+
'/template.yaml'
}}"
-
name
:
Deployment command
set_fact
:
depcreate_cmd
:
"
orchent
depcreate
--ojson
template.yaml
-g
admins/beta-testers
{{
paas_ci_test.inputs
}}"
-
name
:
Create the deployment
command
:
"
{{
depcreate_cmd
}}"
args
:
chdir
:
"
{{
paas_ci_workdir
}}"
register
:
depcreate_output
failed_when
:
"
'CREATE'
not
in
depcreate_output.stdout"
-
set_fact
:
deployment
:
"
{{
depcreate_output.stdout|from_json
}}"
-
debug
:
var
:
deployment
-
name
:
Sleep for 60 seconds and timeout
wait_for
:
delay
:
60
timeout
:
0
-
name
:
Check the deployment status (every 5 mins)
command
:
orchent depshow --ojson "{{ deployment.uuid }}"
register
:
depshow_output
until
:
"
'PROGRESS'
not
in
depshow_output.stdout"
retries
:
10
delay
:
300
failed_when
:
"
'error'
in
depshow_output.stdout"
-
set_fact
:
deployment
:
"
{{
depshow_output.stdout|from_json
}}"
-
name
:
Save result to file
copy
:
dest
:
"
{{
paas_ci_workdir
}}/dep.json"
content
:
"
{{
depshow_output.stdout
}}"
-
name
:
Get deployment status and outputs (if successful)
assert
:
that
:
-
deployment.status == 'CREATE_COMPLETE'
fail_msg
:
"
TEST
FAILED
-
deployment
uuid:
{{
deployment.uuid
}},
status:
{{
deployment.status
}}"
success_msg
:
"
TEST
PASSED
-
deployment
uuid:
{{
deployment.uuid
}},
status:
{{
deployment.status
}},
outputs:
{{
deployment.outputs
}}"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tasks/2-scan.yml
0 → 100644
+
41
−
0
View file @
ba1e0564
-
name
:
Set SSH tunnel
command
:
ssh -f -N -L "{{ ansible_default_ipv4.address }}":9390:192.168.187.162:9390 jenkins@scans.cloud.infn.it
-
set_fact
:
endpoints_to_scan
:
"
{{
paas_ci_test.endpoints_to_scan
}}"
-
debug
:
var
:
endpoints_to_scan
-
name
:
Run scan
command
:
"
{{
python3_script_path
}}
{{
endpoints_to_scan
}}
{{
paas_ci_workdir
+
'/dep.json'}}
{{
paas_ci_workdir
}}"
register
:
scan_output
-
name
:
Find report files
find
:
paths
:
"
{{paas_ci_workdir}}"
patterns
:
'
*report.txt'
register
:
report_files
-
name
:
Show reports
debug
:
msg
:
"
{{lookup('file',
item.path)}}"
with_items
:
"
{{report_files.files}}"
-
name
:
get Severity file content
shell
:
cat "{{ paas_ci_workdir + '/severity.json'}}"
register
:
severity
-
name
:
import severity
set_fact
:
severity_json
:
"
{{
severity.stdout
|
from_json
}}"
-
debug
:
var
:
severity_json
-
name
:
Get scan outputs (if successful)
assert
:
that
:
-
severity_json.global == 'OK'
fail_msg
:
"
SCAN
FAILED
-
global_severity:
{{
severity_json.global_severity
}}"
success_msg
:
"
SCAN
PASSED
-
global_severity:
{{
severity_json.global_severity
}}"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tasks/3-clean.yml
0 → 100644
+
7
−
0
View file @
ba1e0564
-
set_fact
:
deployment
:
"
{{
lookup('file',
paas_ci_workdir
+
'/dep.json')
}}"
-
name
:
Delete deployment
command
:
orchent depdel "{{ deployment.uuid }}"
register
:
depdel_output
failed_when
:
"
'error'
in
depdel_output.stdout"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tasks/main.yml
+
4
−
103
View file @
ba1e0564
...
...
@@ -7,110 +7,11 @@
-
debug
:
var
:
paas_ci_workdir
-
block
:
-
name
:
Get template
get_url
:
url
:
"
{{
paas_ci_test.template_url
}}"
dest
:
"
{{
paas_ci_workdir
+
'/template.yaml'
}}"
-
name
:
Deployment command
set_fact
:
depcreate_cmd
:
"
orchent
depcreate
--ojson
template.yaml
-g
admins/beta-testers
{{
paas_ci_test.inputs
}}"
-
name
:
Create the deployment
command
:
"
{{depcreate_cmd}}"
args
:
chdir
:
"
{{
paas_ci_workdir
}}"
register
:
depcreate_output
failed_when
:
"
'CREATE'
not
in
depcreate_output.stdout"
-
set_fact
:
deployment
:
"
{{
depcreate_output.stdout|from_json
}}"
-
debug
:
var
:
deployment
-
name
:
Sleep for 60 seconds and timeout
wait_for
:
delay
:
60
timeout
:
0
-
name
:
Check the deployment status (every 5 mins)
command
:
orchent depshow --ojson "{{ deployment.uuid }}"
register
:
depshow_output
until
:
"
'PROGRESS'
not
in
depshow_output.stdout"
retries
:
10
delay
:
300
failed_when
:
"
'error'
in
depshow_output.stdout"
-
set_fact
:
deployment
:
"
{{
depshow_output.stdout|from_json
}}"
-
name
:
Save result to file
copy
:
dest
:
"
{{
paas_ci_workdir
}}/dep.json"
content
:
"
{{
depshow_output.stdout
}}"
-
name
:
Get deployment status and outputs (if successful)
assert
:
that
:
-
deployment.status == 'CREATE_COMPLETE'
fail_msg
:
"
TEST
FAILED
-
deployment
uuid:
{{
deployment.uuid
}},
status:
{{
deployment.status
}}"
success_msg
:
"
TEST
PASSED
-
deployment
uuid:
{{
deployment.uuid
}},
status:
{{
deployment.status
}},
outputs:
{{
deployment.outputs
}}"
-
include
:
1-create-deployment.yml
when
:
paas_ci_test_step == 'create_deployment'
-
block
:
-
name
:
Set ssh bind
command
:
ssh -f -N -L "{{ ansible_default_ipv4.address }}":9390:192.168.187.162:9390 jenkins@scans.cloud.infn.it
-
set_fact
:
endpoints_to_scan
:
"
{{
paas_ci_test.endpoints_to_scan
}}"
-
debug
:
var
:
endpoints_to_scan
-
name
:
Run scan
command
:
"
{{
python3_script_path
}}
{{
endpoints_to_scan
}}
{{
paas_ci_workdir
+
'/dep.json'}}
{{
paas_ci_workdir
}}"
register
:
scan_output
-
name
:
Find report files
find
:
paths
:
"
{{paas_ci_workdir}}"
patterns
:
'
*report.txt'
register
:
report_files
-
name
:
Show reports
debug
:
msg
:
"
{{lookup('file',
item.path)}}"
with_items
:
"
{{report_files.files}}"
-
name
:
get Severity file content
shell
:
cat "{{ paas_ci_workdir + '/severity.json'}}"
register
:
severity
-
name
:
import severity
set_fact
:
severity_json
:
"
{{
severity.stdout
|
from_json
}}"
-
debug
:
var
:
severity_json
-
name
:
Get scan outputs (if successful)
assert
:
that
:
-
severity_json.global == 'OK'
fail_msg
:
"
SCAN
FAILED
-
global_severity:
{{
severity_json.global_severity
}}"
success_msg
:
"
SCAN
PASSED
-
global_severity:
{{
severity_json.global_severity
}}"
-
include
:
2-scan.yml
when
:
paas_ci_test_step == 'scan'
-
block
:
-
set_fact
:
deployment
:
"
{{
lookup('file',
paas_ci_workdir
+
'/dep.json')
}}"
-
name
:
Delete deployment
command
:
orchent depdel "{{ deployment.uuid }}"
register
:
depdel_output
failed_when
:
"
'error'
in
depdel_output.stdout"
when
:
paas_ci_test_step == 'clean'
-
include
:
3-clean.yml
when
:
paas_ci_test_step == 'clean'
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment