Debian Codegraph @

ansible_collections/fortinet/fortios/plugins/modules/fortios_user_group.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3
4 # Copyright: (c) 2022 Fortinet
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 __metaclass__ = type
13
14 ANSIBLE_METADATA = {
15 "status": ["preview"],
16 "supported_by": "community",
17 "metadata_version": "1.1",
18 }
19
20 DOCUMENTATION = """
21 ---
22 module: fortios_user_group
23 short_description: Configure user groups in Fortinet's FortiOS and FortiGate.
24 description:
25 - This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the
26 user to set and modify user feature and group category.
27 Examples include all parameters and values need to be adjusted to datasources before usage.
28 Tested with FOS v6.0.0
29 version_added: "2.0.0"
30 author:
31 - Link Zheng (@chillancezen)
32 - Jie Xue (@JieX19)
33 - Hongbin Lu (@fgtdev-hblu)
34 - Frank Shen (@frankshen01)
35 - Miguel Angel Munoz (@mamunozgonzalez)
36 - Nicolas Thomas (@thomnico)
37 notes:
38 - Legacy fortiosapi has been deprecated, httpapi is the preferred way to run playbooks
39
40 - The module supports check_mode.
41
42 requirements:
43 - ansible>=2.16
44 options:
45 access_token:
46 description:
47 - Token-based authentication.
48 Generated from GUI of Fortigate.
49 type: str
50 required: false
51 enable_log:
52 description:
53 - Enable/Disable logging for task.
54 type: bool
55 required: false
56 default: false
57 vdom:
58 description:
59 - Virtual domain, among those defined previously. A vdom is a
60 virtual instance of the FortiGate that can be configured and
61 used as a different unit.
62 type: str
63 default: root
64 member_path:
65 type: str
66 description:
67 - Member attribute path to operate on.
68 - Delimited by a slash character if there are more than one attribute.
69 - Parameter marked with member_path is legitimate for doing member operation.
70 member_state:
71 type: str
72 description:
73 - Add or delete a member under specified attribute path.
74 - When member_state is specified, the state option is ignored.
75 choices:
76 - 'present'
77 - 'absent'
78
79 state:
80 description:
81 - Indicates whether to create or remove the object.
82 type: str
83 required: true
84 choices:
85 - 'present'
86 - 'absent'
87 user_group:
88 description:
89 - Configure user groups.
90 default: null
91 type: dict
92 suboptions:
93 auth_concurrent_override:
94 description:
95 - Enable/disable overriding the global number of concurrent authentication sessions for this user group.
96 type: str
97 choices:
98 - 'enable'
99 - 'disable'
100 auth_concurrent_value:
101 description:
102 - Maximum number of concurrent authenticated connections per user (0 - 100).
103 type: int
104 authtimeout:
105 description:
106 - Authentication timeout in minutes for this user group. 0 to use the global user setting auth-timeout.
107 type: int
108 company:
109 description:
110 - Set the action for the company guest user field.
111 type: str
112 choices:
113 - 'optional'
114 - 'mandatory'
115 - 'disabled'
116 email:
117 description:
118 - Enable/disable the guest user email address field.
119 type: str
120 choices:
121 - 'disable'
122 - 'enable'
123 expire:
124 description:
125 - Time in seconds before guest user accounts expire (1 - 31536000).
126 type: int
127 expire_type:
128 description:
129 - Determine when the expiration countdown begins.
130 type: str
131 choices:
132 - 'immediately'
133 - 'first-successful-login'
134 group_type:
135 description:
136 - Set the group to be for firewall authentication, FSSO, RSSO, or guest users.
137 type: str
138 choices:
139 - 'firewall'
140 - 'fsso-service'
141 - 'rsso'
142 - 'guest'
143 guest:
144 description:
145 - Guest User.
146 type: list
147 elements: dict
148 suboptions:
149 comment:
150 description:
151 - Comment.
152 type: str
153 company:
154 description:
155 - Set the action for the company guest user field.
156 type: str
157 email:
158 description:
159 - Email.
160 type: str
161 expiration:
162 description:
163 - Expire time.
164 type: str
165 id:
166 description:
167 - Guest ID. see <a href='#notes'>Notes</a>.
168 required: true
169 type: int
170 mobile_phone:
171 description:
172 - Mobile phone.
173 type: str
174 name:
175 description:
176 - Guest name.
177 type: str
178 password:
179 description:
180 - Guest password.
181 type: str
182 sponsor:
183 description:
184 - Set the action for the sponsor guest user field.
185 type: str
186 user_id:
187 description:
188 - Guest ID.
189 type: str
190 http_digest_realm:
191 description:
192 - Realm attribute for MD5-digest authentication.
193 type: str
194 id:
195 description:
196 - Group ID.
197 type: int
198 match:
199 description:
200 - Group matches.
201 type: list
202 elements: dict
203 suboptions:
204 group_name:
205 description:
206 - Name of matching user or group on remote authentication server or SCIM.
207 type: str
208 id:
209 description:
210 - ID. see <a href='#notes'>Notes</a>.
211 required: true
212 type: int
213 server_name:
214 description:
215 - Name of remote auth server. Source user.radius.name user.ldap.name user.tacacs+.name user.saml.name user
216 .external-identity-provider.name.
217 type: str
218 max_accounts:
219 description:
220 - Maximum number of guest accounts that can be created for this group (0 means unlimited).
221 type: int
222 member:
223 description:
224 - Names of users, peers, LDAP severs, RADIUS servers or external idp servers to add to the user group.
225 type: list
226 elements: dict
227 suboptions:
228 name:
229 description:
230 - Group member name. Source user.peer.name user.local.name user.radius.name user.tacacs+.name user.ldap.name user.saml.name user
231 .external-identity-provider.name user.adgrp.name user.pop3.name user.certificate.name.
232 required: true
233 type: str
234 mobile_phone:
235 description:
236 - Enable/disable the guest user mobile phone number field.
237 type: str
238 choices:
239 - 'disable'
240 - 'enable'
241 multiple_guest_add:
242 description:
243 - Enable/disable addition of multiple guests.
244 type: str
245 choices:
246 - 'disable'
247 - 'enable'
248 name:
249 description:
250 - Group name.
251 required: true
252 type: str
253 password:
254 description:
255 - Guest user password type.
256 type: str
257 choices:
258 - 'auto-generate'
259 - 'specify'
260 - 'disable'
261 sms_custom_server:
262 description:
263 - SMS server. Source system.sms-server.name.
264 type: str
265 sms_server:
266 description:
267 - Send SMS through FortiGuard or other external server.
268 type: str
269 choices:
270 - 'fortiguard'
271 - 'custom'
272 sponsor:
273 description:
274 - Set the action for the sponsor guest user field.
275 type: str
276 choices:
277 - 'optional'
278 - 'mandatory'
279 - 'disabled'
280 sso_attribute_value:
281 description:
282 - RADIUS attribute value.
283 type: str
284 user_id:
285 description:
286 - Guest user ID type.
287 type: str
288 choices:
289 - 'email'
290 - 'auto-generate'
291 - 'specify'
292 user_name:
293 description:
294 - Enable/disable the guest user name entry.
295 type: str
296 choices:
297 - 'disable'
298 - 'enable'
299 """
300
301 EXAMPLES = """
302 - name: Configure user groups.
303 fortinet.fortios.fortios_user_group:
304 vdom: "{{ vdom }}"
305 state: "present"
306 access_token: "<your_own_value>"
307 user_group:
308 auth_concurrent_override: "enable"
309 auth_concurrent_value: "0"
310 authtimeout: "0"
311 company: "optional"
312 email: "disable"
313 expire: "14400"
314 expire_type: "immediately"
315 group_type: "firewall"
316 guest:
317 -
318 comment: "Comment."
319 company: "<your_own_value>"
320 email: "<your_own_value>"
321 expiration: "<your_own_value>"
322 id: "16"
323 mobile_phone: "<your_own_value>"
324 name: "default_name_18"
325 password: "<your_own_value>"
326 sponsor: "<your_own_value>"
327 user_id: "<your_own_value>"
328 http_digest_realm: "<your_own_value>"
329 id: "23"
330 match:
331 -
332 group_name: "<your_own_value>"
333 id: "26"
334 server_name: "<your_own_value> (source user.radius.name user.ldap.name user.tacacs+.name user.saml.name user.external-identity-provider
335 .name)"
336 max_accounts: "0"
337 member:
338 -
339 name: "default_name_30 (source user.peer.name user.local.name user.radius.name user.tacacs+.name user.ldap.name user.saml.name user
340 .external-identity-provider.name user.adgrp.name user.pop3.name user.certificate.name)"
341 mobile_phone: "disable"
342 multiple_guest_add: "disable"
343 name: "default_name_33"
344 password: "auto-generate"
345 sms_custom_server: "<your_own_value> (source system.sms-server.name)"
346 sms_server: "fortiguard"
347 sponsor: "optional"
348 sso_attribute_value: "<your_own_value>"
349 user_id: "email"
350 user_name: "disable"
351 """
352
353 RETURN = """
354 build:
355 description: Build number of the fortigate image
356 returned: always
357 type: str
358 sample: '1547'
359 http_method:
360 description: Last method used to provision the content into FortiGate
361 returned: always
362 type: str
363 sample: 'PUT'
364 http_status:
365 description: Last result given by FortiGate on last operation applied
366 returned: always
367 type: str
368 sample: "200"
369 mkey:
370 description: Master key (id) used in the last call to FortiGate
371 returned: success
372 type: str
373 sample: "id"
374 name:
375 description: Name of the table used to fulfill the request
376 returned: always
377 type: str
378 sample: "urlfilter"
379 path:
380 description: Path of the table used to fulfill the request
381 returned: always
382 type: str
383 sample: "webfilter"
384 revision:
385 description: Internal revision number
386 returned: always
387 type: str
388 sample: "17.0.2.10658"
389 serial:
390 description: Serial number of the unit
391 returned: always
392 type: str
393 sample: "FGVMEVYYQT3AB5352"
394 status:
395 description: Indication of the operation's result
396 returned: always
397 type: str
398 sample: "success"
399 vdom:
400 description: Virtual domain used
401 returned: always
402 type: str
403 sample: "root"
404 version:
405 description: Version of the FortiGate
406 returned: always
407 type: str
408 sample: "v5.6.3"
409 """
410 from ansible.module_utils.basic import AnsibleModule
411 from ansible.module_utils.connection import Connection
412 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
413 FortiOSHandler,
414 )
415 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
416 check_legacy_fortiosapi,
417 )
418 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
419 schema_to_module_spec,
420 )
421 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
422 check_schema_versioning,
423 )
424 from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.common import (
425 FAIL_SOCKET_MSG,
426 )
427 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.data_post_processor import (
428 remove_invalid_fields,
429 )
430 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
431 is_same_comparison,
432 )
433 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
434 serialize,
435 )
436 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
437 find_current_values,
438 )
439 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
440 unify_data_format,
441 )
442
443
444 def filter_user_group_data(json):
445 option_list = [
446 "auth_concurrent_override",
447 "auth_concurrent_value",
448 "authtimeout",
449 "company",
450 "email",
451 "expire",
452 "expire_type",
453 "group_type",
454 "guest",
455 "http_digest_realm",
456 "id",
457 "match",
458 "max_accounts",
459 "member",
460 "mobile_phone",
461 "multiple_guest_add",
462 "name",
463 "password",
464 "sms_custom_server",
465 "sms_server",
466 "sponsor",
467 "sso_attribute_value",
468 "user_id",
469 "user_name",
470 ]
471
472 json = remove_invalid_fields(json)
473 dictionary = {}
474
475 for attribute in option_list:
476 if attribute in json and json[attribute] is not None:
477 dictionary[attribute] = json[attribute]
478
479 return dictionary
480
481
482 def underscore_to_hyphen(data):
483 new_data = None
484 if isinstance(data, list):
485 new_data = []
486 for i, elem in enumerate(data):
487 new_data.append(underscore_to_hyphen(elem))
488 elif isinstance(data, dict):
489 new_data = {}
490 for k, v in data.items():
491 new_data[k.replace("_", "-")] = underscore_to_hyphen(v)
492 else:
493 return data
494 return new_data
495
496
497 def user_group(data, fos, check_mode=False):
498
499 state = None
500 vdom = data["vdom"]
501 parameters = None
502 state = data.get("state", None)
503 user_group_data = data["user_group"]
504
505 filtered_data = filter_user_group_data(user_group_data)
506 converted_data = underscore_to_hyphen(filtered_data)
507
508 # check_mode starts from here
509 if check_mode:
510 diff = {
511 "before": "",
512 "after": filtered_data,
513 }
514 mkeyname = fos.get_mkeyname(None, None)
515 mkey = fos.get_mkey("user", "group", filtered_data, vdom=vdom)
516 current_data = fos.get(
517 "user", "group", vdom=vdom, mkey=mkey, parameters=parameters
518 )
519 is_existed = (
520 current_data
521 and current_data.get("http_status") == 200
522 and (
523 mkeyname
524 and isinstance(current_data.get("results"), list)
525 and len(current_data["results"]) > 0
526 or not mkeyname
527 and current_data["results"] # global object response
528 )
529 )
530
531 # 2. if it exists and the state is 'present' then compare current settings with desired
532 if state == "present" or state is True or state is None:
533 # for non global modules, mkeyname must exist and it's a new module when mkey is None
534 if mkeyname is not None and mkey is None:
535 return False, True, filtered_data, diff
536
537 # if mkey exists then compare each other
538 # record exits and they're matched or not
539 copied_filtered_data = filtered_data.copy()
540 copied_filtered_data.pop(mkeyname, None)
541 unified_filtered_data = unify_data_format(copied_filtered_data)
542
543 current_data_results = current_data.get("results", {})
544 current_config = (
545 current_data_results[0]
546 if mkeyname
547 and isinstance(current_data_results, list)
548 and len(current_data_results) > 0
549 else current_data_results
550 )
551 if is_existed:
552 unified_current_values = find_current_values(
553 unified_filtered_data,
554 unify_data_format(current_config),
555 )
556
557 is_same = is_same_comparison(
558 serialize(unified_current_values), serialize(unified_filtered_data)
559 )
560
561 return (
562 False,
563 not is_same,
564 filtered_data,
565 {"before": unified_current_values, "after": unified_filtered_data},
566 )
567
568 # record does not exist
569 return False, True, filtered_data, diff
570
571 if state == "absent":
572 if mkey is None:
573 return (
574 False,
575 False,
576 filtered_data,
577 {"before": current_data["results"][0], "after": ""},
578 )
579
580 if is_existed:
581 return (
582 False,
583 True,
584 filtered_data,
585 {"before": current_data["results"][0], "after": ""},
586 )
587 return False, False, filtered_data, {}
588
589 return True, False, {"reason: ": "Must provide state parameter"}, {}
590 # pass post processed data to member operations
591 # no need to do underscore_to_hyphen since do_member_operation handles it by itself
592 data_copy = data.copy()
593 data_copy["user_group"] = filtered_data
594 fos.do_member_operation(
595 "user",
596 "group",
597 data_copy,
598 )
599
600 if state == "present" or state is True:
601 return fos.set(
602 "user", "group", data=converted_data, vdom=vdom, parameters=parameters
603 )
604
605 elif state == "absent":
606 return fos.delete(
607 "user",
608 "group",
609 mkey=converted_data["name"],
610 vdom=vdom,
611 parameters=parameters,
612 )
613 else:
614 fos._module.fail_json(msg="state must be present or absent!")
615
616
617 def is_successful_status(resp):
618 return (
619 "status" in resp
620 and resp["status"] == "success"
621 or "http_status" in resp
622 and resp["http_status"] == 200
623 or "http_method" in resp
624 and resp["http_method"] == "DELETE"
625 and resp["http_status"] == 404
626 )
627
628
629 def fortios_user(data, fos, check_mode):
630
631 if data["user_group"]:
632 resp = user_group(data, fos, check_mode)
633 else:
634 fos._module.fail_json(msg="missing task body: %s" % ("user_group"))
635 if isinstance(resp, tuple) and len(resp) == 4:
636 return resp
637 return (
638 not is_successful_status(resp),
639 is_successful_status(resp)
640 and (resp["revision_changed"] if "revision_changed" in resp else True),
641 resp,
642 {},
643 )
644
645
646 versioned_schema = {
647 "type": "list",
648 "elements": "dict",
649 "children": {
650 "name": {"v_range": [["v6.0.0", ""]], "type": "string", "required": True},
651 "group_type": {
652 "v_range": [["v6.0.0", ""]],
653 "type": "string",
654 "options": [
655 {"value": "firewall"},
656 {"value": "fsso-service"},
657 {"value": "rsso"},
658 {"value": "guest"},
659 ],
660 },
661 "authtimeout": {"v_range": [["v6.0.0", ""]], "type": "integer"},
662 "auth_concurrent_override": {
663 "v_range": [["v6.0.0", ""]],
664 "type": "string",
665 "options": [{"value": "enable"}, {"value": "disable"}],
666 },
667 "auth_concurrent_value": {"v_range": [["v6.0.0", ""]], "type": "integer"},
668 "http_digest_realm": {"v_range": [["v6.0.0", ""]], "type": "string"},
669 "sso_attribute_value": {"v_range": [["v6.0.0", ""]], "type": "string"},
670 "member": {
671 "type": "list",
672 "elements": "dict",
673 "children": {
674 "name": {
675 "v_range": [["v6.0.0", ""]],
676 "type": "string",
677 "required": True,
678 }
679 },
680 "v_range": [["v6.0.0", ""]],
681 },
682 "match": {
683 "type": "list",
684 "elements": "dict",
685 "children": {
686 "id": {
687 "v_range": [["v6.0.0", ""]],
688 "type": "integer",
689 "required": True,
690 },
691 "server_name": {"v_range": [["v6.0.0", ""]], "type": "string"},
692 "group_name": {"v_range": [["v6.0.0", ""]], "type": "string"},
693 },
694 "v_range": [["v6.0.0", ""]],
695 },
696 "user_id": {
697 "v_range": [["v6.0.0", ""]],
698 "type": "string",
699 "options": [
700 {"value": "email"},
701 {"value": "auto-generate"},
702 {"value": "specify"},
703 ],
704 },
705 "password": {
706 "v_range": [["v6.0.0", ""]],
707 "type": "string",
708 "options": [
709 {"value": "auto-generate"},
710 {"value": "specify"},
711 {"value": "disable"},
712 ],
713 },
714 "user_name": {
715 "v_range": [["v6.0.0", ""]],
716 "type": "string",
717 "options": [{"value": "disable"}, {"value": "enable"}],
718 },
719 "sponsor": {
720 "v_range": [["v6.0.0", ""]],
721 "type": "string",
722 "options": [
723 {"value": "optional"},
724 {"value": "mandatory"},
725 {"value": "disabled"},
726 ],
727 },
728 "company": {
729 "v_range": [["v6.0.0", ""]],
730 "type": "string",
731 "options": [
732 {"value": "optional"},
733 {"value": "mandatory"},
734 {"value": "disabled"},
735 ],
736 },
737 "email": {
738 "v_range": [["v6.0.0", ""]],
739 "type": "string",
740 "options": [{"value": "disable"}, {"value": "enable"}],
741 },
742 "mobile_phone": {
743 "v_range": [["v6.0.0", ""]],
744 "type": "string",
745 "options": [{"value": "disable"}, {"value": "enable"}],
746 },
747 "sms_server": {
748 "v_range": [["v6.0.0", ""]],
749 "type": "string",
750 "options": [{"value": "fortiguard"}, {"value": "custom"}],
751 },
752 "sms_custom_server": {"v_range": [["v6.0.0", ""]], "type": "string"},
753 "expire_type": {
754 "v_range": [["v6.0.0", ""]],
755 "type": "string",
756 "options": [{"value": "immediately"}, {"value": "first-successful-login"}],
757 },
758 "expire": {"v_range": [["v6.0.0", ""]], "type": "integer"},
759 "max_accounts": {"v_range": [["v6.0.0", ""]], "type": "integer"},
760 "multiple_guest_add": {
761 "v_range": [["v6.0.0", ""]],
762 "type": "string",
763 "options": [{"value": "disable"}, {"value": "enable"}],
764 },
765 "guest": {
766 "type": "list",
767 "elements": "dict",
768 "children": {
769 "id": {
770 "v_range": [["v6.2.0", ""]],
771 "type": "integer",
772 "required": True,
773 },
774 "user_id": {"v_range": [["v6.0.0", ""]], "type": "string"},
775 "name": {"v_range": [["v6.0.0", ""]], "type": "string"},
776 "password": {"v_range": [["v6.0.0", ""]], "type": "string"},
777 "mobile_phone": {"v_range": [["v6.0.0", ""]], "type": "string"},
778 "sponsor": {"v_range": [["v6.0.0", ""]], "type": "string"},
779 "company": {"v_range": [["v6.0.0", ""]], "type": "string"},
780 "email": {"v_range": [["v6.0.0", ""]], "type": "string"},
781 "expiration": {"v_range": [["v6.0.0", ""]], "type": "string"},
782 "comment": {"v_range": [["v6.0.0", ""]], "type": "string"},
783 },
784 "v_range": [["v6.0.0", ""]],
785 },
786 "id": {
787 "v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]],
788 "type": "integer",
789 },
790 },
791 "v_range": [["v6.0.0", ""]],
792 }
793
794
795 def main():
796 module_spec = schema_to_module_spec(versioned_schema)
797 mkeyname = "name"
798 fields = {
799 "access_token": {"required": False, "type": "str", "no_log": True},
800 "enable_log": {"required": False, "type": "bool", "default": False},
801 "vdom": {"required": False, "type": "str", "default": "root"},
802 "member_path": {"required": False, "type": "str"},
803 "member_state": {
804 "type": "str",
805 "required": False,
806 "choices": ["present", "absent"],
807 },
808 "state": {"required": True, "type": "str", "choices": ["present", "absent"]},
809 "user_group": {
810 "required": False,
811 "type": "dict",
812 "default": None,
813 "options": {},
814 },
815 }
816 for attribute_name in module_spec["options"]:
817 fields["user_group"]["options"][attribute_name] = module_spec["options"][
818 attribute_name
819 ]
820 if mkeyname and mkeyname == attribute_name:
821 fields["user_group"]["options"][attribute_name]["required"] = True
822
823 module = AnsibleModule(argument_spec=fields, supports_check_mode=True)
824 check_legacy_fortiosapi(module)
825
826 is_error = False
827 has_changed = False
828 result = None
829 diff = None
830
831 versions_check_result = None
832 if module._socket_path:
833 connection = Connection(module._socket_path)
834 if "access_token" in module.params:
835 connection.set_custom_option("access_token", module.params["access_token"])
836
837 if "enable_log" in module.params:
838 connection.set_custom_option("enable_log", module.params["enable_log"])
839 else:
840 connection.set_custom_option("enable_log", False)
841 fos = FortiOSHandler(connection, module, mkeyname, admin_passwd_header=False)
842 versions_check_result = check_schema_versioning(
843 fos, versioned_schema, "user_group"
844 )
845
846 is_error, has_changed, result, diff = fortios_user(
847 module.params, fos, module.check_mode
848 )
849
850 else:
851 module.fail_json(**FAIL_SOCKET_MSG)
852
853 if versions_check_result and versions_check_result["matched"] is False:
854 module.warn(
855 "Ansible has detected version mismatch between FortOS system and your playbook, see more details by specifying option -vvv"
856 )
857
858 if not is_error:
859 if versions_check_result and versions_check_result["matched"] is False:
860 module.exit_json(
861 changed=has_changed,
862 version_check_warning=versions_check_result,
863 meta=result,
864 diff=diff,
865 )
866 else:
867 module.exit_json(changed=has_changed, meta=result, diff=diff)
868 else:
869 if versions_check_result and versions_check_result["matched"] is False:
870 module.fail_json(
871 msg="Error in repo",
872 version_check_warning=versions_check_result,
873 meta=result,
874 )
875 else:
876 module.fail_json(msg="Error in repo", meta=result)
877
878
879 if __name__ == "__main__":
880 main()