Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_vipgrp_dynamicmapping.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_vipgrp_dynamicmapping
15 short_description: Configure IPv4 virtual IP groups.
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 vipgrp:
29 description: The parameter (vipgrp) in requested url.
30 type: str
31 required: true
32 firewall_vipgrp_dynamicmapping:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 _scope:
38 type: list
39 elements: dict
40 description: Scope.
41 suboptions:
42 name:
43 type: str
44 description: Name.
45 vdom:
46 type: str
47 description: Vdom.
48 color:
49 type: int
50 description: Color.
51 comments:
52 type: str
53 description: Comments.
54 interface:
55 type: str
56 description: Interface.
57 member:
58 type: raw
59 description: (list or str) Member.
60 uuid:
61 type: str
62 description: Uuid.
63 '''
64
65 EXAMPLES = '''
66 - name: Example playbook
67 hosts: fortimanagers
68 gather_facts: false
69 connection: httpapi
70 vars:
71 ansible_httpapi_use_ssl: true
72 ansible_httpapi_validate_certs: false
73 ansible_httpapi_port: 443
74 tasks:
75 - name: Configure dynamic mappings of IPv4 virtual IP groups
76 fortinet.fortimanager.fmgr_firewall_vipgrp_dynamicmapping:
77 bypass_validation: false
78 adom: ansible
79 vipgrp: "ansible-test-vipgrp" # name
80 state: present
81 firewall_vipgrp_dynamicmapping:
82 _scope:
83 - name: FGT_AWS # need a valid device name
84 vdom: root # need a valid vdom name under the device
85 color: 1
86 comments: "ansible-comment"
87 member: "ansible-test-vip"
88
89 - name: Gathering fortimanager facts
90 hosts: fortimanagers
91 gather_facts: false
92 connection: httpapi
93 vars:
94 ansible_httpapi_use_ssl: true
95 ansible_httpapi_validate_certs: false
96 ansible_httpapi_port: 443
97 tasks:
98 - name: Retrieve all the dynamic mappings of IPv4 virtual IP groups
99 fortinet.fortimanager.fmgr_fact:
100 facts:
101 selector: "firewall_vipgrp_dynamicmapping"
102 params:
103 adom: "ansible"
104 vipgrp: "ansible-test-vipgrp" # name
105 dynamic_mapping: "your_value"
106 '''
107
108 RETURN = '''
109 meta:
110 description: The result of the request.
111 type: dict
112 returned: always
113 contains:
114 request_url:
115 description: The full url requested.
116 returned: always
117 type: str
118 sample: /sys/login/user
119 response_code:
120 description: The status of api request.
121 returned: always
122 type: int
123 sample: 0
124 response_data:
125 description: The api response.
126 type: list
127 returned: always
128 response_message:
129 description: The descriptive message of the api response.
130 type: str
131 returned: always
132 sample: OK.
133 system_information:
134 description: The information of the target system.
135 type: dict
136 returned: always
137 rc:
138 description: The status the request.
139 type: int
140 returned: always
141 sample: 0
142 version_check_warning:
143 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
144 type: list
145 returned: complex
146 '''
147 from ansible.module_utils.basic import AnsibleModule
148 from ansible.module_utils.connection import Connection
149 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
150 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
151
152
153 def main():
154 urls_list = [
155 '/pm/config/adom/{adom}/obj/firewall/vipgrp/{vipgrp}/dynamic_mapping',
156 '/pm/config/global/obj/firewall/vipgrp/{vipgrp}/dynamic_mapping'
157 ]
158 module_arg_spec = {
159 'adom': {'required': True, 'type': 'str'},
160 'vipgrp': {'required': True, 'type': 'str'},
161 'revision_note': {'type': 'str'},
162 'firewall_vipgrp_dynamicmapping': {
163 'type': 'dict', 'v_range': [['6.0.0', '']],
164 'options': {
165 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
166 'color': {'type': 'int'},
167 'comments': {'type': 'str'},
168 'interface': {'type': 'str'},
169 'member': {'type': 'raw'},
170 'uuid': {'type': 'str'}
171 }
172 }
173 }
174
175 module_option_spec = get_module_arg_spec('full crud')
176 module_arg_spec.update(module_option_spec)
177 check_galaxy_version(module_arg_spec)
178 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_vipgrp_dynamicmapping'),
179 supports_check_mode=True)
180 if not module._socket_path:
181 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
182 connection = Connection(module._socket_path)
183 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
184 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
185 fmgr.process_crud()
186 module.exit_json(meta=module.params)
187
188
189 if __name__ == '__main__':
190 main()