Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vip_realservers.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_vip_realservers
15 short_description: Select the real servers that this server load balancing VIP will distribute traffic to.
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 vip:
29 description: The parameter (vip) in requested url.
30 type: str
31 required: true
32 firewall_vip_realservers:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 client_ip:
38 aliases: ['client-ip']
39 type: raw
40 description: (list) Only clients in this IP range can connect to this real server.
41 healthcheck:
42 type: str
43 description: Enable to check the responsiveness of the real server before forwarding traffic.
44 choices: ['disable', 'enable', 'vip']
45 holddown_interval:
46 aliases: ['holddown-interval']
47 type: int
48 description: Time in seconds that the health check monitor continues to monitor and unresponsive server that should be active.
49 http_host:
50 aliases: ['http-host']
51 type: str
52 description: HTTP server domain name in HTTP header.
53 ip:
54 type: str
55 description: IP address of the real server.
56 max_connections:
57 aliases: ['max-connections']
58 type: int
59 description: Max number of active connections that can be directed to the real server.
60 monitor:
61 type: raw
62 description: (list or str) Name of the health check monitor to use when polling to determine a virtual servers connectivity status.
63 port:
64 type: int
65 description: Port for communicating with the real server.
66 seq:
67 type: int
68 description: Seq.
69 required: true
70 status:
71 type: str
72 description: Set the status of the real server to active so that it can accept traffic, or on standby or disabled so no traffic is sent.
73 choices: ['active', 'standby', 'disable']
74 weight:
75 type: int
76 description: Weight of the real server.
77 address:
78 type: str
79 description: Dynamic address of the real server.
80 id:
81 type: int
82 description: Real server ID.
83 type:
84 type: str
85 description: Type of address.
86 choices: ['ip', 'address']
87 translate_host:
88 aliases: ['translate-host']
89 type: str
90 description: Enable/disable translation of hostname/IP from virtual server to real server.
91 choices: ['disable', 'enable']
92 verify_cert:
93 aliases: ['verify-cert']
94 type: str
95 description: Enable/disable certificate verification of the real server.
96 choices: ['disable', 'enable']
97 health_check_proto:
98 aliases: ['health-check-proto']
99 type: str
100 description: Health check proto.
101 choices: ['ping', 'http']
102 '''
103
104 EXAMPLES = '''
105 - name: Example playbook
106 hosts: fortimanagers
107 gather_facts: false
108 connection: httpapi
109 vars:
110 ansible_httpapi_use_ssl: true
111 ansible_httpapi_validate_certs: false
112 ansible_httpapi_port: 443
113 tasks:
114 - name: Select the real servers that this server load balancing VIP will distribute traffic to.
115 fortinet.fortimanager.fmgr_firewall_vip_realservers:
116 bypass_validation: false
117 adom: ansible
118 vip: "ansible-test-vip" # name
119 state: present
120 firewall_vip_realservers: # available only when type is set to 'server-load-balance' in vip
121 healthcheck: enable # <value in [disable, enable, vip]>
122 ip: "222.222.222.1"
123 port: 1
124 seq: 1
125 status: active # <value in [active, standby, disable]>
126
127 - name: Gathering fortimanager facts
128 hosts: fortimanagers
129 gather_facts: false
130 connection: httpapi
131 vars:
132 ansible_httpapi_use_ssl: true
133 ansible_httpapi_validate_certs: false
134 ansible_httpapi_port: 443
135 tasks:
136 - name: Retrieve all the real servers of IPv4 virtual ip
137 fortinet.fortimanager.fmgr_fact:
138 facts:
139 selector: "firewall_vip_realservers" # available only when type is set to 'server-load-balance' in vip
140 params:
141 adom: "ansible"
142 vip: "ansible-test-vip" # name
143 realservers: "your_value"
144 '''
145
146 RETURN = '''
147 meta:
148 description: The result of the request.
149 type: dict
150 returned: always
151 contains:
152 request_url:
153 description: The full url requested.
154 returned: always
155 type: str
156 sample: /sys/login/user
157 response_code:
158 description: The status of api request.
159 returned: always
160 type: int
161 sample: 0
162 response_data:
163 description: The api response.
164 type: list
165 returned: always
166 response_message:
167 description: The descriptive message of the api response.
168 type: str
169 returned: always
170 sample: OK.
171 system_information:
172 description: The information of the target system.
173 type: dict
174 returned: always
175 rc:
176 description: The status the request.
177 type: int
178 returned: always
179 sample: 0
180 version_check_warning:
181 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
182 type: list
183 returned: complex
184 '''
185 from ansible.module_utils.basic import AnsibleModule
186 from ansible.module_utils.connection import Connection
187 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
188 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
189
190
191 def main():
192 urls_list = [
193 '/pm/config/adom/{adom}/obj/firewall/vip/{vip}/realservers',
194 '/pm/config/global/obj/firewall/vip/{vip}/realservers'
195 ]
196 module_arg_spec = {
197 'adom': {'required': True, 'type': 'str'},
198 'vip': {'required': True, 'type': 'str'},
199 'revision_note': {'type': 'str'},
200 'firewall_vip_realservers': {
201 'type': 'dict', 'v_range': [['6.0.0', '']],
202 'options': {
203 'client-ip': {'type': 'raw'},
204 'healthcheck': {'choices': ['disable', 'enable', 'vip'], 'type': 'str'},
205 'holddown-interval': {'type': 'int'},
206 'http-host': {'type': 'str'},
207 'ip': {'type': 'str'},
208 'max-connections': {'type': 'int'},
209 'monitor': {'type': 'raw'},
210 'port': {'type': 'int'},
211 'seq': {'v_range': [['6.0.0', '7.6.2'], ['7.6.4', '']], 'required': True, 'type': 'int'},
212 'status': {'choices': ['active', 'standby', 'disable'], 'type': 'str'},
213 'weight': {'type': 'int'},
214 'address': {'v_range': [['6.4.0', '']], 'type': 'str'},
215 'id': {'v_range': [['6.4.0', '']], 'type': 'int'},
216 'type': {'v_range': [['6.4.0', '']], 'choices': ['ip', 'address'], 'type': 'str'},
217 'translate-host': {'v_range': [['7.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
218 'verify-cert': {'v_range': [['7.4.8', '7.4.10'], ['7.6.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
219 'health-check-proto': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['ping', 'http'], 'type': 'str'}
220 }
221 }
222 }
223
224 module_option_spec = get_module_arg_spec('full crud')
225 module_arg_spec.update(module_option_spec)
226 check_galaxy_version(module_arg_spec)
227 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vip_realservers'),
228 supports_check_mode=True)
229 if not module._socket_path:
230 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
231 connection = Connection(module._socket_path)
232 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
233 'seq', 'data', module, connection)
234 fmgr.process_crud()
235 module.exit_json(meta=module.params)
236
237
238 if __name__ == '__main__':
239 main()