-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No matter what I try I am unable to push configuration to fortimanager #58
Comments
Hi, Did you configure something like this on your FMG? config system admin user
edit admin
set rpc-permit read-write
next
end BR. |
Yes, I have it configured already. |
I have the exact same issue. This is the same issue as this old one that was patched a while ago. Ref; ftntcorecse/fndn_ansible#4 Fresh new install in new venv with Python 3.8 and Ansible 2.13.8
I got the latest collections from Galaxy.
That's pretty much the only collections installed in this venv. Running the sample playbook from https://ansible-galaxy-fortimanager-docs.readthedocs.io/en/latest/playbook.html or any other playbooks returns the same error.
There is no attempt to connect to the FortiManager from Ansible (I ran a tcpdump and there is no connection). There is no recommendations in the documentation for the version of Python and Ansible for any specific versions of the FortiManager collection. I am also trying to find the proper recipe to make this work. |
We tried to run another more simple playbook by simply log in with fmgr_sys_login_user. The key error is:
But even if we set rc_succeeded: [0, 1] we still get an error with code 1. We tried the same call in Postman and we get an rc code of 0. {
"id": 1,
"method": "exec",
"params": [
{
"data": {
"user": "{{user}}",
"passwd": "{{password}}"
},
"url": "/sys/login/user"
}
]
} Answer: {
"id": 1,
"result": [
{
"status": {
"code": 0,
"message": "OK"
},
"url": "/sys/login/user"
}
],
"session": "vxRtEGZz6GbDIQXL5MwoG7o9bgZUJgfsEXMLCQOrMM9DATc5YPRFwQ3wik9iHPk357BR5IJQoYnnQyZqUyiMsQ=="
} Code is 0 in the ouput. We believe that the permissions in the Fortimanager, for our user, are allowing us to login (hence Postman output) but the Ansible Collection equivalent must be doing something else as a RC of 1 is returned. Our FortiManager version is v7.2.2 GA build1334 With this playbook, we still do not see Ansible connecting to the FortiManager in our tcpdump. This is simply trying a login... any help would be appreciated. |
Hi all, I can reproduce this issue with latest ansible-core version, could you please downgrade it to 2.12.3 by run Thanks, |
Same error message...
Here is the output of the playbook run (redacted to remove sensible information):
|
Hi @Wallpix , Your environment looks good to me, this error usually happens when credentials' information are wrong, could you help me delete the local log file
Thanks, |
So, our userID to connect to FortiManager does not have system access (in its applied profile) as we were trying to go with the least permissions required for this API access. The log file location was also overlooked. We did enable logging at some point but we did not find the file location until you pointed it out. Oh and by the way, it's This is now clear that the issue is related to the userID access as per the following logs:
Maybe the error message should be a bit more detailed. The session did work, but some access were denied. Also, is there any reference to this requirement either in the collection's documentation of the FortiManager admin guide? |
inventory-file
[fortimanager]
192.168.122.51
[fortimanager:vars]
ansible_user=admin
ansible_password=password
ansible_network_os=fortinet.fortimanager.fortimanager
playbook file
hosts: fortimanager
collections:
connection: httpapi
gather_facts: false
vars:
ansible_httpapi_use_ssl: yes
ansible_httpapi_validate_certs: no
ansible_httpapi_port: 443
tasks:
fmgr_firewall_address:
bypass_validation: False
adom: root
state: present
firewall_address:
allow-routing: disable
associated-interface: any
name: 'ansible-test'
visibility: disable
hosts: fortimanager
collections:
connection: httpapi
gather_facts: false
vars:
ansible_httpapi_use_ssl: yes
ansible_httpapi_validate_certs: no
ansible_httpapi_port: 443
tasks:
fmgr_firewall_address:
bypass_validation: False
adom: root
state: present
firewall_address:
allow-routing: disable
associated-interface: any
name: 'ansible-test'
visibility: disable
<192.168.122.51> EXEC /bin/sh -c 'rm -f -r /home/superuser/.ansible/tmp/ansible-local-4971aga3wpy3/ansible-tmp-1673134266.360391-95251768668581/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/home/superuser/.ansible/tmp/ansible-local-4971aga3wpy3/ansible-tmp-1673134266.360391-95251768668581/AnsiballZ_fmgr_firewall_address.py", line 102, in
_ansiballz_main()
File "/home/superuser/.ansible/tmp/ansible-local-4971aga3wpy3/ansible-tmp-1673134266.360391-95251768668581/AnsiballZ_fmgr_firewall_address.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/superuser/.ansible/tmp/ansible-local-4971aga3wpy3/ansible-tmp-1673134266.360391-95251768668581/AnsiballZ_fmgr_firewall_address.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.fortinet.fortimanager.plugins.modules.fmgr_firewall_address', init_globals=None, run_name='main', alter_sys=False)
File "/usr/lib/python3.10/runpy.py", line 227, in run_module
return _run_code(code, {}, init_globals, run_name, mod_spec)
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_address.py", line 2191, in
File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_address.py", line 2182, in main
File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible_collections/fortinet/fortimanager/plugins/module_utils/napi.py", line 146, in init
File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible_collections/fortinet/fortimanager/plugins/module_utils/napi.py", line 326, in get_system_status
File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible/module_utils/connection.py", line 185, in rpc
ansible.module_utils.connection.ConnectionError: An attempt was made at communicating with a FMG with no valid session and an unexpected error was discovered.
[DEPRECATION WARNING]: Distribution ubuntu 22.04 on host 192.168.122.51 should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A
future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for
more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
fatal: [192.168.122.51]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File "/home/superuser/.ansible/tmp/ansible-local-4971aga3wpy3/ansible-tmp-1673134266.360391-95251768668581/AnsiballZ_fmgr_firewall_address.py", line 102, in \n _ansiballz_main()\n File "/home/superuser/.ansible/tmp/ansible-local-4971aga3wpy3/ansible-tmp-1673134266.360391-95251768668581/AnsiballZ_fmgr_firewall_address.py", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/superuser/.ansible/tmp/ansible-local-4971aga3wpy3/ansible-tmp-1673134266.360391-95251768668581/AnsiballZ_fmgr_firewall_address.py", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.fortinet.fortimanager.plugins.modules.fmgr_firewall_address', init_globals=None, run_name='main', alter_sys=False)\n File "/usr/lib/python3.10/runpy.py", line 227, in run_module\n return _run_code(code, {}, init_globals, run_name, mod_spec)\n File "/usr/lib/python3.10/runpy.py", line 86, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_address.py", line 2191, in \n File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_address.py", line 2182, in main\n File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible_collections/fortinet/fortimanager/plugins/module_utils/napi.py", line 146, in init\n File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible_collections/fortinet/fortimanager/plugins/module_utils/napi.py", line 326, in get_system_status\n File "/tmp/ansible_fmgr_firewall_address_payload_iqs22y_6/ansible_fmgr_firewall_address_payload.zip/ansible/module_utils/connection.py", line 185, in rpc\nansible.module_utils.connection.ConnectionError: An attempt was made at communicating with a FMG with no valid session and an unexpected error was discovered.\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
Do you guys recommend a specific ansible version / python?
The text was updated successfully, but these errors were encountered: