Hi Jeremy,
Thanks have taking a look.
The first patch should have been squashed with the second, those were
one black fixes.
I'll attach new patches 13 and 14, please drop the old ones.
0014 implements the exception handling, 0013 is the squashed old 0013+0014
Karsten
Am 11.11.19 um 17:07 schrieb Jeremy Cline:
On Sat, Nov 09, 2019 at 01:38:32AM +0100, karsten@xxxxxxxxxxxxxxxxx wrote:
Hello,
There is work in progress to migrate our applications from the current
message bus 'fedmsg' to the AMPG based 'fedora-messaging'.
Attached are a couple of patches that prepare our ansible scripts for this.
Please review those patches and comment, thanks !
Karsten
From 538f112bc17a511b0117ccac31f6c2e5ff0ee97a Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@xxxxxxxxxx>
Date: Fri, 8 Nov 2019 22:34:47 +0100
Subject: [PATCH 14/14] add callbacks for fedora-messaging
The subject here doesn't reflect at all what is in the patch, which is
pure style changes.
Signed-off-by: Karsten Hopp <karsten@xxxxxxxxxx>
---
callback_plugins/fedora_messaging_callback.py | 16 ++++++----------
callback_plugins/fedora_messaging_callback2.py | 17 +++++++----------
2 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/callback_plugins/fedora_messaging_callback.py b/callback_plugins/fedora_messaging_callback.py
index c83785e9b..31e918dde 100644
--- a/callback_plugins/fedora_messaging_callback.py
+++ b/callback_plugins/fedora_messaging_callback.py
@@ -29,10 +29,11 @@ except ImportError:
# Ansible v1 compat
CallbackBase = object
+
def getlogin():
try:
user = os.getlogin()
- except OSError, e:
+ except OSError as e:
user = pwd.getpwuid(os.geteuid())[0]
return user
@@ -45,11 +46,10 @@ class CallbackModule(CallbackBase):
def __init__(self):
pass
-
def playbook_on_play_start(self, pattern):
# This gets called once for each play.. but we just issue a message once
# for the first one. One per "playbook"
- play = getattr(self, 'play', None)
+ play = getattr(self, "play", None)
if play:
# figure out where the playbook FILE is
path = os.path.abspath(play.playbook.filename)
@@ -60,7 +60,7 @@ class CallbackModule(CallbackBase):
if not self.playbook_path:
msg = Message(
- topic='ansible.playbook.start',
+ topic="ansible.playbook.start",
body=dict(
playbook=path,
userid=getlogin(),
@@ -79,11 +79,7 @@ class CallbackModule(CallbackBase):
results = dict([(h, stats.summarize(h)) for h in stats.processed])
msg = Message(
- topic='ansible.playbook.complete',
- body=dict(
- playbook=self.playbook_path,
- userid=getlogin(),
- results=results,
- ),
+ topic="ansible.playbook.complete",
+ body=dict(playbook=self.playbook_path, userid=getlogin(), results=results),
)
publish(msg)
diff --git a/callback_plugins/fedora_messaging_callback2.py b/callback_plugins/fedora_messaging_callback2.py
index 733e159a7..3d1e357ac 100644
--- a/callback_plugins/fedora_messaging_callback2.py
+++ b/callback_plugins/fedora_messaging_callback2.py
@@ -34,10 +34,11 @@ try:
except ImportError:
from ansible.utils import md5 as secure_hash
+
def getlogin():
try:
user = os.getlogin()
- except OSError, e:
+ except OSError as e:
user = pwd.getpwuid(os.geteuid())[0]
return user
@@ -45,8 +46,8 @@ def getlogin():
class CallbackModule(CallbackBase):
""" Publish playbook starts and stops to fedora_messaging. """
- CALLBACK_NAME = 'fedora_messaging_callback2'
- CALLBACK_TYPE = 'notification'
+ CALLBACK_NAME = "fedora_messaging_callback2"
+ CALLBACK_TYPE = "notification"
CALLBACK_VERSION = 2.0
CALLBACK_NEEDS_WHITELIST = True
@@ -77,7 +78,7 @@ class CallbackModule(CallbackBase):
if not self.playbook_path:
msg = Message(
- topic='ansible.playbook.start',
+ topic="ansible.playbook.start",
body=dict(
playbook=path,
userid=getlogin(),
@@ -96,11 +97,7 @@ class CallbackModule(CallbackBase):
results = dict([(h, stats.summarize(h)) for h in stats.processed])
msg = Message(
- topic='ansible.playbook.complete',
- body=dict(
- playbook=self.playbook_path,
- userid=getlogin(),
- results=results,
- ),
+ topic="ansible.playbook.complete",
+ body=dict(playbook=self.playbook_path, userid=getlogin(), results=results),
)
publish(msg)
--
2.21.0
From 1563b45d15092cd86a636fd32e90a2f02f952169 Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@xxxxxxxxxx>
Date: Fri, 8 Nov 2019 22:34:47 +0100
Subject: [PATCH 13/14] add callbacks for fedora-messaging
Signed-off-by: Karsten Hopp <karsten@xxxxxxxxxx>
---
callback_plugins/fedora_messaging_callback.py | 89 +++++++++++++++
.../fedora_messaging_callback2.py | 106 ++++++++++++++++++
2 files changed, 195 insertions(+)
create mode 100644 callback_plugins/fedora_messaging_callback.py
create mode 100644 callback_plugins/fedora_messaging_callback2.py
diff --git a/callback_plugins/fedora_messaging_callback.py b/callback_plugins/fedora_messaging_callback.py
new file mode 100644
index 000000000..c83785e9b
--- /dev/null
+++ b/callback_plugins/fedora_messaging_callback.py
@@ -0,0 +1,89 @@
+# (C) 2012, Michael DeHaan, <michael.dehaan@xxxxxxxxx>
+# based on the log_plays example
+# skvidal@xxxxxxxxxxxxxxxxx
+# rbean@xxxxxxxxxx
+# karsten@xxxxxxxxxx changes for fedora-messaging
+
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import pwd
+
+from fedora_messaging.api import Message, publish
+from fedora_messaging.exceptions import PublishReturned, ConnectionException
+
+try:
+ from ansible.plugins.callback import CallbackBase
+except ImportError:
+ # Ansible v1 compat
+ CallbackBase = object
+
+def getlogin():
+ try:
+ user = os.getlogin()
+ except OSError, e:
+ user = pwd.getpwuid(os.geteuid())[0]
+ return user
+
+
+class CallbackModule(CallbackBase):
+ """ Publish playbook starts and stops to fedora-messaging. """
+
+ playbook_path = None
+
+ def __init__(self):
+ pass
+
+
+ def playbook_on_play_start(self, pattern):
+ # This gets called once for each play.. but we just issue a message once
+ # for the first one. One per "playbook"
+ play = getattr(self, 'play', None)
+ if play:
+ # figure out where the playbook FILE is
+ path = os.path.abspath(play.playbook.filename)
+
+ # Bail out early without publishing if we're in --check mode
+ if play.playbook.check:
+ return
+
+ if not self.playbook_path:
+ msg = Message(
+ topic='ansible.playbook.start',
+ body=dict(
+ playbook=path,
+ userid=getlogin(),
+ extra_vars=play.playbook.extra_vars,
+ inventory=play.playbook.inventory.host_list,
+ playbook_checksum=play.playbook.check,
+ check=play.playbook.check,
+ ),
+ )
+ publish(msg)
You're importing the exceptions, but not actually handling them here.
+ self.playbook_path = path
+
+ def playbook_on_stats(self, stats):
+ if not self.playbook_path:
+ return
+
+ results = dict([(h, stats.summarize(h)) for h in stats.processed])
+ msg = Message(
+ topic='ansible.playbook.complete',
+ body=dict(
+ playbook=self.playbook_path,
+ userid=getlogin(),
+ results=results,
+ ),
+ )
+ publish(msg)
diff --git a/callback_plugins/fedora_messaging_callback2.py b/callback_plugins/fedora_messaging_callback2.py
new file mode 100644
index 000000000..733e159a7
--- /dev/null
+++ b/callback_plugins/fedora_messaging_callback2.py
@@ -0,0 +1,106 @@
+# (C) 2012, Michael DeHaan, <michael.dehaan@xxxxxxxxx>
+# based on the log_plays example
+# skvidal@xxxxxxxxxxxxxxxxx
+# rbean@xxxxxxxxxx
+# karsten@xxxxxxxxxx changes for fedora-messaging
+
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import pwd
+
+from fedora_messaging.api import Message, publish
+from fedora_messaging.exceptions import PublishReturned, ConnectionException
+
+try:
+ from ansible.plugins.callback import CallbackBase
+except ImportError:
+ # Ansible v1 compat
+ CallbackBase = object
+
+try:
+ from ansible.utils.hashing import secure_hash
+except ImportError:
+ from ansible.utils import md5 as secure_hash
+
+def getlogin():
+ try:
+ user = os.getlogin()
+ except OSError, e:
+ user = pwd.getpwuid(os.geteuid())[0]
+ return user
+
+
+class CallbackModule(CallbackBase):
+ """ Publish playbook starts and stops to fedora_messaging. """
+
+ CALLBACK_NAME = 'fedora_messaging_callback2'
+ CALLBACK_TYPE = 'notification'
+ CALLBACK_VERSION = 2.0
+ CALLBACK_NEEDS_WHITELIST = True
+
+ playbook_path = None
+
+ def __init__(self):
+ self.play = None
+ self.playbook = None
+
+ super(CallbackModule, self).__init__()
+
+ def set_play_context(self, play_context):
+ self.play_context = play_context
+
+ def v2_playbook_on_start(self, playbook):
+ self.playbook = playbook
+
+ def v2_playbook_on_play_start(self, play):
+ # This gets called once for each play.. but we just issue a message once
+ # for the first one. One per "playbook"
+ if self.playbook:
+ # figure out where the playbook FILE is
+ path = os.path.abspath(self.playbook._file_name)
+
+ # Bail out early without publishing if we're in --check mode
+ if self.play_context.check_mode:
+ return
+
+ if not self.playbook_path:
+ msg = Message(
+ topic='ansible.playbook.start',
+ body=dict(
+ playbook=path,
+ userid=getlogin(),
+ extra_vars=play._variable_manager.extra_vars,
+ inventory=play._variable_manager._inventory._sources,
+ playbook_checksum=secure_hash(path),
+ check=self.play_context.check_mode,
+ ),
+ )
+ publish(msg)
Same deal here as above with the exceptions.
+ self.playbook_path = path
+
+ def v2_playbook_on_stats(self, stats):
+ if not self.playbook_path:
+ return
+
+ results = dict([(h, stats.summarize(h)) for h in stats.processed])
+ msg = Message(
+ topic='ansible.playbook.complete',
+ body=dict(
+ playbook=self.playbook_path,
+ userid=getlogin(),
+ results=results,
+ ),
+ )
+ publish(msg)
--
2.21.0
I have no comments on the Ansible side of things.
_______________________________________________
infrastructure mailing list -- infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to infrastructure-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
>From 45bdec473449ec9c8b1468a810f105894faa4806 Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@xxxxxxxxxx>
Date: Fri, 8 Nov 2019 22:34:47 +0100
Subject: [PATCH 13/14] add callbacks for fedora-messaging
Signed-off-by: Karsten Hopp <karsten@xxxxxxxxxx>
---
callback_plugins/fedora_messaging_callback.py | 85 +++++++++++++++
.../fedora_messaging_callback2.py | 103 ++++++++++++++++++
2 files changed, 188 insertions(+)
create mode 100644 callback_plugins/fedora_messaging_callback.py
create mode 100644 callback_plugins/fedora_messaging_callback2.py
diff --git a/callback_plugins/fedora_messaging_callback.py b/callback_plugins/fedora_messaging_callback.py
new file mode 100644
index 000000000..31e918dde
--- /dev/null
+++ b/callback_plugins/fedora_messaging_callback.py
@@ -0,0 +1,85 @@
+# (C) 2012, Michael DeHaan, <michael.dehaan@xxxxxxxxx>
+# based on the log_plays example
+# skvidal@xxxxxxxxxxxxxxxxx
+# rbean@xxxxxxxxxx
+# karsten@xxxxxxxxxx changes for fedora-messaging
+
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import pwd
+
+from fedora_messaging.api import Message, publish
+from fedora_messaging.exceptions import PublishReturned, ConnectionException
+
+try:
+ from ansible.plugins.callback import CallbackBase
+except ImportError:
+ # Ansible v1 compat
+ CallbackBase = object
+
+
+def getlogin():
+ try:
+ user = os.getlogin()
+ except OSError as e:
+ user = pwd.getpwuid(os.geteuid())[0]
+ return user
+
+
+class CallbackModule(CallbackBase):
+ """ Publish playbook starts and stops to fedora-messaging. """
+
+ playbook_path = None
+
+ def __init__(self):
+ pass
+
+ def playbook_on_play_start(self, pattern):
+ # This gets called once for each play.. but we just issue a message once
+ # for the first one. One per "playbook"
+ play = getattr(self, "play", None)
+ if play:
+ # figure out where the playbook FILE is
+ path = os.path.abspath(play.playbook.filename)
+
+ # Bail out early without publishing if we're in --check mode
+ if play.playbook.check:
+ return
+
+ if not self.playbook_path:
+ msg = Message(
+ topic="ansible.playbook.start",
+ body=dict(
+ playbook=path,
+ userid=getlogin(),
+ extra_vars=play.playbook.extra_vars,
+ inventory=play.playbook.inventory.host_list,
+ playbook_checksum=play.playbook.check,
+ check=play.playbook.check,
+ ),
+ )
+ publish(msg)
+ self.playbook_path = path
+
+ def playbook_on_stats(self, stats):
+ if not self.playbook_path:
+ return
+
+ results = dict([(h, stats.summarize(h)) for h in stats.processed])
+ msg = Message(
+ topic="ansible.playbook.complete",
+ body=dict(playbook=self.playbook_path, userid=getlogin(), results=results),
+ )
+ publish(msg)
diff --git a/callback_plugins/fedora_messaging_callback2.py b/callback_plugins/fedora_messaging_callback2.py
new file mode 100644
index 000000000..3d1e357ac
--- /dev/null
+++ b/callback_plugins/fedora_messaging_callback2.py
@@ -0,0 +1,103 @@
+# (C) 2012, Michael DeHaan, <michael.dehaan@xxxxxxxxx>
+# based on the log_plays example
+# skvidal@xxxxxxxxxxxxxxxxx
+# rbean@xxxxxxxxxx
+# karsten@xxxxxxxxxx changes for fedora-messaging
+
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import pwd
+
+from fedora_messaging.api import Message, publish
+from fedora_messaging.exceptions import PublishReturned, ConnectionException
+
+try:
+ from ansible.plugins.callback import CallbackBase
+except ImportError:
+ # Ansible v1 compat
+ CallbackBase = object
+
+try:
+ from ansible.utils.hashing import secure_hash
+except ImportError:
+ from ansible.utils import md5 as secure_hash
+
+
+def getlogin():
+ try:
+ user = os.getlogin()
+ except OSError as e:
+ user = pwd.getpwuid(os.geteuid())[0]
+ return user
+
+
+class CallbackModule(CallbackBase):
+ """ Publish playbook starts and stops to fedora_messaging. """
+
+ CALLBACK_NAME = "fedora_messaging_callback2"
+ CALLBACK_TYPE = "notification"
+ CALLBACK_VERSION = 2.0
+ CALLBACK_NEEDS_WHITELIST = True
+
+ playbook_path = None
+
+ def __init__(self):
+ self.play = None
+ self.playbook = None
+
+ super(CallbackModule, self).__init__()
+
+ def set_play_context(self, play_context):
+ self.play_context = play_context
+
+ def v2_playbook_on_start(self, playbook):
+ self.playbook = playbook
+
+ def v2_playbook_on_play_start(self, play):
+ # This gets called once for each play.. but we just issue a message once
+ # for the first one. One per "playbook"
+ if self.playbook:
+ # figure out where the playbook FILE is
+ path = os.path.abspath(self.playbook._file_name)
+
+ # Bail out early without publishing if we're in --check mode
+ if self.play_context.check_mode:
+ return
+
+ if not self.playbook_path:
+ msg = Message(
+ topic="ansible.playbook.start",
+ body=dict(
+ playbook=path,
+ userid=getlogin(),
+ extra_vars=play._variable_manager.extra_vars,
+ inventory=play._variable_manager._inventory._sources,
+ playbook_checksum=secure_hash(path),
+ check=self.play_context.check_mode,
+ ),
+ )
+ publish(msg)
+ self.playbook_path = path
+
+ def v2_playbook_on_stats(self, stats):
+ if not self.playbook_path:
+ return
+
+ results = dict([(h, stats.summarize(h)) for h in stats.processed])
+ msg = Message(
+ topic="ansible.playbook.complete",
+ body=dict(playbook=self.playbook_path, userid=getlogin(), results=results),
+ )
+ publish(msg)
--
2.21.0
>From 72f8442714b0092061d7fdda953271e16f66f84d Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@xxxxxxxxxx>
Date: Tue, 12 Nov 2019 14:47:22 +0100
Subject: [PATCH 14/14] add exception handling for fedora-messaging callbacks
Signed-off-by: Karsten Hopp <karsten@xxxxxxxxxx>
---
callback_plugins/fedora_messaging_callback.py | 50 ++++++++++++-------
.../fedora_messaging_callback2.py | 50 ++++++++++++-------
2 files changed, 66 insertions(+), 34 deletions(-)
diff --git a/callback_plugins/fedora_messaging_callback.py b/callback_plugins/fedora_messaging_callback.py
index 31e918dde..372080212 100644
--- a/callback_plugins/fedora_messaging_callback.py
+++ b/callback_plugins/fedora_messaging_callback.py
@@ -19,6 +19,7 @@
import os
import pwd
+import logging
from fedora_messaging.api import Message, publish
from fedora_messaging.exceptions import PublishReturned, ConnectionException
@@ -29,6 +30,7 @@ except ImportError:
# Ansible v1 compat
CallbackBase = object
+LOGGER = logging.getLogger(__name__)
def getlogin():
try:
@@ -59,18 +61,25 @@ class CallbackModule(CallbackBase):
return
if not self.playbook_path:
- msg = Message(
- topic="ansible.playbook.start",
- body=dict(
- playbook=path,
- userid=getlogin(),
- extra_vars=play.playbook.extra_vars,
- inventory=play.playbook.inventory.host_list,
- playbook_checksum=play.playbook.check,
- check=play.playbook.check,
- ),
- )
- publish(msg)
+ try:
+ msg = Message(
+ topic="ansible.playbook.start",
+ body=dict(
+ playbook=path,
+ userid=getlogin(),
+ extra_vars=play.playbook.extra_vars,
+ inventory=play.playbook.inventory.host_list,
+ playbook_checksum=play.playbook.check,
+ check=play.playbook.check,
+ ),
+ )
+ publish(msg)
+ except PublishReturned as e:
+ LOGGER.warning(
+ "Fedora Messaging broker rejected message %s: %s", msg.id, e
+ )
+ except ConnectionException as e:
+ LOGGER.warning("Error sending message %s: %s", msg.id, e)
self.playbook_path = path
def playbook_on_stats(self, stats):
@@ -78,8 +87,15 @@ class CallbackModule(CallbackBase):
return
results = dict([(h, stats.summarize(h)) for h in stats.processed])
- msg = Message(
- topic="ansible.playbook.complete",
- body=dict(playbook=self.playbook_path, userid=getlogin(), results=results),
- )
- publish(msg)
+ try:
+ msg = Message(
+ topic="ansible.playbook.complete",
+ body=dict(
+ playbook=self.playbook_path, userid=getlogin(), results=results
+ ),
+ )
+ publish(msg)
+ except PublishReturned as e:
+ LOGGER.warning("Fedora Messaging broker rejected message %s: %s", msg.id, e)
+ except ConnectionException as e:
+ LOGGER.warning("Error sending message %s: %s", msg.id, e)
diff --git a/callback_plugins/fedora_messaging_callback2.py b/callback_plugins/fedora_messaging_callback2.py
index 3d1e357ac..0b08d6b36 100644
--- a/callback_plugins/fedora_messaging_callback2.py
+++ b/callback_plugins/fedora_messaging_callback2.py
@@ -19,6 +19,7 @@
import os
import pwd
+import logging
from fedora_messaging.api import Message, publish
from fedora_messaging.exceptions import PublishReturned, ConnectionException
@@ -34,6 +35,7 @@ try:
except ImportError:
from ansible.utils import md5 as secure_hash
+LOGGER = logging.getLogger(__name__)
def getlogin():
try:
@@ -77,18 +79,25 @@ class CallbackModule(CallbackBase):
return
if not self.playbook_path:
- msg = Message(
- topic="ansible.playbook.start",
- body=dict(
- playbook=path,
- userid=getlogin(),
- extra_vars=play._variable_manager.extra_vars,
- inventory=play._variable_manager._inventory._sources,
- playbook_checksum=secure_hash(path),
- check=self.play_context.check_mode,
- ),
- )
- publish(msg)
+ try:
+ msg = Message(
+ topic="ansible.playbook.start",
+ body=dict(
+ playbook=path,
+ userid=getlogin(),
+ extra_vars=play._variable_manager.extra_vars,
+ inventory=play._variable_manager._inventory._sources,
+ playbook_checksum=secure_hash(path),
+ check=self.play_context.check_mode,
+ ),
+ )
+ publish(msg)
+ except PublishReturned as e:
+ LOGGER.warning(
+ "Fedora Messaging broker rejected message %s: %s", msg.id, e
+ )
+ except ConnectionException as e:
+ LOGGER.warning("Error sending message %s: %s", msg.id, e)
self.playbook_path = path
def v2_playbook_on_stats(self, stats):
@@ -96,8 +105,15 @@ class CallbackModule(CallbackBase):
return
results = dict([(h, stats.summarize(h)) for h in stats.processed])
- msg = Message(
- topic="ansible.playbook.complete",
- body=dict(playbook=self.playbook_path, userid=getlogin(), results=results),
- )
- publish(msg)
+ try:
+ msg = Message(
+ topic="ansible.playbook.complete",
+ body=dict(
+ playbook=self.playbook_path, userid=getlogin(), results=results
+ ),
+ )
+ publish(msg)
+ except PublishReturned as e:
+ LOGGER.warning("Fedora Messaging broker rejected message %s: %s", msg.id, e)
+ except ConnectionException as e:
+ LOGGER.warning("Error sending message %s: %s", msg.id, e)
--
2.21.0
_______________________________________________
infrastructure mailing list -- infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to infrastructure-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/infrastructure@xxxxxxxxxxxxxxxxxxxxxxx