ansible [core 2.15.13]
python version = 3.9.18
fortigate running 7.6.2
Installed the latest fortios collection in ansible.
When ever I run a simple playbook I get the following:
[root@fm02-proxy02a ansible]# ansible -i hosts all -m ping
[WARNING]: Unhandled error in Python interpreter discovery for host us2fgt1.example.net: unexpected output from Python interpreter discovery
[WARNING]: Platform unknown on host us2fgt1.example.net is using the discovered Python interpreter at /usr/bin/python, but future installation of another
Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.15/reference_appendices/interpreter_discovery.html for
more information.
us2fgt1.exmaple.net | FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"module_stderr": "",
"module_stdout": "us2fgt1 # Unknown action 0\n\nus2fgt1 # ",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}
I am trying to use ssh with an ssh key to access the fortigate. From the command line I can ssh to the fortigate with the ssh key just fine. So why is ansible having difficulties? Is it because ansible cannot find python on the fortigate and does not know what to do at this point? I have this same error if I do a ping or try to use one of the fortios collections do something on the fortigate.
Solved! Go to Solution.
Yep, as you already found, all Ansible Fortinet modules use HTTPS and REST API for automation, as said here: https://github.com/fortinet-ansible-dev/ansible-galaxy-fortios-collection
"The FortiOS collection supports both username/password and access token authentication, with access tokens being the recommended method for enhanced security. For more information about generating an access_token, please refer to https://ansible-galaxy-fortios-docs.readthedocs.io/en/latest/faq.html#what-s-access-token"
I was able to use connection: httpapi to access the fortigate. Kinda surprised there is no way to do this via SSH.
Yep, as you already found, all Ansible Fortinet modules use HTTPS and REST API for automation, as said here: https://github.com/fortinet-ansible-dev/ansible-galaxy-fortios-collection
"The FortiOS collection supports both username/password and access token authentication, with access tokens being the recommended method for enhanced security. For more information about generating an access_token, please refer to https://ansible-galaxy-fortios-docs.readthedocs.io/en/latest/faq.html#what-s-access-token"
User | Count |
---|---|
2570 | |
1362 | |
796 | |
651 | |
455 |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.