| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
ANSIBLE_METADATA = {'status': ['preview'], |
| 9 |
'supported_by': 'community', |
| 10 |
'metadata_version': '1.1'} |
| 11 |
|
| 12 |
DOCUMENTATION = ''' |
| 13 |
--- |
| 14 |
module: fmgr_icap_server |
| 15 |
short_description: Configure ICAP servers. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.full_crud |
| 20 |
options: |
| 21 |
revision_note: |
| 22 |
description: The change note that can be specified when an object is created or updated. |
| 23 |
type: str |
| 24 |
adom: |
| 25 |
description: The parameter (adom) in requested url. |
| 26 |
type: str |
| 27 |
required: true |
| 28 |
icap_server: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
ip_address: |
| 34 |
aliases: ['ip-address'] |
| 35 |
type: str |
| 36 |
description: IPv4 address of the ICAP server. |
| 37 |
ip_version: |
| 38 |
aliases: ['ip-version'] |
| 39 |
type: str |
| 40 |
description: IP version. |
| 41 |
choices: ['4', '6'] |
| 42 |
ip6_address: |
| 43 |
aliases: ['ip6-address'] |
| 44 |
type: str |
| 45 |
description: IPv6 address of the ICAP server. |
| 46 |
max_connections: |
| 47 |
aliases: ['max-connections'] |
| 48 |
type: int |
| 49 |
description: Maximum number of concurrent connections to ICAP server. |
| 50 |
name: |
| 51 |
type: str |
| 52 |
description: Server name. |
| 53 |
required: true |
| 54 |
port: |
| 55 |
type: int |
| 56 |
description: ICAP server port. |
| 57 |
secure: |
| 58 |
type: str |
| 59 |
description: Enable/disable secure connection to ICAP server. |
| 60 |
choices: ['disable', 'enable'] |
| 61 |
ssl_cert: |
| 62 |
aliases: ['ssl-cert'] |
| 63 |
type: str |
| 64 |
description: CA certificate name. |
| 65 |
addr_type: |
| 66 |
aliases: ['addr-type'] |
| 67 |
type: str |
| 68 |
description: Address type of the remote ICAP server |
| 69 |
choices: ['fqdn', 'ip4', 'ip6'] |
| 70 |
fqdn: |
| 71 |
type: str |
| 72 |
description: ICAP remote server Fully Qualified Domain Name |
| 73 |
healthcheck: |
| 74 |
type: str |
| 75 |
description: Enable/disable ICAP remote server health checking. |
| 76 |
choices: ['disable', 'enable'] |
| 77 |
healthcheck_service: |
| 78 |
aliases: ['healthcheck-service'] |
| 79 |
type: str |
| 80 |
description: ICAP Service name to use for health checks. |
| 81 |
''' |
| 82 |
|
| 83 |
EXAMPLES = ''' |
| 84 |
- name: Example playbook (generated based on argument schema) |
| 85 |
hosts: fortimanagers |
| 86 |
connection: httpapi |
| 87 |
gather_facts: false |
| 88 |
tasks: |
| 89 |
- name: Configure ICAP servers. |
| 90 |
fortinet.fortimanager.fmgr_icap_server: |
| 91 |
# workspace_locking_adom: <global or your adom name> |
| 92 |
adom: <your own value> |
| 93 |
state: present # <value in [present, absent]> |
| 94 |
icap_server: |
| 95 |
name: "your value" # Required variable, string |
| 96 |
# ip_address: <string> |
| 97 |
# ip_version: <value in [4, 6]> |
| 98 |
# ip6_address: <string> |
| 99 |
# max_connections: <integer> |
| 100 |
# port: <integer> |
| 101 |
# secure: <value in [disable, enable]> |
| 102 |
# ssl_cert: <string> |
| 103 |
# addr_type: <value in [fqdn, ip4, ip6]> |
| 104 |
# fqdn: <string> |
| 105 |
# healthcheck: <value in [disable, enable]> |
| 106 |
# healthcheck_service: <string> |
| 107 |
''' |
| 108 |
|
| 109 |
RETURN = ''' |
| 110 |
meta: |
| 111 |
description: The result of the request. |
| 112 |
type: dict |
| 113 |
returned: always |
| 114 |
contains: |
| 115 |
request_url: |
| 116 |
description: The full url requested. |
| 117 |
returned: always |
| 118 |
type: str |
| 119 |
sample: /sys/login/user |
| 120 |
response_code: |
| 121 |
description: The status of api request. |
| 122 |
returned: always |
| 123 |
type: int |
| 124 |
sample: 0 |
| 125 |
response_data: |
| 126 |
description: The api response. |
| 127 |
type: list |
| 128 |
returned: always |
| 129 |
response_message: |
| 130 |
description: The descriptive message of the api response. |
| 131 |
type: str |
| 132 |
returned: always |
| 133 |
sample: OK. |
| 134 |
system_information: |
| 135 |
description: The information of the target system. |
| 136 |
type: dict |
| 137 |
returned: always |
| 138 |
rc: |
| 139 |
description: The status the request. |
| 140 |
type: int |
| 141 |
returned: always |
| 142 |
sample: 0 |
| 143 |
version_check_warning: |
| 144 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 145 |
type: list |
| 146 |
returned: complex |
| 147 |
''' |
| 148 |
from ansible.module_utils.basic import AnsibleModule |
| 149 |
from ansible.module_utils.connection import Connection |
| 150 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 151 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 152 |
|
| 153 |
|
| 154 |
def main(): |
| 155 |
urls_list = [ |
| 156 |
'/pm/config/adom/{adom}/obj/icap/server', |
| 157 |
'/pm/config/global/obj/icap/server' |
| 158 |
] |
| 159 |
module_arg_spec = { |
| 160 |
'adom': {'required': True, 'type': 'str'}, |
| 161 |
'revision_note': {'type': 'str'}, |
| 162 |
'icap_server': { |
| 163 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 164 |
'options': { |
| 165 |
'ip-address': {'type': 'str'}, |
| 166 |
'ip-version': {'choices': ['4', '6'], 'type': 'str'}, |
| 167 |
'ip6-address': {'type': 'str'}, |
| 168 |
'max-connections': {'type': 'int'}, |
| 169 |
'name': {'required': True, 'type': 'str'}, |
| 170 |
'port': {'type': 'int'}, |
| 171 |
'secure': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 172 |
'ssl-cert': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 173 |
'addr-type': {'v_range': [['7.2.0', '']], 'choices': ['fqdn', 'ip4', 'ip6'], 'type': 'str'}, |
| 174 |
'fqdn': {'v_range': [['7.2.0', '']], 'type': 'str'}, |
| 175 |
'healthcheck': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 176 |
'healthcheck-service': {'v_range': [['7.2.0', '']], 'type': 'str'} |
| 177 |
} |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
module_option_spec = get_module_arg_spec('full crud') |
| 182 |
module_arg_spec.update(module_option_spec) |
| 183 |
check_galaxy_version(module_arg_spec) |
| 184 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'icap_server'), |
| 185 |
supports_check_mode=True) |
| 186 |
if not module._socket_path: |
| 187 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 188 |
connection = Connection(module._socket_path) |
| 189 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 190 |
'name', 'data', module, connection) |
| 191 |
fmgr.process_crud() |
| 192 |
module.exit_json(meta=module.params) |
| 193 |
|
| 194 |
|
| 195 |
if __name__ == '__main__': |
| 196 |
main() |