Debian Codegraph @

ansible_collections/fortinet/fortios/plugins/modules/fortios_router_ripng.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_router_ripng
23 short_description: Configure RIPng 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 router feature and ripng 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 router_ripng:
80 description:
81 - Configure RIPng.
82 default: null
83 type: dict
84 suboptions:
85 aggregate_address:
86 description:
87 - Aggregate address.
88 type: list
89 elements: dict
90 suboptions:
91 id:
92 description:
93 - Aggregate address entry ID. see <a href='#notes'>Notes</a>.
94 required: true
95 type: int
96 prefix6:
97 description:
98 - Aggregate address prefix.
99 type: str
100 default_information_originate:
101 description:
102 - Enable/disable generation of default route.
103 type: str
104 choices:
105 - 'enable'
106 - 'disable'
107 default_metric:
108 description:
109 - Default metric.
110 type: int
111 distance:
112 description:
113 - Distance.
114 type: list
115 elements: dict
116 suboptions:
117 access_list6:
118 description:
119 - Access list for route destination. Source router.access-list6.name.
120 type: str
121 distance:
122 description:
123 - Distance (1 - 255).
124 type: int
125 id:
126 description:
127 - Distance ID. see <a href='#notes'>Notes</a>.
128 required: true
129 type: int
130 prefix6:
131 description:
132 - Distance prefix6.
133 type: str
134 distribute_list:
135 description:
136 - Distribute list.
137 type: list
138 elements: dict
139 suboptions:
140 direction:
141 description:
142 - Distribute list direction.
143 type: str
144 choices:
145 - 'in'
146 - 'out'
147 id:
148 description:
149 - Distribute list ID. see <a href='#notes'>Notes</a>.
150 required: true
151 type: int
152 interface:
153 description:
154 - Distribute list interface name. Source system.interface.name.
155 type: str
156 listname:
157 description:
158 - Distribute access/prefix list name. Source router.access-list6.name router.prefix-list6.name.
159 type: str
160 status:
161 description:
162 - Status.
163 type: str
164 choices:
165 - 'enable'
166 - 'disable'
167 garbage_timer:
168 description:
169 - Garbage timer in seconds.
170 type: int
171 interface:
172 description:
173 - RIPng interface configuration.
174 type: list
175 elements: dict
176 suboptions:
177 flags:
178 description:
179 - Flags.
180 type: int
181 name:
182 description:
183 - Interface name. Source system.interface.name.
184 required: true
185 type: str
186 split_horizon:
187 description:
188 - Enable/disable split horizon.
189 type: str
190 choices:
191 - 'poisoned'
192 - 'regular'
193 split_horizon_status:
194 description:
195 - Enable/disable split horizon.
196 type: str
197 choices:
198 - 'enable'
199 - 'disable'
200 max_out_metric:
201 description:
202 - Maximum metric allowed to output(0 means "not set").
203 type: int
204 neighbor:
205 description:
206 - Neighbor.
207 type: list
208 elements: dict
209 suboptions:
210 id:
211 description:
212 - Neighbor entry ID. see <a href='#notes'>Notes</a>.
213 required: true
214 type: int
215 interface:
216 description:
217 - Interface name. Source system.interface.name.
218 type: str
219 ip6:
220 description:
221 - IPv6 link-local address.
222 type: str
223 network:
224 description:
225 - Network.
226 type: list
227 elements: dict
228 suboptions:
229 id:
230 description:
231 - Network entry ID. see <a href='#notes'>Notes</a>.
232 required: true
233 type: int
234 prefix:
235 description:
236 - Network IPv6 link-local prefix.
237 type: str
238 offset_list:
239 description:
240 - Offset list.
241 type: list
242 elements: dict
243 suboptions:
244 access_list6:
245 description:
246 - IPv6 access list name. Source router.access-list6.name.
247 type: str
248 direction:
249 description:
250 - Offset list direction.
251 type: str
252 choices:
253 - 'in'
254 - 'out'
255 id:
256 description:
257 - Offset-list ID. see <a href='#notes'>Notes</a>.
258 required: true
259 type: int
260 interface:
261 description:
262 - Interface name. Source system.interface.name.
263 type: str
264 offset:
265 description:
266 - Offset.
267 type: int
268 status:
269 description:
270 - Status.
271 type: str
272 choices:
273 - 'enable'
274 - 'disable'
275 passive_interface:
276 description:
277 - Passive interface configuration.
278 type: list
279 elements: dict
280 suboptions:
281 name:
282 description:
283 - Passive interface name. Source system.interface.name.
284 required: true
285 type: str
286 redistribute:
287 description:
288 - Redistribute configuration.
289 type: list
290 elements: dict
291 suboptions:
292 metric:
293 description:
294 - Redistribute metric setting.
295 type: int
296 name:
297 description:
298 - Redistribute name.
299 required: true
300 type: str
301 routemap:
302 description:
303 - Route map name. Source router.route-map.name.
304 type: str
305 status:
306 description:
307 - Status.
308 type: str
309 choices:
310 - 'enable'
311 - 'disable'
312 timeout_timer:
313 description:
314 - Timeout timer in seconds.
315 type: int
316 update_timer:
317 description:
318 - Update timer in seconds.
319 type: int
320 """
321
322 EXAMPLES = """
323 - name: Configure RIPng.
324 fortinet.fortios.fortios_router_ripng:
325 vdom: "{{ vdom }}"
326 router_ripng:
327 aggregate_address:
328 -
329 id: "4"
330 prefix6: "<your_own_value>"
331 default_information_originate: "enable"
332 default_metric: "1"
333 distance:
334 -
335 access_list6: "<your_own_value> (source router.access-list6.name)"
336 distance: "0"
337 id: "11"
338 prefix6: "<your_own_value>"
339 distribute_list:
340 -
341 direction: "in"
342 id: "15"
343 interface: "<your_own_value> (source system.interface.name)"
344 listname: "<your_own_value> (source router.access-list6.name router.prefix-list6.name)"
345 status: "enable"
346 garbage_timer: "120"
347 interface:
348 -
349 flags: "8"
350 name: "default_name_22 (source system.interface.name)"
351 split_horizon: "poisoned"
352 split_horizon_status: "enable"
353 max_out_metric: "0"
354 neighbor:
355 -
356 id: "27"
357 interface: "<your_own_value> (source system.interface.name)"
358 ip6: "<your_own_value>"
359 network:
360 -
361 id: "31"
362 prefix: "<your_own_value>"
363 offset_list:
364 -
365 access_list6: "<your_own_value> (source router.access-list6.name)"
366 direction: "in"
367 id: "36"
368 interface: "<your_own_value> (source system.interface.name)"
369 offset: "0"
370 status: "enable"
371 passive_interface:
372 -
373 name: "default_name_41 (source system.interface.name)"
374 redistribute:
375 -
376 metric: "0"
377 name: "default_name_44"
378 routemap: "<your_own_value> (source router.route-map.name)"
379 status: "enable"
380 timeout_timer: "180"
381 update_timer: "30"
382 """
383
384 RETURN = """
385 build:
386 description: Build number of the fortigate image
387 returned: always
388 type: str
389 sample: '1547'
390 http_method:
391 description: Last method used to provision the content into FortiGate
392 returned: always
393 type: str
394 sample: 'PUT'
395 http_status:
396 description: Last result given by FortiGate on last operation applied
397 returned: always
398 type: str
399 sample: "200"
400 mkey:
401 description: Master key (id) used in the last call to FortiGate
402 returned: success
403 type: str
404 sample: "id"
405 name:
406 description: Name of the table used to fulfill the request
407 returned: always
408 type: str
409 sample: "urlfilter"
410 path:
411 description: Path of the table used to fulfill the request
412 returned: always
413 type: str
414 sample: "webfilter"
415 revision:
416 description: Internal revision number
417 returned: always
418 type: str
419 sample: "17.0.2.10658"
420 serial:
421 description: Serial number of the unit
422 returned: always
423 type: str
424 sample: "FGVMEVYYQT3AB5352"
425 status:
426 description: Indication of the operation's result
427 returned: always
428 type: str
429 sample: "success"
430 vdom:
431 description: Virtual domain used
432 returned: always
433 type: str
434 sample: "root"
435 version:
436 description: Version of the FortiGate
437 returned: always
438 type: str
439 sample: "v5.6.3"
440 """
441 from ansible.module_utils.basic import AnsibleModule
442 from ansible.module_utils.connection import Connection
443 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
444 FortiOSHandler,
445 )
446 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
447 check_legacy_fortiosapi,
448 )
449 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
450 schema_to_module_spec,
451 )
452 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
453 check_schema_versioning,
454 )
455 from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.common import (
456 FAIL_SOCKET_MSG,
457 )
458 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.data_post_processor import (
459 remove_invalid_fields,
460 )
461 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
462 is_same_comparison,
463 )
464 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
465 serialize,
466 )
467 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
468 find_current_values,
469 )
470 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
471 unify_data_format,
472 )
473
474
475 def filter_router_ripng_data(json):
476 option_list = [
477 "aggregate_address",
478 "default_information_originate",
479 "default_metric",
480 "distance",
481 "distribute_list",
482 "garbage_timer",
483 "interface",
484 "max_out_metric",
485 "neighbor",
486 "network",
487 "offset_list",
488 "passive_interface",
489 "redistribute",
490 "timeout_timer",
491 "update_timer",
492 ]
493
494 json = remove_invalid_fields(json)
495 dictionary = {}
496
497 for attribute in option_list:
498 if attribute in json and json[attribute] is not None:
499 dictionary[attribute] = json[attribute]
500
501 return dictionary
502
503
504 def underscore_to_hyphen(data):
505 new_data = None
506 if isinstance(data, list):
507 new_data = []
508 for i, elem in enumerate(data):
509 new_data.append(underscore_to_hyphen(elem))
510 elif isinstance(data, dict):
511 new_data = {}
512 for k, v in data.items():
513 new_data[k.replace("_", "-")] = underscore_to_hyphen(v)
514 else:
515 return data
516 return new_data
517
518
519 def router_ripng(data, fos, check_mode=False):
520
521 state = None
522 vdom = data["vdom"]
523 parameters = None
524 state = data.get("state", None)
525 router_ripng_data = data["router_ripng"]
526
527 filtered_data = filter_router_ripng_data(router_ripng_data)
528 converted_data = underscore_to_hyphen(filtered_data)
529
530 # check_mode starts from here
531 if check_mode:
532 diff = {
533 "before": "",
534 "after": filtered_data,
535 }
536 mkeyname = fos.get_mkeyname(None, None)
537 mkey = fos.get_mkey("router", "ripng", filtered_data, vdom=vdom)
538 current_data = fos.get(
539 "router", "ripng", vdom=vdom, mkey=mkey, parameters=parameters
540 )
541 is_existed = (
542 current_data
543 and current_data.get("http_status") == 200
544 and (
545 mkeyname
546 and isinstance(current_data.get("results"), list)
547 and len(current_data["results"]) > 0
548 or not mkeyname
549 and current_data["results"] # global object response
550 )
551 )
552
553 # 2. if it exists and the state is 'present' then compare current settings with desired
554 if state == "present" or state is True or state is None:
555 # for non global modules, mkeyname must exist and it's a new module when mkey is None
556 if mkeyname is not None and mkey is None:
557 return False, True, filtered_data, diff
558
559 # if mkey exists then compare each other
560 # record exits and they're matched or not
561 copied_filtered_data = filtered_data.copy()
562 copied_filtered_data.pop(mkeyname, None)
563 unified_filtered_data = unify_data_format(copied_filtered_data)
564
565 current_data_results = current_data.get("results", {})
566 current_config = (
567 current_data_results[0]
568 if mkeyname
569 and isinstance(current_data_results, list)
570 and len(current_data_results) > 0
571 else current_data_results
572 )
573 if is_existed:
574 unified_current_values = find_current_values(
575 unified_filtered_data,
576 unify_data_format(current_config),
577 )
578
579 is_same = is_same_comparison(
580 serialize(unified_current_values), serialize(unified_filtered_data)
581 )
582
583 return (
584 False,
585 not is_same,
586 filtered_data,
587 {"before": unified_current_values, "after": unified_filtered_data},
588 )
589
590 # record does not exist
591 return False, True, filtered_data, diff
592
593 if state == "absent":
594 if mkey is None:
595 return (
596 False,
597 False,
598 filtered_data,
599 {"before": current_data["results"][0], "after": ""},
600 )
601
602 if is_existed:
603 return (
604 False,
605 True,
606 filtered_data,
607 {"before": current_data["results"][0], "after": ""},
608 )
609 return False, False, filtered_data, {}
610
611 return True, False, {"reason: ": "Must provide state parameter"}, {}
612 # pass post processed data to member operations
613 # no need to do underscore_to_hyphen since do_member_operation handles it by itself
614 data_copy = data.copy()
615 data_copy["router_ripng"] = filtered_data
616 fos.do_member_operation(
617 "router",
618 "ripng",
619 data_copy,
620 )
621
622 return fos.set(
623 "router", "ripng", data=converted_data, vdom=vdom, parameters=parameters
624 )
625
626
627 def is_successful_status(resp):
628 return (
629 "status" in resp
630 and resp["status"] == "success"
631 or "http_status" in resp
632 and resp["http_status"] == 200
633 or "http_method" in resp
634 and resp["http_method"] == "DELETE"
635 and resp["http_status"] == 404
636 )
637
638
639 def fortios_router(data, fos, check_mode):
640
641 if data["router_ripng"]:
642 resp = router_ripng(data, fos, check_mode)
643 else:
644 fos._module.fail_json(msg="missing task body: %s" % ("router_ripng"))
645 if isinstance(resp, tuple) and len(resp) == 4:
646 return resp
647 return (
648 not is_successful_status(resp),
649 is_successful_status(resp)
650 and (resp["revision_changed"] if "revision_changed" in resp else True),
651 resp,
652 {},
653 )
654
655
656 versioned_schema = {
657 "v_range": [["v6.0.0", ""]],
658 "type": "dict",
659 "children": {
660 "default_information_originate": {
661 "v_range": [["v6.0.0", ""]],
662 "type": "string",
663 "options": [{"value": "enable"}, {"value": "disable"}],
664 },
665 "default_metric": {"v_range": [["v6.0.0", ""]], "type": "integer"},
666 "max_out_metric": {"v_range": [["v6.0.0", ""]], "type": "integer"},
667 "distance": {
668 "type": "list",
669 "elements": "dict",
670 "children": {
671 "id": {
672 "v_range": [["v6.0.0", ""]],
673 "type": "integer",
674 "required": True,
675 },
676 "distance": {"v_range": [["v6.0.0", ""]], "type": "integer"},
677 "prefix6": {"v_range": [["v6.0.0", ""]], "type": "string"},
678 "access_list6": {"v_range": [["v6.0.0", ""]], "type": "string"},
679 },
680 "v_range": [["v6.0.0", ""]],
681 },
682 "distribute_list": {
683 "type": "list",
684 "elements": "dict",
685 "children": {
686 "id": {
687 "v_range": [["v6.0.0", ""]],
688 "type": "integer",
689 "required": True,
690 },
691 "status": {
692 "v_range": [["v6.0.0", ""]],
693 "type": "string",
694 "options": [{"value": "enable"}, {"value": "disable"}],
695 },
696 "direction": {
697 "v_range": [["v6.0.0", ""]],
698 "type": "string",
699 "options": [{"value": "in"}, {"value": "out"}],
700 },
701 "listname": {"v_range": [["v6.0.0", ""]], "type": "string"},
702 "interface": {"v_range": [["v6.0.0", ""]], "type": "string"},
703 },
704 "v_range": [["v6.0.0", ""]],
705 },
706 "neighbor": {
707 "type": "list",
708 "elements": "dict",
709 "children": {
710 "id": {
711 "v_range": [["v6.0.0", ""]],
712 "type": "integer",
713 "required": True,
714 },
715 "ip6": {"v_range": [["v6.0.0", ""]], "type": "string"},
716 "interface": {"v_range": [["v6.0.0", ""]], "type": "string"},
717 },
718 "v_range": [["v6.0.0", ""]],
719 },
720 "network": {
721 "type": "list",
722 "elements": "dict",
723 "children": {
724 "id": {
725 "v_range": [["v6.0.0", ""]],
726 "type": "integer",
727 "required": True,
728 },
729 "prefix": {"v_range": [["v6.0.0", ""]], "type": "string"},
730 },
731 "v_range": [["v6.0.0", ""]],
732 },
733 "aggregate_address": {
734 "type": "list",
735 "elements": "dict",
736 "children": {
737 "id": {
738 "v_range": [["v6.0.0", ""]],
739 "type": "integer",
740 "required": True,
741 },
742 "prefix6": {"v_range": [["v6.0.0", ""]], "type": "string"},
743 },
744 "v_range": [["v6.0.0", ""]],
745 },
746 "offset_list": {
747 "type": "list",
748 "elements": "dict",
749 "children": {
750 "id": {
751 "v_range": [["v6.0.0", ""]],
752 "type": "integer",
753 "required": True,
754 },
755 "status": {
756 "v_range": [["v6.0.0", ""]],
757 "type": "string",
758 "options": [{"value": "enable"}, {"value": "disable"}],
759 },
760 "direction": {
761 "v_range": [["v6.0.0", ""]],
762 "type": "string",
763 "options": [{"value": "in"}, {"value": "out"}],
764 },
765 "access_list6": {"v_range": [["v6.0.0", ""]], "type": "string"},
766 "offset": {"v_range": [["v6.0.0", ""]], "type": "integer"},
767 "interface": {"v_range": [["v6.0.0", ""]], "type": "string"},
768 },
769 "v_range": [["v6.0.0", ""]],
770 },
771 "passive_interface": {
772 "type": "list",
773 "elements": "dict",
774 "children": {
775 "name": {
776 "v_range": [["v6.0.0", ""]],
777 "type": "string",
778 "required": True,
779 }
780 },
781 "v_range": [["v6.0.0", ""]],
782 },
783 "update_timer": {"v_range": [["v6.0.0", ""]], "type": "integer"},
784 "timeout_timer": {"v_range": [["v6.0.0", ""]], "type": "integer"},
785 "garbage_timer": {"v_range": [["v6.0.0", ""]], "type": "integer"},
786 "interface": {
787 "type": "list",
788 "elements": "dict",
789 "children": {
790 "name": {
791 "v_range": [["v6.0.0", ""]],
792 "type": "string",
793 "required": True,
794 },
795 "split_horizon_status": {
796 "v_range": [["v6.0.0", ""]],
797 "type": "string",
798 "options": [{"value": "enable"}, {"value": "disable"}],
799 },
800 "split_horizon": {
801 "v_range": [["v6.0.0", ""]],
802 "type": "string",
803 "options": [{"value": "poisoned"}, {"value": "regular"}],
804 },
805 "flags": {
806 "v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]],
807 "type": "integer",
808 },
809 },
810 "v_range": [["v6.0.0", ""]],
811 },
812 "redistribute": {
813 "type": "list",
814 "elements": "dict",
815 "children": {
816 "name": {
817 "v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]],
818 "type": "string",
819 "required": True,
820 },
821 "status": {
822 "v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]],
823 "type": "string",
824 "options": [{"value": "enable"}, {"value": "disable"}],
825 },
826 "metric": {
827 "v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]],
828 "type": "integer",
829 },
830 "routemap": {
831 "v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]],
832 "type": "string",
833 },
834 },
835 "v_range": [["v6.0.0", "v7.0.5"], ["v7.2.0", "v7.2.0"]],
836 },
837 },
838 }
839
840
841 def main():
842 module_spec = schema_to_module_spec(versioned_schema)
843 mkeyname = None
844 fields = {
845 "access_token": {"required": False, "type": "str", "no_log": True},
846 "enable_log": {"required": False, "type": "bool", "default": False},
847 "vdom": {"required": False, "type": "str", "default": "root"},
848 "member_path": {"required": False, "type": "str"},
849 "member_state": {
850 "type": "str",
851 "required": False,
852 "choices": ["present", "absent"],
853 },
854 "router_ripng": {
855 "required": False,
856 "type": "dict",
857 "default": None,
858 "options": {},
859 },
860 }
861 for attribute_name in module_spec["options"]:
862 fields["router_ripng"]["options"][attribute_name] = module_spec["options"][
863 attribute_name
864 ]
865 if mkeyname and mkeyname == attribute_name:
866 fields["router_ripng"]["options"][attribute_name]["required"] = True
867
868 module = AnsibleModule(argument_spec=fields, supports_check_mode=True)
869 check_legacy_fortiosapi(module)
870
871 is_error = False
872 has_changed = False
873 result = None
874 diff = None
875
876 versions_check_result = None
877 if module._socket_path:
878 connection = Connection(module._socket_path)
879 if "access_token" in module.params:
880 connection.set_custom_option("access_token", module.params["access_token"])
881
882 if "enable_log" in module.params:
883 connection.set_custom_option("enable_log", module.params["enable_log"])
884 else:
885 connection.set_custom_option("enable_log", False)
886 fos = FortiOSHandler(connection, module, mkeyname, admin_passwd_header=False)
887 versions_check_result = check_schema_versioning(
888 fos, versioned_schema, "router_ripng"
889 )
890
891 is_error, has_changed, result, diff = fortios_router(
892 module.params, fos, module.check_mode
893 )
894
895 else:
896 module.fail_json(**FAIL_SOCKET_MSG)
897
898 if versions_check_result and versions_check_result["matched"] is False:
899 module.warn(
900 "Ansible has detected version mismatch between FortOS system and your playbook, see more details by specifying option -vvv"
901 )
902
903 if not is_error:
904 if versions_check_result and versions_check_result["matched"] is False:
905 module.exit_json(
906 changed=has_changed,
907 version_check_warning=versions_check_result,
908 meta=result,
909 diff=diff,
910 )
911 else:
912 module.exit_json(changed=has_changed, meta=result, diff=diff)
913 else:
914 if versions_check_result and versions_check_result["matched"] is False:
915 module.fail_json(
916 msg="Error in repo",
917 version_check_warning=versions_check_result,
918 meta=result,
919 )
920 else:
921 module.fail_json(msg="Error in repo", meta=result)
922
923
924 if __name__ == "__main__":
925 main()