Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_managedswitch_remotelog.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_switchcontroller_managedswitch_remotelog
15 short_description: Configure logging by FortiSwitch device to a remote syslog server.
16 version_added: "2.1.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 managed-switch:
29 description: Deprecated, please use "managed_switch"
30 type: str
31 managed_switch:
32 description: The parameter (managed-switch) in requested url.
33 type: str
34 switchcontroller_managedswitch_remotelog:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 csv:
40 type: str
41 description: Enable/disable comma-separated value
42 choices: ['disable', 'enable']
43 facility:
44 type: str
45 description: Facility to log to remote syslog server.
46 choices: ['kernel', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news',
47 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'audit', 'alert', 'clock',
48 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6',
49 'local7']
50 name:
51 type: str
52 description: Remote log name.
53 required: true
54 port:
55 type: int
56 description: Remote syslog server listening port.
57 server:
58 type: str
59 description: IPv4 address of the remote syslog server.
60 severity:
61 type: str
62 description: Severity of logs to be transferred to remote log server.
63 choices: ['emergency', 'alert', 'critical', 'error', 'warning', 'notification',
64 'information', 'debug']
65 status:
66 type: str
67 description: Enable/disable logging by FortiSwitch device to a remote syslog server.
68 choices: ['disable', 'enable']
69 '''
70
71 EXAMPLES = '''
72 - name: Example playbook (generated based on argument schema)
73 hosts: fortimanagers
74 connection: httpapi
75 gather_facts: false
76 tasks:
77 - name: Configure logging by FortiSwitch device to a remote syslog server.
78 fortinet.fortimanager.fmgr_switchcontroller_managedswitch_remotelog:
79 # workspace_locking_adom: <global or your adom name>
80 adom: <your own value>
81 managed_switch: <your own value>
82 state: present # <value in [present, absent]>
83 switchcontroller_managedswitch_remotelog:
84 name: "your value" # Required variable, string
85 # csv: <value in [disable, enable]>
86 # facility: <value in [kernel, user, mail, ...]>
87 # port: <integer>
88 # server: <string>
89 # severity: <value in [emergency, alert, critical, ...]>
90 # status: <value in [disable, enable]>
91 '''
92
93 RETURN = '''
94 meta:
95 description: The result of the request.
96 type: dict
97 returned: always
98 contains:
99 request_url:
100 description: The full url requested.
101 returned: always
102 type: str
103 sample: /sys/login/user
104 response_code:
105 description: The status of api request.
106 returned: always
107 type: int
108 sample: 0
109 response_data:
110 description: The api response.
111 type: list
112 returned: always
113 response_message:
114 description: The descriptive message of the api response.
115 type: str
116 returned: always
117 sample: OK.
118 system_information:
119 description: The information of the target system.
120 type: dict
121 returned: always
122 rc:
123 description: The status the request.
124 type: int
125 returned: always
126 sample: 0
127 version_check_warning:
128 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
129 type: list
130 returned: complex
131 '''
132 from ansible.module_utils.basic import AnsibleModule
133 from ansible.module_utils.connection import Connection
134 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
135 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
136
137
138 def main():
139 urls_list = [
140 '/pm/config/adom/{adom}/obj/switch-controller/managed-switch/{managed-switch}/remote-log',
141 '/pm/config/global/obj/switch-controller/managed-switch/{managed-switch}/remote-log'
142 ]
143 module_arg_spec = {
144 'adom': {'required': True, 'type': 'str'},
145 'managed-switch': {'type': 'str', 'api_name': 'managed_switch'},
146 'managed_switch': {'type': 'str'},
147 'revision_note': {'type': 'str'},
148 'switchcontroller_managedswitch_remotelog': {
149 'type': 'dict', 'v_range': [['6.2.1', '6.2.3']],
150 'options': {
151 'csv': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'},
152 'facility': {
153 'v_range': [['6.2.1', '6.2.3']],
154 'choices': [
155 'kernel', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'audit', 'alert',
156 'clock', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7'
157 ],
158 'type': 'str'
159 },
160 'name': {'v_range': [['6.2.1', '6.2.3']], 'required': True, 'type': 'str'},
161 'port': {'v_range': [['6.2.1', '6.2.3']], 'type': 'int'},
162 'server': {'v_range': [['6.2.1', '6.2.3']], 'type': 'str'},
163 'severity': {
164 'v_range': [['6.2.1', '6.2.3']],
165 'choices': ['emergency', 'alert', 'critical', 'error', 'warning', 'notification', 'information', 'debug'],
166 'type': 'str'
167 },
168 'status': {'v_range': [['6.2.1', '6.2.3']], 'choices': ['disable', 'enable'], 'type': 'str'}
169 }
170 }
171 }
172
173 module_option_spec = get_module_arg_spec('full crud')
174 module_arg_spec.update(module_option_spec)
175 check_galaxy_version(module_arg_spec)
176 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_managedswitch_remotelog'),
177 supports_check_mode=True)
178 if not module._socket_path:
179 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
180 connection = Connection(module._socket_path)
181 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
182 'name', 'data', module, connection)
183 fmgr.process_crud()
184 module.exit_json(meta=module.params)
185
186
187 if __name__ == '__main__':
188 main()