Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
c13f40f5
Commit
c13f40f5
authored
Nov 06, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1530 from dagwieers/mail-fixes
Improve the mail callback to support differing failures
parents
ac6f67b5
8323a03f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
25 deletions
+37
-25
plugins/callbacks/mail.py
+37
-25
No files found.
plugins/callbacks/mail.py
View file @
c13f40f5
...
...
@@ -51,33 +51,45 @@ class CallbackModule(object):
def
runner_on_failed
(
self
,
host
,
res
,
ignore_errors
=
False
):
if
ignore_errors
:
return
sender
=
'Ansible error on
%
s <root>'
%
host
subject
=
'Failure:
%
s'
%
res
[
'msg'
]
.
split
(
'
\n
'
)[
0
]
mail
(
sender
=
sender
,
subject
=
subject
,
body
=
'''The following task failed for host
%
s:
%
s
%
s
with the following error message:
%
s
A complete dump of the error:
%
s'''
%
(
host
,
res
[
'invocation'
][
'module_name'
],
res
[
'invocation'
][
'module_args'
],
res
[
'msg'
],
res
)
)
sender
=
'"Ansible:
%
s" <root>'
%
host
subject
=
'Failed:
%(module_name)
s
%(module_args)
s'
%
res
[
'invocation'
]
body
=
'The following task failed for host '
+
host
+
':
\n\n
%(module_name)
s
%(module_args)
s
\n\n
'
%
res
[
'invocation'
]
if
'stdout'
in
res
.
keys
()
and
res
[
'stdout'
]:
subject
=
res
[
'stdout'
]
.
strip
(
'
\r\n
'
)
.
split
(
'
\n
'
)[
-
1
]
body
+=
'with the following output in standard output:
\n\n
'
+
res
[
'stdout'
]
+
'
\n\n
'
if
'stderr'
in
res
.
keys
()
and
res
[
'stderr'
]:
subject
=
res
[
'stderr'
]
.
strip
(
'
\r\n
'
)
.
split
(
'
\n
'
)[
-
1
]
body
+=
'with the following output in standard error:
\n\n
'
+
res
[
'stderr'
]
+
'
\n\n
'
if
'msg'
in
res
.
keys
()
and
res
[
'msg'
]:
subject
=
res
[
'msg'
]
.
strip
(
'
\r\n
'
)
.
split
(
'
\n
'
)[
0
]
body
+=
'with the following message:
\n\n
'
+
res
[
'msg'
]
+
'
\n\n
'
body
+=
'A complete dump of the error:
\n\n
'
+
str
(
res
)
mail
(
sender
=
sender
,
subject
=
subject
,
body
=
body
)
def
runner_on_error
(
self
,
host
,
msg
):
sender
=
'Ansible:
%
s <root>'
%
host
subject
=
'Error:
%
s'
%
res
[
'msg'
]
.
split
(
'
\n
'
)[
0
]
mail
(
sender
=
sender
,
subject
=
subject
,
body
=
msg
)
sender
=
'"Ansible:
%
s" <root>'
%
host
subject
=
'Error:
%
s'
%
msg
.
strip
(
'
\r\n
'
)
.
split
(
'
\n
'
)[
0
]
body
=
'An error occured for host '
+
host
+
' with the following message:
\n\n
'
+
msg
mail
(
sender
=
sender
,
subject
=
subject
,
body
=
body
)
def
runner_on_unreachable
(
self
,
host
,
res
):
sender
=
'Ansible:
%
s <root>'
%
host
subject
=
'Unreachable:
%
s'
%
res
.
split
(
'
\n
'
)[
0
]
mail
(
sender
=
sender
,
subject
=
subject
,
body
=
res
)
sender
=
'"Ansible:
%
s" <root>'
%
host
if
isinstance
(
res
,
basestring
):
subject
=
'Unreachable:
%
s'
%
res
.
strip
(
'
\r\n
'
)
.
split
(
'
\n
'
)[
-
1
]
body
=
'An error occured for host '
+
host
+
' with the following message:
\n\n
'
+
res
else
:
subject
=
'Unreachable:
%
s'
%
res
[
'msg'
]
.
strip
(
'
\r\n
'
)
.
split
(
'
\n
'
)[
0
]
body
=
'An error occured for host '
+
host
+
' with the following message:
\n\n
'
+
\
res
[
'msg'
]
+
'
\n\n
A complete dump of the error:
\n\n
'
+
str
(
res
)
mail
(
sender
=
sender
,
subject
=
subject
,
body
=
body
)
def
runner_on_async_failed
(
self
,
host
,
res
,
jid
):
sender
=
'Ansible:
%
s <root>'
%
host
subject
=
'Async failure:
%
s'
%
res
.
split
(
'
\n
'
)[
0
]
mail
(
sender
=
sender
,
subject
=
subject
,
body
=
res
)
sender
=
'"Ansible:
%
s" <root>'
%
host
if
isinstance
(
res
,
basestring
):
subject
=
'Async failure:
%
s'
%
res
.
strip
(
'
\r\n
'
)
.
split
(
'
\n
'
)[
-
1
]
body
=
'An error occured for host '
+
host
+
' with the following message:
\n\n
'
+
res
else
:
subject
=
'Async failure:
%
s'
%
res
[
'msg'
]
.
strip
(
'
\r\n
'
)
.
split
(
'
\n
'
)[
0
]
body
=
'An error occured for host '
+
host
+
' with the following message:
\n\n
'
+
\
res
[
'msg'
]
+
'
\n\n
A complete dump of the error:
\n\n
'
+
str
(
res
)
mail
(
sender
=
sender
,
subject
=
subject
,
body
=
body
)
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