Skip to main content
systemgeek
Visitor III
May 23, 2025
Solved

Unknown platform when using ansible on fortigate

  • May 23, 2025
  • 2 replies
  • 1264 views

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.

Best answer by Yurisk

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" 

2 replies

systemgeek
Visitor III
May 23, 2025

I was able to use connection: httpapi to access the fortigate.  Kinda surprised there is no way to do this via SSH.

Yurisk
SuperUser
YuriskAnswer
SuperUser
May 23, 2025

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" 

yurisk.info - all things Fortinet blog, no ads
Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!