Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vip46_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_vip46_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 vip46:
29 description: The parameter (vip46) in requested url.
30 type: str
31 required: true
32 firewall_vip46_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 IPv6.
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_vip46_realservers:
87 bypass_validation: false
88 adom: ansible
89 vip46: "ansible-test-vip46" # name
90 state: present
91 firewall_vip46_realservers:
92 healthcheck: disable
93 id: 1
94
95 - name: Gathering fortimanager facts
96 hosts: fortimanagers
97 gather_facts: false
98 connection: httpapi
99 vars:
100 ansible_httpapi_use_ssl: true
101 ansible_httpapi_validate_certs: false
102 ansible_httpapi_port: 443
103 tasks:
104 - name: Retrieve all the real servers of IPv4 to IPv6 virtual IP
105 fortinet.fortimanager.fmgr_fact:
106 facts:
107 selector: "firewall_vip46_realservers"
108 params:
109 adom: "ansible"
110 vip46: "ansible-test-vip46" # name
111 realservers: "your_value"
112 '''
113
114 RETURN = '''
115 meta:
116 description: The result of the request.
117 type: dict
118 returned: always
119 contains:
120 request_url:
121 description: The full url requested.
122 returned: always
123 type: str
124 sample: /sys/login/user
125 response_code:
126 description: The status of api request.
127 returned: always
128 type: int
129 sample: 0
130 response_data:
131 description: The api response.
132 type: list
133 returned: always
134 response_message:
135 description: The descriptive message of the api response.
136 type: str
137 returned: always
138 sample: OK.
139 system_information:
140 description: The information of the target system.
141 type: dict
142 returned: always
143 rc:
144 description: The status the request.
145 type: int
146 returned: always
147 sample: 0
148 version_check_warning:
149 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
150 type: list
151 returned: complex
152 '''
153 from ansible.module_utils.basic import AnsibleModule
154 from ansible.module_utils.connection import Connection
155 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
156 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
157
158
159 def main():
160 urls_list = [
161 '/pm/config/adom/{adom}/obj/firewall/vip46/{vip46}/realservers',
162 '/pm/config/global/obj/firewall/vip46/{vip46}/realservers'
163 ]
164 module_arg_spec = {
165 'adom': {'required': True, 'type': 'str'},
166 'vip46': {'required': True, 'type': 'str'},
167 'revision_note': {'type': 'str'},
168 'firewall_vip46_realservers': {
169 'type': 'dict', 'v_range': [['6.0.0', '']],
170 'options': {
171 'client-ip': {'type': 'str'},
172 'healthcheck': {'choices': ['disable', 'enable', 'vip'], 'type': 'str'},
173 'holddown-interval': {'type': 'int'},
174 'id': {'required': True, 'type': 'int'},
175 'ip': {'type': 'str'},
176 'max-connections': {'type': 'int'},
177 'monitor': {'type': 'raw'},
178 'port': {'type': 'int'},
179 'status': {'choices': ['active', 'standby', 'disable'], 'type': 'str'},
180 'weight': {'type': 'int'}
181 }
182 }
183 }
184
185 module_option_spec = get_module_arg_spec('full crud')
186 module_arg_spec.update(module_option_spec)
187 check_galaxy_version(module_arg_spec)
188 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vip46_realservers'),
189 supports_check_mode=True)
190 if not module._socket_path:
191 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
192 connection = Connection(module._socket_path)
193 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
194 'id', 'data', module, connection)
195 fmgr.process_crud()
196 module.exit_json(meta=module.params)
197
198
199 if __name__ == '__main__':
200 main()