Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pkg_firewall_acl.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_pkg_firewall_acl
15 short_description: Configure IPv4 access control list.
16 version_added: "2.1.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 pkg:
29 description: The parameter (pkg) in requested url.
30 type: str
31 required: true
32 pkg_firewall_acl:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 comments:
38 type: str
39 description: Comment.
40 dstaddr:
41 type: raw
42 description: (list) Destination address name.
43 interface:
44 type: str
45 description: Interface name.
46 name:
47 type: str
48 description: Policy name.
49 policyid:
50 type: int
51 description: Policy ID.
52 required: true
53 service:
54 type: raw
55 description: (list) Service name.
56 srcaddr:
57 type: raw
58 description: (list) Source address name.
59 status:
60 type: str
61 description: Enable/disable access control list status.
62 choices: ['disable', 'enable']
63 uuid:
64 type: str
65 description: Universally Unique Identifier
66 fragment:
67 type: str
68 description: Pass/drop fragments that match L3 information.
69 choices: ['pass', 'drop']
70 '''
71
72 EXAMPLES = '''
73 - name: Example playbook (generated based on argument schema)
74 hosts: fortimanagers
75 connection: httpapi
76 gather_facts: false
77 tasks:
78 - name: Configure IPv4 access control list.
79 fortinet.fortimanager.fmgr_pkg_firewall_acl:
80 # workspace_locking_adom: <global or your adom name>
81 adom: <your own value>
82 pkg: <your own value>
83 state: present # <value in [present, absent]>
84 pkg_firewall_acl:
85 policyid: 0 # Required variable, integer
86 # comments: <string>
87 # dstaddr: <list or string>
88 # interface: <string>
89 # name: <string>
90 # service: <list or string>
91 # srcaddr: <list or string>
92 # status: <value in [disable, enable]>
93 # uuid: <string>
94 # fragment: <value in [pass, drop]>
95 '''
96
97 RETURN = '''
98 meta:
99 description: The result of the request.
100 type: dict
101 returned: always
102 contains:
103 request_url:
104 description: The full url requested.
105 returned: always
106 type: str
107 sample: /sys/login/user
108 response_code:
109 description: The status of api request.
110 returned: always
111 type: int
112 sample: 0
113 response_data:
114 description: The api response.
115 type: list
116 returned: always
117 response_message:
118 description: The descriptive message of the api response.
119 type: str
120 returned: always
121 sample: OK.
122 system_information:
123 description: The information of the target system.
124 type: dict
125 returned: always
126 rc:
127 description: The status the request.
128 type: int
129 returned: always
130 sample: 0
131 version_check_warning:
132 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
133 type: list
134 returned: complex
135 '''
136 from ansible.module_utils.basic import AnsibleModule
137 from ansible.module_utils.connection import Connection
138 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
139 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
140
141
142 def main():
143 urls_list = [
144 '/pm/config/adom/{adom}/pkg/{pkg}/firewall/acl'
145 ]
146 module_arg_spec = {
147 'adom': {'required': True, 'type': 'str'},
148 'pkg': {'required': True, 'type': 'str'},
149 'revision_note': {'type': 'str'},
150 'pkg_firewall_acl': {
151 'type': 'dict', 'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']],
152 'options': {
153 'comments': {'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
154 'dstaddr': {'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
155 'interface': {'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
156 'name': {'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'str'},
157 'policyid': {'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'required': True, 'type': 'int'},
158 'service': {'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
159 'srcaddr': {'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
160 'status': {'v_range': [['7.2.0', '7.2.0'], ['7.2.6', '7.2.12'], ['7.4.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
161 'uuid': {'v_range': [['7.2.0', '7.2.0']], 'type': 'str'},
162 'fragment': {'v_range': [['7.4.3', '']], 'choices': ['pass', 'drop'], 'type': 'str'}
163 }
164 }
165 }
166
167 module_option_spec = get_module_arg_spec('full crud')
168 module_arg_spec.update(module_option_spec)
169 check_galaxy_version(module_arg_spec)
170 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_firewall_acl'),
171 supports_check_mode=True)
172 if not module._socket_path:
173 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
174 connection = Connection(module._socket_path)
175 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
176 'policyid', 'data', module, connection)
177 fmgr.process_crud()
178 module.exit_json(meta=module.params)
179
180
181 if __name__ == '__main__':
182 main()