I have a problem when I used Ansible to config Fortigate

36 Views Asked by At

I tried to follow the user's guide on this website "https://ansible-galaxy-fortios-docs.readthedocs.io/en/latest/playbook.html" But it wasn't successful.

YML Playbook

---
- hosts: fortigate01
  connection: httpapi
  collections:
  - fortinet.fortios
  vars:
   vdom: "root"
   ansible_httpapi_use_ssl: true
   ansible_httpapi_validate_certs: false
   ansible_httpapi_port: 443
  tasks:
   - name: Configure global attributes.
     fortios_system_global:
        vdom:  "{{ vdom }}"
        system_global:
            hostname: 'FGT40F-VPN4'

Host file


[fortigates]
fortigate01 ansible_host=10.15.4.1 ansible_user="admin" ansible_password="password"
[fortigates:vars]
ansible_network_os=fortinet.fortios.fortio

Error Output

The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-local-7747sp358ucc/ansible-tmp-1710926320.9967477-7833-72418283842729/AnsiballZ_fortios_system_global.py", line 107, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-local-7747sp358ucc/ansible-tmp-1710926320.9967477-7833-72418283842729/AnsiballZ_fortios_system_global.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-local-7747sp358ucc/ansible-tmp-1710926320.9967477-7833-72418283842729/AnsiballZ_fortios_system_global.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.fortinet.fortios.plugins.modules.fortios_system_global', init_globals=dict(_module_fqn='ansible_collections.fortinet.fortios.plugins.modules.fortios_system_global', _modlib_path=modlib_path),
  File "/usr/lib/python3.10/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_fortios_system_global_payload_403qmu53/ansible_fortios_system_global_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_system_global.py", line 4011, in <module>
  File "/tmp/ansible_fortios_system_global_payload_403qmu53/ansible_fortios_system_global_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_system_global.py", line 3975, in main
  File "/tmp/ansible_fortios_system_global_payload_403qmu53/ansible_fortios_system_global_payload.zip/ansible_collections/fortinet/fortios/plugins/module_utils/fortios/fortios.py", line 261, in check_schema_versioning
  File "/tmp/ansible_fortios_system_global_payload_403qmu53/ansible_fortios_system_global_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
ansible.module_utils.connection.ConnectionError: Expecting value: line 1 column 1 (char 0)
fatal: [fortigate01]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-local-7747sp358ucc/ansible-tmp-1710926320.9967477-7833-72418283842729/AnsiballZ_fortios_system_global.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-local-7747sp358ucc/ansible-tmp-1710926320.9967477-7833-72418283842729/AnsiballZ_fortios_system_global.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-local-7747sp358ucc/ansible-tmp-1710926320.9967477-7833-72418283842729/AnsiballZ_fortios_system_global.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.fortinet.fortios.plugins.modules.fortios_system_global', init_globals=dict(_module_fqn='ansible_collections.fortinet.fortios.plugins.modules.fortios_system_global', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_fortios_system_global_payload_403qmu53/ansible_fortios_system_global_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_system_global.py\", line 4011, in <module>\n  File \"/tmp/ansible_fortios_system_global_payload_403qmu53/ansible_fortios_system_global_payload.zip/ansible_collections/fortinet/fortios/plugins/modules/fortios_system_global.py\", line 3975, in main\n  File \"/tmp/ansible_fortios_system_global_payload_403qmu53/ansible_fortios_system_global_payload.zip/ansible_collections/fortinet/fortios/plugins/module_utils/fortios/fortios.py\", line 261, in check_schema_versioning\n  File \"/tmp/ansible_fortios_system_global_payload_403qmu53/ansible_fortios_system_global_payload.zip/ansible/module_utils/connection.py\", line 200, in __rpc__\nansible.module_utils.connection.ConnectionError: Expecting value: line 1 column 1 (char 0)\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}


And I have installed the Ansible Galaxy package latest version

I would like to know what is causing the problem.

Ubuntu 22.04.3 LTS

ansible core version 2.15.9

My Fortigate 40F Firmware v6.0.13 build6893

0

There are 0 best solutions below