New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Ansible UTM Module for managing network aaa entries. #49863
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
147 changes: 147 additions & 0 deletions
147
lib/ansible/modules/web_infrastructure/sophos_utm/utm_network_aaa.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#!/usr/bin/python | ||
|
||
# Copyright: (c) 2018, Stephan Schwarz <stearz@gmx.de> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
|
||
__metaclass__ = type | ||
|
||
ANSIBLE_METADATA = { | ||
'metadata_version': '1.1', | ||
'status': ['preview'], | ||
'supported_by': 'community' | ||
} | ||
|
||
DOCUMENTATION = """ | ||
--- | ||
module: utm_network_aaa | ||
|
||
author: | ||
- Stephan Schwarz (@stearz) | ||
|
||
short_description: create, update or destroy network aaa entry in Sophos UTM | ||
|
||
description: | ||
- Create, update or destroy a network aaa entry in Sophos UTM. | ||
- This module needs to have the REST Ability of the UTM to be activated. | ||
|
||
version_added: "2.8" | ||
|
||
options: | ||
name: | ||
description: | ||
- The name of the object. Will be used to identify the entry | ||
required: true | ||
addresses: | ||
description: | ||
- List of IPv4 addresses | ||
default: [] | ||
addresses6: | ||
description: | ||
- List of IPv6 addresses | ||
default: [] | ||
comment: | ||
description: | ||
- Optional comment string | ||
default: "" | ||
resolved: | ||
description: | ||
- Optional boolean | ||
default: false | ||
type: bool | ||
resolved6: | ||
description: | ||
- Optional boolean | ||
default: false | ||
type: bool | ||
|
||
extends_documentation_fragment: | ||
- utm | ||
""" | ||
|
||
EXAMPLES = """ | ||
- name: Create UTM network_aaa | ||
utm_network_aaa: | ||
utm_host: sophos.host.name | ||
utm_token: abcdefghijklmno1234 | ||
name: TestAAAGroupEntry | ||
state: present | ||
|
||
- name: Remove UTM network_aaa | ||
utm_network_aaa: | ||
utm_host: sophos.host.name | ||
utm_token: abcdefghijklmno1234 | ||
name: TestAAAGroupEntry | ||
state: absent | ||
|
||
- name: Remove UTM network_aaa | ||
utm_network_aaa: | ||
utm_host: sophos.host.name | ||
utm_token: abcdefghijklmno1234 | ||
name: TestAAAGroupEntry | ||
state: info | ||
|
||
""" | ||
|
||
RETURN = """ | ||
result: | ||
description: The utm object that was created | ||
returned: success | ||
type: complex | ||
contains: | ||
_ref: | ||
description: The reference name of the object | ||
type: string | ||
_locked: | ||
description: Whether or not the object is currently locked | ||
type: boolean | ||
_type: | ||
description: The type of the object | ||
type: string | ||
name: | ||
description: The name of the object | ||
type: string | ||
addresses: | ||
description: List of IPv4 addresses | ||
type: list | ||
addresses6: | ||
description: List of IPv6 addresses | ||
type: list | ||
comment: | ||
description: Optional comment string | ||
type: string | ||
resolved: | ||
description: Optional boolean | ||
type: boolean | ||
resolved6: | ||
description: Optional boolean | ||
type: boolean | ||
""" | ||
|
||
from ansible.module_utils.utm_utils import UTM, UTMModule | ||
from ansible.module_utils._text import to_native | ||
|
||
|
||
def main(): | ||
endpoint = "network/aaa" | ||
key_to_check_for_changes = ["addresses", "addresses6", "comment", "resolved", "resolved6"] | ||
module = UTMModule( | ||
argument_spec=dict( | ||
name=dict(type='str', required=True), | ||
comment=dict(type='str', required=False, default=""), | ||
addresses=dict(type='list', elements='str', required=False, default=[]), | ||
addresses6=dict(type='list', elements='str', required=False, default=[]), | ||
resolved=dict(type='bool', required=False, default=False), | ||
resolved6=dict(type='bool', required=False, default=False), | ||
) | ||
) | ||
try: | ||
UTM(module, endpoint, key_to_check_for_changes).execute() | ||
except Exception as e: | ||
module.fail_json(msg=to_native(e)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this to your name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry? This is my name. What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the other PR. @stearz did the code but i commited it in his name so he is the author. We're working colleagues and i was reviewing the code.