Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_devprof_system_emailserver.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_devprof_system_emailserver
15 short_description: Configure the email server used by the FortiGate various things.
16 version_added: "1.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_crud
20 options:
21 adom:
22 description: The parameter (adom) in requested url.
23 type: str
24 required: true
25 devprof:
26 description: The parameter (devprof) in requested url.
27 type: str
28 required: true
29 devprof_system_emailserver:
30 description: The top level parameters set.
31 required: false
32 type: dict
33 suboptions:
34 authenticate:
35 type: str
36 description: Enable/disable authentication.
37 choices: ['disable', 'enable']
38 password:
39 type: raw
40 description: (list) SMTP server user password for authentication.
41 port:
42 type: int
43 description: SMTP server port.
44 reply_to:
45 aliases: ['reply-to']
46 type: str
47 description: Reply-To email address.
48 security:
49 type: str
50 description: Connection security used by the email server.
51 choices: ['none', 'starttls', 'smtps']
52 server:
53 type: str
54 description: SMTP server IP address or hostname.
55 source_ip:
56 aliases: ['source-ip']
57 type: str
58 description: SMTP server IPv4 source IP.
59 source_ip6:
60 aliases: ['source-ip6']
61 type: str
62 description: SMTP server IPv6 source IP.
63 ssl_min_proto_version:
64 aliases: ['ssl-min-proto-version']
65 type: str
66 description: Minimum supported protocol version for SSL/TLS connections
67 choices: ['default', 'TLSv1', 'TLSv1-1', 'TLSv1-2', 'SSLv3', 'TLSv1-3']
68 type:
69 type: str
70 description: Use FortiGuard Message service or custom email server.
71 choices: ['custom']
72 username:
73 type: str
74 description: SMTP server user name for authentication.
75 validate_server:
76 aliases: ['validate-server']
77 type: str
78 description: Enable/disable validation of server certificate.
79 choices: ['disable', 'enable']
80 interface:
81 type: str
82 description: Specify outgoing interface to reach server.
83 interface_select_method:
84 aliases: ['interface-select-method']
85 type: str
86 description: Specify how to select outgoing interface to reach server.
87 choices: ['auto', 'sdwan', 'specify']
88 vrf_select:
89 aliases: ['vrf-select']
90 type: int
91 description: VRF ID used for connection to server.
92 '''
93
94 EXAMPLES = '''
95 - name: Example playbook (generated based on argument schema)
96 hosts: fortimanagers
97 connection: httpapi
98 gather_facts: false
99 tasks:
100 - name: Configure the email server used by the FortiGate various things.
101 fortinet.fortimanager.fmgr_devprof_system_emailserver:
102 # workspace_locking_adom: <global or your adom name>
103 adom: <your own value>
104 devprof: <your own value>
105 devprof_system_emailserver:
106 # authenticate: <value in [disable, enable]>
107 # password: <list or string>
108 # port: <integer>
109 # reply_to: <string>
110 # security: <value in [none, starttls, smtps]>
111 # server: <string>
112 # source_ip: <string>
113 # source_ip6: <string>
114 # ssl_min_proto_version: <value in [default, TLSv1, TLSv1-1, ...]>
115 # type: <value in [custom]>
116 # username: <string>
117 # validate_server: <value in [disable, enable]>
118 # interface: <string>
119 # interface_select_method: <value in [auto, sdwan, specify]>
120 # vrf_select: <integer>
121 '''
122
123 RETURN = '''
124 meta:
125 description: The result of the request.
126 type: dict
127 returned: always
128 contains:
129 request_url:
130 description: The full url requested.
131 returned: always
132 type: str
133 sample: /sys/login/user
134 response_code:
135 description: The status of api request.
136 returned: always
137 type: int
138 sample: 0
139 response_data:
140 description: The api response.
141 type: list
142 returned: always
143 response_message:
144 description: The descriptive message of the api response.
145 type: str
146 returned: always
147 sample: OK.
148 system_information:
149 description: The information of the target system.
150 type: dict
151 returned: always
152 rc:
153 description: The status the request.
154 type: int
155 returned: always
156 sample: 0
157 version_check_warning:
158 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
159 type: list
160 returned: complex
161 '''
162 from ansible.module_utils.basic import AnsibleModule
163 from ansible.module_utils.connection import Connection
164 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
165 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
166
167
168 def main():
169 urls_list = [
170 '/pm/config/adom/{adom}/devprof/{devprof}/system/email-server'
171 ]
172 module_arg_spec = {
173 'adom': {'required': True, 'type': 'str'},
174 'devprof': {'required': True, 'type': 'str'},
175 'devprof_system_emailserver': {
176 'type': 'dict', 'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']],
177 'options': {
178 'authenticate': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
179 'password': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'no_log': True, 'type': 'raw'},
180 'port': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'int'},
181 'reply-to': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'str'},
182 'security': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['none', 'starttls', 'smtps'], 'type': 'str'},
183 'server': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'str'},
184 'source-ip': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'str'},
185 'source-ip6': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'str'},
186 'ssl-min-proto-version': {
187 'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']],
188 'choices': ['default', 'TLSv1', 'TLSv1-1', 'TLSv1-2', 'SSLv3', 'TLSv1-3'],
189 'type': 'str'
190 },
191 'type': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['custom'], 'type': 'str'},
192 'username': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'type': 'str'},
193 'validate-server': {'v_range': [['6.0.0', '6.2.5'], ['6.2.7', '6.4.1'], ['6.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
194 'interface': {'v_range': [['7.0.0', '']], 'type': 'str'},
195 'interface-select-method': {'v_range': [['7.0.0', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'},
196 'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'}
197 }
198 }
199 }
200
201 module_option_spec = get_module_arg_spec('partial crud')
202 module_arg_spec.update(module_option_spec)
203 check_galaxy_version(module_arg_spec)
204 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'devprof_system_emailserver'),
205 supports_check_mode=True)
206 if not module._socket_path:
207 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
208 connection = Connection(module._socket_path)
209 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
210 None, 'data', module, connection)
211 fmgr.process_partial_crud()
212 module.exit_json(meta=module.params)
213
214
215 if __name__ == '__main__':
216 main()