Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vip6_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_vip6_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 vip6:
29 description: The parameter (vip6) in requested url.
30 type: str
31 required: true
32 firewall_vip6_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: str
40 description: 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 an 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 id:
54 type: int
55 description: Real server ID.
56 required: true
57 ip:
58 type: str
59 description: IPv6 address of the real server.
60 max_connections:
61 aliases: ['max-connections']
62 type: int
63 description: Max number of active connections that can directed to the real server.
64 monitor:
65 type: raw
66 description: (list or str) Name of the health check monitor to use when polling to determine a virtual servers connectivity status.
67 port:
68 type: int
69 description: Port for communicating with the real server.
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 translate_host:
78 aliases: ['translate-host']
79 type: str
80 description: Enable/disable translation of hostname/IP from virtual server to real server.
81 choices: ['disable', 'enable']
82 verify_cert:
83 aliases: ['verify-cert']
84 type: str
85 description: Enable/disable certificate verification of the real server.
86 choices: ['disable', 'enable']
87 '''
88
89 EXAMPLES = '''
90 - name: Example playbook
91 hosts: fortimanagers
92 gather_facts: false
93 connection: httpapi
94 vars:
95 ansible_httpapi_use_ssl: true
96 ansible_httpapi_validate_certs: false
97 ansible_httpapi_port: 443
98 tasks:
99 - name: Select the real servers that this server load balancing VIP will distribute traffic to.
100 fortinet.fortimanager.fmgr_firewall_vip6_realservers:
101 bypass_validation: false
102 adom: ansible
103 vip6: "ansible-test-vip6" # name
104 state: present
105 firewall_vip6_realservers:
106 healthcheck: disable # <value in [disable, enable, vip]>
107 id: 1
108 status: active # <value in [active, standby, disable]>
109
110 - name: Gathering fortimanager facts
111 hosts: fortimanagers
112 gather_facts: false
113 connection: httpapi
114 vars:
115 ansible_httpapi_use_ssl: true
116 ansible_httpapi_validate_certs: false
117 ansible_httpapi_port: 443
118 tasks:
119 - name: Retrieve all the real servers of virtual IP for IPv6
120 fortinet.fortimanager.fmgr_fact:
121 facts:
122 selector: "firewall_vip6_realservers"
123 params:
124 adom: "ansible"
125 vip6: "ansible-test-vip6" # name
126 realservers: "your_value"
127 '''
128
129 RETURN = '''
130 meta:
131 description: The result of the request.
132 type: dict
133 returned: always
134 contains:
135 request_url:
136 description: The full url requested.
137 returned: always
138 type: str
139 sample: /sys/login/user
140 response_code:
141 description: The status of api request.
142 returned: always
143 type: int
144 sample: 0
145 response_data:
146 description: The api response.
147 type: list
148 returned: always
149 response_message:
150 description: The descriptive message of the api response.
151 type: str
152 returned: always
153 sample: OK.
154 system_information:
155 description: The information of the target system.
156 type: dict
157 returned: always
158 rc:
159 description: The status the request.
160 type: int
161 returned: always
162 sample: 0
163 version_check_warning:
164 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
165 type: list
166 returned: complex
167 '''
168 from ansible.module_utils.basic import AnsibleModule
169 from ansible.module_utils.connection import Connection
170 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
171 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
172
173
174 def main():
175 urls_list = [
176 '/pm/config/adom/{adom}/obj/firewall/vip6/{vip6}/realservers',
177 '/pm/config/global/obj/firewall/vip6/{vip6}/realservers'
178 ]
179 module_arg_spec = {
180 'adom': {'required': True, 'type': 'str'},
181 'vip6': {'required': True, 'type': 'str'},
182 'revision_note': {'type': 'str'},
183 'firewall_vip6_realservers': {
184 'type': 'dict', 'v_range': [['6.0.0', '']],
185 'options': {
186 'client-ip': {'type': 'str'},
187 'healthcheck': {'choices': ['disable', 'enable', 'vip'], 'type': 'str'},
188 'holddown-interval': {'type': 'int'},
189 'http-host': {'type': 'str'},
190 'id': {'required': True, 'type': 'int'},
191 'ip': {'type': 'str'},
192 'max-connections': {'type': 'int'},
193 'monitor': {'type': 'raw'},
194 'port': {'type': 'int'},
195 'status': {'choices': ['active', 'standby', 'disable'], 'type': 'str'},
196 'weight': {'type': 'int'},
197 'translate-host': {'v_range': [['7.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
198 'verify-cert': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
199 }
200 }
201 }
202
203 module_option_spec = get_module_arg_spec('full crud')
204 module_arg_spec.update(module_option_spec)
205 check_galaxy_version(module_arg_spec)
206 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vip6_realservers'),
207 supports_check_mode=True)
208 if not module._socket_path:
209 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
210 connection = Connection(module._socket_path)
211 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
212 'id', 'data', module, connection)
213 fmgr.process_crud()
214 module.exit_json(meta=module.params)
215
216
217 if __name__ == '__main__':
218 main()