|
|
@ -72,6 +72,11 @@ options:
|
|
|
|
messages, this is to prevent an endless loop
|
|
|
|
messages, this is to prevent an endless loop
|
|
|
|
default: 30
|
|
|
|
default: 30
|
|
|
|
version_added: 1.5
|
|
|
|
version_added: 1.5
|
|
|
|
|
|
|
|
use_ssl:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Designates whether TLS/SSL should be used when connecting to the IRC server
|
|
|
|
|
|
|
|
default: False
|
|
|
|
|
|
|
|
version_added: 1.7
|
|
|
|
|
|
|
|
|
|
|
|
# informational: requirements for nodes
|
|
|
|
# informational: requirements for nodes
|
|
|
|
requirements: [ socket ]
|
|
|
|
requirements: [ socket ]
|
|
|
@ -94,12 +99,13 @@ EXAMPLES = '''
|
|
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import socket
|
|
|
|
import socket
|
|
|
|
|
|
|
|
import ssl
|
|
|
|
|
|
|
|
|
|
|
|
from time import sleep
|
|
|
|
from time import sleep
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def send_msg(channel, msg, server='localhost', port='6667', key=None,
|
|
|
|
def send_msg(channel, msg, server='localhost', port='6667', key=None,
|
|
|
|
nick="ansible", color='none', passwd=False, timeout=30):
|
|
|
|
nick="ansible", color='none', passwd=False, timeout=30, use_ssl=False):
|
|
|
|
'''send message to IRC'''
|
|
|
|
'''send message to IRC'''
|
|
|
|
|
|
|
|
|
|
|
|
colornumbers = {
|
|
|
|
colornumbers = {
|
|
|
@ -119,6 +125,8 @@ def send_msg(channel, msg, server='localhost', port='6667', key=None,
|
|
|
|
message = colortext + msg
|
|
|
|
message = colortext + msg
|
|
|
|
|
|
|
|
|
|
|
|
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
|
|
|
|
if use_ssl:
|
|
|
|
|
|
|
|
irc = ssl.wrap_socket(irc)
|
|
|
|
irc.connect((server, int(port)))
|
|
|
|
irc.connect((server, int(port)))
|
|
|
|
if passwd:
|
|
|
|
if passwd:
|
|
|
|
irc.send('PASS %s\r\n' % passwd)
|
|
|
|
irc.send('PASS %s\r\n' % passwd)
|
|
|
@ -177,7 +185,8 @@ def main():
|
|
|
|
channel=dict(required=True),
|
|
|
|
channel=dict(required=True),
|
|
|
|
key=dict(),
|
|
|
|
key=dict(),
|
|
|
|
passwd=dict(),
|
|
|
|
passwd=dict(),
|
|
|
|
timeout=dict(type='int', default=30)
|
|
|
|
timeout=dict(type='int', default=30),
|
|
|
|
|
|
|
|
use_ssl=dict(type='bool', default=False)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode=True
|
|
|
|
supports_check_mode=True
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -191,9 +200,10 @@ def main():
|
|
|
|
key = module.params["key"]
|
|
|
|
key = module.params["key"]
|
|
|
|
passwd = module.params["passwd"]
|
|
|
|
passwd = module.params["passwd"]
|
|
|
|
timeout = module.params["timeout"]
|
|
|
|
timeout = module.params["timeout"]
|
|
|
|
|
|
|
|
use_ssl = module.params["use_ssl"]
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
send_msg(channel, msg, server, port, key, nick, color, passwd, timeout)
|
|
|
|
send_msg(channel, msg, server, port, key, nick, color, passwd, timeout, use_ssl)
|
|
|
|
except Exception, e:
|
|
|
|
except Exception, e:
|
|
|
|
module.fail_json(msg="unable to send to IRC: %s" % e)
|
|
|
|
module.fail_json(msg="unable to send to IRC: %s" % e)
|
|
|
|
|
|
|
|
|
|
|
|