Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_webproxy_forwardservergroup.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_webproxy_forwardservergroup
15 short_description: Configure a forward server group consisting or multiple forward 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 webproxy_forwardservergroup:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 affinity:
34 type: str
35 description: Enable/disable affinity, attaching a source-ips traffic to the assigned forwarding server until the forward-server-affinit...
36 choices: ['disable', 'enable']
37 group_down_option:
38 aliases: ['group-down-option']
39 type: str
40 description: Action to take when all of the servers in the forward server group are down
41 choices: ['block', 'pass']
42 ldb_method:
43 aliases: ['ldb-method']
44 type: str
45 description: Load balance method
46 choices: ['weighted', 'least-session', 'active-passive']
47 name:
48 type: str
49 description: Configure a forward server group consisting one or multiple forward servers.
50 required: true
51 server_list:
52 aliases: ['server-list']
53 type: list
54 elements: dict
55 description: Server list.
56 suboptions:
57 name:
58 type: str
59 description: Forward server name.
60 weight:
61 type: int
62 description: Optionally assign a weight of the forwarding server for weighted load balancing
63 '''
64
65 EXAMPLES = '''
66 - name: Example playbook (generated based on argument schema)
67 hosts: fortimanagers
68 connection: httpapi
69 gather_facts: false
70 tasks:
71 - name: Configure a forward server group consisting or multiple forward servers.
72 fortinet.fortimanager.fmgr_webproxy_forwardservergroup:
73 # workspace_locking_adom: <global or your adom name>
74 adom: <your own value>
75 state: present # <value in [present, absent]>
76 webproxy_forwardservergroup:
77 name: "your value" # Required variable, string
78 # affinity: <value in [disable, enable]>
79 # group_down_option: <value in [block, pass]>
80 # ldb_method: <value in [weighted, least-session, active-passive]>
81 # server_list:
82 # - name: <string>
83 # weight: <integer>
84 '''
85
86 RETURN = '''
87 meta:
88 description: The result of the request.
89 type: dict
90 returned: always
91 contains:
92 request_url:
93 description: The full url requested.
94 returned: always
95 type: str
96 sample: /sys/login/user
97 response_code:
98 description: The status of api request.
99 returned: always
100 type: int
101 sample: 0
102 response_data:
103 description: The api response.
104 type: list
105 returned: always
106 response_message:
107 description: The descriptive message of the api response.
108 type: str
109 returned: always
110 sample: OK.
111 system_information:
112 description: The information of the target system.
113 type: dict
114 returned: always
115 rc:
116 description: The status the request.
117 type: int
118 returned: always
119 sample: 0
120 version_check_warning:
121 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
122 type: list
123 returned: complex
124 '''
125 from ansible.module_utils.basic import AnsibleModule
126 from ansible.module_utils.connection import Connection
127 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
128 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
129
130
131 def main():
132 urls_list = [
133 '/pm/config/adom/{adom}/obj/web-proxy/forward-server-group',
134 '/pm/config/global/obj/web-proxy/forward-server-group'
135 ]
136 module_arg_spec = {
137 'adom': {'required': True, 'type': 'str'},
138 'revision_note': {'type': 'str'},
139 'webproxy_forwardservergroup': {
140 'type': 'dict', 'v_range': [['6.0.0', '']],
141 'options': {
142 'affinity': {'choices': ['disable', 'enable'], 'type': 'str'},
143 'group-down-option': {'choices': ['block', 'pass'], 'type': 'str'},
144 'ldb-method': {'choices': ['weighted', 'least-session', 'active-passive'], 'type': 'str'},
145 'name': {'required': True, 'type': 'str'},
146 'server-list': {'type': 'list', 'options': {'name': {'type': 'str'}, 'weight': {'type': 'int'}}, 'elements': 'dict'}
147 }
148 }
149 }
150
151 module_option_spec = get_module_arg_spec('full crud')
152 module_arg_spec.update(module_option_spec)
153 check_galaxy_version(module_arg_spec)
154 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'webproxy_forwardservergroup'),
155 supports_check_mode=True)
156 if not module._socket_path:
157 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
158 connection = Connection(module._socket_path)
159 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
160 'name', 'data', module, connection)
161 fmgr.process_crud()
162 module.exit_json(meta=module.params)
163
164
165 if __name__ == '__main__':
166 main()