Ansible connects to FortiGate using an API, which is a method of communication between different
software components. Ansible uses the fortios_* modules to interact with the FortiOS API, which is a
RESTful API that allows configuration and monitoring of FortiGate devices12. Ansible can use either
HTTP or HTTPS as the transport protocol, and can authenticate with either a username and password
or an API token3.
The other options are incorrect because:
Ansible does not use TCP port 21 to connect to FortiGate. Port 21 is typically used for FTP, which is
not supported by FortiOS4.
Ansible does not use SSH as a connection method to FortiOS. SSH is a secure shell protocol that
allows remote command execution and file transfer, but it is not the preferred way of automating
configuration changes on FortiGate devices.
Ansible does not use YAML to connect to FortiGate. YAML is a data serialization language that Ansible
uses to write playbooks and inventory files, but it is not a connection method. Reference:
Fortinet.Fortios — Ansible Documentation
FortiOS REST API Reference
FortiOS Module Guide — Ansible Documentation
FortiOS 7.0 CLI Reference
[Connection methods and details — Ansible Documentation]
[YAML Syntax — Ansible Documentation]