添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

Bug Report

Ansible Version:
ansible 2.0.0 (devel b97887ba41) last updated 2015/10/30 17:11:02 (GMT +200)
  lib/ansible/modules/core: (detached HEAD a3a7cdb9aa) last updated 2015/10/30 17:36:37 (GMT +200)
  lib/ansible/modules/extras: (detached HEAD b1db0e893c) last updated 2015/10/30 17:36:37 (GMT +200)
  config file = /[REDACTED]/ansible.cfg
  configured module search path = None
Environment:

What OS are you running Ansible from: Ubuntu 14.04.3 LTS
And what OS are you managing? Red Hat Enterprise Linux Server release 6.7 (Santiago)

Summary:

Executing a "service" task always fails with ValueError: No JSON object could be decoded error.

Steps To Reproduce:

The failing task (from role ansible-role-check_mk-agent):

- name: Make sure Xinetd is running
  service: name=xinetd state=started
  tags: [ 'configuration', 'package', 'check_mk-agent' ]
Expected Results:

An "OK" status, as Xinetd is actually running (pgrep xinetd on the server output 31637).

Actual Results:
TASK [check_mk-agent : Make sure Xinetd is running] ****************************
fatal: [example.com]: FAILED! => {"changed": false, "failed": true, "msg": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service\", line 3418, in <module>\r\n    main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service\", line 1468, in main\r\n    service.get_service_status()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service\", line 566, in get_service_status\r\n    rc, status_stdout, status_stderr = self.service_control()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service\", line 893, in service_control\r\n    rc_state, stdout, stderr = self.execute_command(\"%s %s %s\" % (svc_cmd, self.action, arguments), daemonize=True)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service\", line 257, in execute_command\r\n    return json.loads(data)\r\n  File \"/usr/lib64/python2.6/json/__init__.py\", line 307, in loads\r\n    return _default_decoder.decode(s)\r\n  File \"/usr/lib64/python2.6/json/decoder.py\", line 319, in decode\r\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n  File \"/usr/lib64/python2.6/json/decoder.py\", line 338, in raw_decode\r\n    raise ValueError(\"No JSON object could be decoded\")\r\nValueError: No JSON object could be decoded\r\n", "parsed": false}

I used ANSIBLE_KEEP_REMOTE_FILES=1 to try directly on the server, and it is also failing:

python /root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service", line 3418, in <module>
    main()
  File "/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service", line 1468, in main
    service.get_service_status()
  File "/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service", line 566, in get_service_status
    rc, status_stdout, status_stderr = self.service_control()
  File "/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service", line 893, in service_control
    rc_state, stdout, stderr = self.execute_command("%s %s %s" % (svc_cmd, self.action, arguments), daemonize=True)
  File "/root/.ansible/tmp/ansible-tmp-1446223145.3-3902778941545/service", line 257, in execute_command
    return json.loads(data)
  File "/usr/lib64/python2.6/json/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.6/json/decoder.py", line 319, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.6/json/decoder.py", line 338, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Workaround fix

I found that it was necessary to modify the /etc/sysconfig/i18n file to modify a line from LC_ALL="fr_FR@euro" to LC_ALL="en_US.UTF-8"

This looks like the issue #11055 is not really fixed by #12830 :-(

I cannot reproduce the issue in current devel with /etc/sysconfig/i18n having LC_ALL="fr_FR@euro" he, just needed a restart

narrowed down the issue. using the service executable on the distro, only LANG get's passed which is ignored if the system's LC_ALL is set so I don't see a way to override this behavior.

running the init script emits a localized string, which can break the to json parser, normally we avoid this by setting LC_ALL=C which forces posix/english/ascii messages to avoid issues like these.

The 'service' utility in this case ignores LC_ALL (and most other env vars) and then default to using the system set defaults to be used instead, which causes the message to always be 'localized'.

Closing This Ticket

We believe this has been resolved for a while, and as there have been no updates in over 6 months we're going to go ahead and close this now.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

  • https://groups.google.com/forum/#!forum/ansible-project - for user questions, tips, and tricks
  • https://groups.google.com/forum/#!forum/ansible-devel - for strategy, future planning, and questions about writing code
  • Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

    Thank you!