Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_ldbmonitor.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_firewall_ldbmonitor
15 short_description: Configure server load balancing health monitors.
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 firewall_ldbmonitor:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 http_get:
34 aliases: ['http-get']
35 type: str
36 description: URL used to send a GET request to check the health of an HTTP server.
37 http_match:
38 aliases: ['http-match']
39 type: str
40 description: String to match the value expected in response to an HTTP-GET request.
41 http_max_redirects:
42 aliases: ['http-max-redirects']
43 type: int
44 description: The maximum number of HTTP redirects to be allowed
45 interval:
46 type: int
47 description: Time between health checks
48 name:
49 type: str
50 description: Monitor name.
51 required: true
52 port:
53 type: int
54 description: Service port used to perform the health check.
55 retry:
56 type: int
57 description: Number health check attempts before the server is considered down
58 timeout:
59 type: int
60 description: Time to wait to receive response to a health check from a server.
61 type:
62 type: str
63 description: Select the Monitor type used by the health check monitor to check the health of the server
64 choices: ['ping', 'tcp', 'http', 'passive-sip', 'https', 'dns']
65 src_ip:
66 aliases: ['src-ip']
67 type: str
68 description: Source IP for ldb-monitor.
69 dns_match_ip:
70 aliases: ['dns-match-ip']
71 type: str
72 description: Response IP expected from DNS server.
73 dns_protocol:
74 aliases: ['dns-protocol']
75 type: str
76 description: Select the protocol used by the DNS health check monitor to check the health of the server
77 choices: ['udp', 'tcp']
78 dns_request_domain:
79 aliases: ['dns-request-domain']
80 type: str
81 description: Fully qualified domain name to resolve for the DNS probe.
82 '''
83
84 EXAMPLES = '''
85 - name: Example playbook
86 hosts: fortimanagers
87 gather_facts: false
88 connection: httpapi
89 vars:
90 ansible_httpapi_use_ssl: true
91 ansible_httpapi_validate_certs: false
92 ansible_httpapi_port: 443
93 tasks:
94 - name: Configure server load balancing health monitors.
95 fortinet.fortimanager.fmgr_firewall_ldbmonitor:
96 bypass_validation: false
97 adom: ansible
98 state: present
99 firewall_ldbmonitor:
100 name: "ansible-test"
101 port: 1
102 type: tcp # <value in [ping, tcp, http, ...]>
103
104 - name: Gathering fortimanager facts
105 hosts: fortimanagers
106 gather_facts: false
107 connection: httpapi
108 vars:
109 ansible_httpapi_use_ssl: true
110 ansible_httpapi_validate_certs: false
111 ansible_httpapi_port: 443
112 tasks:
113 - name: Retrieve all the server load balancing health monitors
114 fortinet.fortimanager.fmgr_fact:
115 facts:
116 selector: "firewall_ldbmonitor"
117 params:
118 adom: "ansible"
119 ldb_monitor: "your_value"
120 '''
121
122 RETURN = '''
123 meta:
124 description: The result of the request.
125 type: dict
126 returned: always
127 contains:
128 request_url:
129 description: The full url requested.
130 returned: always
131 type: str
132 sample: /sys/login/user
133 response_code:
134 description: The status of api request.
135 returned: always
136 type: int
137 sample: 0
138 response_data:
139 description: The api response.
140 type: list
141 returned: always
142 response_message:
143 description: The descriptive message of the api response.
144 type: str
145 returned: always
146 sample: OK.
147 system_information:
148 description: The information of the target system.
149 type: dict
150 returned: always
151 rc:
152 description: The status the request.
153 type: int
154 returned: always
155 sample: 0
156 version_check_warning:
157 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
158 type: list
159 returned: complex
160 '''
161 from ansible.module_utils.basic import AnsibleModule
162 from ansible.module_utils.connection import Connection
163 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
164 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
165
166
167 def main():
168 urls_list = [
169 '/pm/config/adom/{adom}/obj/firewall/ldb-monitor',
170 '/pm/config/global/obj/firewall/ldb-monitor'
171 ]
172 module_arg_spec = {
173 'adom': {'required': True, 'type': 'str'},
174 'revision_note': {'type': 'str'},
175 'firewall_ldbmonitor': {
176 'type': 'dict', 'v_range': [['6.0.0', '']],
177 'options': {
178 'http-get': {'type': 'str'},
179 'http-match': {'type': 'str'},
180 'http-max-redirects': {'type': 'int'},
181 'interval': {'type': 'int'},
182 'name': {'required': True, 'type': 'str'},
183 'port': {'type': 'int'},
184 'retry': {'type': 'int'},
185 'timeout': {'type': 'int'},
186 'type': {'choices': ['ping', 'tcp', 'http', 'passive-sip', 'https', 'dns'], 'type': 'str'},
187 'src-ip': {'v_range': [['6.4.0', '']], 'type': 'str'},
188 'dns-match-ip': {'v_range': [['7.0.0', '']], 'type': 'str'},
189 'dns-protocol': {'v_range': [['7.0.0', '']], 'choices': ['udp', 'tcp'], 'type': 'str'},
190 'dns-request-domain': {'v_range': [['7.0.0', '']], 'type': 'str'}
191 }
192 }
193 }
194
195 module_option_spec = get_module_arg_spec('full crud')
196 module_arg_spec.update(module_option_spec)
197 check_galaxy_version(module_arg_spec)
198 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_ldbmonitor'),
199 supports_check_mode=True)
200 if not module._socket_path:
201 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
202 connection = Connection(module._socket_path)
203 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
204 'name', 'data', module, connection)
205 fmgr.process_crud()
206 module.exit_json(meta=module.params)
207
208
209 if __name__ == '__main__':
210 main()