fortinet-solutions-cse/40ansible

No JSON object could be decoded

Opened this issue · 1 comments

- hosts: localhost
  vars_files:
   - /home/centos/ansible/40ansible/vars/main.yml
  gather_facts: no
  tasks:
   - name: backup system config
     fortiosconfig:
       config: "system config backup"
       action: "backup"
       host:  "{{ host }}"
       username: "{{ username }}"
       password: "{{ password }}"
       vdom: "global"
       config_parameters:
        filename: "backup_config_001"

Error:

<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767 `" && echo ansible-tmp-1544694017.59-81219007331767="` echo /root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767 `" ) && sleep 0'
Using module file /home/centos/ansible/40ansible/library/fortiosconfig.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-4545fKpH0J/tmpWKs7jH TO /root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767/AnsiballZ_fortiosconfig.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767/ /root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767/AnsiballZ_fortiosconfig.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767/AnsiballZ_fortiosconfig.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767/AnsiballZ_fortiosconfig.py", line 113, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767/AnsiballZ_fortiosconfig.py", line 105, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1544694017.59-81219007331767/AnsiballZ_fortiosconfig.py", line 48, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/tmp/ansible_fortiosconfig_payload_417Zzw/__main__.py", line 845, in <module>
  File "/tmp/ansible_fortiosconfig_payload_417Zzw/__main__.py", line 833, in main
  File "/tmp/ansible_fortiosconfig_payload_417Zzw/__main__.py", line 720, in fortigate_config_backup
  File "/usr/lib/python2.7/site-packages/fortiosapi/fortiosapi.py", line 191, in monitor
    return self.formatresponse(res, vdom=vdom)
  File "/usr/lib/python2.7/site-packages/fortiosapi/fortiosapi.py", line 87, in formatresponse
    resp = json.loads(res.content.decode('utf-8'))[0]
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: No JSON object could be decoded
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1544692684.03-2  7946625238735/AnsiballZ_fortiosconfig.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1544692684.03-27946625238735/  AnsiballZ_fortiosconfig.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp  -1544692684.03-27946625238735/AnsiballZ_fortiosconfig.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/an  sible_fortiosconfig_payload_WnNTvM/__main__.py\", line 845, in <module>\n  File \"/tmp/ansible_fortiosconfig_payload_WnNTvM/__main__.py\", line 833, in main\n    File \"/tmp/ansible_fortiosconfig_payload_WnNTvM/__main__.py\", line 720, in fortigate_config_backup\n  File \"/usr/lib/python2.7/site-packages/fortiosapi/for  tiosapi.py\", line 191, in monitor\n    return self.formatresponse(res, vdom=vdom)\n  File \"/usr/lib/python2.7/site-packages/fortiosapi/fortiosapi.py\", line   91, in formatresponse\n    resp = json.loads(res.content.decode('utf-8'))\n  File \"/usr/lib64/python2.7/json/__init__.py\", line 338, in loads\n    return _de  fault_decoder.decode(s)\n  File \"/usr/lib64/python2.7/json/decoder.py\", line 366, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n  File \"  /usr/lib64/python2.7/json/decoder.py\", line 384, in raw_decode\n    raise ValueError(\"No JSON object could be decoded\")\nValueError: No JSON object could be   decoded\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

solved using fortios_config:

  • name: backup system config
    fortios_config:
    host: "{{ host }}"
    username: "{{ username }}"
    password: "{{ password }}"
    backup: yes
    backup_path: /tmp/forti_backup/
    backup_filename: "test"