Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_admin_tacacs.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_system_admin_tacacs
15 short_description: TACACS+ server entry configuration.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_admin_tacacs:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 authen_type:
27 aliases: ['authen-type']
28 type: str
29 description:
30 - Authentication type.
31 - auto - Use PAP, MSCHAP, and CHAP
32 - ascii - ASCII.
33 - pap - PAP.
34 - chap - CHAP.
35 - mschap - MSCHAP.
36 choices: ['auto', 'ascii', 'pap', 'chap', 'mschap']
37 authorization:
38 type: str
39 description:
40 - Enable/disable TACACS+ authorization.
41 - disable - Disable TACACS+ authorization.
42 - enable - Enable TACACS+ authorization
43 choices: ['disable', 'enable']
44 key:
45 type: raw
46 description: (list) No description
47 name:
48 type: str
49 description: TACACS+ server entry name.
50 required: true
51 port:
52 type: int
53 description: Port number of TACACS+ server.
54 secondary_key:
55 aliases: ['secondary-key']
56 type: raw
57 description: (list) No description
58 secondary_server:
59 aliases: ['secondary-server']
60 type: str
61 description: No description
62 server:
63 type: str
64 description: No description
65 tertiary_key:
66 aliases: ['tertiary-key']
67 type: raw
68 description: (list) No description
69 tertiary_server:
70 aliases: ['tertiary-server']
71 type: str
72 description: No description
73 src_ip:
74 aliases: ['src-ip']
75 type: str
76 description: Src ip.
77 '''
78
79 EXAMPLES = '''
80 - name: Example playbook
81 hosts: fortimanagers
82 gather_facts: false
83 connection: httpapi
84 vars:
85 ansible_httpapi_use_ssl: true
86 ansible_httpapi_validate_certs: false
87 ansible_httpapi_port: 443
88 tasks:
89 - name: TACACS+ server entry configuration.
90 fortinet.fortimanager.fmgr_system_admin_tacacs:
91 bypass_validation: false
92 state: present
93 system_admin_tacacs:
94 authen_type: auto # <value in [auto, ascii, pap, ...]>
95 authorization: disable
96 key: fortinet
97 name: ansible-test-tacacs
98 port: 1
99 server: ansible
100
101 - name: Gathering fortimanager facts
102 hosts: fortimanagers
103 gather_facts: false
104 connection: httpapi
105 vars:
106 ansible_httpapi_use_ssl: true
107 ansible_httpapi_validate_certs: false
108 ansible_httpapi_port: 443
109 tasks:
110 - name: Retrieve all the TACACS+ servers
111 fortinet.fortimanager.fmgr_fact:
112 facts:
113 selector: "system_admin_tacacs"
114 params:
115 tacacs: "your_value"
116 '''
117
118 RETURN = '''
119 meta:
120 description: The result of the request.
121 type: dict
122 returned: always
123 contains:
124 request_url:
125 description: The full url requested.
126 returned: always
127 type: str
128 sample: /sys/login/user
129 response_code:
130 description: The status of api request.
131 returned: always
132 type: int
133 sample: 0
134 response_data:
135 description: The api response.
136 type: list
137 returned: always
138 response_message:
139 description: The descriptive message of the api response.
140 type: str
141 returned: always
142 sample: OK.
143 system_information:
144 description: The information of the target system.
145 type: dict
146 returned: always
147 rc:
148 description: The status the request.
149 type: int
150 returned: always
151 sample: 0
152 version_check_warning:
153 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
154 type: list
155 returned: complex
156 '''
157 from ansible.module_utils.basic import AnsibleModule
158 from ansible.module_utils.connection import Connection
159 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
160 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
161
162
163 def main():
164 urls_list = [
165 '/cli/global/system/admin/tacacs'
166 ]
167 module_arg_spec = {
168 'system_admin_tacacs': {
169 'type': 'dict', 'v_range': [['6.0.0', '']],
170 'options': {
171 'authen-type': {'choices': ['auto', 'ascii', 'pap', 'chap', 'mschap'], 'type': 'str'},
172 'authorization': {'choices': ['disable', 'enable'], 'type': 'str'},
173 'key': {'no_log': True, 'type': 'raw'},
174 'name': {'required': True, 'type': 'str'},
175 'port': {'type': 'int'},
176 'secondary-key': {'no_log': True, 'type': 'raw'},
177 'secondary-server': {'type': 'str'},
178 'server': {'type': 'str'},
179 'tertiary-key': {'no_log': True, 'type': 'raw'},
180 'tertiary-server': {'type': 'str'},
181 'src-ip': {'v_range': [['7.6.5', '']], 'type': 'str'}
182 }
183 }
184 }
185
186 module_option_spec = get_module_arg_spec('full crud')
187 module_arg_spec.update(module_option_spec)
188 check_galaxy_version(module_arg_spec)
189 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_admin_tacacs'),
190 supports_check_mode=True)
191 if not module._socket_path:
192 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
193 connection = Connection(module._socket_path)
194 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
195 'name', 'data', module, connection)
196 fmgr.process_crud()
197 module.exit_json(meta=module.params)
198
199
200 if __name__ == '__main__':
201 main()