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
b86d93ad
Commit
b86d93ad
authored
Jun 26, 2013
by
Kevin Montuori
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a provision for passing a server password to IRC
parent
68535533
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
library/notification/irc
+11
-3
No files found.
library/notification/irc
View file @
b86d93ad
...
...
@@ -56,6 +56,10 @@ options:
description:
- Channel name
required: true
passwd:
description:
- Server password
required: false
# informational: requirements for nodes
requirements: [ socket ]
...
...
@@ -80,7 +84,7 @@ from time import sleep
import
socket
def
send_msg
(
channel
,
msg
,
server
=
'localhost'
,
port
=
'6667'
,
nick
=
"ansible"
,
color
=
'black'
):
nick
=
"ansible"
,
color
=
'black'
,
passwd
=
False
):
'''send message to IRC'''
colornumbers
=
{
...
...
@@ -100,6 +104,8 @@ def send_msg(channel, msg, server='localhost', port='6667',
irc
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
irc
.
connect
(
(
server
,
int
(
port
)
)
)
if
passwd
:
irc
.
send
(
'PASS
%
s
\r\n
'
%
passwd
)
irc
.
send
(
'NICK
%
s
\r\n
'
%
nick
)
irc
.
send
(
'USER
%
s
%
s
%
s :ansible IRC
\r\n
'
%
(
nick
,
nick
,
nick
))
time
.
sleep
(
1
)
...
...
@@ -125,7 +131,8 @@ def main():
msg
=
dict
(
required
=
True
),
color
=
dict
(
default
=
"black"
,
choices
=
[
"yellow"
,
"red"
,
"green"
,
"blue"
,
"black"
]),
channel
=
dict
(
required
=
True
)
channel
=
dict
(
required
=
True
),
passwd
=
dict
()
),
supports_check_mode
=
True
)
...
...
@@ -136,9 +143,10 @@ def main():
msg
=
module
.
params
[
"msg"
]
color
=
module
.
params
[
"color"
]
channel
=
module
.
params
[
"channel"
]
passwd
=
module
.
params
[
"passwd"
]
try
:
send_msg
(
channel
,
msg
,
server
,
port
,
nick
,
color
)
send_msg
(
channel
,
msg
,
server
,
port
,
nick
,
color
,
passwd
)
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