Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
slapos.package
Commits
0ee609e5
Commit
0ee609e5
authored
Jul 31, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm-bootstrap: upload empty FAILED file when there is no failures
parent
9359cf97
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
playbook/roles/vm-bootstrap/tasks/uploadlog.yml
playbook/roles/vm-bootstrap/tasks/uploadlog.yml
+1
-1
playbook/roles/vm-bootstrap/templates/upload-script.j2
playbook/roles/vm-bootstrap/templates/upload-script.j2
+11
-2
No files found.
playbook/roles/vm-bootstrap/tasks/uploadlog.yml
View file @
0ee609e5
...
...
@@ -5,5 +5,5 @@
-
name
:
Add a periodical upload of logs and result
cron
:
name="Upload ansible files to http server"
minute="*/7"
job="
bash -lc
/usr/local/bin/ansible-upload-vm-logs http://10.0.2.100/ /var/log/vm-bootstrap.log > /var/log/ansible-upload.log"
job="/usr/local/bin/ansible-upload-vm-logs http://10.0.2.100/ /var/log/vm-bootstrap.log > /var/log/ansible-upload.log"
playbook/roles/vm-bootstrap/templates/upload-script.j2
View file @
0ee609e5
...
...
@@ -8,9 +8,11 @@ class uploader():
log_path
=
'/var/log/ansible/hosts'
url
=
''
host
=
'127.0.0.1'
def
__init__
(
self
,
url
=
'http://10.0.2.100/'
):
def
__init__
(
self
,
url
=
'http://10.0.2.100/'
,
host
=
'127.0.0.1'
):
self
.
url
=
url
self
.
host
=
host
def
upload_file
(
self
,
file_name
,
content
,
override
=
False
):
values
=
{
'path'
:
file_name
,
'content'
:
content
}
...
...
@@ -20,6 +22,7 @@ class uploader():
return
result
def
upload_result
(
self
):
has_failure
=
False
for
filename
in
os
.
listdir
(
self
.
log_path
):
filepath
=
os
.
path
.
join
(
self
.
log_path
,
filename
)
to_path
=
'ansible/%s'
%
filename
...
...
@@ -29,6 +32,12 @@ class uploader():
content
=
','
.
join
(
fd
.
readlines
())
r
=
self
.
upload_file
(
to_path
,
'[%s]'
%
content
,
True
)
print
'Content uploaded to %s'
%
to_path
,
r
if
filename
.
endswith
(
'FAILED'
):
has_failure
=
True
if
not
has_failure
:
to_path
=
'ansible/%s_FAILED'
%
self
.
host
r
=
self
.
upload_file
(
to_path
,
'[]'
,
True
)
print
'Content uploaded to %s'
%
to_path
,
r
def
readFileFrom
(
self
,
f
,
lastPosition
,
limit
=
20000
):
"""
...
...
@@ -83,7 +92,7 @@ if __name__ == "__main__":
if
len
(
sys
.
argv
)
>=
3
:
ansible_log
=
sys
.
argv
[
2
]
uploader
=
uploader
()
uploader
=
uploader
(
url
=
url
)
state_file
=
"/opt/.ansible_log.state"
log_destination
=
"ansible/vm-bootstrap.log"
current_state
=
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment