Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_radius_accountingserver.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_radius_accountingserver
15 short_description: Additional accounting servers.
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 radius:
29 description: The parameter (radius) in requested url.
30 type: str
31 required: true
32 user_radius_accountingserver:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 id:
38 type: int
39 description: ID
40 required: true
41 port:
42 type: int
43 description: RADIUS accounting port number.
44 secret:
45 type: raw
46 description: (list) Secret key.
47 server:
48 type: str
49 description: No description
50 source_ip:
51 aliases: ['source-ip']
52 type: str
53 description: Source IP address for communications to the RADIUS server.
54 status:
55 type: str
56 description: Status.
57 choices: ['disable', 'enable']
58 interface:
59 type: str
60 description: Specify outgoing interface to reach server.
61 interface_select_method:
62 aliases: ['interface-select-method']
63 type: str
64 description: Specify how to select outgoing interface to reach server.
65 choices: ['auto', 'sdwan', 'specify']
66 vrf_select:
67 aliases: ['vrf-select']
68 type: int
69 description: VRF ID used for connection to server.
70 '''
71
72 EXAMPLES = '''
73 - name: Example playbook
74 hosts: fortimanagers
75 gather_facts: false
76 connection: httpapi
77 vars:
78 ansible_httpapi_use_ssl: true
79 ansible_httpapi_validate_certs: false
80 ansible_httpapi_port: 443
81 tasks:
82 - name: Additional accounting servers.
83 fortinet.fortimanager.fmgr_user_radius_accountingserver:
84 bypass_validation: false
85 adom: ansible
86 radius: ansible-test-radius # name
87 state: present
88 user_radius_accountingserver:
89 id: 1
90 port: 8000
91 server: ansible
92 status: disable
93
94 - name: Gathering fortimanager facts
95 hosts: fortimanagers
96 gather_facts: false
97 connection: httpapi
98 vars:
99 ansible_httpapi_use_ssl: true
100 ansible_httpapi_validate_certs: false
101 ansible_httpapi_port: 443
102 tasks:
103 - name: Retrieve all the additional accounting servers
104 fortinet.fortimanager.fmgr_fact:
105 facts:
106 selector: "user_radius_accountingserver"
107 params:
108 adom: "ansible"
109 radius: "ansible-test-radius" # name
110 accounting_server: "your_value"
111 '''
112
113 RETURN = '''
114 meta:
115 description: The result of the request.
116 type: dict
117 returned: always
118 contains:
119 request_url:
120 description: The full url requested.
121 returned: always
122 type: str
123 sample: /sys/login/user
124 response_code:
125 description: The status of api request.
126 returned: always
127 type: int
128 sample: 0
129 response_data:
130 description: The api response.
131 type: list
132 returned: always
133 response_message:
134 description: The descriptive message of the api response.
135 type: str
136 returned: always
137 sample: OK.
138 system_information:
139 description: The information of the target system.
140 type: dict
141 returned: always
142 rc:
143 description: The status the request.
144 type: int
145 returned: always
146 sample: 0
147 version_check_warning:
148 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
149 type: list
150 returned: complex
151 '''
152 from ansible.module_utils.basic import AnsibleModule
153 from ansible.module_utils.connection import Connection
154 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
155 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
156
157
158 def main():
159 urls_list = [
160 '/pm/config/adom/{adom}/obj/user/radius/{radius}/accounting-server',
161 '/pm/config/global/obj/user/radius/{radius}/accounting-server'
162 ]
163 module_arg_spec = {
164 'adom': {'required': True, 'type': 'str'},
165 'radius': {'required': True, 'type': 'str'},
166 'revision_note': {'type': 'str'},
167 'user_radius_accountingserver': {
168 'type': 'dict', 'v_range': [['6.0.0', '']],
169 'options': {
170 'id': {'required': True, 'type': 'int'},
171 'port': {'type': 'int'},
172 'secret': {'no_log': True, 'type': 'raw'},
173 'server': {'type': 'str'},
174 'source-ip': {'type': 'str'},
175 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
176 'interface': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'},
177 'interface-select-method': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'},
178 'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'}
179 }
180 }
181 }
182
183 module_option_spec = get_module_arg_spec('full crud')
184 module_arg_spec.update(module_option_spec)
185 check_galaxy_version(module_arg_spec)
186 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_radius_accountingserver'),
187 supports_check_mode=True)
188 if not module._socket_path:
189 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
190 connection = Connection(module._socket_path)
191 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
192 'id', 'data', module, connection)
193 fmgr.process_crud()
194 module.exit_json(meta=module.params)
195
196
197 if __name__ == '__main__':
198 main()