| 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_user_domaincontroller |
| 15 |
short_description: Configure domain controller entries. |
| 16 |
version_added: "2.1.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 |
user_domaincontroller: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
domain_name: |
| 34 |
aliases: ['domain-name'] |
| 35 |
type: str |
| 36 |
description: Domain DNS name. |
| 37 |
extra_server: |
| 38 |
aliases: ['extra-server'] |
| 39 |
type: list |
| 40 |
elements: dict |
| 41 |
description: Extra server. |
| 42 |
suboptions: |
| 43 |
id: |
| 44 |
type: int |
| 45 |
description: Server ID. |
| 46 |
ip_address: |
| 47 |
aliases: ['ip-address'] |
| 48 |
type: str |
| 49 |
description: Domain controller IP address. |
| 50 |
port: |
| 51 |
type: int |
| 52 |
description: Port to be used for communication with the domain controller |
| 53 |
source_ip_address: |
| 54 |
aliases: ['source-ip-address'] |
| 55 |
type: str |
| 56 |
description: FortiGate IPv4 address to be used for communication with the domain controller. |
| 57 |
source_port: |
| 58 |
aliases: ['source-port'] |
| 59 |
type: int |
| 60 |
description: Source port to be used for communication with the domain controller. |
| 61 |
ip_address: |
| 62 |
aliases: ['ip-address'] |
| 63 |
type: str |
| 64 |
description: Domain controller IP address. |
| 65 |
ldap_server: |
| 66 |
aliases: ['ldap-server'] |
| 67 |
type: raw |
| 68 |
description: (list or str) LDAP server name. |
| 69 |
name: |
| 70 |
type: str |
| 71 |
description: Domain controller entry name. |
| 72 |
required: true |
| 73 |
port: |
| 74 |
type: int |
| 75 |
description: Port to be used for communication with the domain controller |
| 76 |
ad_mode: |
| 77 |
aliases: ['ad-mode'] |
| 78 |
type: str |
| 79 |
description: Set Active Directory mode. |
| 80 |
choices: ['none', 'ds', 'lds'] |
| 81 |
adlds_dn: |
| 82 |
aliases: ['adlds-dn'] |
| 83 |
type: str |
| 84 |
description: AD LDS distinguished name. |
| 85 |
adlds_ip_address: |
| 86 |
aliases: ['adlds-ip-address'] |
| 87 |
type: str |
| 88 |
description: AD LDS IPv4 address. |
| 89 |
adlds_ip6: |
| 90 |
aliases: ['adlds-ip6'] |
| 91 |
type: str |
| 92 |
description: AD LDS IPv6 address. |
| 93 |
adlds_port: |
| 94 |
aliases: ['adlds-port'] |
| 95 |
type: int |
| 96 |
description: Port number of AD LDS service |
| 97 |
dns_srv_lookup: |
| 98 |
aliases: ['dns-srv-lookup'] |
| 99 |
type: str |
| 100 |
description: Enable/disable DNS service lookup. |
| 101 |
choices: ['disable', 'enable'] |
| 102 |
hostname: |
| 103 |
type: str |
| 104 |
description: Hostname of the server to connect to. |
| 105 |
interface: |
| 106 |
type: str |
| 107 |
description: Specify outgoing interface to reach server. |
| 108 |
interface_select_method: |
| 109 |
aliases: ['interface-select-method'] |
| 110 |
type: str |
| 111 |
description: Specify how to select outgoing interface to reach server. |
| 112 |
choices: ['auto', 'sdwan', 'specify'] |
| 113 |
ip6: |
| 114 |
type: str |
| 115 |
description: Domain controller IPv6 address. |
| 116 |
password: |
| 117 |
type: raw |
| 118 |
description: (list) Password for specified username. |
| 119 |
replication_port: |
| 120 |
aliases: ['replication-port'] |
| 121 |
type: int |
| 122 |
description: Port to be used for communication with the domain controller for replication service. |
| 123 |
source_ip_address: |
| 124 |
aliases: ['source-ip-address'] |
| 125 |
type: str |
| 126 |
description: FortiGate IPv4 address to be used for communication with the domain controller. |
| 127 |
source_ip6: |
| 128 |
aliases: ['source-ip6'] |
| 129 |
type: str |
| 130 |
description: FortiGate IPv6 address to be used for communication with the domain controller. |
| 131 |
source_port: |
| 132 |
aliases: ['source-port'] |
| 133 |
type: int |
| 134 |
description: Source port to be used for communication with the domain controller. |
| 135 |
username: |
| 136 |
type: str |
| 137 |
description: User name to sign in with. |
| 138 |
change_detection: |
| 139 |
aliases: ['change-detection'] |
| 140 |
type: str |
| 141 |
description: Enable/disable detection of a configuration change in the Active Directory server. |
| 142 |
choices: ['disable', 'enable'] |
| 143 |
change_detection_period: |
| 144 |
aliases: ['change-detection-period'] |
| 145 |
type: int |
| 146 |
description: Minutes to detect a configuration change in the Active Directory server |
| 147 |
domain_name_src: |
| 148 |
aliases: ['domain-name-src'] |
| 149 |
type: str |
| 150 |
description: Domain name src. |
| 151 |
choices: ['server', 'client'] |
| 152 |
''' |
| 153 |
|
| 154 |
EXAMPLES = ''' |
| 155 |
- name: Example playbook (generated based on argument schema) |
| 156 |
hosts: fortimanagers |
| 157 |
connection: httpapi |
| 158 |
gather_facts: false |
| 159 |
tasks: |
| 160 |
- name: Configure domain controller entries. |
| 161 |
fortinet.fortimanager.fmgr_user_domaincontroller: |
| 162 |
# workspace_locking_adom: <global or your adom name> |
| 163 |
adom: <your own value> |
| 164 |
state: present # <value in [present, absent]> |
| 165 |
user_domaincontroller: |
| 166 |
name: "your value" # Required variable, string |
| 167 |
# domain_name: <string> |
| 168 |
# extra_server: |
| 169 |
# - id: <integer> |
| 170 |
# ip_address: <string> |
| 171 |
# port: <integer> |
| 172 |
# source_ip_address: <string> |
| 173 |
# source_port: <integer> |
| 174 |
# ip_address: <string> |
| 175 |
# ldap_server: <list or string> |
| 176 |
# port: <integer> |
| 177 |
# ad_mode: <value in [none, ds, lds]> |
| 178 |
# adlds_dn: <string> |
| 179 |
# adlds_ip_address: <string> |
| 180 |
# adlds_ip6: <string> |
| 181 |
# adlds_port: <integer> |
| 182 |
# dns_srv_lookup: <value in [disable, enable]> |
| 183 |
# hostname: <string> |
| 184 |
# interface: <string> |
| 185 |
# interface_select_method: <value in [auto, sdwan, specify]> |
| 186 |
# ip6: <string> |
| 187 |
# password: <list or string> |
| 188 |
# replication_port: <integer> |
| 189 |
# source_ip_address: <string> |
| 190 |
# source_ip6: <string> |
| 191 |
# source_port: <integer> |
| 192 |
# username: <string> |
| 193 |
# change_detection: <value in [disable, enable]> |
| 194 |
# change_detection_period: <integer> |
| 195 |
# domain_name_src: <value in [server, client]> |
| 196 |
''' |
| 197 |
|
| 198 |
RETURN = ''' |
| 199 |
meta: |
| 200 |
description: The result of the request. |
| 201 |
type: dict |
| 202 |
returned: always |
| 203 |
contains: |
| 204 |
request_url: |
| 205 |
description: The full url requested. |
| 206 |
returned: always |
| 207 |
type: str |
| 208 |
sample: /sys/login/user |
| 209 |
response_code: |
| 210 |
description: The status of api request. |
| 211 |
returned: always |
| 212 |
type: int |
| 213 |
sample: 0 |
| 214 |
response_data: |
| 215 |
description: The api response. |
| 216 |
type: list |
| 217 |
returned: always |
| 218 |
response_message: |
| 219 |
description: The descriptive message of the api response. |
| 220 |
type: str |
| 221 |
returned: always |
| 222 |
sample: OK. |
| 223 |
system_information: |
| 224 |
description: The information of the target system. |
| 225 |
type: dict |
| 226 |
returned: always |
| 227 |
rc: |
| 228 |
description: The status the request. |
| 229 |
type: int |
| 230 |
returned: always |
| 231 |
sample: 0 |
| 232 |
version_check_warning: |
| 233 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 234 |
type: list |
| 235 |
returned: complex |
| 236 |
''' |
| 237 |
from ansible.module_utils.basic import AnsibleModule |
| 238 |
from ansible.module_utils.connection import Connection |
| 239 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 240 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 241 |
|
| 242 |
|
| 243 |
def main(): |
| 244 |
urls_list = [ |
| 245 |
'/pm/config/adom/{adom}/obj/user/domain-controller', |
| 246 |
'/pm/config/global/obj/user/domain-controller' |
| 247 |
] |
| 248 |
module_arg_spec = { |
| 249 |
'adom': {'required': True, 'type': 'str'}, |
| 250 |
'revision_note': {'type': 'str'}, |
| 251 |
'user_domaincontroller': { |
| 252 |
'type': 'dict', 'v_range': [['6.2.1', '']], |
| 253 |
'options': { |
| 254 |
'domain-name': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 255 |
'extra-server': { |
| 256 |
'v_range': [['6.2.1', '']], |
| 257 |
'type': 'list', |
| 258 |
'options': { |
| 259 |
'id': {'v_range': [['6.2.1', '']], 'type': 'int'}, |
| 260 |
'ip-address': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 261 |
'port': {'v_range': [['6.2.1', '']], 'type': 'int'}, |
| 262 |
'source-ip-address': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 263 |
'source-port': {'v_range': [['7.0.0', '']], 'type': 'int'} |
| 264 |
}, |
| 265 |
'elements': 'dict' |
| 266 |
}, |
| 267 |
'ip-address': {'v_range': [['6.2.1', '']], 'type': 'str'}, |
| 268 |
'ldap-server': {'v_range': [['6.2.1', '']], 'type': 'raw'}, |
| 269 |
'name': {'v_range': [['6.2.1', '']], 'required': True, 'type': 'str'}, |
| 270 |
'port': {'v_range': [['6.2.1', '']], 'type': 'int'}, |
| 271 |
'ad-mode': {'v_range': [['7.0.0', '']], 'choices': ['none', 'ds', 'lds'], 'type': 'str'}, |
| 272 |
'adlds-dn': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 273 |
'adlds-ip-address': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 274 |
'adlds-ip6': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 275 |
'adlds-port': {'v_range': [['7.0.0', '']], 'type': 'int'}, |
| 276 |
'dns-srv-lookup': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 277 |
'hostname': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 278 |
'interface': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 279 |
'interface-select-method': {'v_range': [['7.0.0', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'}, |
| 280 |
'ip6': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 281 |
'password': {'v_range': [['7.0.0', '']], 'no_log': True, 'type': 'raw'}, |
| 282 |
'replication-port': {'v_range': [['7.0.0', '']], 'type': 'int'}, |
| 283 |
'source-ip-address': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 284 |
'source-ip6': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 285 |
'source-port': {'v_range': [['7.0.0', '']], 'type': 'int'}, |
| 286 |
'username': {'v_range': [['7.0.0', '']], 'type': 'str'}, |
| 287 |
'change-detection': {'v_range': [['7.2.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 288 |
'change-detection-period': {'v_range': [['7.2.3', '']], 'type': 'int'}, |
| 289 |
'domain-name-src': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['server', 'client'], 'type': 'str'} |
| 290 |
} |
| 291 |
} |
| 292 |
} |
| 293 |
|
| 294 |
module_option_spec = get_module_arg_spec('full crud') |
| 295 |
module_arg_spec.update(module_option_spec) |
| 296 |
check_galaxy_version(module_arg_spec) |
| 297 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_domaincontroller'), |
| 298 |
supports_check_mode=True) |
| 299 |
if not module._socket_path: |
| 300 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 301 |
connection = Connection(module._socket_path) |
| 302 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 303 |
'name', 'data', module, connection) |
| 304 |
fmgr.process_crud() |
| 305 |
module.exit_json(meta=module.params) |
| 306 |
|
| 307 |
|
| 308 |
if __name__ == '__main__': |
| 309 |
main() |