| 1 |
#!/usr/bin/python |
| 2 |
|
| 3 |
# Copyright (c) 2018, Juergen Wiebe <[email protected]> |
| 4 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 6 |
from __future__ import annotations |
| 7 |
|
| 8 |
DOCUMENTATION = r""" |
| 9 |
module: utm_network_interface_address |
| 10 |
|
| 11 |
author: |
| 12 |
- Juergen Wiebe (@steamx) |
| 13 |
|
| 14 |
short_description: Create, update or destroy network/interface_address object |
| 15 |
|
| 16 |
description: |
| 17 |
- Create, update or destroy a network/interface_address object in SOPHOS UTM. |
| 18 |
- This module needs to have the REST Ability of the UTM to be activated. |
| 19 |
attributes: |
| 20 |
check_mode: |
| 21 |
support: none |
| 22 |
diff_mode: |
| 23 |
support: none |
| 24 |
|
| 25 |
options: |
| 26 |
name: |
| 27 |
type: str |
| 28 |
description: |
| 29 |
- The name of the object that identifies the entry. |
| 30 |
required: true |
| 31 |
address: |
| 32 |
type: str |
| 33 |
description: |
| 34 |
- The ip4 address of the network/interface_address object. |
| 35 |
required: true |
| 36 |
address6: |
| 37 |
type: str |
| 38 |
description: |
| 39 |
- The ip6 address of the network/interface_address object. |
| 40 |
comment: |
| 41 |
type: str |
| 42 |
description: |
| 43 |
- An optional comment to add to the object. |
| 44 |
default: '' |
| 45 |
resolved: |
| 46 |
type: bool |
| 47 |
description: |
| 48 |
- Whether or not the object is resolved. |
| 49 |
resolved6: |
| 50 |
type: bool |
| 51 |
description: |
| 52 |
- Whether or not the object is resolved. |
| 53 |
extends_documentation_fragment: |
| 54 |
- community.general._utm |
| 55 |
- community.general._attributes |
| 56 |
""" |
| 57 |
|
| 58 |
EXAMPLES = r""" |
| 59 |
- name: Create a network interface address |
| 60 |
utm_proxy_backend: |
| 61 |
utm_host: sophos.host.name |
| 62 |
utm_token: abcdefghijklmno1234 |
| 63 |
name: TestNetworkInterfaceAddress |
| 64 |
address: 0.0.0.0 |
| 65 |
state: present |
| 66 |
|
| 67 |
- name: Remove a network interface address |
| 68 |
network_interface_address: |
| 69 |
utm_host: sophos.host.name |
| 70 |
utm_token: abcdefghijklmno1234 |
| 71 |
name: TestNetworkInterfaceAddress |
| 72 |
address: 0.0.0.0 |
| 73 |
state: absent |
| 74 |
""" |
| 75 |
|
| 76 |
RETURN = r""" |
| 77 |
result: |
| 78 |
description: The utm object that was created. |
| 79 |
returned: success |
| 80 |
type: complex |
| 81 |
contains: |
| 82 |
_ref: |
| 83 |
description: The reference name of the object. |
| 84 |
type: str |
| 85 |
_locked: |
| 86 |
description: Whether or not the object is currently locked. |
| 87 |
type: bool |
| 88 |
_type: |
| 89 |
description: The type of the object. |
| 90 |
type: str |
| 91 |
name: |
| 92 |
description: The name of the object. |
| 93 |
type: str |
| 94 |
address: |
| 95 |
description: The ip4 address of the network/interface_address object. |
| 96 |
type: str |
| 97 |
address6: |
| 98 |
description: The ip6 address of the network/interface_address object. |
| 99 |
type: str |
| 100 |
comment: |
| 101 |
description: The comment string. |
| 102 |
type: str |
| 103 |
resolved: |
| 104 |
description: Whether or not the object is resolved. |
| 105 |
type: bool |
| 106 |
resolved6: |
| 107 |
description: Whether or not the object is resolved. |
| 108 |
type: bool |
| 109 |
""" |
| 110 |
|
| 111 |
from ansible_collections.community.general.plugins.module_utils._utm_utils import UTM, UTMModule |
| 112 |
|
| 113 |
|
| 114 |
def main(): |
| 115 |
endpoint = "network/interface_address" |
| 116 |
key_to_check_for_changes = ["comment", "address"] |
| 117 |
module = UTMModule( |
| 118 |
argument_spec=dict( |
| 119 |
name=dict(type="str", required=True), |
| 120 |
address=dict(type="str", required=True), |
| 121 |
comment=dict(type="str", default=""), |
| 122 |
address6=dict(type="str"), |
| 123 |
resolved=dict(type="bool"), |
| 124 |
resolved6=dict(type="bool"), |
| 125 |
) |
| 126 |
) |
| 127 |
try: |
| 128 |
UTM(module, endpoint, key_to_check_for_changes).execute() |
| 129 |
except Exception as e: |
| 130 |
module.fail_json(msg=f"{e}") |
| 131 |
|
| 132 |
|
| 133 |
if __name__ == "__main__": |
| 134 |
main() |