| 1 |
#!/usr/bin/python |
| 2 |
|
| 3 |
# Copyright (c) 2018, Johannes Brunswicker <[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 |
|
| 7 |
from __future__ import annotations |
| 8 |
|
| 9 |
DOCUMENTATION = r""" |
| 10 |
module: utm_proxy_frontend_info |
| 11 |
|
| 12 |
author: |
| 13 |
- Johannes Brunswicker (@MatrixCrawler) |
| 14 |
|
| 15 |
short_description: Create, update or destroy reverse_proxy frontend entry in Sophos UTM |
| 16 |
|
| 17 |
description: |
| 18 |
- Create, update or destroy a reverse_proxy frontend entry in SOPHOS UTM. |
| 19 |
- This module needs to have the REST Ability of the UTM to be activated. |
| 20 |
attributes: |
| 21 |
check_mode: |
| 22 |
version_added: 3.3.0 |
| 23 |
# This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix |
| 24 |
|
| 25 |
options: |
| 26 |
name: |
| 27 |
type: str |
| 28 |
description: |
| 29 |
- The name of the object that identifies the entry. |
| 30 |
required: true |
| 31 |
|
| 32 |
extends_documentation_fragment: |
| 33 |
- community.general._utm |
| 34 |
- community.general._attributes |
| 35 |
- community.general._attributes.info_module |
| 36 |
""" |
| 37 |
|
| 38 |
EXAMPLES = r""" |
| 39 |
- name: Get utm proxy_frontend |
| 40 |
community.general.utm_proxy_frontend_info: |
| 41 |
utm_host: sophos.host.name |
| 42 |
utm_token: abcdefghijklmno1234 |
| 43 |
name: TestBackendEntry |
| 44 |
host: REF_OBJECT_STRING |
| 45 |
""" |
| 46 |
|
| 47 |
RETURN = r""" |
| 48 |
result: |
| 49 |
description: The utm object that was created. |
| 50 |
returned: success |
| 51 |
type: complex |
| 52 |
contains: |
| 53 |
_ref: |
| 54 |
description: The reference name of the object. |
| 55 |
type: str |
| 56 |
_locked: |
| 57 |
description: Whether or not the object is currently locked. |
| 58 |
type: bool |
| 59 |
_type: |
| 60 |
description: The type of the object. |
| 61 |
type: str |
| 62 |
name: |
| 63 |
description: The name of the object. |
| 64 |
type: str |
| 65 |
add_content_type_header: |
| 66 |
description: Whether to add the content type header. |
| 67 |
type: bool |
| 68 |
address: |
| 69 |
description: The reference name of the address. |
| 70 |
type: str |
| 71 |
allowed_networks: |
| 72 |
description: List of reference names of networks associated. |
| 73 |
type: list |
| 74 |
certificate: |
| 75 |
description: Reference name of certificate (ca/host_key_cert). |
| 76 |
type: str |
| 77 |
comment: |
| 78 |
description: The comment string. |
| 79 |
type: str |
| 80 |
disable_compression: |
| 81 |
description: State of compression support. |
| 82 |
type: bool |
| 83 |
domain: |
| 84 |
description: List of hostnames. |
| 85 |
type: list |
| 86 |
exceptions: |
| 87 |
description: List of associated proxy exceptions. |
| 88 |
type: list |
| 89 |
htmlrewrite: |
| 90 |
description: State of HTML rewrite. |
| 91 |
type: bool |
| 92 |
htmlrewrite_cookies: |
| 93 |
description: Whether the HTML rewrite cookie is set. |
| 94 |
type: bool |
| 95 |
implicitredirect: |
| 96 |
description: Whether to use implicit redirection. |
| 97 |
type: bool |
| 98 |
lbmethod: |
| 99 |
description: The method of loadbalancer to use. |
| 100 |
type: str |
| 101 |
locations: |
| 102 |
description: The reference names of reverse_proxy/locations associated with the object. |
| 103 |
type: list |
| 104 |
port: |
| 105 |
description: The port of the frontend connection. |
| 106 |
type: int |
| 107 |
preservehost: |
| 108 |
description: Preserve host header. |
| 109 |
type: bool |
| 110 |
profile: |
| 111 |
description: The associated reverse_proxy/profile. |
| 112 |
type: str |
| 113 |
status: |
| 114 |
description: Whether the frontend object is active or not. |
| 115 |
type: bool |
| 116 |
type: |
| 117 |
description: The connection type. |
| 118 |
type: str |
| 119 |
xheaders: |
| 120 |
description: The xheaders state. |
| 121 |
type: bool |
| 122 |
""" |
| 123 |
|
| 124 |
from ansible_collections.community.general.plugins.module_utils._utm_utils import UTM, UTMModule |
| 125 |
|
| 126 |
|
| 127 |
def main(): |
| 128 |
endpoint = "reverse_proxy/frontend" |
| 129 |
key_to_check_for_changes = [] |
| 130 |
module = UTMModule( |
| 131 |
argument_spec=dict( |
| 132 |
name=dict(type="str", required=True), |
| 133 |
), |
| 134 |
supports_check_mode=True, |
| 135 |
) |
| 136 |
try: |
| 137 |
UTM(module, endpoint, key_to_check_for_changes, info_only=True).execute() |
| 138 |
except Exception as e: |
| 139 |
module.fail_json(msg=f"{e}") |
| 140 |
|
| 141 |
|
| 142 |
if __name__ == "__main__": |
| 143 |
main() |