Skip to content

Commit

Permalink
feat(zabbix_mediatype): expose content_type field for email (ansible-…
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare authored and pyrodie18 committed Apr 14, 2024
1 parent b9d3dce commit 6759b1c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1176-content_type-in-mediatype.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Added content_type for email in zabbix_mediatypes
11 changes: 11 additions & 0 deletions plugins/modules/zabbix_mediatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@
- SSL verify peer for SMTP.
- Can be specified when I(smtp_security=STARTTLS) or I(smtp_security=SSL/TLS)
default: false
content_type:
type: "str"
description:
- Can be used when I(type=email).
- Message format.
choices:
- plaintext
- html
default: html
message_text_limit:
type: "str"
description:
Expand Down Expand Up @@ -525,6 +534,7 @@ def construct_parameters(self):
smtp_authentication=truths.get(str(self._module.params["smtp_authentication"])),
smtp_verify_host=truths.get(str(self._module.params["smtp_verify_host"])),
smtp_verify_peer=truths.get(str(self._module.params["smtp_verify_peer"])),
content_type={"plaintext": "0", "html": "1"}.get(str(self._module.params["content_type"])),
username=self._module.params["username"],
passwd=self._module.params["password"]
))
Expand Down Expand Up @@ -693,6 +703,7 @@ def main():
smtp_authentication=dict(type="bool", default=False, required=False),
smtp_verify_host=dict(type="bool", default=False, required=False),
smtp_verify_peer=dict(type="bool", default=False, required=False),
content_type=dict(type="str", choices=["plaintext", "html"], default="html", required=False),
# EZ Text
message_text_limit=dict(type="str", required=False, choices=["USA", "Canada"]),
# Webhook
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/targets/test_zabbix_mediatype/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@
- ansible.builtin.assert:
that: zbxmediatype_reset.changed is sameas True

- name: test - check email mediatype content_type for html default
community.zabbix.zabbix_mediatype:
content_type: "html"
register: zbxmediatype_verif

- ansible.builtin.assert:
that: zbxmediatype_verif.changed is sameas False

- name: test - update email mediatype content_type to plaintext
community.zabbix.zabbix_mediatype:
content_type: "plaintext"
register: zbxmediatype_verif

- ansible.builtin.assert:
that: zbxmediatype_verif.changed is sameas True

- name: test - reset email mediatype content_type to default
community.zabbix.zabbix_mediatype:
register: zbxmediatype_reset

- ansible.builtin.assert:
that: zbxmediatype_reset.changed is sameas True

- name: test - update email mediatype concurrent settings
community.zabbix.zabbix_mediatype:
max_sessions: 99
Expand Down

0 comments on commit 6759b1c

Please sign in to comment.