summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/BOTMETA.yml2
-rw-r--r--changelogs/fragments/33740-osx_say_callback_renamed_say.yml2
-rw-r--r--docs/docsite/rst/plugins/callback.rst2
-rw-r--r--docs/docsite/rst/porting_guides/porting_guide_2.8.rst2
l---------[-rw-r--r--]lib/ansible/plugins/callback/osx_say.py93
-rw-r--r--lib/ansible/plugins/callback/say.py114
6 files changed, 121 insertions, 94 deletions
diff --git a/.github/BOTMETA.yml b/.github/BOTMETA.yml
index a39e05a439..a6aeb9c086 100644
--- a/.github/BOTMETA.yml
+++ b/.github/BOTMETA.yml
@@ -959,7 +959,7 @@ files:
support: core
$plugins/callback/oneline:
support: core
- $plugins/callback/osx_say.py: *macos
+ $plugins/callback/say.py: *macos
$plugins/callback/profile:
support: core
$plugins/callback/stderr.py:
diff --git a/changelogs/fragments/33740-osx_say_callback_renamed_say.yml b/changelogs/fragments/33740-osx_say_callback_renamed_say.yml
new file mode 100644
index 0000000000..45bffaf491
--- /dev/null
+++ b/changelogs/fragments/33740-osx_say_callback_renamed_say.yml
@@ -0,0 +1,2 @@
+minor_changes:
+ - "``osx_say`` callback plugin was renamed into ``say``."
diff --git a/docs/docsite/rst/plugins/callback.rst b/docs/docsite/rst/plugins/callback.rst
index b3a5dbd373..0614a0c9b6 100644
--- a/docs/docsite/rst/plugins/callback.rst
+++ b/docs/docsite/rst/plugins/callback.rst
@@ -19,7 +19,7 @@ Example callback plugins
The :ref:`log_plays <log_plays_callback>` callback is an example of how to record playbook events to a log file,
and the :ref:`mail <mail_callback>` callback sends email on playbook failures.
-The :ref:`osx_say <osx_say_callback>` callback responds with computer synthesized speech on macOS in relation to playbook events.
+The :ref:`say <say_callback>` callback responds with computer synthesized speech in relation to playbook events.
.. _enabling_callbacks:
diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.8.rst b/docs/docsite/rst/porting_guides/porting_guide_2.8.rst
index 5126f4dcaa..b7508a9767 100644
--- a/docs/docsite/rst/porting_guides/porting_guide_2.8.rst
+++ b/docs/docsite/rst/porting_guides/porting_guide_2.8.rst
@@ -242,6 +242,8 @@ Plugins
* Play recap now counts ``ignored`` and ``rescued`` tasks as well as ``ok``, ``changed``, ``unreachable``, ``failed`` and ``skipped`` tasks, thanks to two additional stat counters in the ``default`` callback plugin. Tasks that fail and have ``ignore_errors: yes`` set are listed as ``ignored``. Tasks that fail and then execute a rescue section are listed as ``rescued``. Note that ``rescued`` tasks are no longer counted as ``failed`` as in Ansible 2.7 (and earlier).
+* ``osx_say`` callback plugin was renamed into :ref:`say <say_callback>`.
+
Porting custom scripts
======================
diff --git a/lib/ansible/plugins/callback/osx_say.py b/lib/ansible/plugins/callback/osx_say.py
index d264e154ba..f080521d9d 100644..120000
--- a/lib/ansible/plugins/callback/osx_say.py
+++ b/lib/ansible/plugins/callback/osx_say.py
@@ -1,92 +1 @@
-# (c) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
-# (c) 2017 Ansible Project
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-DOCUMENTATION = '''
- callback: osx_say
- type: notification
- requirements:
- - whitelisting in configuration
- - the '/usr/bin/say' command line program (standard on macOS)
- short_description: oneline Ansible screen output
- version_added: historical
- description:
- - This plugin will use the 'say' program to "speak" about play events.
-'''
-
-import subprocess
-import os
-
-from ansible.plugins.callback import CallbackBase
-
-FAILED_VOICE = "Zarvox"
-REGULAR_VOICE = "Trinoids"
-HAPPY_VOICE = "Cellos"
-LASER_VOICE = "Princess"
-SAY_CMD = "/usr/bin/say"
-
-
-class CallbackModule(CallbackBase):
- """
- makes Ansible much more exciting on macOS.
- """
- CALLBACK_VERSION = 2.0
- CALLBACK_TYPE = 'notification'
- CALLBACK_NAME = 'osx_say'
- CALLBACK_NEEDS_WHITELIST = True
-
- def __init__(self):
-
- super(CallbackModule, self).__init__()
-
- # plugin disable itself if say is not present
- # ansible will not call any callback if disabled is set to True
- if not os.path.exists(SAY_CMD):
- self.disabled = True
- self._display.warning("%s does not exist, plugin %s disabled" % (SAY_CMD, os.path.basename(__file__)))
-
- def say(self, msg, voice):
- subprocess.call([SAY_CMD, msg, "--voice=%s" % (voice)])
-
- def runner_on_failed(self, host, res, ignore_errors=False):
- self.say("Failure on host %s" % host, FAILED_VOICE)
-
- def runner_on_ok(self, host, res):
- self.say("pew", LASER_VOICE)
-
- def runner_on_skipped(self, host, item=None):
- self.say("pew", LASER_VOICE)
-
- def runner_on_unreachable(self, host, res):
- self.say("Failure on host %s" % host, FAILED_VOICE)
-
- def runner_on_async_ok(self, host, res, jid):
- self.say("pew", LASER_VOICE)
-
- def runner_on_async_failed(self, host, res, jid):
- self.say("Failure on host %s" % host, FAILED_VOICE)
-
- def playbook_on_start(self):
- self.say("Running Playbook", REGULAR_VOICE)
-
- def playbook_on_notify(self, host, handler):
- self.say("pew", LASER_VOICE)
-
- def playbook_on_task_start(self, name, is_conditional):
- if not is_conditional:
- self.say("Starting task: %s" % name, REGULAR_VOICE)
- else:
- self.say("Notifying task: %s" % name, REGULAR_VOICE)
-
- def playbook_on_setup(self):
- self.say("Gathering facts", REGULAR_VOICE)
-
- def playbook_on_play_start(self, name):
- self.say("Starting play: %s" % name, HAPPY_VOICE)
-
- def playbook_on_stats(self, stats):
- self.say("Play complete", HAPPY_VOICE)
+say.py \ No newline at end of file
diff --git a/lib/ansible/plugins/callback/say.py b/lib/ansible/plugins/callback/say.py
new file mode 100644
index 0000000000..0e9d635f79
--- /dev/null
+++ b/lib/ansible/plugins/callback/say.py
@@ -0,0 +1,114 @@
+# (c) 2012, Michael DeHaan, <michael.dehaan@gmail.com>
+# (c) 2017 Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+DOCUMENTATION = '''
+ callback: say
+ type: notification
+ requirements:
+ - whitelisting in configuration
+ - the '/usr/bin/say' command line program (standard on macOS) or 'espeak' command line program
+ short_description: notify using software speech synthesizer
+ version_added: historical
+ description:
+ - This plugin will use the 'say' or 'espeak' program to "speak" about play events.
+ notes:
+ - In 2.8, this callback has been renamed from C(osx_say) into M(say).
+'''
+
+import distutils.spawn
+import platform
+import subprocess
+import os
+
+from ansible.plugins.callback import CallbackBase
+
+
+class CallbackModule(CallbackBase):
+ """
+ makes Ansible much more exciting.
+ """
+ CALLBACK_VERSION = 2.0
+ CALLBACK_TYPE = 'notification'
+ CALLBACK_NAME = 'say'
+ CALLBACK_NEEDS_WHITELIST = True
+
+ def __init__(self):
+
+ super(CallbackModule, self).__init__()
+
+ self.FAILED_VOICE = None
+ self.REGULAR_VOICE = None
+ self.HAPPY_VOICE = None
+ self.LASER_VOICE = None
+
+ self.synthesizer = distutils.spawn.find_executable('say')
+ if not self.synthesizer:
+ self.synthesizer = distutils.spawn.find_executable('espeak')
+ if self.synthesizer:
+ self.FAILED_VOICE = 'klatt'
+ self.HAPPY_VOICE = 'f5'
+ self.LASER_VOICE = 'whisper'
+ elif platform.system() != 'Darwin':
+ # 'say' binary available, it might be GNUstep tool which doesn't support 'voice' parameter
+ self._display.warning("'say' executable found but system is '%s': ignoring voice parameter" % platform.system())
+ else:
+ self.FAILED_VOICE = 'Zarvox'
+ self.REGULAR_VOICE = 'Trinoids'
+ self.HAPPY_VOICE = 'Cellos'
+ self.LASER_VOICE = 'Princess'
+
+ # plugin disable itself if say is not present
+ # ansible will not call any callback if disabled is set to True
+ if not self.synthesizer:
+ self.disabled = True
+ self._display.warning("Unable to find either 'say' or 'espeak' executable, plugin %s disabled" % os.path.basename(__file__))
+
+ def say(self, msg, voice):
+ cmd = [self.synthesizer, msg]
+ if voice:
+ cmd.extend(('-v', voice))
+ subprocess.call(cmd)
+
+ def runner_on_failed(self, host, res, ignore_errors=False):
+ self.say("Failure on host %s" % host, self.FAILED_VOICE)
+
+ def runner_on_ok(self, host, res):
+ self.say("pew", self.LASER_VOICE)
+
+ def runner_on_skipped(self, host, item=None):
+ self.say("pew", self.LASER_VOICE)
+
+ def runner_on_unreachable(self, host, res):
+ self.say("Failure on host %s" % host, self.FAILED_VOICE)
+
+ def runner_on_async_ok(self, host, res, jid):
+ self.say("pew", self.LASER_VOICE)
+
+ def runner_on_async_failed(self, host, res, jid):
+ self.say("Failure on host %s" % host, self.FAILED_VOICE)
+
+ def playbook_on_start(self):
+ self.say("Running Playbook", self.REGULAR_VOICE)
+
+ def playbook_on_notify(self, host, handler):
+ self.say("pew", self.LASER_VOICE)
+
+ def playbook_on_task_start(self, name, is_conditional):
+ if not is_conditional:
+ self.say("Starting task: %s" % name, self.REGULAR_VOICE)
+ else:
+ self.say("Notifying task: %s" % name, self.REGULAR_VOICE)
+
+ def playbook_on_setup(self):
+ self.say("Gathering facts", self.REGULAR_VOICE)
+
+ def playbook_on_play_start(self, name):
+ self.say("Starting play: %s" % name, self.HAPPY_VOICE)
+
+ def playbook_on_stats(self, stats):
+ self.say("Play complete", self.HAPPY_VOICE)