community.zabbix.zabbix_mediatype – Create/Update/Delete Zabbix media types¶
Note
This plugin is part of the community.zabbix collection (version 1.3.0).
To install it use: ansible-galaxy collection install community.zabbix
.
To use it in a playbook, specify: community.zabbix.zabbix_mediatype
.
Requirements¶
The below requirements are needed on the host that executes this module.
zabbix-api >= 0.5.4
Parameters¶
Notes¶
Note
If you use login_password=zabbix, the word “zabbix” is replaced by “****” in all module output, because login_password uses
no_log
. See this FAQ for more information.
Examples¶
- name: 'Create an email mediatype with SMTP authentication'
community.zabbix.zabbix_mediatype:
name: "Ops email"
server_url: "http://example.com/zabbix/"
login_user: Admin
login_password: "zabbix"
type: 'email'
smtp_server: 'example.com'
smtp_server_port: 2000
smtp_email: '[email protected]'
smtp_authentication: true
username: 'smtp_user'
password: 'smtp_pass'
- name: 'Create a script mediatype'
community.zabbix.zabbix_mediatype:
name: "my script"
server_url: "http://example.com/zabbix/"
login_user: Admin
login_password: "zabbix"
type: 'script'
script_name: 'my_script.py'
script_params:
- 'arg1'
- 'arg2'
- name: 'Create a jabber mediatype'
community.zabbix.zabbix_mediatype:
name: "My jabber"
server_url: "http://example.com/zabbix/"
login_user: Admin
login_password: "zabbix"
type: 'jabber'
username: 'jabber_id'
password: 'jabber_pass'
- name: 'Create a SMS mediatype'
community.zabbix.zabbix_mediatype:
name: "My SMS Mediatype"
server_url: "http://example.com/zabbix/"
login_user: Admin
login_password: "zabbix"
type: 'sms'
gsm_modem: '/dev/ttyS0'
# Supported since Zabbix 4.4
- name: 'Create a webhook mediatype'
community.zabbix.zabbix_mediatype:
name: "My webhook Mediatype"
server_url: "http://example.com/zabbix/"
login_user: Admin
login_password: "zabbix"
type: 'webhook'
webhook_script: "{{ lookup('file', 'slack.js') }}"
webhook_params:
- name: alert_message
value: '{ALERT.MESSAGE}'
- name: zabbix_url
value: '{$ZABBIX.URL}'
process_tags: True
event_menu: true
event_menu_name: "Open in Slack: '{EVENT.TAGS.__channel_name}'"
event_menu_url: '{EVENT.TAGS.__message_link}'
# Supported since Zabbix 5.0
- name: 'Create an email mediatype with message templates'
community.zabbix.zabbix_mediatype:
name: "Ops email"
server_url: "http://example.com/zabbix/"
login_user: Admin
login_password: "zabbix"
type: 'email'
smtp_email: '[email protected]'
message_templates:
- eventsource: triggers
recovery: operations
subject: "Problem: {EVENT.NAME}"
body: "Problem started at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n"
- eventsource: triggers
recovery: recovery_operations
subject: "Resolved: {EVENT.NAME}"
body: "Problem resolved at {EVENT.TIME} on {EVENT.DATE}\r\nProblem name: {EVENT.NAME}\r\n"
- eventsource: triggers
recovery: update_operations
subject: "Updated problem: {EVENT.NAME}"
body: "{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.\r\n"
- eventsource: discovery
recovery: operations
subject: "Discovery: {DISCOVERY.DEVICE.STATUS} {DISCOVERY.DEVICE.IPADDRESS}"
body: "Discovery rule: {DISCOVERY.RULE.NAME}\r\n\r\nDevice IP: {DISCOVERY.DEVICE.IPADDRESS}"
- eventsource: autoregistration
recovery: operations
subject: "Autoregistration: {HOST.HOST}"
body: "Host name: {HOST.HOST}\r\nHost IP: {HOST.IP}\r\nAgent port: {HOST.PORT}"
Authors¶
Ruben Tsirunyan (@rubentsirunyan)