Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_admin_radius.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_radius
15 short_description: Configure radius.
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_radius:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 auth_type:
27 aliases: ['auth-type']
28 type: str
29 description:
30 - Authentication protocol.
31 - any - Use any supported authentication protocol.
32 - pap - PAP.
33 - chap - CHAP.
34 - mschap2 - MSCHAPv2.
35 choices: ['any', 'pap', 'chap', 'mschap2']
36 name:
37 type: str
38 description: Name.
39 required: true
40 nas_ip:
41 aliases: ['nas-ip']
42 type: str
43 description: NAS IP address and called station ID.
44 port:
45 type: int
46 description: Server port.
47 secondary_secret:
48 aliases: ['secondary-secret']
49 type: raw
50 description: (list) Secondary server secret.
51 secondary_server:
52 aliases: ['secondary-server']
53 type: str
54 description: Secondary server name/IP.
55 secret:
56 type: raw
57 description: (list) Server secret.
58 server:
59 type: str
60 description: Server name/IP.
61 ca_cert:
62 aliases: ['ca-cert']
63 type: str
64 description: Ca cert.
65 client_cert:
66 aliases: ['client-cert']
67 type: str
68 description: Client cert.
69 message_authenticator:
70 aliases: ['message-authenticator']
71 type: str
72 description: Message authenticator.
73 choices: ['optional', 'require']
74 protocol:
75 type: str
76 description: Protocol.
77 choices: ['udp', 'tls']
78 '''
79
80 EXAMPLES = '''
81 - name: Example playbook
82 hosts: fortimanagers
83 gather_facts: false
84 connection: httpapi
85 vars:
86 ansible_httpapi_use_ssl: true
87 ansible_httpapi_validate_certs: false
88 ansible_httpapi_port: 443
89 tasks:
90 - name: Configure radius.
91 fortinet.fortimanager.fmgr_system_admin_radius:
92 bypass_validation: false
93 state: present
94 system_admin_radius:
95 auth_type: pap # <value in [any, pap, chap, ...]>
96 name: ansible-test-radius
97 port: 1812
98 server: "ALL"
99
100 - name: Gathering fortimanager facts
101 hosts: fortimanagers
102 gather_facts: false
103 connection: httpapi
104 vars:
105 ansible_httpapi_use_ssl: true
106 ansible_httpapi_validate_certs: false
107 ansible_httpapi_port: 443
108 tasks:
109 - name: Retrieve all the radius
110 fortinet.fortimanager.fmgr_fact:
111 facts:
112 selector: "system_admin_radius"
113 params:
114 radius: "your_value"
115 '''
116
117 RETURN = '''
118 meta:
119 description: The result of the request.
120 type: dict
121 returned: always
122 contains:
123 request_url:
124 description: The full url requested.
125 returned: always
126 type: str
127 sample: /sys/login/user
128 response_code:
129 description: The status of api request.
130 returned: always
131 type: int
132 sample: 0
133 response_data:
134 description: The api response.
135 type: list
136 returned: always
137 response_message:
138 description: The descriptive message of the api response.
139 type: str
140 returned: always
141 sample: OK.
142 system_information:
143 description: The information of the target system.
144 type: dict
145 returned: always
146 rc:
147 description: The status the request.
148 type: int
149 returned: always
150 sample: 0
151 version_check_warning:
152 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
153 type: list
154 returned: complex
155 '''
156 from ansible.module_utils.basic import AnsibleModule
157 from ansible.module_utils.connection import Connection
158 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
159 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
160
161
162 def main():
163 urls_list = [
164 '/cli/global/system/admin/radius'
165 ]
166 module_arg_spec = {
167 'system_admin_radius': {
168 'type': 'dict', 'v_range': [['6.0.0', '']],
169 'options': {
170 'auth-type': {'choices': ['any', 'pap', 'chap', 'mschap2'], 'type': 'str'},
171 'name': {'required': True, 'type': 'str'},
172 'nas-ip': {'type': 'str'},
173 'port': {'type': 'int'},
174 'secondary-secret': {'no_log': True, 'type': 'raw'},
175 'secondary-server': {'type': 'str'},
176 'secret': {'no_log': True, 'type': 'raw'},
177 'server': {'type': 'str'},
178 'ca-cert': {'v_range': [['7.2.10', '7.2.12'], ['7.4.6', '7.4.10'], ['7.6.2', '']], 'type': 'str'},
179 'client-cert': {'v_range': [['7.2.10', '7.2.12'], ['7.4.6', '7.4.10'], ['7.6.2', '']], 'type': 'str'},
180 'message-authenticator': {
181 'v_range': [['7.2.10', '7.2.12'], ['7.4.6', '7.4.10'], ['7.6.2', '']],
182 'choices': ['optional', 'require'],
183 'type': 'str'
184 },
185 'protocol': {'v_range': [['7.2.10', '7.2.12'], ['7.4.6', '7.4.10'], ['7.6.2', '']], 'choices': ['udp', 'tls'], 'type': 'str'}
186 }
187 }
188 }
189
190 module_option_spec = get_module_arg_spec('full crud')
191 module_arg_spec.update(module_option_spec)
192 check_galaxy_version(module_arg_spec)
193 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_admin_radius'),
194 supports_check_mode=True)
195 if not module._socket_path:
196 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
197 connection = Connection(module._socket_path)
198 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
199 'name', 'data', module, connection)
200 fmgr.process_crud()
201 module.exit_json(meta=module.params)
202
203
204 if __name__ == '__main__':
205 main()