Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_tacacs_dynamicmapping.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
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_dynamicmapping
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 tacacs+:
29 description: Deprecated, please use "tacacs_"
30 type: str
31 tacacs_:
32 description: The parameter (tacacs+) in requested url.
33 type: str
34 user_tacacs_dynamicmapping:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 _scope:
40 type: list
41 elements: dict
42 description: Scope.
43 suboptions:
44 name:
45 type: str
46 description: Name.
47 vdom:
48 type: str
49 description: Vdom.
50 authen_type:
51 aliases: ['authen-type']
52 type: str
53 description: Authen type.
54 choices: ['auto', 'ascii', 'pap', 'chap', 'mschap']
55 authorization:
56 type: str
57 description: Authorization.
58 choices: ['disable', 'enable']
59 key:
60 type: raw
61 description: (list) Key.
62 port:
63 type: int
64 description: Port.
65 secondary_key:
66 aliases: ['secondary-key']
67 type: raw
68 description: (list) Secondary key.
69 secondary_server:
70 aliases: ['secondary-server']
71 type: str
72 description: Secondary server.
73 server:
74 type: str
75 description: Server.
76 source_ip:
77 aliases: ['source-ip']
78 type: str
79 description: Source ip.
80 tertiary_key:
81 aliases: ['tertiary-key']
82 type: raw
83 description: (list) Tertiary key.
84 tertiary_server:
85 aliases: ['tertiary-server']
86 type: str
87 description: Tertiary server.
88 interface:
89 type: str
90 description: Interface.
91 interface_select_method:
92 aliases: ['interface-select-method']
93 type: str
94 description: Interface select method.
95 choices: ['auto', 'sdwan', 'specify']
96 status_ttl:
97 aliases: ['status-ttl']
98 type: int
99 description: Time for which server reachability is cached so that when a server is unreachable, it will not be retried for at least thi...
100 vrf_select:
101 aliases: ['vrf-select']
102 type: int
103 description: VRF ID used for connection to server.
104 '''
105
106 EXAMPLES = '''
107 - name: Example playbook (generated based on argument schema)
108 hosts: fortimanagers
109 connection: httpapi
110 gather_facts: false
111 tasks:
112 - name: Configure TACACS+ server entries.
113 fortinet.fortimanager.fmgr_user_tacacs_dynamicmapping:
114 # workspace_locking_adom: <global or your adom name>
115 adom: <your own value>
116 tacacs_: <your own value>
117 state: present # <value in [present, absent]>
118 user_tacacs_dynamicmapping:
119 _scope: # Required variable, list of device
120 - name: <string>
121 vdom: <string>
122 # authen_type: <value in [auto, ascii, pap, ...]>
123 # authorization: <value in [disable, enable]>
124 # key: <list or string>
125 # port: <integer>
126 # secondary_key: <list or string>
127 # secondary_server: <string>
128 # server: <string>
129 # source_ip: <string>
130 # tertiary_key: <list or string>
131 # tertiary_server: <string>
132 # interface: <string>
133 # interface_select_method: <value in [auto, sdwan, specify]>
134 # status_ttl: <integer>
135 # vrf_select: <integer>
136 '''
137
138 RETURN = '''
139 meta:
140 description: The result of the request.
141 type: dict
142 returned: always
143 contains:
144 request_url:
145 description: The full url requested.
146 returned: always
147 type: str
148 sample: /sys/login/user
149 response_code:
150 description: The status of api request.
151 returned: always
152 type: int
153 sample: 0
154 response_data:
155 description: The api response.
156 type: list
157 returned: always
158 response_message:
159 description: The descriptive message of the api response.
160 type: str
161 returned: always
162 sample: OK.
163 system_information:
164 description: The information of the target system.
165 type: dict
166 returned: always
167 rc:
168 description: The status the request.
169 type: int
170 returned: always
171 sample: 0
172 version_check_warning:
173 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
174 type: list
175 returned: complex
176 '''
177 from ansible.module_utils.basic import AnsibleModule
178 from ansible.module_utils.connection import Connection
179 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
180 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
181
182
183 def main():
184 urls_list = [
185 '/pm/config/adom/{adom}/obj/user/tacacs+/{tacacs+}/dynamic_mapping',
186 '/pm/config/global/obj/user/tacacs+/{tacacs+}/dynamic_mapping'
187 ]
188 module_arg_spec = {
189 'adom': {'required': True, 'type': 'str'},
190 'tacacs+': {'type': 'str', 'api_name': 'tacacs_'},
191 'tacacs_': {'type': 'str'},
192 'revision_note': {'type': 'str'},
193 'user_tacacs_dynamicmapping': {
194 'type': 'dict', 'v_range': [['6.0.0', '']],
195 'options': {
196 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
197 'authen-type': {'choices': ['auto', 'ascii', 'pap', 'chap', 'mschap'], 'type': 'str'},
198 'authorization': {'choices': ['disable', 'enable'], 'type': 'str'},
199 'key': {'no_log': True, 'type': 'raw'},
200 'port': {'type': 'int'},
201 'secondary-key': {'no_log': True, 'type': 'raw'},
202 'secondary-server': {'type': 'str'},
203 'server': {'type': 'str'},
204 'source-ip': {'type': 'str'},
205 'tertiary-key': {'no_log': True, 'type': 'raw'},
206 'tertiary-server': {'type': 'str'},
207 'interface': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'},
208 'interface-select-method': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'},
209 'status-ttl': {'v_range': [['7.4.3', '']], 'type': 'int'},
210 'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'}
211 }
212 }
213 }
214
215 module_option_spec = get_module_arg_spec('full crud')
216 module_arg_spec.update(module_option_spec)
217 check_galaxy_version(module_arg_spec)
218 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_tacacs_dynamicmapping'),
219 supports_check_mode=True)
220 if not module._socket_path:
221 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
222 connection = Connection(module._socket_path)
223 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
224 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
225 fmgr.process_crud()
226 module.exit_json(meta=module.params)
227
228
229 if __name__ == '__main__':
230 main()