{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/11007","labels_url":"https://api.github.com/repos/ansible/ansible/issues/11007/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/11007/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/11007/events","html_url":"https://github.com/ansible/ansible/issues/11007","id":76265354,"number":11007,"title":"ansible  inventory script ValueError: No JSON object could be decoded","user":{"login":"baxiaoshi","id":11749031,"avatar_url":"https://avatars.githubusercontent.com/u/11749031?v=3","gravatar_id":"","url":"https://api.github.com/users/baxiaoshi","html_url":"https://github.com/baxiaoshi","followers_url":"https://api.github.com/users/baxiaoshi/followers","following_url":"https://api.github.com/users/baxiaoshi/following{/other_user}","gists_url":"https://api.github.com/users/baxiaoshi/gists{/gist_id}","starred_url":"https://api.github.com/users/baxiaoshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baxiaoshi/subscriptions","organizations_url":"https://api.github.com/users/baxiaoshi/orgs","repos_url":"https://api.github.com/users/baxiaoshi/repos","events_url":"https://api.github.com/users/baxiaoshi/events{/privacy}","received_events_url":"https://api.github.com/users/baxiaoshi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-14T07:17:57Z","updated_at":"2015-05-14T07:17:57Z","closed_at":null,"body":"cat inventory/get_hosts.py \r\n#!/usr/sbin/python2.7\r\n#import argparse\r\nimport redis \r\nimport json \r\nimport sys\r\n\r\n\r\ndef get_all_members(parsed_args=\"\"):\r\n    r = redis.StrictRedis(host='172.16.1.220')\r\n    return_data = {'local':'127.0.0.1'}\r\n    all_groups =  r.keys()\r\n    for group in all_groups:\r\n        return_data[group] = {'hosts':[]}\r\n        for host in r.hkeys(group):\r\n                return_data[group]['hosts'].append(host)\r\n    print json.dumps(return_data,indent=4)\r\n\r\ndef get_group_members(groupname):\r\n    print json.dumps({groupname:r.hkeys(groupname)})\r\n\r\ndef get_host(host):\r\n    print json.dumps(host)\r\n\r\nif __name__ == \"__main__\":\r\n    print sys.argv\r\n    if len(sys.argv) == 2 and (sys.argv[1] == '--list'):\r\n        get_all_members()\r\n\r\nWhen I use the following command execution ansible\r\nansible --inventory-file=/etc/ansible/inventory/get_hosts.py  all \r\nto me:\r\n  File \"/usr/local/python/lib/python2.7/json/decoder.py\", line 346, in decode\r\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n  File \"/usr/local/python/lib/python2.7/json/decoder.py\", line 365, in raw_decode\r\n    raise ValueError(\"No JSON object could be decoded\")\r\nValueError: No JSON object could be decoded\r\n\r\nMy English is not very good, thank you!"}}