community.general.irc module – Send a message to an IRC channel or a nick

Note

This module is part of the community.general collection (version 10.0.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.irc.

Synopsis

  • Send a message to an IRC channel or a nick. This is a very simplistic implementation.

Requirements

The below requirements are needed on the host that executes this module.

  • socket

Parameters

Parameter

Comments

channel

string

Channel name. One of nick_to or channel needs to be set. When both are set, the message will be sent to both of them.

color

aliases: colour

string

Text color for the message.

Choices:

  • "none" ← (default)

  • "white"

  • "black"

  • "blue"

  • "green"

  • "red"

  • "brown"

  • "purple"

  • "orange"

  • "yellow"

  • "light_green"

  • "teal"

  • "light_cyan"

  • "light_blue"

  • "pink"

  • "gray"

  • "light_gray"

key

string

Channel key

msg

string / required

The message body.

nick

string

Nickname to send the message from. May be shortened, depending on server’s NICKLEN setting.

Default: "ansible"

nick_to

list / elements=string

A list of nicknames to send the message to. One of nick_to or channel needs to be set. When both are defined, the message will be sent to both of them.

part

boolean

Designates whether user should part from channel after sending message or not. Useful for when using a faux bot and not wanting join/parts between messages.

Choices:

  • false

  • true ← (default)

passwd

string

Server password

port

integer

IRC server port number

Default: 6667

server

string

IRC server name/address

Default: "localhost"

style

string

Text style for the message. Note italic does not work on some clients

Choices:

  • "bold"

  • "underline"

  • "reverse"

  • "italic"

  • "none" ← (default)

timeout

integer

Timeout to use while waiting for successful registration and join messages, this is to prevent an endless loop

Default: 30

topic

string

Set the channel topic

use_tls

aliases: use_ssl

boolean

Designates whether TLS/SSL should be used when connecting to the IRC server

use_tls is available since community.general 8.1.0, before the option was exlusively called use_ssl. The latter is now an alias of use_tls.

Note: for security reasons, you should always set use_tls=true and validate_certs=true whenever possible.

The default of this option changed to true in community.general 10.0.0.

Choices:

  • false

  • true ← (default)

validate_certs

boolean

added in community.general 8.1.0

If set to false, the SSL certificates will not be validated.

This should always be set to true. Using false is unsafe and should only be done if the network between between Ansible and the IRC server is known to be safe.

Note: for security reasons, you should always set use_tls=true and validate_certs=true whenever possible.

The default of this option changed to true in community.general 10.0.0.

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Send a message to an IRC channel from nick ansible
  community.general.irc:
    server: irc.example.net
    use_tls: true
    validate_certs: true
    channel: #t1
    msg: Hello world

- name: Send a message to an IRC channel
  local_action:
    module: irc
    port: 6669
    server: irc.example.net
    use_tls: true
    validate_certs: true
    channel: #t1
    msg: 'All finished at {{ ansible_date_time.iso8601 }}'
    color: red
    nick: ansibleIRC

- name: Send a message to an IRC channel
  local_action:
    module: irc
    port: 6669
    server: irc.example.net
    use_tls: true
    validate_certs: true
    channel: #t1
    nick_to:
      - nick1
      - nick2
    msg: 'All finished at {{ ansible_date_time.iso8601 }}'
    color: red
    nick: ansibleIRC

Authors

  • Jan-Piet Mens (@jpmens)

  • Matt Martz (@sivel)