Debian Codegraph @

ansible_collections/fortinet/fortios/plugins/modules/fortios_voip_profile.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_voip_profile
23 short_description: Configure VoIP profiles 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 voip feature and profile 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 voip_profile:
88 description:
89 - Configure VoIP profiles.
90 default: null
91 type: dict
92 suboptions:
93 comment:
94 description:
95 - Comment.
96 type: str
97 feature_set:
98 description:
99 - IPS or voipd (SIP-ALG) inspection feature set.
100 type: str
101 choices:
102 - 'ips'
103 - 'voipd'
104 - 'flow'
105 - 'proxy'
106 msrp:
107 description:
108 - MSRP.
109 type: dict
110 suboptions:
111 log_violations:
112 description:
113 - Enable/disable logging of MSRP violations.
114 type: str
115 choices:
116 - 'disable'
117 - 'enable'
118 max_msg_size:
119 description:
120 - Maximum allowable MSRP message size (1-65535).
121 type: int
122 max_msg_size_action:
123 description:
124 - Action for violation of max-msg-size.
125 type: str
126 choices:
127 - 'pass'
128 - 'block'
129 - 'reset'
130 - 'monitor'
131 status:
132 description:
133 - Enable/disable MSRP.
134 type: str
135 choices:
136 - 'disable'
137 - 'enable'
138 name:
139 description:
140 - Profile name.
141 required: true
142 type: str
143 sccp:
144 description:
145 - SCCP.
146 type: dict
147 suboptions:
148 block_mcast:
149 description:
150 - Enable/disable block multicast RTP connections.
151 type: str
152 choices:
153 - 'disable'
154 - 'enable'
155 log_call_summary:
156 description:
157 - Enable/disable log summary of SCCP calls.
158 type: str
159 choices:
160 - 'disable'
161 - 'enable'
162 log_violations:
163 description:
164 - Enable/disable logging of SCCP violations.
165 type: str
166 choices:
167 - 'disable'
168 - 'enable'
169 max_calls:
170 description:
171 - Maximum calls per minute per SCCP client (max 65535).
172 type: int
173 status:
174 description:
175 - Enable/disable SCCP.
176 type: str
177 choices:
178 - 'disable'
179 - 'enable'
180 verify_header:
181 description:
182 - Enable/disable verify SCCP header content.
183 type: str
184 choices:
185 - 'disable'
186 - 'enable'
187 sip:
188 description:
189 - SIP.
190 type: dict
191 suboptions:
192 ack_rate:
193 description:
194 - ACK request rate limit (per second, per policy).
195 type: int
196 ack_rate_track:
197 description:
198 - Track the packet protocol field.
199 type: str
200 choices:
201 - 'none'
202 - 'src-ip'
203 - 'dest-ip'
204 block_ack:
205 description:
206 - Enable/disable block ACK requests.
207 type: str
208 choices:
209 - 'disable'
210 - 'enable'
211 block_bye:
212 description:
213 - Enable/disable block BYE requests.
214 type: str
215 choices:
216 - 'disable'
217 - 'enable'
218 block_cancel:
219 description:
220 - Enable/disable block CANCEL requests.
221 type: str
222 choices:
223 - 'disable'
224 - 'enable'
225 block_geo_red_options:
226 description:
227 - Enable/disable block OPTIONS requests, but OPTIONS requests still notify for redundancy.
228 type: str
229 choices:
230 - 'disable'
231 - 'enable'
232 block_info:
233 description:
234 - Enable/disable block INFO requests.
235 type: str
236 choices:
237 - 'disable'
238 - 'enable'
239 block_invite:
240 description:
241 - Enable/disable block INVITE requests.
242 type: str
243 choices:
244 - 'disable'
245 - 'enable'
246 block_long_lines:
247 description:
248 - Enable/disable block requests with headers exceeding max-line-length.
249 type: str
250 choices:
251 - 'disable'
252 - 'enable'
253 block_message:
254 description:
255 - Enable/disable block MESSAGE requests.
256 type: str
257 choices:
258 - 'disable'
259 - 'enable'
260 block_notify:
261 description:
262 - Enable/disable block NOTIFY requests.
263 type: str
264 choices:
265 - 'disable'
266 - 'enable'
267 block_options:
268 description:
269 - Enable/disable block OPTIONS requests and no OPTIONS as notifying message for redundancy either.
270 type: str
271 choices:
272 - 'disable'
273 - 'enable'
274 block_prack:
275 description:
276 - Enable/disable block prack requests.
277 type: str
278 choices:
279 - 'disable'
280 - 'enable'
281 block_publish:
282 description:
283 - Enable/disable block PUBLISH requests.
284 type: str
285 choices:
286 - 'disable'
287 - 'enable'
288 block_refer:
289 description:
290 - Enable/disable block REFER requests.
291 type: str
292 choices:
293 - 'disable'
294 - 'enable'
295 block_register:
296 description:
297 - Enable/disable block REGISTER requests.
298 type: str
299 choices:
300 - 'disable'
301 - 'enable'
302 block_subscribe:
303 description:
304 - Enable/disable block SUBSCRIBE requests.
305 type: str
306 choices:
307 - 'disable'
308 - 'enable'
309 block_unknown:
310 description:
311 - Block unrecognized SIP requests (enabled by default).
312 type: str
313 choices:
314 - 'disable'
315 - 'enable'
316 block_update:
317 description:
318 - Enable/disable block UPDATE requests.
319 type: str
320 choices:
321 - 'disable'
322 - 'enable'
323 bye_rate:
324 description:
325 - BYE request rate limit (per second, per policy).
326 type: int
327 bye_rate_track:
328 description:
329 - Track the packet protocol field.
330 type: str
331 choices:
332 - 'none'
333 - 'src-ip'
334 - 'dest-ip'
335 call_id_regex:
336 description:
337 - Validate PCRE regular expression for Call-Id header value.
338 type: str
339 call_keepalive:
340 description:
341 - Continue tracking calls with no RTP for this many minutes.
342 type: int
343 cancel_rate:
344 description:
345 - CANCEL request rate limit (per second, per policy).
346 type: int
347 cancel_rate_track:
348 description:
349 - Track the packet protocol field.
350 type: str
351 choices:
352 - 'none'
353 - 'src-ip'
354 - 'dest-ip'
355 contact_fixup:
356 description:
357 - 'Fixup contact anyway even if contact"s IP:port doesn"t match session"s IP:port.'
358 type: str
359 choices:
360 - 'disable'
361 - 'enable'
362 content_type_regex:
363 description:
364 - Validate PCRE regular expression for Content-Type header value.
365 type: str
366 hnt_restrict_source_ip:
367 description:
368 - Enable/disable restrict RTP source IP to be the same as SIP source IP when HNT is enabled.
369 type: str
370 choices:
371 - 'disable'
372 - 'enable'
373 hosted_nat_traversal:
374 description:
375 - Hosted NAT Traversal (HNT).
376 type: str
377 choices:
378 - 'disable'
379 - 'enable'
380 info_rate:
381 description:
382 - INFO request rate limit (per second, per policy).
383 type: int
384 info_rate_track:
385 description:
386 - Track the packet protocol field.
387 type: str
388 choices:
389 - 'none'
390 - 'src-ip'
391 - 'dest-ip'
392 invite_rate:
393 description:
394 - INVITE request rate limit (per second, per policy).
395 type: int
396 invite_rate_track:
397 description:
398 - Track the packet protocol field.
399 type: str
400 choices:
401 - 'none'
402 - 'src-ip'
403 - 'dest-ip'
404 ips_rtp:
405 description:
406 - Enable/disable allow IPS on RTP.
407 type: str
408 choices:
409 - 'disable'
410 - 'enable'
411 log_call_summary:
412 description:
413 - Enable/disable logging of SIP call summary.
414 type: str
415 choices:
416 - 'disable'
417 - 'enable'
418 log_violations:
419 description:
420 - Enable/disable logging of SIP violations.
421 type: str
422 choices:
423 - 'disable'
424 - 'enable'
425 malformed_header_allow:
426 description:
427 - Action for malformed Allow header.
428 type: str
429 choices:
430 - 'discard'
431 - 'pass'
432 - 'respond'
433 malformed_header_call_id:
434 description:
435 - Action for malformed Call-ID header.
436 type: str
437 choices:
438 - 'discard'
439 - 'pass'
440 - 'respond'
441 malformed_header_contact:
442 description:
443 - Action for malformed Contact header.
444 type: str
445 choices:
446 - 'discard'
447 - 'pass'
448 - 'respond'
449 malformed_header_content_length:
450 description:
451 - Action for malformed Content-Length header.
452 type: str
453 choices:
454 - 'discard'
455 - 'pass'
456 - 'respond'
457 malformed_header_content_type:
458 description:
459 - Action for malformed Content-Type header.
460 type: str
461 choices:
462 - 'discard'
463 - 'pass'
464 - 'respond'
465 malformed_header_cseq:
466 description:
467 - Action for malformed CSeq header.
468 type: str
469 choices:
470 - 'discard'
471 - 'pass'
472 - 'respond'
473 malformed_header_expires:
474 description:
475 - Action for malformed Expires header.
476 type: str
477 choices:
478 - 'discard'
479 - 'pass'
480 - 'respond'
481 malformed_header_from:
482 description:
483 - Action for malformed From header.
484 type: str
485 choices:
486 - 'discard'
487 - 'pass'
488 - 'respond'
489 malformed_header_max_forwards:
490 description:
491 - Action for malformed Max-Forwards header.
492 type: str
493 choices:
494 - 'discard'
495 - 'pass'
496 - 'respond'
497 malformed_header_no_proxy_require:
498 description:
499 - Action for malformed SIP messages without Proxy-Require header.
500 type: str
501 choices:
502 - 'discard'
503 - 'pass'
504 - 'respond'
505 malformed_header_no_require:
506 description:
507 - Action for malformed SIP messages without Require header.
508 type: str
509 choices:
510 - 'discard'
511 - 'pass'
512 - 'respond'
513 malformed_header_p_asserted_identity:
514 description:
515 - Action for malformed P-Asserted-Identity header.
516 type: str
517 choices:
518 - 'discard'
519 - 'pass'
520 - 'respond'
521 malformed_header_rack:
522 description:
523 - Action for malformed RAck header.
524 type: str
525 choices:
526 - 'discard'
527 - 'pass'
528 - 'respond'
529 malformed_header_record_route:
530 description:
531 - Action for malformed Record-Route header.
532 type: str
533 choices:
534 - 'discard'
535 - 'pass'
536 - 'respond'
537 malformed_header_route:
538 description:
539 - Action for malformed Route header.
540 type: str
541 choices:
542 - 'discard'
543 - 'pass'
544 - 'respond'
545 malformed_header_rseq:
546 description:
547 - Action for malformed RSeq header.
548 type: str
549 choices:
550 - 'discard'
551 - 'pass'
552 - 'respond'
553 malformed_header_sdp_a:
554 description:
555 - Action for malformed SDP a line.
556 type: str
557 choices:
558 - 'discard'
559 - 'pass'
560 - 'respond'
561 malformed_header_sdp_b:
562 description:
563 - Action for malformed SDP b line.
564 type: str
565 choices:
566 - 'discard'
567 - 'pass'
568 - 'respond'
569 malformed_header_sdp_c:
570 description:
571 - Action for malformed SDP c line.
572 type: str
573 choices:
574 - 'discard'
575 - 'pass'
576 - 'respond'
577 malformed_header_sdp_i:
578 description:
579 - Action for malformed SDP i line.
580 type: str
581 choices:
582 - 'discard'
583 - 'pass'
584 - 'respond'
585 malformed_header_sdp_k:
586 description:
587 - Action for malformed SDP k line.
588 type: str
589 choices:
590 - 'discard'
591 - 'pass'
592 - 'respond'
593 malformed_header_sdp_m:
594 description:
595 - Action for malformed SDP m line.
596 type: str
597 choices:
598 - 'discard'
599 - 'pass'
600 - 'respond'
601 malformed_header_sdp_o:
602 description:
603 - Action for malformed SDP o line.
604 type: str
605 choices:
606 - 'discard'
607 - 'pass'
608 - 'respond'
609 malformed_header_sdp_r:
610 description:
611 - Action for malformed SDP r line.
612 type: str
613 choices:
614 - 'discard'
615 - 'pass'
616 - 'respond'
617 malformed_header_sdp_s:
618 description:
619 - Action for malformed SDP s line.
620 type: str
621 choices:
622 - 'discard'
623 - 'pass'
624 - 'respond'
625 malformed_header_sdp_t:
626 description:
627 - Action for malformed SDP t line.
628 type: str
629 choices:
630 - 'discard'
631 - 'pass'
632 - 'respond'
633 malformed_header_sdp_v:
634 description:
635 - Action for malformed SDP v line.
636 type: str
637 choices:
638 - 'discard'
639 - 'pass'
640 - 'respond'
641 malformed_header_sdp_z:
642 description:
643 - Action for malformed SDP z line.
644 type: str
645 choices:
646 - 'discard'
647 - 'pass'
648 - 'respond'
649 malformed_header_to:
650 description:
651 - Action for malformed To header.
652 type: str
653 choices:
654 - 'discard'
655 - 'pass'
656 - 'respond'
657 malformed_header_via:
658 description:
659 - Action for malformed VIA header.
660 type: str
661 choices:
662 - 'discard'
663 - 'pass'
664 - 'respond'
665 malformed_request_line:
666 description:
667 - Action for malformed request line.
668 type: str
669 choices:
670 - 'discard'
671 - 'pass'
672 - 'respond'
673 max_body_length:
674 description:
675 - Maximum SIP message body length (0 meaning no limit).
676 type: int
677 max_dialogs:
678 description:
679 - Maximum number of concurrent calls/dialogs (per policy).
680 type: int
681 max_idle_dialogs:
682 description:
683 - Maximum number established but idle dialogs to retain (per policy).
684 type: int
685 max_line_length:
686 description:
687 - Maximum SIP header line length (78-4096).
688 type: int
689 message_rate:
690 description:
691 - MESSAGE request rate limit (per second, per policy).
692 type: int
693 message_rate_track:
694 description:
695 - Track the packet protocol field.
696 type: str
697 choices:
698 - 'none'
699 - 'src-ip'
700 - 'dest-ip'
701 nat_port_range:
702 description:
703 - RTP NAT port range.
704 type: str
705 nat_trace:
706 description:
707 - Enable/disable preservation of original IP in SDP i line.
708 type: str
709 choices:
710 - 'disable'
711 - 'enable'
712 no_sdp_fixup:
713 description:
714 - Enable/disable no SDP fix-up.
715 type: str
716 choices:
717 - 'disable'
718 - 'enable'
719 notify_rate:
720 description:
721 - NOTIFY request rate limit (per second, per policy).
722 type: int
723 notify_rate_track:
724 description:
725 - Track the packet protocol field.
726 type: str
727 choices:
728 - 'none'
729 - 'src-ip'
730 - 'dest-ip'
731 open_contact_pinhole:
732 description:
733 - Enable/disable open pinhole for non-REGISTER Contact port.
734 type: str
735 choices:
736 - 'disable'
737 - 'enable'
738 open_record_route_pinhole:
739 description:
740 - Enable/disable open pinhole for Record-Route port.
741 type: str
742 choices:
743 - 'disable'
744 - 'enable'
745 open_register_pinhole:
746 description:
747 - Enable/disable open pinhole for REGISTER Contact port.
748 type: str
749 choices:
750 - 'disable'
751 - 'enable'
752 open_via_pinhole:
753 description:
754 - Enable/disable open pinhole for Via port.
755 type: str
756 choices:
757 - 'disable'
758 - 'enable'
759 options_rate:
760 description:
761 - OPTIONS request rate limit (per second, per policy).
762 type: int
763 options_rate_track:
764 description:
765 - Track the packet protocol field.
766 type: str
767 choices:
768 - 'none'
769 - 'src-ip'
770 - 'dest-ip'
771 prack_rate:
772 description:
773 - PRACK request rate limit (per second, per policy).
774 type: int
775 prack_rate_track:
776 description:
777 - Track the packet protocol field.
778 type: str
779 choices:
780 - 'none'
781 - 'src-ip'
782 - 'dest-ip'
783 preserve_override:
784 description:
785 - 'Override i line to preserve original IPs .'
786 type: str
787 choices:
788 - 'disable'
789 - 'enable'
790 provisional_invite_expiry_time:
791 description:
792 - Expiry time (10-3600, in seconds) for provisional INVITE.
793 type: int
794 publish_rate:
795 description:
796 - PUBLISH request rate limit (per second, per policy).
797 type: int
798 publish_rate_track:
799 description:
800 - Track the packet protocol field.
801 type: str
802 choices:
803 - 'none'
804 - 'src-ip'
805 - 'dest-ip'
806 refer_rate:
807 description:
808 - REFER request rate limit (per second, per policy).
809 type: int
810 refer_rate_track:
811 description:
812 - Track the packet protocol field.
813 type: str
814 choices:
815 - 'none'
816 - 'src-ip'
817 - 'dest-ip'
818 register_contact_trace:
819 description:
820 - Enable/disable trace original IP/port within the contact header of REGISTER requests.
821 type: str
822 choices:
823 - 'disable'
824 - 'enable'
825 register_rate:
826 description:
827 - REGISTER request rate limit (per second, per policy).
828 type: int
829 register_rate_track:
830 description:
831 - Track the packet protocol field.
832 type: str
833 choices:
834 - 'none'
835 - 'src-ip'
836 - 'dest-ip'
837 rfc2543_branch:
838 description:
839 - Enable/disable support via branch compliant with RFC 2543.
840 type: str
841 choices:
842 - 'disable'
843 - 'enable'
844 rtp:
845 description:
846 - Enable/disable create pinholes for RTP traffic to traverse firewall.
847 type: str
848 choices:
849 - 'disable'
850 - 'enable'
851 ssl_algorithm:
852 description:
853 - Relative strength of encryption algorithms accepted in negotiation.
854 type: str
855 choices:
856 - 'high'
857 - 'medium'
858 - 'low'
859 ssl_auth_client:
860 description:
861 - Require a client certificate and authenticate it with the peer/peergrp. Source user.peer.name user.peergrp.name.
862 type: str
863 ssl_auth_server:
864 description:
865 - Authenticate the server"s certificate with the peer/peergrp. Source user.peer.name user.peergrp.name.
866 type: str
867 ssl_client_certificate:
868 description:
869 - Name of Certificate to offer to server if requested. Source vpn.certificate.local.name.
870 type: str
871 ssl_client_renegotiation:
872 description:
873 - Allow/block client renegotiation by server.
874 type: str
875 choices:
876 - 'allow'
877 - 'deny'
878 - 'secure'
879 ssl_max_version:
880 description:
881 - Highest SSL/TLS version to negotiate.
882 type: str
883 choices:
884 - 'ssl-3.0'
885 - 'tls-1.0'
886 - 'tls-1.1'
887 - 'tls-1.2'
888 - 'tls-1.3'
889 ssl_min_version:
890 description:
891 - Lowest SSL/TLS version to negotiate.
892 type: str
893 choices:
894 - 'ssl-3.0'
895 - 'tls-1.0'
896 - 'tls-1.1'
897 - 'tls-1.2'
898 - 'tls-1.3'
899 ssl_mode:
900 description:
901 - SSL/TLS mode for encryption & decryption of traffic.
902 type: str
903 choices:
904 - 'off'
905 - 'full'
906 ssl_pfs:
907 description:
908 - SSL Perfect Forward Secrecy.
909 type: str
910 choices:
911 - 'require'
912 - 'deny'
913 - 'allow'
914 ssl_send_empty_frags:
915 description:
916 - Send empty fragments to avoid attack on CBC IV (SSL 3.0 & TLS 1.0 only).
917 type: str
918 choices:
919 - 'enable'
920 - 'disable'
921 ssl_server_certificate:
922 description:
923 - Name of Certificate return to the client in every SSL connection. Source vpn.certificate.local.name.
924 type: str
925 status:
926 description:
927 - Enable/disable SIP.
928 type: str
929 choices:
930 - 'disable'
931 - 'enable'
932 strict_register:
933 description:
934 - Enable/disable only allow the registrar to connect.
935 type: str
936 choices:
937 - 'disable'
938 - 'enable'
939 subscribe_rate:
940 description:
941 - SUBSCRIBE request rate limit (per second, per policy).
942 type: int
943 subscribe_rate_track:
944 description:
945 - Track the packet protocol field.
946 type: str
947 choices:
948 - 'none'
949 - 'src-ip'
950 - 'dest-ip'
951 unknown_header:
952 description:
953 - Action for unknown SIP header.
954 type: str
955 choices:
956 - 'discard'
957 - 'pass'
958 - 'respond'
959 update_rate:
960 description:
961 - UPDATE request rate limit (per second, per policy).
962 type: int
963 update_rate_track:
964 description:
965 - Track the packet protocol field.
966 type: str
967 choices:
968 - 'none'
969 - 'src-ip'
970 - 'dest-ip'
971 """
972
973 EXAMPLES = """
974 - name: Configure VoIP profiles.
975 fortinet.fortios.fortios_voip_profile:
976 vdom: "{{ vdom }}"
977 state: "present"
978 access_token: "<your_own_value>"
979 voip_profile:
980 comment: "Comment."
981 feature_set: "ips"
982 msrp:
983 log_violations: "disable"
984 max_msg_size: "0"
985 max_msg_size_action: "pass"
986 status: "disable"
987 name: "default_name_10"
988 sccp:
989 block_mcast: "disable"
990 log_call_summary: "disable"
991 log_violations: "disable"
992 max_calls: "0"
993 status: "disable"
994 verify_header: "disable"
995 sip:
996 ack_rate: "0"
997 ack_rate_track: "none"
998 block_ack: "disable"
999 block_bye: "disable"
1000 block_cancel: "disable"
1001 block_geo_red_options: "disable"
1002 block_info: "disable"
1003 block_invite: "disable"
1004 block_long_lines: "disable"
1005 block_message: "disable"
1006 block_notify: "disable"
1007 block_options: "disable"
1008 block_prack: "disable"
1009 block_publish: "disable"
1010 block_refer: "disable"
1011 block_register: "disable"
1012 block_subscribe: "disable"
1013 block_unknown: "disable"
1014 block_update: "disable"
1015 bye_rate: "0"
1016 bye_rate_track: "none"
1017 call_id_regex: "<your_own_value>"
1018 call_keepalive: "0"
1019 cancel_rate: "0"
1020 cancel_rate_track: "none"
1021 contact_fixup: "disable"
1022 content_type_regex: "<your_own_value>"
1023 hnt_restrict_source_ip: "disable"
1024 hosted_nat_traversal: "disable"
1025 info_rate: "0"
1026 info_rate_track: "none"
1027 invite_rate: "0"
1028 invite_rate_track: "none"
1029 ips_rtp: "disable"
1030 log_call_summary: "disable"
1031 log_violations: "disable"
1032 malformed_header_allow: "discard"
1033 malformed_header_call_id: "discard"
1034 malformed_header_contact: "discard"
1035 malformed_header_content_length: "discard"
1036 malformed_header_content_type: "discard"
1037 malformed_header_cseq: "discard"
1038 malformed_header_expires: "discard"
1039 malformed_header_from: "discard"
1040 malformed_header_max_forwards: "discard"
1041 malformed_header_no_proxy_require: "discard"
1042 malformed_header_no_require: "discard"
1043 malformed_header_p_asserted_identity: "discard"
1044 malformed_header_rack: "discard"
1045 malformed_header_record_route: "discard"
1046 malformed_header_route: "discard"
1047 malformed_header_rseq: "discard"
1048 malformed_header_sdp_a: "discard"
1049 malformed_header_sdp_b: "discard"
1050 malformed_header_sdp_c: "discard"
1051 malformed_header_sdp_i: "discard"
1052 malformed_header_sdp_k: "discard"
1053 malformed_header_sdp_m: "discard"
1054 malformed_header_sdp_o: "discard"
1055 malformed_header_sdp_r: "discard"
1056 malformed_header_sdp_s: "discard"
1057 malformed_header_sdp_t: "discard"
1058 malformed_header_sdp_v: "discard"
1059 malformed_header_sdp_z: "discard"
1060 malformed_header_to: "discard"
1061 malformed_header_via: "discard"
1062 malformed_request_line: "discard"
1063 max_body_length: "0"
1064 max_dialogs: "0"
1065 max_idle_dialogs: "0"
1066 max_line_length: "998"
1067 message_rate: "0"
1068 message_rate_track: "none"
1069 nat_port_range: "<your_own_value>"
1070 nat_trace: "disable"
1071 no_sdp_fixup: "disable"
1072 notify_rate: "0"
1073 notify_rate_track: "none"
1074 open_contact_pinhole: "disable"
1075 open_record_route_pinhole: "disable"
1076 open_register_pinhole: "disable"
1077 open_via_pinhole: "disable"
1078 options_rate: "0"
1079 options_rate_track: "none"
1080 prack_rate: "0"
1081 prack_rate_track: "none"
1082 preserve_override: "disable"
1083 provisional_invite_expiry_time: "210"
1084 publish_rate: "0"
1085 publish_rate_track: "none"
1086 refer_rate: "0"
1087 refer_rate_track: "none"
1088 register_contact_trace: "disable"
1089 register_rate: "0"
1090 register_rate_track: "none"
1091 rfc2543_branch: "disable"
1092 rtp: "disable"
1093 ssl_algorithm: "high"
1094 ssl_auth_client: "<your_own_value> (source user.peer.name user.peergrp.name)"
1095 ssl_auth_server: "<your_own_value> (source user.peer.name user.peergrp.name)"
1096 ssl_client_certificate: "<your_own_value> (source vpn.certificate.local.name)"
1097 ssl_client_renegotiation: "allow"
1098 ssl_max_version: "ssl-3.0"
1099 ssl_min_version: "ssl-3.0"
1100 ssl_mode: "off"
1101 ssl_pfs: "require"
1102 ssl_send_empty_frags: "enable"
1103 ssl_server_certificate: "<your_own_value> (source vpn.certificate.local.name)"
1104 status: "disable"
1105 strict_register: "disable"
1106 subscribe_rate: "0"
1107 subscribe_rate_track: "none"
1108 unknown_header: "discard"
1109 update_rate: "0"
1110 update_rate_track: "none"
1111 """
1112
1113 RETURN = """
1114 build:
1115 description: Build number of the fortigate image
1116 returned: always
1117 type: str
1118 sample: '1547'
1119 http_method:
1120 description: Last method used to provision the content into FortiGate
1121 returned: always
1122 type: str
1123 sample: 'PUT'
1124 http_status:
1125 description: Last result given by FortiGate on last operation applied
1126 returned: always
1127 type: str
1128 sample: "200"
1129 mkey:
1130 description: Master key (id) used in the last call to FortiGate
1131 returned: success
1132 type: str
1133 sample: "id"
1134 name:
1135 description: Name of the table used to fulfill the request
1136 returned: always
1137 type: str
1138 sample: "urlfilter"
1139 path:
1140 description: Path of the table used to fulfill the request
1141 returned: always
1142 type: str
1143 sample: "webfilter"
1144 revision:
1145 description: Internal revision number
1146 returned: always
1147 type: str
1148 sample: "17.0.2.10658"
1149 serial:
1150 description: Serial number of the unit
1151 returned: always
1152 type: str
1153 sample: "FGVMEVYYQT3AB5352"
1154 status:
1155 description: Indication of the operation's result
1156 returned: always
1157 type: str
1158 sample: "success"
1159 vdom:
1160 description: Virtual domain used
1161 returned: always
1162 type: str
1163 sample: "root"
1164 version:
1165 description: Version of the FortiGate
1166 returned: always
1167 type: str
1168 sample: "v5.6.3"
1169 """
1170 from ansible.module_utils.basic import AnsibleModule
1171 from ansible.module_utils.connection import Connection
1172 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
1173 FortiOSHandler,
1174 )
1175 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
1176 check_legacy_fortiosapi,
1177 )
1178 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
1179 schema_to_module_spec,
1180 )
1181 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.fortios import (
1182 check_schema_versioning,
1183 )
1184 from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.common import (
1185 FAIL_SOCKET_MSG,
1186 )
1187 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.data_post_processor import (
1188 remove_invalid_fields,
1189 )
1190 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
1191 is_same_comparison,
1192 )
1193 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
1194 serialize,
1195 )
1196 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
1197 find_current_values,
1198 )
1199 from ansible_collections.fortinet.fortios.plugins.module_utils.fortios.comparison import (
1200 unify_data_format,
1201 )
1202
1203
1204 def filter_voip_profile_data(json):
1205 option_list = ["comment", "feature_set", "msrp", "name", "sccp", "sip"]
1206
1207 json = remove_invalid_fields(json)
1208 dictionary = {}
1209
1210 for attribute in option_list:
1211 if attribute in json and json[attribute] is not None:
1212 dictionary[attribute] = json[attribute]
1213
1214 return dictionary
1215
1216
1217 def underscore_to_hyphen(data):
1218 new_data = None
1219 if isinstance(data, list):
1220 new_data = []
1221 for i, elem in enumerate(data):
1222 new_data.append(underscore_to_hyphen(elem))
1223 elif isinstance(data, dict):
1224 new_data = {}
1225 for k, v in data.items():
1226 new_data[k.replace("_", "-")] = underscore_to_hyphen(v)
1227 else:
1228 return data
1229 return new_data
1230
1231
1232 def voip_profile(data, fos, check_mode=False):
1233
1234 state = None
1235 vdom = data["vdom"]
1236 parameters = None
1237 state = data.get("state", None)
1238 voip_profile_data = data["voip_profile"]
1239
1240 filtered_data = filter_voip_profile_data(voip_profile_data)
1241 converted_data = underscore_to_hyphen(filtered_data)
1242
1243 # check_mode starts from here
1244 if check_mode:
1245 diff = {
1246 "before": "",
1247 "after": filtered_data,
1248 }
1249 mkeyname = fos.get_mkeyname(None, None)
1250 mkey = fos.get_mkey("voip", "profile", filtered_data, vdom=vdom)
1251 current_data = fos.get(
1252 "voip", "profile", vdom=vdom, mkey=mkey, parameters=parameters
1253 )
1254 is_existed = (
1255 current_data
1256 and current_data.get("http_status") == 200
1257 and (
1258 mkeyname
1259 and isinstance(current_data.get("results"), list)
1260 and len(current_data["results"]) > 0
1261 or not mkeyname
1262 and current_data["results"] # global object response
1263 )
1264 )
1265
1266 # 2. if it exists and the state is 'present' then compare current settings with desired
1267 if state == "present" or state is True or state is None:
1268 # for non global modules, mkeyname must exist and it's a new module when mkey is None
1269 if mkeyname is not None and mkey is None:
1270 return False, True, filtered_data, diff
1271
1272 # if mkey exists then compare each other
1273 # record exits and they're matched or not
1274 copied_filtered_data = filtered_data.copy()
1275 copied_filtered_data.pop(mkeyname, None)
1276 unified_filtered_data = unify_data_format(copied_filtered_data)
1277
1278 current_data_results = current_data.get("results", {})
1279 current_config = (
1280 current_data_results[0]
1281 if mkeyname
1282 and isinstance(current_data_results, list)
1283 and len(current_data_results) > 0
1284 else current_data_results
1285 )
1286 if is_existed:
1287 unified_current_values = find_current_values(
1288 unified_filtered_data,
1289 unify_data_format(current_config),
1290 )
1291
1292 is_same = is_same_comparison(
1293 serialize(unified_current_values), serialize(unified_filtered_data)
1294 )
1295
1296 return (
1297 False,
1298 not is_same,
1299 filtered_data,
1300 {"before": unified_current_values, "after": unified_filtered_data},
1301 )
1302
1303 # record does not exist
1304 return False, True, filtered_data, diff
1305
1306 if state == "absent":
1307 if mkey is None:
1308 return (
1309 False,
1310 False,
1311 filtered_data,
1312 {"before": current_data["results"][0], "after": ""},
1313 )
1314
1315 if is_existed:
1316 return (
1317 False,
1318 True,
1319 filtered_data,
1320 {"before": current_data["results"][0], "after": ""},
1321 )
1322 return False, False, filtered_data, {}
1323
1324 return True, False, {"reason: ": "Must provide state parameter"}, {}
1325 # pass post processed data to member operations
1326 # no need to do underscore_to_hyphen since do_member_operation handles it by itself
1327 data_copy = data.copy()
1328 data_copy["voip_profile"] = filtered_data
1329 fos.do_member_operation(
1330 "voip",
1331 "profile",
1332 data_copy,
1333 )
1334
1335 if state == "present" or state is True:
1336 return fos.set(
1337 "voip", "profile", data=converted_data, vdom=vdom, parameters=parameters
1338 )
1339
1340 elif state == "absent":
1341 return fos.delete(
1342 "voip",
1343 "profile",
1344 mkey=converted_data["name"],
1345 vdom=vdom,
1346 parameters=parameters,
1347 )
1348 else:
1349 fos._module.fail_json(msg="state must be present or absent!")
1350
1351
1352 def is_successful_status(resp):
1353 return (
1354 "status" in resp
1355 and resp["status"] == "success"
1356 or "http_status" in resp
1357 and resp["http_status"] == 200
1358 or "http_method" in resp
1359 and resp["http_method"] == "DELETE"
1360 and resp["http_status"] == 404
1361 )
1362
1363
1364 def fortios_voip(data, fos, check_mode):
1365
1366 if data["voip_profile"]:
1367 resp = voip_profile(data, fos, check_mode)
1368 else:
1369 fos._module.fail_json(msg="missing task body: %s" % ("voip_profile"))
1370 if isinstance(resp, tuple) and len(resp) == 4:
1371 return resp
1372 return (
1373 not is_successful_status(resp),
1374 is_successful_status(resp)
1375 and (resp["revision_changed"] if "revision_changed" in resp else True),
1376 resp,
1377 {},
1378 )
1379
1380
1381 versioned_schema = {
1382 "type": "list",
1383 "elements": "dict",
1384 "children": {
1385 "name": {"v_range": [["v6.0.0", ""]], "type": "string", "required": True},
1386 "feature_set": {
1387 "v_range": [["v7.0.0", ""]],
1388 "type": "string",
1389 "options": [
1390 {"value": "ips", "v_range": [["v7.4.0", ""]]},
1391 {"value": "voipd", "v_range": [["v7.4.0", ""]]},
1392 {"value": "flow", "v_range": [["v7.0.0", "v7.2.4"]]},
1393 {"value": "proxy", "v_range": [["v7.0.0", "v7.2.4"]]},
1394 ],
1395 },
1396 "comment": {"v_range": [["v6.0.0", ""]], "type": "string"},
1397 "sip": {
1398 "v_range": [["v6.0.0", ""]],
1399 "type": "dict",
1400 "children": {
1401 "status": {
1402 "v_range": [["v6.0.0", ""]],
1403 "type": "string",
1404 "options": [{"value": "disable"}, {"value": "enable"}],
1405 },
1406 "rtp": {
1407 "v_range": [["v6.0.0", ""]],
1408 "type": "string",
1409 "options": [{"value": "disable"}, {"value": "enable"}],
1410 },
1411 "nat_port_range": {"v_range": [["v6.2.0", ""]], "type": "string"},
1412 "open_register_pinhole": {
1413 "v_range": [["v6.0.0", ""]],
1414 "type": "string",
1415 "options": [{"value": "disable"}, {"value": "enable"}],
1416 },
1417 "open_contact_pinhole": {
1418 "v_range": [["v6.0.0", ""]],
1419 "type": "string",
1420 "options": [{"value": "disable"}, {"value": "enable"}],
1421 },
1422 "strict_register": {
1423 "v_range": [["v6.0.0", ""]],
1424 "type": "string",
1425 "options": [{"value": "disable"}, {"value": "enable"}],
1426 },
1427 "register_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1428 "register_rate_track": {
1429 "v_range": [["v7.0.0", ""]],
1430 "type": "string",
1431 "options": [
1432 {"value": "none"},
1433 {"value": "src-ip"},
1434 {"value": "dest-ip"},
1435 ],
1436 },
1437 "invite_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1438 "invite_rate_track": {
1439 "v_range": [["v7.0.0", ""]],
1440 "type": "string",
1441 "options": [
1442 {"value": "none"},
1443 {"value": "src-ip"},
1444 {"value": "dest-ip"},
1445 ],
1446 },
1447 "max_dialogs": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1448 "max_line_length": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1449 "block_long_lines": {
1450 "v_range": [["v6.0.0", ""]],
1451 "type": "string",
1452 "options": [{"value": "disable"}, {"value": "enable"}],
1453 },
1454 "block_unknown": {
1455 "v_range": [["v6.0.0", ""]],
1456 "type": "string",
1457 "options": [{"value": "disable"}, {"value": "enable"}],
1458 },
1459 "call_keepalive": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1460 "block_ack": {
1461 "v_range": [["v6.0.0", ""]],
1462 "type": "string",
1463 "options": [{"value": "disable"}, {"value": "enable"}],
1464 },
1465 "block_bye": {
1466 "v_range": [["v6.0.0", ""]],
1467 "type": "string",
1468 "options": [{"value": "disable"}, {"value": "enable"}],
1469 },
1470 "block_cancel": {
1471 "v_range": [["v6.0.0", ""]],
1472 "type": "string",
1473 "options": [{"value": "disable"}, {"value": "enable"}],
1474 },
1475 "block_info": {
1476 "v_range": [["v6.0.0", ""]],
1477 "type": "string",
1478 "options": [{"value": "disable"}, {"value": "enable"}],
1479 },
1480 "block_invite": {
1481 "v_range": [["v6.0.0", ""]],
1482 "type": "string",
1483 "options": [{"value": "disable"}, {"value": "enable"}],
1484 },
1485 "block_message": {
1486 "v_range": [["v6.0.0", ""]],
1487 "type": "string",
1488 "options": [{"value": "disable"}, {"value": "enable"}],
1489 },
1490 "block_notify": {
1491 "v_range": [["v6.0.0", ""]],
1492 "type": "string",
1493 "options": [{"value": "disable"}, {"value": "enable"}],
1494 },
1495 "block_options": {
1496 "v_range": [["v6.0.0", ""]],
1497 "type": "string",
1498 "options": [{"value": "disable"}, {"value": "enable"}],
1499 },
1500 "block_prack": {
1501 "v_range": [["v6.0.0", ""]],
1502 "type": "string",
1503 "options": [{"value": "disable"}, {"value": "enable"}],
1504 },
1505 "block_publish": {
1506 "v_range": [["v6.0.0", ""]],
1507 "type": "string",
1508 "options": [{"value": "disable"}, {"value": "enable"}],
1509 },
1510 "block_refer": {
1511 "v_range": [["v6.0.0", ""]],
1512 "type": "string",
1513 "options": [{"value": "disable"}, {"value": "enable"}],
1514 },
1515 "block_register": {
1516 "v_range": [["v6.0.0", ""]],
1517 "type": "string",
1518 "options": [{"value": "disable"}, {"value": "enable"}],
1519 },
1520 "block_subscribe": {
1521 "v_range": [["v6.0.0", ""]],
1522 "type": "string",
1523 "options": [{"value": "disable"}, {"value": "enable"}],
1524 },
1525 "block_update": {
1526 "v_range": [["v6.0.0", ""]],
1527 "type": "string",
1528 "options": [{"value": "disable"}, {"value": "enable"}],
1529 },
1530 "register_contact_trace": {
1531 "v_range": [["v6.0.0", ""]],
1532 "type": "string",
1533 "options": [{"value": "disable"}, {"value": "enable"}],
1534 },
1535 "open_via_pinhole": {
1536 "v_range": [["v6.0.0", ""]],
1537 "type": "string",
1538 "options": [{"value": "disable"}, {"value": "enable"}],
1539 },
1540 "open_record_route_pinhole": {
1541 "v_range": [["v6.0.0", ""]],
1542 "type": "string",
1543 "options": [{"value": "disable"}, {"value": "enable"}],
1544 },
1545 "rfc2543_branch": {
1546 "v_range": [["v6.0.0", ""]],
1547 "type": "string",
1548 "options": [{"value": "disable"}, {"value": "enable"}],
1549 },
1550 "log_violations": {
1551 "v_range": [["v6.0.0", ""]],
1552 "type": "string",
1553 "options": [{"value": "disable"}, {"value": "enable"}],
1554 },
1555 "log_call_summary": {
1556 "v_range": [["v6.0.0", ""]],
1557 "type": "string",
1558 "options": [{"value": "disable"}, {"value": "enable"}],
1559 },
1560 "nat_trace": {
1561 "v_range": [["v6.0.0", ""]],
1562 "type": "string",
1563 "options": [{"value": "disable"}, {"value": "enable"}],
1564 },
1565 "subscribe_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1566 "subscribe_rate_track": {
1567 "v_range": [["v7.0.0", ""]],
1568 "type": "string",
1569 "options": [
1570 {"value": "none"},
1571 {"value": "src-ip"},
1572 {"value": "dest-ip"},
1573 ],
1574 },
1575 "message_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1576 "message_rate_track": {
1577 "v_range": [["v7.0.0", ""]],
1578 "type": "string",
1579 "options": [
1580 {"value": "none"},
1581 {"value": "src-ip"},
1582 {"value": "dest-ip"},
1583 ],
1584 },
1585 "notify_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1586 "notify_rate_track": {
1587 "v_range": [["v7.0.0", ""]],
1588 "type": "string",
1589 "options": [
1590 {"value": "none"},
1591 {"value": "src-ip"},
1592 {"value": "dest-ip"},
1593 ],
1594 },
1595 "refer_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1596 "refer_rate_track": {
1597 "v_range": [["v7.0.0", ""]],
1598 "type": "string",
1599 "options": [
1600 {"value": "none"},
1601 {"value": "src-ip"},
1602 {"value": "dest-ip"},
1603 ],
1604 },
1605 "update_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1606 "update_rate_track": {
1607 "v_range": [["v7.0.0", ""]],
1608 "type": "string",
1609 "options": [
1610 {"value": "none"},
1611 {"value": "src-ip"},
1612 {"value": "dest-ip"},
1613 ],
1614 },
1615 "options_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1616 "options_rate_track": {
1617 "v_range": [["v7.0.0", ""]],
1618 "type": "string",
1619 "options": [
1620 {"value": "none"},
1621 {"value": "src-ip"},
1622 {"value": "dest-ip"},
1623 ],
1624 },
1625 "ack_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1626 "ack_rate_track": {
1627 "v_range": [["v7.0.0", ""]],
1628 "type": "string",
1629 "options": [
1630 {"value": "none"},
1631 {"value": "src-ip"},
1632 {"value": "dest-ip"},
1633 ],
1634 },
1635 "prack_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1636 "prack_rate_track": {
1637 "v_range": [["v7.0.0", ""]],
1638 "type": "string",
1639 "options": [
1640 {"value": "none"},
1641 {"value": "src-ip"},
1642 {"value": "dest-ip"},
1643 ],
1644 },
1645 "info_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1646 "info_rate_track": {
1647 "v_range": [["v7.0.0", ""]],
1648 "type": "string",
1649 "options": [
1650 {"value": "none"},
1651 {"value": "src-ip"},
1652 {"value": "dest-ip"},
1653 ],
1654 },
1655 "publish_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1656 "publish_rate_track": {
1657 "v_range": [["v7.0.0", ""]],
1658 "type": "string",
1659 "options": [
1660 {"value": "none"},
1661 {"value": "src-ip"},
1662 {"value": "dest-ip"},
1663 ],
1664 },
1665 "bye_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1666 "bye_rate_track": {
1667 "v_range": [["v7.0.0", ""]],
1668 "type": "string",
1669 "options": [
1670 {"value": "none"},
1671 {"value": "src-ip"},
1672 {"value": "dest-ip"},
1673 ],
1674 },
1675 "cancel_rate": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1676 "cancel_rate_track": {
1677 "v_range": [["v7.0.0", ""]],
1678 "type": "string",
1679 "options": [
1680 {"value": "none"},
1681 {"value": "src-ip"},
1682 {"value": "dest-ip"},
1683 ],
1684 },
1685 "preserve_override": {
1686 "v_range": [["v6.0.0", ""]],
1687 "type": "string",
1688 "options": [{"value": "disable"}, {"value": "enable"}],
1689 },
1690 "no_sdp_fixup": {
1691 "v_range": [["v6.0.0", ""]],
1692 "type": "string",
1693 "options": [{"value": "disable"}, {"value": "enable"}],
1694 },
1695 "contact_fixup": {
1696 "v_range": [["v6.0.0", ""]],
1697 "type": "string",
1698 "options": [{"value": "disable"}, {"value": "enable"}],
1699 },
1700 "max_idle_dialogs": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1701 "block_geo_red_options": {
1702 "v_range": [["v6.0.0", ""]],
1703 "type": "string",
1704 "options": [{"value": "disable"}, {"value": "enable"}],
1705 },
1706 "hosted_nat_traversal": {
1707 "v_range": [["v6.0.0", ""]],
1708 "type": "string",
1709 "options": [{"value": "disable"}, {"value": "enable"}],
1710 },
1711 "hnt_restrict_source_ip": {
1712 "v_range": [["v6.0.0", ""]],
1713 "type": "string",
1714 "options": [{"value": "disable"}, {"value": "enable"}],
1715 },
1716 "call_id_regex": {"v_range": [["v7.4.0", ""]], "type": "string"},
1717 "content_type_regex": {"v_range": [["v7.4.0", ""]], "type": "string"},
1718 "max_body_length": {"v_range": [["v6.0.0", ""]], "type": "integer"},
1719 "unknown_header": {
1720 "v_range": [["v6.0.0", ""]],
1721 "type": "string",
1722 "options": [
1723 {"value": "discard"},
1724 {"value": "pass"},
1725 {"value": "respond"},
1726 ],
1727 },
1728 "malformed_request_line": {
1729 "v_range": [["v6.0.0", ""]],
1730 "type": "string",
1731 "options": [
1732 {"value": "discard"},
1733 {"value": "pass"},
1734 {"value": "respond"},
1735 ],
1736 },
1737 "malformed_header_via": {
1738 "v_range": [["v6.0.0", ""]],
1739 "type": "string",
1740 "options": [
1741 {"value": "discard"},
1742 {"value": "pass"},
1743 {"value": "respond"},
1744 ],
1745 },
1746 "malformed_header_from": {
1747 "v_range": [["v6.0.0", ""]],
1748 "type": "string",
1749 "options": [
1750 {"value": "discard"},
1751 {"value": "pass"},
1752 {"value": "respond"},
1753 ],
1754 },
1755 "malformed_header_to": {
1756 "v_range": [["v6.0.0", ""]],
1757 "type": "string",
1758 "options": [
1759 {"value": "discard"},
1760 {"value": "pass"},
1761 {"value": "respond"},
1762 ],
1763 },
1764 "malformed_header_call_id": {
1765 "v_range": [["v6.0.0", ""]],
1766 "type": "string",
1767 "options": [
1768 {"value": "discard"},
1769 {"value": "pass"},
1770 {"value": "respond"},
1771 ],
1772 },
1773 "malformed_header_cseq": {
1774 "v_range": [["v6.0.0", ""]],
1775 "type": "string",
1776 "options": [
1777 {"value": "discard"},
1778 {"value": "pass"},
1779 {"value": "respond"},
1780 ],
1781 },
1782 "malformed_header_rack": {
1783 "v_range": [["v6.0.0", ""]],
1784 "type": "string",
1785 "options": [
1786 {"value": "discard"},
1787 {"value": "pass"},
1788 {"value": "respond"},
1789 ],
1790 },
1791 "malformed_header_rseq": {
1792 "v_range": [["v6.0.0", ""]],
1793 "type": "string",
1794 "options": [
1795 {"value": "discard"},
1796 {"value": "pass"},
1797 {"value": "respond"},
1798 ],
1799 },
1800 "malformed_header_contact": {
1801 "v_range": [["v6.0.0", ""]],
1802 "type": "string",
1803 "options": [
1804 {"value": "discard"},
1805 {"value": "pass"},
1806 {"value": "respond"},
1807 ],
1808 },
1809 "malformed_header_record_route": {
1810 "v_range": [["v6.0.0", ""]],
1811 "type": "string",
1812 "options": [
1813 {"value": "discard"},
1814 {"value": "pass"},
1815 {"value": "respond"},
1816 ],
1817 },
1818 "malformed_header_route": {
1819 "v_range": [["v6.0.0", ""]],
1820 "type": "string",
1821 "options": [
1822 {"value": "discard"},
1823 {"value": "pass"},
1824 {"value": "respond"},
1825 ],
1826 },
1827 "malformed_header_expires": {
1828 "v_range": [["v6.0.0", ""]],
1829 "type": "string",
1830 "options": [
1831 {"value": "discard"},
1832 {"value": "pass"},
1833 {"value": "respond"},
1834 ],
1835 },
1836 "malformed_header_content_type": {
1837 "v_range": [["v6.0.0", ""]],
1838 "type": "string",
1839 "options": [
1840 {"value": "discard"},
1841 {"value": "pass"},
1842 {"value": "respond"},
1843 ],
1844 },
1845 "malformed_header_content_length": {
1846 "v_range": [["v6.0.0", ""]],
1847 "type": "string",
1848 "options": [
1849 {"value": "discard"},
1850 {"value": "pass"},
1851 {"value": "respond"},
1852 ],
1853 },
1854 "malformed_header_max_forwards": {
1855 "v_range": [["v6.0.0", ""]],
1856 "type": "string",
1857 "options": [
1858 {"value": "discard"},
1859 {"value": "pass"},
1860 {"value": "respond"},
1861 ],
1862 },
1863 "malformed_header_allow": {
1864 "v_range": [["v6.0.0", ""]],
1865 "type": "string",
1866 "options": [
1867 {"value": "discard"},
1868 {"value": "pass"},
1869 {"value": "respond"},
1870 ],
1871 },
1872 "malformed_header_p_asserted_identity": {
1873 "v_range": [["v6.0.0", ""]],
1874 "type": "string",
1875 "options": [
1876 {"value": "discard"},
1877 {"value": "pass"},
1878 {"value": "respond"},
1879 ],
1880 },
1881 "malformed_header_no_require": {
1882 "v_range": [["v7.0.0", ""]],
1883 "type": "string",
1884 "options": [
1885 {"value": "discard"},
1886 {"value": "pass"},
1887 {"value": "respond"},
1888 ],
1889 },
1890 "malformed_header_no_proxy_require": {
1891 "v_range": [["v7.0.0", ""]],
1892 "type": "string",
1893 "options": [
1894 {"value": "discard"},
1895 {"value": "pass"},
1896 {"value": "respond"},
1897 ],
1898 },
1899 "malformed_header_sdp_v": {
1900 "v_range": [["v6.0.0", ""]],
1901 "type": "string",
1902 "options": [
1903 {"value": "discard"},
1904 {"value": "pass"},
1905 {"value": "respond"},
1906 ],
1907 },
1908 "malformed_header_sdp_o": {
1909 "v_range": [["v6.0.0", ""]],
1910 "type": "string",
1911 "options": [
1912 {"value": "discard"},
1913 {"value": "pass"},
1914 {"value": "respond"},
1915 ],
1916 },
1917 "malformed_header_sdp_s": {
1918 "v_range": [["v6.0.0", ""]],
1919 "type": "string",
1920 "options": [
1921 {"value": "discard"},
1922 {"value": "pass"},
1923 {"value": "respond"},
1924 ],
1925 },
1926 "malformed_header_sdp_i": {
1927 "v_range": [["v6.0.0", ""]],
1928 "type": "string",
1929 "options": [
1930 {"value": "discard"},
1931 {"value": "pass"},
1932 {"value": "respond"},
1933 ],
1934 },
1935 "malformed_header_sdp_c": {
1936 "v_range": [["v6.0.0", ""]],
1937 "type": "string",
1938 "options": [
1939 {"value": "discard"},
1940 {"value": "pass"},
1941 {"value": "respond"},
1942 ],
1943 },
1944 "malformed_header_sdp_b": {
1945 "v_range": [["v6.0.0", ""]],
1946 "type": "string",
1947 "options": [
1948 {"value": "discard"},
1949 {"value": "pass"},
1950 {"value": "respond"},
1951 ],
1952 },
1953 "malformed_header_sdp_z": {
1954 "v_range": [["v6.0.0", ""]],
1955 "type": "string",
1956 "options": [
1957 {"value": "discard"},
1958 {"value": "pass"},
1959 {"value": "respond"},
1960 ],
1961 },
1962 "malformed_header_sdp_k": {
1963 "v_range": [["v6.0.0", ""]],
1964 "type": "string",
1965 "options": [
1966 {"value": "discard"},
1967 {"value": "pass"},
1968 {"value": "respond"},
1969 ],
1970 },
1971 "malformed_header_sdp_a": {
1972 "v_range": [["v6.0.0", ""]],
1973 "type": "string",
1974 "options": [
1975 {"value": "discard"},
1976 {"value": "pass"},
1977 {"value": "respond"},
1978 ],
1979 },
1980 "malformed_header_sdp_t": {
1981 "v_range": [["v6.0.0", ""]],
1982 "type": "string",
1983 "options": [
1984 {"value": "discard"},
1985 {"value": "pass"},
1986 {"value": "respond"},
1987 ],
1988 },
1989 "malformed_header_sdp_r": {
1990 "v_range": [["v6.0.0", ""]],
1991 "type": "string",
1992 "options": [
1993 {"value": "discard"},
1994 {"value": "pass"},
1995 {"value": "respond"},
1996 ],
1997 },
1998 "malformed_header_sdp_m": {
1999 "v_range": [["v6.0.0", ""]],
2000 "type": "string",
2001 "options": [
2002 {"value": "discard"},
2003 {"value": "pass"},
2004 {"value": "respond"},
2005 ],
2006 },
2007 "provisional_invite_expiry_time": {
2008 "v_range": [["v6.0.0", ""]],
2009 "type": "integer",
2010 },
2011 "ips_rtp": {
2012 "v_range": [["v6.0.0", ""]],
2013 "type": "string",
2014 "options": [{"value": "disable"}, {"value": "enable"}],
2015 },
2016 "ssl_mode": {
2017 "v_range": [["v6.0.0", ""]],
2018 "type": "string",
2019 "options": [{"value": "off"}, {"value": "full"}],
2020 },
2021 "ssl_send_empty_frags": {
2022 "v_range": [["v6.0.0", ""]],
2023 "type": "string",
2024 "options": [{"value": "enable"}, {"value": "disable"}],
2025 },
2026 "ssl_client_renegotiation": {
2027 "v_range": [["v6.0.0", ""]],
2028 "type": "string",
2029 "options": [
2030 {"value": "allow"},
2031 {"value": "deny"},
2032 {"value": "secure"},
2033 ],
2034 },
2035 "ssl_algorithm": {
2036 "v_range": [["v6.0.0", ""]],
2037 "type": "string",
2038 "options": [
2039 {"value": "high"},
2040 {"value": "medium"},
2041 {"value": "low"},
2042 ],
2043 },
2044 "ssl_pfs": {
2045 "v_range": [["v6.0.0", ""]],
2046 "type": "string",
2047 "options": [
2048 {"value": "require"},
2049 {"value": "deny"},
2050 {"value": "allow"},
2051 ],
2052 },
2053 "ssl_min_version": {
2054 "v_range": [["v6.0.0", ""]],
2055 "type": "string",
2056 "options": [
2057 {"value": "ssl-3.0"},
2058 {"value": "tls-1.0"},
2059 {"value": "tls-1.1"},
2060 {"value": "tls-1.2"},
2061 {"value": "tls-1.3", "v_range": [["v6.2.0", ""]]},
2062 ],
2063 },
2064 "ssl_max_version": {
2065 "v_range": [["v6.0.0", ""]],
2066 "type": "string",
2067 "options": [
2068 {"value": "ssl-3.0"},
2069 {"value": "tls-1.0"},
2070 {"value": "tls-1.1"},
2071 {"value": "tls-1.2"},
2072 {"value": "tls-1.3", "v_range": [["v6.2.0", ""]]},
2073 ],
2074 },
2075 "ssl_client_certificate": {
2076 "v_range": [["v6.0.0", ""]],
2077 "type": "string",
2078 },
2079 "ssl_server_certificate": {
2080 "v_range": [["v6.0.0", ""]],
2081 "type": "string",
2082 },
2083 "ssl_auth_client": {"v_range": [["v6.0.0", ""]], "type": "string"},
2084 "ssl_auth_server": {"v_range": [["v6.0.0", ""]], "type": "string"},
2085 },
2086 },
2087 "sccp": {
2088 "v_range": [["v6.0.0", ""]],
2089 "type": "dict",
2090 "children": {
2091 "status": {
2092 "v_range": [["v6.0.0", ""]],
2093 "type": "string",
2094 "options": [{"value": "disable"}, {"value": "enable"}],
2095 },
2096 "block_mcast": {
2097 "v_range": [["v6.0.0", ""]],
2098 "type": "string",
2099 "options": [{"value": "disable"}, {"value": "enable"}],
2100 },
2101 "verify_header": {
2102 "v_range": [["v6.0.0", ""]],
2103 "type": "string",
2104 "options": [{"value": "disable"}, {"value": "enable"}],
2105 },
2106 "log_call_summary": {
2107 "v_range": [["v6.0.0", ""]],
2108 "type": "string",
2109 "options": [{"value": "disable"}, {"value": "enable"}],
2110 },
2111 "log_violations": {
2112 "v_range": [["v6.0.0", ""]],
2113 "type": "string",
2114 "options": [{"value": "disable"}, {"value": "enable"}],
2115 },
2116 "max_calls": {"v_range": [["v6.0.0", ""]], "type": "integer"},
2117 },
2118 },
2119 "msrp": {
2120 "v_range": [["v7.0.2", ""]],
2121 "type": "dict",
2122 "children": {
2123 "status": {
2124 "v_range": [["v7.0.2", ""]],
2125 "type": "string",
2126 "options": [{"value": "disable"}, {"value": "enable"}],
2127 },
2128 "log_violations": {
2129 "v_range": [["v7.0.2", ""]],
2130 "type": "string",
2131 "options": [{"value": "disable"}, {"value": "enable"}],
2132 },
2133 "max_msg_size": {"v_range": [["v7.0.2", ""]], "type": "integer"},
2134 "max_msg_size_action": {
2135 "v_range": [["v7.0.2", ""]],
2136 "type": "string",
2137 "options": [
2138 {"value": "pass"},
2139 {"value": "block"},
2140 {"value": "reset"},
2141 {"value": "monitor"},
2142 ],
2143 },
2144 },
2145 },
2146 },
2147 "v_range": [["v6.0.0", ""]],
2148 }
2149
2150
2151 def main():
2152 module_spec = schema_to_module_spec(versioned_schema)
2153 mkeyname = "name"
2154 fields = {
2155 "access_token": {"required": False, "type": "str", "no_log": True},
2156 "enable_log": {"required": False, "type": "bool", "default": False},
2157 "vdom": {"required": False, "type": "str", "default": "root"},
2158 "member_path": {"required": False, "type": "str"},
2159 "member_state": {
2160 "type": "str",
2161 "required": False,
2162 "choices": ["present", "absent"],
2163 },
2164 "state": {"required": True, "type": "str", "choices": ["present", "absent"]},
2165 "voip_profile": {
2166 "required": False,
2167 "type": "dict",
2168 "default": None,
2169 "options": {},
2170 },
2171 }
2172 for attribute_name in module_spec["options"]:
2173 fields["voip_profile"]["options"][attribute_name] = module_spec["options"][
2174 attribute_name
2175 ]
2176 if mkeyname and mkeyname == attribute_name:
2177 fields["voip_profile"]["options"][attribute_name]["required"] = True
2178
2179 module = AnsibleModule(argument_spec=fields, supports_check_mode=True)
2180 check_legacy_fortiosapi(module)
2181
2182 is_error = False
2183 has_changed = False
2184 result = None
2185 diff = None
2186
2187 versions_check_result = None
2188 if module._socket_path:
2189 connection = Connection(module._socket_path)
2190 if "access_token" in module.params:
2191 connection.set_custom_option("access_token", module.params["access_token"])
2192
2193 if "enable_log" in module.params:
2194 connection.set_custom_option("enable_log", module.params["enable_log"])
2195 else:
2196 connection.set_custom_option("enable_log", False)
2197 fos = FortiOSHandler(connection, module, mkeyname, admin_passwd_header=False)
2198 versions_check_result = check_schema_versioning(
2199 fos, versioned_schema, "voip_profile"
2200 )
2201
2202 is_error, has_changed, result, diff = fortios_voip(
2203 module.params, fos, module.check_mode
2204 )
2205
2206 else:
2207 module.fail_json(**FAIL_SOCKET_MSG)
2208
2209 if versions_check_result and versions_check_result["matched"] is False:
2210 module.warn(
2211 "Ansible has detected version mismatch between FortOS system and your playbook, see more details by specifying option -vvv"
2212 )
2213
2214 if not is_error:
2215 if versions_check_result and versions_check_result["matched"] is False:
2216 module.exit_json(
2217 changed=has_changed,
2218 version_check_warning=versions_check_result,
2219 meta=result,
2220 diff=diff,
2221 )
2222 else:
2223 module.exit_json(changed=has_changed, meta=result, diff=diff)
2224 else:
2225 if versions_check_result and versions_check_result["matched"] is False:
2226 module.fail_json(
2227 msg="Error in repo",
2228 version_check_warning=versions_check_result,
2229 meta=result,
2230 )
2231 else:
2232 module.fail_json(msg="Error in repo", meta=result)
2233
2234
2235 if __name__ == "__main__":
2236 main()