Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vip64_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_vip64_realservers
15 short_description: Real servers.
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 vip64:
29 description: The parameter (vip64) in requested url.
30 type: str
31 required: true
32 firewall_vip64_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: Restrict server to a client IP in this range.
41 healthcheck:
42 type: str
43 description: Per server health check.
44 choices: ['disable', 'enable', 'vip']
45 holddown_interval:
46 aliases: ['holddown-interval']
47 type: int
48 description: Hold down interval.
49 id:
50 type: int
51 description: Real server ID.
52 required: true
53 ip:
54 type: str
55 description: Mapped server IP.
56 max_connections:
57 aliases: ['max-connections']
58 type: int
59 description: Maximum number of connections allowed to server.
60 monitor:
61 type: raw
62 description: (list or str) Health monitors.
63 port:
64 type: int
65 description: Mapped server port.
66 status:
67 type: str
68 description: Server administrative status.
69 choices: ['active', 'standby', 'disable']
70 weight:
71 type: int
72 description: Weight.
73 '''
74
75 EXAMPLES = '''
76 - name: Example playbook
77 hosts: fortimanagers
78 gather_facts: false
79 connection: httpapi
80 vars:
81 ansible_httpapi_use_ssl: true
82 ansible_httpapi_validate_certs: false
83 ansible_httpapi_port: 443
84 tasks:
85 - name: Real servers.
86 fortinet.fortimanager.fmgr_firewall_vip64_realservers:
87 bypass_validation: false
88 adom: ansible
89 vip64: "ansible-test-vip64" # name
90 state: present
91 firewall_vip64_realservers:
92 healthcheck: enable # <value in [disable, enable, vip]>
93 id: 1
94 status: active # <value in [active, standby, disable]>
95
96 - name: Gathering fortimanager facts
97 hosts: fortimanagers
98 gather_facts: false
99 connection: httpapi
100 vars:
101 ansible_httpapi_use_ssl: true
102 ansible_httpapi_validate_certs: false
103 ansible_httpapi_port: 443
104 tasks:
105 - name: Retrieve all the real servers of IPv6 to IPv4 virtual IP
106 fortinet.fortimanager.fmgr_fact:
107 facts:
108 selector: "firewall_vip64_realservers"
109 params:
110 adom: "ansible"
111 vip64: "ansible-test-vip64" # name
112 realservers: "your_value"
113 '''
114
115 RETURN = '''
116 meta:
117 description: The result of the request.
118 type: dict
119 returned: always
120 contains:
121 request_url:
122 description: The full url requested.
123 returned: always
124 type: str
125 sample: /sys/login/user
126 response_code:
127 description: The status of api request.
128 returned: always
129 type: int
130 sample: 0
131 response_data:
132 description: The api response.
133 type: list
134 returned: always
135 response_message:
136 description: The descriptive message of the api response.
137 type: str
138 returned: always
139 sample: OK.
140 system_information:
141 description: The information of the target system.
142 type: dict
143 returned: always
144 rc:
145 description: The status the request.
146 type: int
147 returned: always
148 sample: 0
149 version_check_warning:
150 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
151 type: list
152 returned: complex
153 '''
154 from ansible.module_utils.basic import AnsibleModule
155 from ansible.module_utils.connection import Connection
156 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
157 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
158
159
160 def main():
161 urls_list = [
162 '/pm/config/adom/{adom}/obj/firewall/vip64/{vip64}/realservers',
163 '/pm/config/global/obj/firewall/vip64/{vip64}/realservers'
164 ]
165 module_arg_spec = {
166 'adom': {'required': True, 'type': 'str'},
167 'vip64': {'required': True, 'type': 'str'},
168 'revision_note': {'type': 'str'},
169 'firewall_vip64_realservers': {
170 'type': 'dict', 'v_range': [['6.0.0', '']],
171 'options': {
172 'client-ip': {'type': 'str'},
173 'healthcheck': {'choices': ['disable', 'enable', 'vip'], 'type': 'str'},
174 'holddown-interval': {'type': 'int'},
175 'id': {'required': True, 'type': 'int'},
176 'ip': {'type': 'str'},
177 'max-connections': {'type': 'int'},
178 'monitor': {'type': 'raw'},
179 'port': {'type': 'int'},
180 'status': {'choices': ['active', 'standby', 'disable'], 'type': 'str'},
181 'weight': {'type': 'int'}
182 }
183 }
184 }
185
186 module_option_spec = get_module_arg_spec('full crud')
187 module_arg_spec.update(module_option_spec)
188 check_galaxy_version(module_arg_spec)
189 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vip64_realservers'),
190 supports_check_mode=True)
191 if not module._socket_path:
192 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
193 connection = Connection(module._socket_path)
194 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
195 'id', 'data', module, connection)
196 fmgr.process_crud()
197 module.exit_json(meta=module.params)
198
199
200 if __name__ == '__main__':
201 main()