Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_syslog.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_syslog
15 short_description: Syslog servers.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_syslog:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 ip:
27 type: str
28 description: Syslog server IP address or hostname.
29 name:
30 type: str
31 description: Syslog server name.
32 required: true
33 port:
34 type: int
35 description: Syslog server port.
36 local_cert:
37 aliases: ['local-cert']
38 type: str
39 description: Select local certificate used for secure connection.
40 peer_cert_cn:
41 aliases: ['peer-cert-cn']
42 type: str
43 description: Certificate common name of syslog server.
44 reliable:
45 type: str
46 description:
47 - Enable/disable reliable connection with syslog server.
48 - disable - Disable reliable connection with syslog server.
49 - enable - Enable reliable connection with syslog server.
50 choices: ['disable', 'enable']
51 secure_connection:
52 aliases: ['secure-connection']
53 type: str
54 description:
55 - Enable/disable connection secured by TLS/SSL.
56 - disable - Disable SSL connection.
57 - enable - Enable SSL connection.
58 choices: ['disable', 'enable']
59 ssl_protocol:
60 aliases: ['ssl-protocol']
61 type: str
62 description:
63 - set the lowest SSL protocol version for connection to syslog server.
64 - follow-global-ssl-protocol - Follow system.
65 - sslv3 - set SSLv3 as the lowest version.
66 - tlsv1.
67 - tlsv1.
68 - tlsv1.
69 - tlsv1.
70 choices: ['follow-global-ssl-protocol', 'sslv3', 'tlsv1.0', 'tlsv1.1', 'tlsv1.2',
71 'tlsv1.3']
72 '''
73
74 EXAMPLES = '''
75 - name: Example playbook (generated based on argument schema)
76 hosts: fortimanagers
77 connection: httpapi
78 gather_facts: false
79 tasks:
80 - name: Syslog servers.
81 fortinet.fortimanager.fmgr_system_syslog:
82 # workspace_locking_adom: <global or your adom name>
83 state: present # <value in [present, absent]>
84 system_syslog:
85 name: "your value" # Required variable, string
86 # ip: <string>
87 # port: <integer>
88 # local_cert: <string>
89 # peer_cert_cn: <string>
90 # reliable: <value in [disable, enable]>
91 # secure_connection: <value in [disable, enable]>
92 # ssl_protocol: <value in [follow-global-ssl-protocol, sslv3, tlsv1.0, ...]>
93 '''
94
95 RETURN = '''
96 meta:
97 description: The result of the request.
98 type: dict
99 returned: always
100 contains:
101 request_url:
102 description: The full url requested.
103 returned: always
104 type: str
105 sample: /sys/login/user
106 response_code:
107 description: The status of api request.
108 returned: always
109 type: int
110 sample: 0
111 response_data:
112 description: The api response.
113 type: list
114 returned: always
115 response_message:
116 description: The descriptive message of the api response.
117 type: str
118 returned: always
119 sample: OK.
120 system_information:
121 description: The information of the target system.
122 type: dict
123 returned: always
124 rc:
125 description: The status the request.
126 type: int
127 returned: always
128 sample: 0
129 version_check_warning:
130 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
131 type: list
132 returned: complex
133 '''
134 from ansible.module_utils.basic import AnsibleModule
135 from ansible.module_utils.connection import Connection
136 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
137 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
138
139
140 def main():
141 urls_list = [
142 '/cli/global/system/syslog'
143 ]
144 module_arg_spec = {
145 'system_syslog': {
146 'type': 'dict', 'v_range': [['6.0.0', '']],
147 'options': {
148 'ip': {'type': 'str'},
149 'name': {'required': True, 'type': 'str'},
150 'port': {'type': 'int'},
151 'local-cert': {'v_range': [['6.4.8', '6.4.15'], ['7.0.4', '']], 'type': 'str'},
152 'peer-cert-cn': {'v_range': [['6.4.8', '6.4.15'], ['7.0.4', '']], 'type': 'str'},
153 'reliable': {'v_range': [['6.4.8', '6.4.15'], ['7.0.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
154 'secure-connection': {'v_range': [['6.4.8', '6.4.15'], ['7.0.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
155 'ssl-protocol': {
156 'v_range': [['7.4.4', '7.4.10'], ['7.6.2', '']],
157 'choices': ['follow-global-ssl-protocol', 'sslv3', 'tlsv1.0', 'tlsv1.1', 'tlsv1.2', 'tlsv1.3'],
158 'type': 'str'
159 }
160 }
161 }
162 }
163
164 module_option_spec = get_module_arg_spec('full crud')
165 module_arg_spec.update(module_option_spec)
166 check_galaxy_version(module_arg_spec)
167 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_syslog'),
168 supports_check_mode=True)
169 if not module._socket_path:
170 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
171 connection = Connection(module._socket_path)
172 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
173 'name', 'data', module, connection)
174 fmgr.process_crud()
175 module.exit_json(meta=module.params)
176
177
178 if __name__ == '__main__':
179 main()