Skip to content

Commit

Permalink
[ Enhancement ] - Add vars parameter to user_template and user modules (
Browse files Browse the repository at this point in the history
  • Loading branch information
gianmarco-mameli authored Oct 29, 2024
1 parent 49389f7 commit 18bcbcd
Show file tree
Hide file tree
Showing 15 changed files with 724 additions and 649 deletions.
7 changes: 6 additions & 1 deletion docs/icinga_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Parameters

Groups can be useful for various reasons. You might prefer to send notifications to groups instead of single users.

vars (optional, dict, {})
Custom properties of the user.

append (optional, bool, None)
Do not overwrite the whole object but instead append the defined properties.
Expand Down Expand Up @@ -149,7 +151,7 @@ Examples

.. code-block:: yaml+jinja


- name: Create user
telekom_mms.icinga_director.icinga_user:
state: present
Expand All @@ -164,6 +166,9 @@ Examples
- foousertemplate
groups:
- onCall
vars:
department: IT
role: CTO

- name: Update user
telekom_mms.icinga_director.icinga_user:
Expand Down
6 changes: 5 additions & 1 deletion docs/icinga_user_template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Parameters
zone (optional, str, None)
Set the zone.

vars (optional, dict, {})
Custom properties of the user template.

append (optional, bool, None)
Do not overwrite the whole object but instead append the defined properties.
Expand Down Expand Up @@ -133,7 +135,7 @@ Examples

.. code-block:: yaml+jinja


- name: Create user template
telekom_mms.icinga_director.icinga_user_template:
state: present
Expand All @@ -143,6 +145,8 @@ Examples
object_name: "foousertemplate"
enable_notifications: false
period: '24/7'
vars:
department: IT
zone: "foozone"

- name: Update user template
Expand Down
2 changes: 2 additions & 0 deletions examples/icinga_user_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
object_name: "foousertemplate"
enable_notifications: false
period: '24/7'
vars:
department: IT
zone: "foozone"
- name: Update user template
telekom_mms.icinga_director.icinga_user_template:
Expand Down
10 changes: 10 additions & 0 deletions plugins/modules/icinga_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
- Groups can be useful for various reasons. You might prefer to send notifications to groups instead of single users.
type: list
elements: str
vars:
description:
- Custom properties of the user.
type: "dict"
default: {}
append:
description:
- Do not overwrite the whole object but instead append the defined properties.
Expand All @@ -107,6 +112,9 @@
- foousertemplate
groups:
- onCall
vars:
department: IT
role: CTO
- name: Update user
telekom_mms.icinga_director.icinga_user:
Expand Down Expand Up @@ -147,6 +155,7 @@ def main():
pager=dict(required=False),
period=dict(required=False),
groups=dict(type="list", elements="str", required=False),
vars=dict(type="dict", default={}, required=False),
)

# Define the main module
Expand All @@ -163,6 +172,7 @@ def main():
"pager",
"period",
"groups",
"vars",
]

data = {}
Expand Down
9 changes: 9 additions & 0 deletions plugins/modules/icinga_user_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
description:
- Set the zone.
type: str
vars:
description:
- Custom properties of the user.
type: "dict"
default: {}
append:
description:
- Do not overwrite the whole object but instead append the defined properties.
Expand All @@ -86,6 +91,8 @@
object_name: "foousertemplate"
enable_notifications: false
period: '24/7'
vars:
department: IT
zone: "foozone"
- name: Update user template
Expand Down Expand Up @@ -123,6 +130,7 @@ def main():
imports=dict(type="list", elements="str", default=[], required=False),
period=dict(required=False),
enable_notifications=dict(type="bool", required=False),
vars=dict(type="dict", default={}, required=False),
zone=dict(required=False, default=None),
)

Expand All @@ -136,6 +144,7 @@ def main():
"imports",
"period",
"enable_notifications",
"vars",
"zone",
]

Expand Down
Loading

0 comments on commit 18bcbcd

Please sign in to comment.