network-automation/ansible_inventory_report

error when run inventory-ios.yml

hoyeunglee opened this issue · 12 comments

TASK [gathering IOS XE facts] **************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: No JSON object could be decoded
fatal: [noc01as01]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/home/martin/.ansible/tmp/ansible-tmp-1540945702.87-111704655859437/AnsiballZ_ios_facts.py", line 113, in \n _ansiballz_main()\n File "/home/martin/.ansible/tmp/ansible-tmp-1540945702.87-111704655859437/AnsiballZ_ios_facts.py", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/martin/.ansible/tmp/ansible-tmp-1540945702.87-111704655859437/AnsiballZ_ios_facts.py", line 48, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File "/tmp/ansible_ios_facts_payload_20JweU/main.py", line 543, in \n File "/tmp/ansible_ios_facts_payload_20JweU/main.py", line 529, in main\n File "/tmp/ansible_ios_facts_payload_20JweU/main.py", line 228, in populate\n File "/tmp/ansible_ios_facts_payload_20JweU/main.py", line 164, in populate\n File "/tmp/ansible_ios_facts_payload_20JweU/ansible_ios_facts_payload.zip/ansible/module_utils/network/ios/ios.py", line 135, in run_commands\n File "/tmp/ansible_ios_facts_payload_20JweU/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py", line 167, in rpc\n File "/tmp/ansible_ios_facts_payload_20JweU/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py", line 146, in _exec_jsonrpc\n File "/usr/lib/python2.7/json/init.py", line 339, in loads\n return _default_decoder.decode(s)\n File "/usr/lib/python2.7/json/decoder.py", line 364, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n File "/usr/lib/python2.7/json/decoder.py", line 382, 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}

which version of ansible? (cut and paste ansible --version), and what version of IOS? (do a show version)

ansible 2.7.1

can you git pull the latest, there was just a PR in here to switch to network_cli. The error you have on ansible/ansible#47836 is about jinja2 installing... that doesn't make sense to me.

after you update the git repo, can you re-run with -vvvv and paste the output?

can I also see your inventory?

[Testdevices]
noc01as01
c0101as01

[Testdevices:vars]
ansible_network_os=ios

i change to Testdevices , still error,

i use other script can get config, but i guess this script error due to template
may not have hostvars[network_switch] or other variables

martin@ubuntu:/etc/ansible$ ansible -m ios_facts -u martinlee -k noc01as01
SSH password:
noc01as01 | FAILED! => {
"changed": false,
"msg": "Connection type ssh is not valid for this module"
}

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="css/main.css">
</head>
<body>
<table>
    <thead>
        <tr>
            <th>Hostname</th>
            <th>Model Type</th>
            <th>Serial Number</th>
        </tr>
    </thead>
    <tbody>
{% for network_switch in groups['Testdevices'] %}
        <tr>
            <td>{{hostvars[network_switch]['ansible_net_hostname']}}</td>
            <td>{{hostvars[network_switch]['ansible_net_model']}}</td>
            <td>{{hostvars[network_switch]['ansible_net_serialnum']}}</td>
        </tr>
{% endfor %}
    </tbody>
</table>

</body>
</html>

TASK [gathering IOS XE facts] **************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: No JSON object could be decoded
fatal: [c0101as01]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/martin/.ansible/tmp/ansible-tmp-1541059761.13-131561984825353/AnsiballZ_ios_facts.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/home/martin/.ansible/tmp/ansible-tmp-1541059761.13-131561984825353/AnsiballZ_ios_facts.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/martin/.ansible/tmp/ansible-tmp-1541059761.13-131561984825353/AnsiballZ_ios_facts.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_ios_facts_payload_rTPxya/__main__.py\", line 543, in <module>\n  File \"/tmp/ansible_ios_facts_payload_rTPxya/__main__.py\", line 529, in main\n  File \"/tmp/ansible_ios_facts_payload_rTPxya/__main__.py\", line 228, in populate\n  File \"/tmp/ansible_ios_facts_payload_rTPxya/__main__.py\", line 164, in populate\n  File \"/tmp/ansible_ios_facts_payload_rTPxya/ansible_ios_facts_payload.zip/ansible/module_utils/network/ios/ios.py\", line 135, in run_commands\n  File \"/tmp/ansible_ios_facts_payload_rTPxya/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py\", line 167, in __rpc__\n  File \"/tmp/ansible_ios_facts_payload_rTPxya/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py\", line 146, in _exec_jsonrpc\n  File \"/usr/lib/python2.7/json/__init__.py\", line 339, in loads\n    return _default_decoder.decode(s)\n  File \"/usr/lib/python2.7/json/decoder.py\", line 364, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n  File \"/usr/lib/python2.7/json/decoder.py\", line 382, 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}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: No JSON object could be decoded
fatal: [noc01as01]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/martin/.ansible/tmp/ansible-tmp-1541059761.13-127531505657203/AnsiballZ_ios_facts.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/home/martin/.ansible/tmp/ansible-tmp-1541059761.13-127531505657203/AnsiballZ_ios_facts.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/martin/.ansible/tmp/ansible-tmp-1541059761.13-127531505657203/AnsiballZ_ios_facts.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_ios_facts_payload_IgBMVP/__main__.py\", line 543, in <module>\n  File \"/tmp/ansible_ios_facts_payload_IgBMVP/__main__.py\", line 529, in main\n  File \"/tmp/ansible_ios_facts_payload_IgBMVP/__main__.py\", line 228, in populate\n  File \"/tmp/ansible_ios_facts_payload_IgBMVP/__main__.py\", line 164, in populate\n  File \"/tmp/ansible_ios_facts_payload_IgBMVP/ansible_ios_facts_payload.zip/ansible/module_utils/network/ios/ios.py\", line 135, in run_commands\n  File \"/tmp/ansible_ios_facts_payload_IgBMVP/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py\", line 167, in __rpc__\n  File \"/tmp/ansible_ios_facts_payload_IgBMVP/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py\", line 146, in _exec_jsonrpc\n  File \"/usr/lib/python2.7/json/__init__.py\", line 339, in loads\n    return _default_decoder.decode(s)\n  File \"/usr/lib/python2.7/json/decoder.py\", line 364, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n  File \"/usr/lib/python2.7/json/decoder.py\", line 382, 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}


change this->

martin@ubuntu:/etc/ansible$ ansible -m ios_facts -u martinlee -k noc01as01

to

martin@ubuntu:/etc/ansible$ ansible -m ios_facts -u martinlee -k noc01as01 -c network_cli

martin@ubuntu:/etc/ansible$ ansible -m ios_facts -u martinlee -k noc01as01 -c network_cli
SSH password:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: No JSON object could be decoded
noc01as01 | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File "/home/martin/.ansible/tmp/ansible-local-2395_beMfx/ansible-tmp-1541118182.69-119543614930279/AnsiballZ_ios_facts.py", line 113, in \n _ansiballz_main()\n File "/home/martin/.ansible/tmp/ansible-local-2395_beMfx/ansible-tmp-1541118182.69-119543614930279/AnsiballZ_ios_facts.py", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/martin/.ansible/tmp/ansible-local-2395_beMfx/ansible-tmp-1541118182.69-119543614930279/AnsiballZ_ios_facts.py", line 48, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File "/tmp/ansible_ios_facts_payload_w7ex2y/main.py", line 543, in \n File "/tmp/ansible_ios_facts_payload_w7ex2y/main.py", line 529, in main\n File "/tmp/ansible_ios_facts_payload_w7ex2y/main.py", line 228, in populate\n File "/tmp/ansible_ios_facts_payload_w7ex2y/main.py", line 164, in populate\n File "/tmp/ansible_ios_facts_payload_w7ex2y/ansible_ios_facts_payload.zip/ansible/module_utils/network/ios/ios.py", line 135, in run_commands\n File "/tmp/ansible_ios_facts_payload_w7ex2y/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py", line 167, in rpc\n File "/tmp/ansible_ios_facts_payload_w7ex2y/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py", line 146, in _exec_jsonrpc\n File "/usr/lib/python2.7/json/init.py", line 339, in loads\n return _default_decoder.decode(s)\n File "/usr/lib/python2.7/json/decoder.py", line 364, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n File "/usr/lib/python2.7/json/decoder.py", line 382, 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
}

this has got to be a bad install, uninstall ansible and reinstall

I use apt get install , not the link of ansible tower, Is apt get install a correct install?

I prepare apt get uninstall and install

i apt-get remove ansible and apt-get install ansible again, still have error

this is not a project problem, this is a user error installing ansible

I uninstall version 2.7.1 and install 2.6 then works and thanks