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
f70e3125
Commit
f70e3125
authored
Aug 08, 2014
by
Andrew Hamilton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added SSL support for IRC
parent
26ea9108
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
library/notification/irc
+13
-3
No files found.
library/notification/irc
View file @
f70e3125
...
...
@@ -72,6 +72,11 @@ options:
messages, this is to prevent an endless loop
default: 30
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
requirements: [ socket ]
...
...
@@ -94,12 +99,13 @@ EXAMPLES = '''
import
re
import
socket
import
ssl
from
time
import
sleep
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'''
colornumbers
=
{
...
...
@@ -119,6 +125,8 @@ def send_msg(channel, msg, server='localhost', port='6667', key=None,
message
=
colortext
+
msg
irc
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
if
use_ssl
:
irc
=
ssl
.
wrap_socket
(
irc
)
irc
.
connect
((
server
,
int
(
port
)))
if
passwd
:
irc
.
send
(
'PASS
%
s
\r\n
'
%
passwd
)
...
...
@@ -177,7 +185,8 @@ def main():
channel
=
dict
(
required
=
True
),
key
=
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
)
...
...
@@ -191,9 +200,10 @@ def main():
key
=
module
.
params
[
"key"
]
passwd
=
module
.
params
[
"passwd"
]
timeout
=
module
.
params
[
"timeout"
]
use_ssl
=
module
.
params
[
"use_ssl"
]
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
:
module
.
fail_json
(
msg
=
"unable to send to IRC:
%
s"
%
e
)
...
...
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