| 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_tacacs |
| 15 |
short_description: Configure TACACS+ server entries. |
| 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 |
user_tacacs: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
authen_type: |
| 34 |
aliases: ['authen-type'] |
| 35 |
type: str |
| 36 |
description: Allowed authentication protocols/methods. |
| 37 |
choices: ['auto', 'ascii', 'pap', 'chap', 'mschap'] |
| 38 |
authorization: |
| 39 |
type: str |
| 40 |
description: Enable/disable TACACS+ authorization. |
| 41 |
choices: ['disable', 'enable'] |
| 42 |
dynamic_mapping: |
| 43 |
type: list |
| 44 |
elements: dict |
| 45 |
description: Dynamic mapping. |
| 46 |
suboptions: |
| 47 |
_scope: |
| 48 |
type: list |
| 49 |
elements: dict |
| 50 |
description: Scope. |
| 51 |
suboptions: |
| 52 |
name: |
| 53 |
type: str |
| 54 |
description: Name. |
| 55 |
vdom: |
| 56 |
type: str |
| 57 |
description: Vdom. |
| 58 |
authen_type: |
| 59 |
aliases: ['authen-type'] |
| 60 |
type: str |
| 61 |
description: Authen type. |
| 62 |
choices: ['auto', 'ascii', 'pap', 'chap', 'mschap'] |
| 63 |
authorization: |
| 64 |
type: str |
| 65 |
description: Authorization. |
| 66 |
choices: ['disable', 'enable'] |
| 67 |
key: |
| 68 |
type: raw |
| 69 |
description: (list) Key. |
| 70 |
port: |
| 71 |
type: int |
| 72 |
description: Port. |
| 73 |
secondary_key: |
| 74 |
aliases: ['secondary-key'] |
| 75 |
type: raw |
| 76 |
description: (list) Secondary key. |
| 77 |
secondary_server: |
| 78 |
aliases: ['secondary-server'] |
| 79 |
type: str |
| 80 |
description: Secondary server. |
| 81 |
server: |
| 82 |
type: str |
| 83 |
description: Server. |
| 84 |
source_ip: |
| 85 |
aliases: ['source-ip'] |
| 86 |
type: str |
| 87 |
description: Source ip. |
| 88 |
tertiary_key: |
| 89 |
aliases: ['tertiary-key'] |
| 90 |
type: raw |
| 91 |
description: (list) Tertiary key. |
| 92 |
tertiary_server: |
| 93 |
aliases: ['tertiary-server'] |
| 94 |
type: str |
| 95 |
description: Tertiary server. |
| 96 |
interface: |
| 97 |
type: str |
| 98 |
description: Interface. |
| 99 |
interface_select_method: |
| 100 |
aliases: ['interface-select-method'] |
| 101 |
type: str |
| 102 |
description: Interface select method. |
| 103 |
choices: ['auto', 'sdwan', 'specify'] |
| 104 |
status_ttl: |
| 105 |
aliases: ['status-ttl'] |
| 106 |
type: int |
| 107 |
description: Time for which server reachability is cached so that when a server is unreachable, it will not be retried for at l... |
| 108 |
vrf_select: |
| 109 |
aliases: ['vrf-select'] |
| 110 |
type: int |
| 111 |
description: VRF ID used for connection to server. |
| 112 |
key: |
| 113 |
type: raw |
| 114 |
description: (list) Key to access the primary server. |
| 115 |
name: |
| 116 |
type: str |
| 117 |
description: TACACS+ server entry name. |
| 118 |
required: true |
| 119 |
port: |
| 120 |
type: int |
| 121 |
description: Port number of the TACACS+ server. |
| 122 |
secondary_key: |
| 123 |
aliases: ['secondary-key'] |
| 124 |
type: raw |
| 125 |
description: (list) Key to access the secondary server. |
| 126 |
secondary_server: |
| 127 |
aliases: ['secondary-server'] |
| 128 |
type: str |
| 129 |
description: Secondary TACACS+ server CN domain name or IP address. |
| 130 |
server: |
| 131 |
type: str |
| 132 |
description: Primary TACACS+ server CN domain name or IP address. |
| 133 |
source_ip: |
| 134 |
aliases: ['source-ip'] |
| 135 |
type: str |
| 136 |
description: Source IP for communications to TACACS+ server. |
| 137 |
tertiary_key: |
| 138 |
aliases: ['tertiary-key'] |
| 139 |
type: raw |
| 140 |
description: (list) Key to access the tertiary server. |
| 141 |
tertiary_server: |
| 142 |
aliases: ['tertiary-server'] |
| 143 |
type: str |
| 144 |
description: Tertiary TACACS+ server CN domain name or IP address. |
| 145 |
interface: |
| 146 |
type: str |
| 147 |
description: Specify outgoing interface to reach server. |
| 148 |
interface_select_method: |
| 149 |
aliases: ['interface-select-method'] |
| 150 |
type: str |
| 151 |
description: Specify how to select outgoing interface to reach server. |
| 152 |
choices: ['auto', 'sdwan', 'specify'] |
| 153 |
status_ttl: |
| 154 |
aliases: ['status-ttl'] |
| 155 |
type: int |
| 156 |
description: Time for which server reachability is cached so that when a server is unreachable, it will not be retried for at least thi... |
| 157 |
vrf_select: |
| 158 |
aliases: ['vrf-select'] |
| 159 |
type: int |
| 160 |
description: VRF ID used for connection to server. |
| 161 |
''' |
| 162 |
|
| 163 |
EXAMPLES = ''' |
| 164 |
- name: Example playbook (generated based on argument schema) |
| 165 |
hosts: fortimanagers |
| 166 |
connection: httpapi |
| 167 |
gather_facts: false |
| 168 |
tasks: |
| 169 |
- name: Configure TACACS+ server entries. |
| 170 |
fortinet.fortimanager.fmgr_user_tacacs: |
| 171 |
# workspace_locking_adom: <global or your adom name> |
| 172 |
adom: <your own value> |
| 173 |
state: present # <value in [present, absent]> |
| 174 |
user_tacacs: |
| 175 |
name: "your value" # Required variable, string |
| 176 |
# authen_type: <value in [auto, ascii, pap, ...]> |
| 177 |
# authorization: <value in [disable, enable]> |
| 178 |
# dynamic_mapping: |
| 179 |
# - _scope: |
| 180 |
# - name: <string> |
| 181 |
# vdom: <string> |
| 182 |
# authen_type: <value in [auto, ascii, pap, ...]> |
| 183 |
# authorization: <value in [disable, enable]> |
| 184 |
# key: <list or string> |
| 185 |
# port: <integer> |
| 186 |
# secondary_key: <list or string> |
| 187 |
# secondary_server: <string> |
| 188 |
# server: <string> |
| 189 |
# source_ip: <string> |
| 190 |
# tertiary_key: <list or string> |
| 191 |
# tertiary_server: <string> |
| 192 |
# interface: <string> |
| 193 |
# interface_select_method: <value in [auto, sdwan, specify]> |
| 194 |
# status_ttl: <integer> |
| 195 |
# vrf_select: <integer> |
| 196 |
# key: <list or string> |
| 197 |
# port: <integer> |
| 198 |
# secondary_key: <list or string> |
| 199 |
# secondary_server: <string> |
| 200 |
# server: <string> |
| 201 |
# source_ip: <string> |
| 202 |
# tertiary_key: <list or string> |
| 203 |
# tertiary_server: <string> |
| 204 |
# interface: <string> |
| 205 |
# interface_select_method: <value in [auto, sdwan, specify]> |
| 206 |
# status_ttl: <integer> |
| 207 |
# vrf_select: <integer> |
| 208 |
''' |
| 209 |
|
| 210 |
RETURN = ''' |
| 211 |
meta: |
| 212 |
description: The result of the request. |
| 213 |
type: dict |
| 214 |
returned: always |
| 215 |
contains: |
| 216 |
request_url: |
| 217 |
description: The full url requested. |
| 218 |
returned: always |
| 219 |
type: str |
| 220 |
sample: /sys/login/user |
| 221 |
response_code: |
| 222 |
description: The status of api request. |
| 223 |
returned: always |
| 224 |
type: int |
| 225 |
sample: 0 |
| 226 |
response_data: |
| 227 |
description: The api response. |
| 228 |
type: list |
| 229 |
returned: always |
| 230 |
response_message: |
| 231 |
description: The descriptive message of the api response. |
| 232 |
type: str |
| 233 |
returned: always |
| 234 |
sample: OK. |
| 235 |
system_information: |
| 236 |
description: The information of the target system. |
| 237 |
type: dict |
| 238 |
returned: always |
| 239 |
rc: |
| 240 |
description: The status the request. |
| 241 |
type: int |
| 242 |
returned: always |
| 243 |
sample: 0 |
| 244 |
version_check_warning: |
| 245 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 246 |
type: list |
| 247 |
returned: complex |
| 248 |
''' |
| 249 |
from ansible.module_utils.basic import AnsibleModule |
| 250 |
from ansible.module_utils.connection import Connection |
| 251 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 252 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 253 |
|
| 254 |
|
| 255 |
def main(): |
| 256 |
urls_list = [ |
| 257 |
'/pm/config/adom/{adom}/obj/user/tacacs+', |
| 258 |
'/pm/config/global/obj/user/tacacs+' |
| 259 |
] |
| 260 |
module_arg_spec = { |
| 261 |
'adom': {'required': True, 'type': 'str'}, |
| 262 |
'revision_note': {'type': 'str'}, |
| 263 |
'user_tacacs': { |
| 264 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 265 |
'options': { |
| 266 |
'authen-type': {'choices': ['auto', 'ascii', 'pap', 'chap', 'mschap'], 'type': 'str'}, |
| 267 |
'authorization': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 268 |
'dynamic_mapping': { |
| 269 |
'type': 'list', |
| 270 |
'options': { |
| 271 |
'_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'}, |
| 272 |
'authen-type': {'choices': ['auto', 'ascii', 'pap', 'chap', 'mschap'], 'type': 'str'}, |
| 273 |
'authorization': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 274 |
'key': {'no_log': True, 'type': 'raw'}, |
| 275 |
'port': {'type': 'int'}, |
| 276 |
'secondary-key': {'no_log': True, 'type': 'raw'}, |
| 277 |
'secondary-server': {'type': 'str'}, |
| 278 |
'server': {'type': 'str'}, |
| 279 |
'source-ip': {'type': 'str'}, |
| 280 |
'tertiary-key': {'no_log': True, 'type': 'raw'}, |
| 281 |
'tertiary-server': {'type': 'str'}, |
| 282 |
'interface': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'}, |
| 283 |
'interface-select-method': { |
| 284 |
'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], |
| 285 |
'choices': ['auto', 'sdwan', 'specify'], |
| 286 |
'type': 'str' |
| 287 |
}, |
| 288 |
'status-ttl': {'v_range': [['7.4.3', '']], 'type': 'int'}, |
| 289 |
'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'} |
| 290 |
}, |
| 291 |
'elements': 'dict' |
| 292 |
}, |
| 293 |
'key': {'no_log': True, 'type': 'raw'}, |
| 294 |
'name': {'required': True, 'type': 'str'}, |
| 295 |
'port': {'type': 'int'}, |
| 296 |
'secondary-key': {'no_log': True, 'type': 'raw'}, |
| 297 |
'secondary-server': {'type': 'str'}, |
| 298 |
'server': {'type': 'str'}, |
| 299 |
'source-ip': {'type': 'str'}, |
| 300 |
'tertiary-key': {'no_log': True, 'type': 'raw'}, |
| 301 |
'tertiary-server': {'type': 'str'}, |
| 302 |
'interface': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'}, |
| 303 |
'interface-select-method': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'}, |
| 304 |
'status-ttl': {'v_range': [['7.4.3', '']], 'type': 'int'}, |
| 305 |
'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'} |
| 306 |
} |
| 307 |
} |
| 308 |
} |
| 309 |
|
| 310 |
module_option_spec = get_module_arg_spec('full crud') |
| 311 |
module_arg_spec.update(module_option_spec) |
| 312 |
check_galaxy_version(module_arg_spec) |
| 313 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_tacacs'), |
| 314 |
supports_check_mode=True) |
| 315 |
if not module._socket_path: |
| 316 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 317 |
connection = Connection(module._socket_path) |
| 318 |
fmgr = NAPIManager('full crud', module_arg_spec, urls_list, |
| 319 |
'name', 'data', module, connection) |
| 320 |
fmgr.process_crud() |
| 321 |
module.exit_json(meta=module.params) |
| 322 |
|
| 323 |
|
| 324 |
if __name__ == '__main__': |
| 325 |
main() |