Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pkg_user_nacpolicy.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_user_nacpolicy
15 short_description: Configure NAC policy matching pattern to identify matching NAC devices.
16 version_added: "2.2.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_user_nacpolicy:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 category:
38 type: str
39 description: Category of NAC policy.
40 choices: ['device', 'firewall-user', 'ems-tag', 'vulnerability', 'fortivoice-tag']
41 description:
42 type: str
43 description: Description for the NAC policy matching pattern.
44 ems_tag:
45 aliases: ['ems-tag']
46 type: str
47 description: NAC policy matching EMS tag.
48 family:
49 type: str
50 description: NAC policy matching family.
51 host:
52 type: str
53 description: NAC policy matching host.
54 hw_vendor:
55 aliases: ['hw-vendor']
56 type: str
57 description: NAC policy matching hardware vendor.
58 hw_version:
59 aliases: ['hw-version']
60 type: str
61 description: NAC policy matching hardware version.
62 mac:
63 type: str
64 description: NAC policy matching MAC address.
65 name:
66 type: str
67 description: NAC policy name.
68 required: true
69 os:
70 type: str
71 description: NAC policy matching operating system.
72 src:
73 type: str
74 description: NAC policy matching source.
75 ssid_policy:
76 aliases: ['ssid-policy']
77 type: str
78 description: SSID policy to be applied on the matched NAC policy.
79 status:
80 type: str
81 description: Enable/disable NAC policy.
82 choices: ['disable', 'enable']
83 sw_version:
84 aliases: ['sw-version']
85 type: str
86 description: NAC policy matching software version.
87 type:
88 type: str
89 description: NAC policy matching type.
90 user:
91 type: str
92 description: NAC policy matching user.
93 user_group:
94 aliases: ['user-group']
95 type: str
96 description: NAC policy matching user group.
97 severity:
98 type: raw
99 description: (list) NAC policy matching devices vulnerability severity lists.
100 firewall_address:
101 aliases: ['firewall-address']
102 type: raw
103 description: (list) Dynamic firewall address to associate MAC which match this policy.
104 fortivoice_tag:
105 aliases: ['fortivoice-tag']
106 type: raw
107 description: (list) NAC policy matching FortiVoice tag.
108 match_period:
109 aliases: ['match-period']
110 type: int
111 description: Number of days the matched devices will be retained
112 match_type:
113 aliases: ['match-type']
114 type: str
115 description: Match and retain the devices based on the type.
116 choices: ['dynamic', 'override']
117 switch_fortilink:
118 aliases: ['switch-fortilink']
119 type: raw
120 description:
121 - (list)
122 - Support meta variable
123 - FortiLink interface for which this NAC policy belongs to.
124 switch_group:
125 aliases: ['switch-group']
126 type: raw
127 description:
128 - (list)
129 - Support meta variable
130 - List of managed FortiSwitch groups on which NAC policy can be applied.
131 switch_mac_policy:
132 aliases: ['switch-mac-policy']
133 type: raw
134 description: (list) Switch MAC policy action to be applied on the matched NAC policy.
135 switch_scope:
136 aliases: ['switch-scope']
137 type: raw
138 description: (list) List of managed FortiSwitches on which NAC policy can be applied.
139 switch_port_policy:
140 aliases: ['switch-port-policy']
141 type: raw
142 description: (list) Switch-port-policy to be applied on the matched NAC policy.
143 switch_auto_auth:
144 aliases: ['switch-auto-auth']
145 type: str
146 description: NAC device auto authorization when discovered and nac-policy matched.
147 choices: ['disable', 'enable', 'global']
148 match_remove:
149 aliases: ['match-remove']
150 type: str
151 description: Options to remove the matched override devices.
152 choices: ['link-down', 'default']
153 '''
154
155 EXAMPLES = '''
156 - name: Example playbook (generated based on argument schema)
157 hosts: fortimanagers
158 connection: httpapi
159 gather_facts: false
160 tasks:
161 - name: Configure NAC policy matching pattern to identify matching NAC devices.
162 fortinet.fortimanager.fmgr_pkg_user_nacpolicy:
163 # workspace_locking_adom: <global or your adom name>
164 adom: <your own value>
165 pkg: <your own value>
166 state: present # <value in [present, absent]>
167 pkg_user_nacpolicy:
168 name: "your value" # Required variable, string
169 # category: <value in [device, firewall-user, ems-tag, ...]>
170 # description: <string>
171 # ems_tag: <string>
172 # family: <string>
173 # host: <string>
174 # hw_vendor: <string>
175 # hw_version: <string>
176 # mac: <string>
177 # os: <string>
178 # src: <string>
179 # ssid_policy: <string>
180 # status: <value in [disable, enable]>
181 # sw_version: <string>
182 # type: <string>
183 # user: <string>
184 # user_group: <string>
185 # severity: <list or integer>
186 # firewall_address: <list or string>
187 # fortivoice_tag: <list or string>
188 # match_period: <integer>
189 # match_type: <value in [dynamic, override]>
190 # switch_fortilink: <list or string>
191 # switch_group: <list or string>
192 # switch_mac_policy: <list or string>
193 # switch_scope: <list or string>
194 # switch_port_policy: <list or string>
195 # switch_auto_auth: <value in [disable, enable, global]>
196 # match_remove: <value in [link-down, default]>
197 '''
198
199 RETURN = '''
200 meta:
201 description: The result of the request.
202 type: dict
203 returned: always
204 contains:
205 request_url:
206 description: The full url requested.
207 returned: always
208 type: str
209 sample: /sys/login/user
210 response_code:
211 description: The status of api request.
212 returned: always
213 type: int
214 sample: 0
215 response_data:
216 description: The api response.
217 type: list
218 returned: always
219 response_message:
220 description: The descriptive message of the api response.
221 type: str
222 returned: always
223 sample: OK.
224 system_information:
225 description: The information of the target system.
226 type: dict
227 returned: always
228 rc:
229 description: The status the request.
230 type: int
231 returned: always
232 sample: 0
233 version_check_warning:
234 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
235 type: list
236 returned: complex
237 '''
238 from ansible.module_utils.basic import AnsibleModule
239 from ansible.module_utils.connection import Connection
240 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
241 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
242
243
244 def main():
245 urls_list = [
246 '/pm/config/adom/{adom}/pkg/{pkg}/user/nac-policy'
247 ]
248 module_arg_spec = {
249 'adom': {'required': True, 'type': 'str'},
250 'pkg': {'required': True, 'type': 'str'},
251 'revision_note': {'type': 'str'},
252 'pkg_user_nacpolicy': {
253 'type': 'dict', 'v_range': [['7.2.1', '']],
254 'options': {
255 'category': {
256 'v_range': [['7.2.1', '']],
257 'choices': ['device', 'firewall-user', 'ems-tag', 'vulnerability', 'fortivoice-tag'],
258 'type': 'str'
259 },
260 'description': {'v_range': [['7.2.1', '']], 'type': 'str'},
261 'ems-tag': {'v_range': [['7.2.1', '']], 'type': 'str'},
262 'family': {'v_range': [['7.2.1', '']], 'type': 'str'},
263 'host': {'v_range': [['7.2.1', '']], 'type': 'str'},
264 'hw-vendor': {'v_range': [['7.2.1', '']], 'type': 'str'},
265 'hw-version': {'v_range': [['7.2.1', '']], 'type': 'str'},
266 'mac': {'v_range': [['7.2.1', '']], 'type': 'str'},
267 'name': {'v_range': [['7.2.1', '']], 'required': True, 'type': 'str'},
268 'os': {'v_range': [['7.2.1', '']], 'type': 'str'},
269 'src': {'v_range': [['7.2.1', '']], 'type': 'str'},
270 'ssid-policy': {'v_range': [['7.2.1', '']], 'type': 'str'},
271 'status': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
272 'sw-version': {'v_range': [['7.2.1', '']], 'type': 'str'},
273 'type': {'v_range': [['7.2.1', '']], 'type': 'str'},
274 'user': {'v_range': [['7.2.1', '']], 'type': 'str'},
275 'user-group': {'v_range': [['7.2.1', '']], 'type': 'str'},
276 'severity': {'v_range': [['7.4.0', '']], 'type': 'raw'},
277 'firewall-address': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
278 'fortivoice-tag': {'v_range': [['7.4.3', '']], 'type': 'raw'},
279 'match-period': {'v_range': [['7.4.3', '']], 'type': 'int'},
280 'match-type': {'v_range': [['7.4.3', '']], 'choices': ['dynamic', 'override'], 'type': 'str'},
281 'switch-fortilink': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
282 'switch-group': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
283 'switch-mac-policy': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
284 'switch-scope': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
285 'switch-port-policy': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'type': 'raw'},
286 'switch-auto-auth': {'v_range': [['7.2.6', '7.2.12'], ['7.4.3', '']], 'choices': ['disable', 'enable', 'global'], 'type': 'str'},
287 'match-remove': {'v_range': [['7.6.3', '']], 'choices': ['link-down', 'default'], 'type': 'str'}
288 }
289 }
290 }
291
292 module_option_spec = get_module_arg_spec('full crud')
293 module_arg_spec.update(module_option_spec)
294 check_galaxy_version(module_arg_spec)
295 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pkg_user_nacpolicy'),
296 supports_check_mode=True)
297 if not module._socket_path:
298 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
299 connection = Connection(module._socket_path)
300 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
301 'name', 'data', module, connection)
302 fmgr.process_crud()
303 module.exit_json(meta=module.params)
304
305
306 if __name__ == '__main__':
307 main()