From 75563d53259e83d37d835c82020b604118deacaa Mon Sep 17 00:00:00 2001
From: Fabio Alessandro Locati <me@fale.io>
Date: Thu, 1 Dec 2016 12:31:20 +0000
Subject: [PATCH] Native YAML - notifications (#3598)

---
 .../modules/extras/notification/campfire.py   | 14 ++++++++---
 .../modules/extras/notification/flowdock.py   | 24 ++++++++++---------
 .../modules/extras/notification/hipchat.py    |  9 +++----
 .../modules/extras/notification/jabber.py     | 13 +++++-----
 .../modules/extras/notification/mail.py       | 10 ++++----
 .../modules/extras/notification/osx_say.py    |  5 +++-
 .../modules/extras/notification/pushover.py   |  7 ++++--
 .../modules/extras/notification/telegram.py   | 10 ++++----
 .../modules/extras/notification/typetalk.py   |  6 ++++-
 9 files changed, 59 insertions(+), 39 deletions(-)

diff --git a/lib/ansible/modules/extras/notification/campfire.py b/lib/ansible/modules/extras/notification/campfire.py
index 3d003e1363a..9f9c34c5da4 100644
--- a/lib/ansible/modules/extras/notification/campfire.py
+++ b/lib/ansible/modules/extras/notification/campfire.py
@@ -60,10 +60,18 @@ author: "Adam Garside (@fabulops)"
 '''
 
 EXAMPLES = '''
-- campfire: subscription=foo token=12345 room=123 msg="Task completed."
+- campfire:
+    subscription: foo
+    token: 12345
+    room: 123
+    msg: Task completed.
 
-- campfire: subscription=foo token=12345 room=123 notify=loggins
-        msg="Task completed ... with feeling."
+- campfire:
+    subscription: foo
+    token: 12345
+    room: 123
+    notify: loggins
+    msg: Task completed ... with feeling.
 '''
 
 import cgi
diff --git a/lib/ansible/modules/extras/notification/flowdock.py b/lib/ansible/modules/extras/notification/flowdock.py
index 24fee07af13..1e1e5e9fde0 100644
--- a/lib/ansible/modules/extras/notification/flowdock.py
+++ b/lib/ansible/modules/extras/notification/flowdock.py
@@ -89,18 +89,20 @@ requirements: [ ]
 '''
 
 EXAMPLES = '''
-- flowdock: type=inbox
-            token=AAAAAA
-            from_address=user@example.com
-            source='my cool app'
-            msg='test from ansible'
-            subject='test subject'
+- flowdock:
+    type: inbox
+    token: AAAAAA
+    from_address: user@example.com
+    source: my cool app
+    msg: test from ansible
+    subject: test subject
 
-- flowdock: type=chat
-            token=AAAAAA
-            external_user_name=testuser
-            msg='test from ansible'
-            tags=tag1,tag2,tag3
+- flowdock:
+    type: chat
+    token: AAAAAA
+    external_user_name: testuser
+    msg: test from ansible
+    tags: tag1,tag2,tag3
 '''
 
 import urllib
diff --git a/lib/ansible/modules/extras/notification/hipchat.py b/lib/ansible/modules/extras/notification/hipchat.py
index e0d20e0ea45..3a77341b68c 100644
--- a/lib/ansible/modules/extras/notification/hipchat.py
+++ b/lib/ansible/modules/extras/notification/hipchat.py
@@ -81,15 +81,16 @@ author: "WAKAYAMA Shirou (@shirou), BOURDEL Paul (@pb8226)"
 '''
 
 EXAMPLES = '''
-- hipchat:  room=notify msg="Ansible task finished"
+- hipchat:
+    room: notif
+    msg: Ansible task finished
 
 # Use Hipchat API version 2
-
 - hipchat:
-    api: "https://api.hipchat.com/v2/"
+    api: 'https://api.hipchat.com/v2/'
     token: OAUTH2_TOKEN
     room: notify
-    msg: "Ansible task finished"
+    msg: Ansible task finished
 '''
 
 # ===========================================
diff --git a/lib/ansible/modules/extras/notification/jabber.py b/lib/ansible/modules/extras/notification/jabber.py
index 02751e93503..d881d28132c 100644
--- a/lib/ansible/modules/extras/notification/jabber.py
+++ b/lib/ansible/modules/extras/notification/jabber.py
@@ -78,12 +78,13 @@ EXAMPLES = '''
           msg="Ansible task finished"
 
 # send a message, specifying the host and port
-- jabber user=mybot@example.net
-         host=talk.example.net
-         port=5223
-         password=secret
-         to=mychaps@example.net
-         msg="Ansible task finished"
+- jabber
+    user: mybot@example.net
+    host: talk.example.net
+    port: 5223
+    password: secret
+    to: mychaps@example.net
+    msg: Ansible task finished
 '''
 
 import os
diff --git a/lib/ansible/modules/extras/notification/mail.py b/lib/ansible/modules/extras/notification/mail.py
index cdd5354b5fa..5cab0d3584a 100644
--- a/lib/ansible/modules/extras/notification/mail.py
+++ b/lib/ansible/modules/extras/notification/mail.py
@@ -146,11 +146,11 @@ EXAMPLES = '''
                 charset=utf8
 # Sending an e-mail using the remote machine, not the Ansible controller node
 - mail:
-    host='localhost'
-    port=25
-    to="John Smith <john.smith@example.com>"
-    subject='Ansible-report'
-    body='System {{ ansible_hostname }} has been successfully provisioned.'
+    host: localhost
+    port: 25
+    to: 'John Smith <john.smith@example.com>'
+    subject: Ansible-report
+    body: 'System {{ ansible_hostname }} has been successfully provisioned.'
 '''
 
 import os
diff --git a/lib/ansible/modules/extras/notification/osx_say.py b/lib/ansible/modules/extras/notification/osx_say.py
index 39e3da88c19..0a64269bab4 100644
--- a/lib/ansible/modules/extras/notification/osx_say.py
+++ b/lib/ansible/modules/extras/notification/osx_say.py
@@ -41,7 +41,10 @@ author: Michael DeHaan
 '''
 
 EXAMPLES = '''
-- local_action: osx_say msg="{{inventory_hostname}} is all done" voice=Zarvox
+- osx_say:
+    msg: '{{ inventory_hostname }} is all done'
+    voice: Zarvox
+  delegate_to: localhost
 '''
 
 DEFAULT_VOICE='Trinoids'
diff --git a/lib/ansible/modules/extras/notification/pushover.py b/lib/ansible/modules/extras/notification/pushover.py
index 2cd973b1bcc..ac924193fec 100644
--- a/lib/ansible/modules/extras/notification/pushover.py
+++ b/lib/ansible/modules/extras/notification/pushover.py
@@ -53,8 +53,11 @@ author: "Jim Richardson (@weaselkeeper)"
 '''
 
 EXAMPLES = '''
-- local_action: pushover msg="{{inventory_hostname}} has exploded in flames,
-  It is now time to panic" app_token=wxfdksl user_key=baa5fe97f2c5ab3ca8f0bb59
+- pushover:
+    msg: '{{ inventory_hostname }} has exploded in flames, It is now time to panic'
+    app_token: wxfdksl
+    user_key: baa5fe97f2c5ab3ca8f0bb59
+  delegate_to: localhost
 '''
 
 import urllib
diff --git a/lib/ansible/modules/extras/notification/telegram.py b/lib/ansible/modules/extras/notification/telegram.py
index 254a1bf12f2..a12fd46929d 100644
--- a/lib/ansible/modules/extras/notification/telegram.py
+++ b/lib/ansible/modules/extras/notification/telegram.py
@@ -51,10 +51,10 @@ options:
 EXAMPLES = """
 
 send a message to chat in playbook
-- telegram:  token=bot9999999:XXXXXXXXXXXXXXXXXXXXXXX
-    chat_id=000000
-    msg="Ansible task finished"
-
+- telegram:
+    token: 'bot9999999:XXXXXXXXXXXXXXXXXXXXXXX'
+    chat_id: 000000
+    msg: Ansible task finished
 """
 
 RETURN = """
@@ -64,8 +64,6 @@ msg:
   returned: success
   type: string
   sample: "Ansible task finished"
-
-
 """
 
 import urllib
diff --git a/lib/ansible/modules/extras/notification/typetalk.py b/lib/ansible/modules/extras/notification/typetalk.py
index 2f91022936f..4d4cf8a2f8a 100644
--- a/lib/ansible/modules/extras/notification/typetalk.py
+++ b/lib/ansible/modules/extras/notification/typetalk.py
@@ -44,7 +44,11 @@ author: "Takashi Someda (@tksmd)"
 '''
 
 EXAMPLES = '''
-- typetalk: client_id=12345 client_secret=12345 topic=1 msg="install completed"
+- typetalk:
+    client_id: 12345
+    client_secret: 12345
+    topic: 1
+    msg: install completed
 '''
 
 import urllib