Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
systemgeek
Contributor II

Unknown platform when using ansible on fortigate

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.

1 Solution
Yurisk
SuperUser
SuperUser

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" 

https://yurisk.info

View solution in original post

https://yurisk.info
2 REPLIES 2
systemgeek
Contributor II

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

Yurisk
SuperUser
SuperUser

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" 

https://yurisk.info
https://yurisk.info
Announcements
Check out our Community Chatter Blog! Click here to get involved
Labels
Top Kudoed Authors