$ ansible-playbook 7319.yml -vv
PLAY [centos65] ***************************************************************
TASK: [reload uwsgi] **********************************************************
<192.168.122.120> REMOTE_MODULE service name=uwsgi state=reloaded
changed: [192.168.122.120] => {"changed": true, "name": "uwsgi", "state": "started"}
PLAY RECAP ********************************************************************
192.168.122.120 : ok=1 changed=1 unreachable=0 failed=0
I also tried the same playbook using sudo: yes with a non-root user, but no difference in output.
I did install uWSGI via pip, and based on your paths above it would appear you've installed yours directly from source or some other method? I wonder if that's the main difference here, though whenever I run the initctl commands directly I'm not seeing any odd output. Just the following:
[root@centos65 ~]# initctl restart uwsgi
uwsgi start/running, process 6941
[root@centos65 ~]# initctl reload uwsgi
[root@centos65 ~]#
[vagrant@localhost init]$ sudo su
[root@localhost init]# initctl stop uwsgi
uwsgi stop/waiting
[root@localhost init]# initctl start uwsgi
uwsgi start/running, process 11675
[root@localhost init]# initctl reload uwsgi
[root@localhost init]# initctl restart uwsgi
uwsgi start/running, process 11684
[root@localhost init]#
From my laptop I ran:
$ ANSIBLE_KEEP_REMOTE_FILES=1 ansible bastion3.hadoop.ripe.net -sK -m service -a 'name=hdfs-sync state=restarted'
sudo password:
bastion3.hadoop.ripe.net | FAILED => failed to parse:
SUDO-SUCCESS-kmznivmdzmspomcdaqzgxkbtmnuxohxf
Traceback (most recent call last):
File "/tmp/ansible-tmp-1399973714.05-163067361684244/service", line 2411, in
main()
File "/tmp/ansible-tmp-1399973714.05-163067361684244/service", line 1198, in main
service.get_service_status()
File "/tmp/ansible-tmp-1399973714.05-163067361684244/service", line 509, in get_service_status
rc, status_stdout, status_stderr = self.service_control()
File "/tmp/ansible-tmp-1399973714.05-163067361684244/service", line 750, in service_control
rc_state, stdout, stderr = self.execute_command("%s %s %s" % (self.action, self.name, arguments), daemonize=True)
File "/tmp/ansible-tmp-1399973714.05-163067361684244/service", line 250, 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
Next, I logged into bastion3.hadoop.ripe.net, and ran:
python ansible-tmp-1399973714.05-163067361684244/service
{"state": "started", "changed": true, "name": "hdfs-sync"}
The module does run, and does do what I expected it to do.
Hrm, so in both of your cases, you seem to be hitting the code that is wanting to daemonize the process. @arhbkb in your case, does hdfs-sync have a proper init script of some kind? I'm unclear as to why this section of code would be reached with @skyler's init script when it does not for my test case.
On a hunch, could one of you try the following patch?
diff --git a/library/system/service b/library/system/service
index ec622ac..f883e00 100644
--- a/library/system/service
+++ b/library/system/service
@@ -209,7 +209,7 @@ class Service(object):
# Start the command
if isinstance(cmd, basestring):
cmd = shlex.split(cmd)
- p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=lambda: os.close(pipe[1]))
+ p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True, preexec_fn=lambda: os.close(pipe[1]))
stdout = ""
stderr = ""
fds = [p.stdout, p.stderr]
We had an issue with the accelerate daemon where processes launched while daemonized were inheriting the file descriptors, which can cause problems for later executions.
pre-start script
set +e # don't complain about already started jobs
start hdfs-sync-instance URL='amqps://server1#hdfs-sync'
start hdfs-sync-instance URL='amqps://server2#hdfs-sync'
start hdfs-sync-instance URL='amqps://server3#hdfs-sync'
start hdfs-sync-instance URL='amqps://server4#hdfs-sync'
exit 0
end script
If I log into the server, and type "start hdfs-sync", this upstart script actually invokes 4 instances, as shown above. I then have 5 jobs in the "start/running" state. However, only the instances have PIDs, whereas the spawner, hdfs-sync, has no PID:
$ initctl list|grep hdfs
hdfs-sync-instance (amqps://server1#hdfs-sync) start/running, process 28003
hdfs-sync-instance (amqps://server2#hdfs-sync) start/running, process 28012
hdfs-sync-instance (amqps://server3#hdfs-sync) start/running, process 28007
hdfs-sync-instance (amqps://server4#hdfs-sync) start/running, process 28018
hdfs-sync start/running
I won't write out the contents of the "hdfs-sync-instance" script, but it has a "stop on stopping hdfs-sync" stanza. This allows me to "stop hdfs-sync" or "restart hdfs-sync" to stop or restart the instances.
In upstart land, it is okay for a running job to have no PID. Is it possible that this is confusing Ansible?
@arhbkb after digging through the code a bit more, I'm wondering if the code where data is read/written to the pipes is running into a situation where partial reads/writes are happening. In that same execute_command(), could you increase the buffer sizes for all read calls to something quite a bit larger than the 4096 used currently and see if that resolves the issue? If so, I can come up with a patch that will try handle those more robustly.
@jimi-c sorry for taking so long to reply. As you asked, I ran
ANSIBLE_KEEP_REMOTE_FILES=1 ansible-playbook web.yml -i local
Which failed with this traceback:
NOTIFIED: [uwsgi_base | reload uwsgi] *****************************************
changed: [localhost]
fatal: [192.168.33.12] => failed to parse: SUDO-SUCCESS-tccostycxxmgehxljqzyreeoilbwkclp
Traceback (most recent call last):
File "/home/skyler/.ansible/tmp/ansible-tmp-1400160533.78-90187794857028/service", line 2411, in <module>
main()
File "/home/skyler/.ansible/tmp/ansible-tmp-1400160533.78-90187794857028/service", line 1198, in main
service.get_service_status()
File "/home/skyler/.ansible/tmp/ansible-tmp-1400160533.78-90187794857028/service", line 509, in get_service_status
rc, status_stdout, status_stderr = self.service_control()
File "/home/skyler/.ansible/tmp/ansible-tmp-1400160533.78-90187794857028/service", line 750, in service_control
rc_state, stdout, stderr = self.execute_command("%s %s %s" % (self.action, self.name, arguments), daemonize=True)
File "/home/skyler/.ansible/tmp/ansible-tmp-1400160533.78-90187794857028/service", line 250, 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
(same as before, I believe).
I then logged into the box and ran:
[vagrant@localhost ~]$ sudo su
[root@localhost vagrant]# python /home/skyler/.ansible/tmp/ansible-tmp-1400160533.78-90187794857028/service
{"state": "started", "changed": true, "name": "uwsgi"}
which you can see worked without an error. This is without applying your patch. Not sure if this adds anything new.
~/ansible/local (master)> ssh skyler@192.168.33.12 <<'END'
> sudo su
> python /home/skyler/.ansible/tmp/ansible-tmp-1400160533.78-90187794857028/service
Pseudo-terminal will not be allocated because stdin is not a terminal.
skyler@192.168.33.12's password:
{"state": "started", "changed": true, "name": "uwsgi"}
~/ansible/local (master)>
@arhbkb or @skyler, was this working in a previous version, like 1.5 or 1.4? If you can find a version that did not have this issue, we could use git bisect to try and identify the commit that started causing problems. If either of you are on IRC, you can ping me there (jimi|ansible) and I can walk you through bisect.
I just tried 1.4.5, and 1.5.0. With these versions, trying to restart a service fails with:
bastion3.hadoop.ripe.net | FAILED >> {
"failed": true,
"msg": "/bin/sh: stop: command not found\n/bin/sh: start: command not found\n"
With 1.5.5, I get the "No JSON object could be decoded" error. With the earlier versions, it looks like ansible could not find "stop" and "start" because PATH did not contain /sbin. However, in a minor release in 1.5, that appears to have been fixed.
But please, please, let me stress that the service module DOES work for many upstart-managed services, but fails for just some.
Ok, I think at this point we need to have a clean setup with steps to reproduce this, for instance please create a new VM, document your installation steps, extra packages, etc. and then the playbook you run on the system to reproduce it. I think that's the only way we're going to pin this down. @arhbkb or @skyler, would one of you be able to provide that?
I think we're seeing something similar:
TASK: [python | Install apt package(s)] ***************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
<127.0.0.1> REMOTE_MODULE apt pkg=python-dev,python-setuptools,python-software-properties,python-pip,build-essential state=latest
<127.0.0.1> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ForwardAgent=yes', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/jenkins/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=2206', '-o', 'IdentityFile=/home/jenkins/.vagrant.d/insecure_private_key', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401981445.77-144592281645790 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401981445.77-144592281645790 && echo $HOME/.ansible/tmp/ansible-tmp-1401981445.77-144592281645790'"]
<127.0.0.1> PUT /tmp/tmpQlqn0s TO /home/vagrant/.ansible/tmp/ansible-tmp-1401981445.77-144592281645790/apt
<127.0.0.1> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ForwardAgent=yes', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/jenkins/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=2206', '-o', 'IdentityFile=/home/jenkins/.vagrant.d/insecure_private_key', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '127.0.0.1', u'/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=klxfyowsydpxkyecwvdxkhlzepvxsjhk] password: " -u root /bin/sh -c \'"\'"\'echo SUDO-SUCCESS-klxfyowsydpxkyecwvdxkhlzepvxsjhk; LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1401981445.77-144592281645790/apt; rm -rf /home/vagrant/.ansible/tmp/ansible-tmp-1401981445.77-144592281645790/ >/dev/null 2>&1\'"\'"\'\'']
failed: [ttvm.local] => (item=python-dev,python-setuptools,python-software-properties,python-pip,build-essential) => {"failed": true, "item": "python-dev,python-setuptools,python-software-properties,python-pip,build-essential", "parsed": false}
invalid output was: SUDO-SUCCESS-klxfyowsydpxkyecwvdxkhlzepvxsjhk
OpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_request_forwards: requesting forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 8702
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Control master terminated unexpectedly
Shared connection to 127.0.0.1 closed.
It looks like a problem with the SSH connection sharing...
I was getting a similar error with Ansible 1.5.4 when trying to add a repository for the latest php version at this task:
- name: add repository for latest php
apt_repository: repo='ppa:ondrej/php5' state=present
Then, when I took a closer look, it appeared I had a typo in the repository name. This was enough to trigger the following error (which looks much like what you have above):
fatal: [default] => failed to parse: SUDO-SUCCESS-zxuilacwkhkzhcqhyvgqqcumigfexeca
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1404168688.02-72667960863768/apt_repository", line 1509, in
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1404168688.02-72667960863768/apt_repository", line 394, in main
sourceslist.add_source(repo)
File "/home/vagrant/.ansible/tmp/ansible-tmp-1404168688.02-72667960863768/apt_repository", line 333, in add_source
info = self._get_ppa_info(ppa_owner, ppa_name)
File "/home/vagrant/.ansible/tmp/ansible-tmp-1404168688.02-72667960863768/apt_repository", line 302, in _get_ppa_info
return self._get_ppa_info_curl(lp_api)
File "/home/vagrant/.ansible/tmp/ansible-tmp-1404168688.02-72667960863768/apt_repository", line 315, in _get_ppa_info_curl
return json.loads(lp_page)
File "/usr/lib/python2.7/json/init.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/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
When I corrected the typo, everything went just fine. It was hard from the error message to detect the fact that I had made a typo.
@jimi-c I can try to create a new VM and document my steps, some time within the next few weeks. I've meant to set aside time to do this but haven't had the opportunity. This isn't too pressing of an issue for me because it doesn't happen for my live CentOS servers, only for my local VM that I use to test my playbooks against. It means I can't fully test playbooks locally, which is a problem, but it's not holding anything up in my org at the moment so it's low priority for me right now. In the meantime I can provide you with any other information you might need.
No, none, sorry. At work we're just launching our app so I haven't had time to do anything other than that.
Should be able to get something to you this week though.
I haven't done the work of setting up a VM from scratch, but testing another role just now I got a similar error.
TASK: [supervisor | start supervisor] *****************************************
fatal: [192.168.33.12] => failed to parse: SUDO-SUCCESS-jhzyatzgpiapvwsgivaeerszxbtysmgo
Traceback (most recent call last):
File "/home/skyler/.ansible/tmp/ansible-tmp-1407789795.23-188642643136975/service", line 2584, in <module>
main()
File "/home/skyler/.ansible/tmp/ansible-tmp-1407789795.23-188642643136975/service", line 1196, in main
service.get_service_status()
File "/home/skyler/.ansible/tmp/ansible-tmp-1407789795.23-188642643136975/service", line 507, in get_service_status
rc, status_stdout, status_stderr = self.service_control()
File "/home/skyler/.ansible/tmp/ansible-tmp-1407789795.23-188642643136975/service", line 748, in service_control
rc_state, stdout, stderr = self.execute_command("%s %s %s" % (self.action, self.name, arguments), daemonize=True)
File "/home/skyler/.ansible/tmp/ansible-tmp-1407789795.23-188642643136975/service", line 250, 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
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/vagrant/web.retry
192.168.33.12 : ok=63 changed=6 unreachable=1 failed=0
And then logging into the host and executing the script I get
python /home/skyler/.ansible/tmp/ansible-tmp-1407789795.23-188642643136975/service
{"msg": "start: Unable to connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory\n", "failed": true}
"Unable to connect to system bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory" would be a better error to display than "No JSON object could be decode,"
@mpdehaan unfortunately I haven't had time to build a box from scratch and test from that. In short, only 80% of my config is in Ansible right now, notably Python 2.7 isn't because at the moment I need to compile it with some flags because I'm using this on CentOS, and a standard 2.7 install doesn't play nicely with CentOS 6.5. So it would take time to set up this test environment which I just haven't been able to dedicate yet.
Anyway, this is another task that's causing my error (the first was uWSGI):
- name: start supervisor
service: name=supervisor state=started
I noticed if I set enabled=yes, then that produces this error:
TASK: [supervisor | start supervisor] *****************************************
failed: [192.168.33.12] => {"failed": true}
msg: cannot detect command to enable service supervisor, typo or init system potentially unknown
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/vagrant/web.retry
192.168.33.12 : ok=63 changed=6 unreachable=0 failed=1
Notably both these errors happen when trying to start an Upstart service. Maybe this will help.
@skyler I just so happened to merge in a patch yesterday to the devel branch which should resolve the supervisor issue. The issue appears to have been related to the fact that upstart on CentOS 6 is quite a bit out of date, and did not support the "manual" param (instead you have to use "start on manual").
This error exists for me on ansible 1.7.1 installed from pip on archlinux:
TASK: [Install Gem Prerequisites] *********************************************
failed: [alloa.app.example.com] => (item=libpq-dev,nodejs) => {"failed": true, "item": "libpq-dev,nodejs", "parsed": false}
invalid output was: SUDO-SUCCESS-jmypmdwoaanmpsjispueepmzehlonoof
Segmentation fault (core dumped)
Rebooting the server solves the problem for me, but obviously that's not an ideal solution...
I think you guys are seeing different issues - especially because you have a core dump, let's keep this issue on topic about the service module.
The sudo success part is actually noise.
Let's figure out the core dump on arch seperately and figure out why it is doing that.
I have the same problem regarding the message "mux_client_read_packet: read header failed: Broken pipe".
I have researched about it and find no objective conclusions pointing out the root of the problem. After a couple of tests I realize that the problem is linked to SSH multiplexing behavior. My network has a very lazy latency (more than 10 seconds). Analysing ansible parrameters of the connection attempted It's possible to see that ansible overrides the timeout configuration o ssh_config to 10 seconds.
It might be possible that the error occurs in some cases due to network latency.
I have tried higher timeout limits but the problem stills the same. The error happens independently of the timeout set. I tried 60 seconds of timeout and the problem happens within 21 seconds.
Not sure the root cause of the problem yet. :(
@leth I believe we have done so already in the devel branch. We recently added better detection code to catch tracebacks, which were one of the main reasons the SUDO-SUCCESS error would be seen. Additional code was added to check for an un-caught SUDO-SUCCESS too, so hopefully we'll see better output that will get to the root cause rather than this generic message.
Hi, I'm getting this error with Ansible 1.8.2 but only when running long-lasting Gatling stress-test simulations:
failed: [54.154.191.110] => (item=ArtifactoryGet50) => {"failed": true, "item": "ArtifactoryGet50", "parsed": false}
SUDO-SUCCESS-ligvhvwixbgbwixjokonfnwtpwrvnskz
I can reproduce it very reliably. Could this help? If yes - I can set up a proper example but later as for now I need to move on and bypass this problem by running simulations outside Ansible.
changed the title
Bug Report: failed to parse: SUDO-SUCCESS / No JSON object could be decoded
Bug Report: failed to parse: No JSON object could be decoded
Feb 20, 2015
Hi, this situation is no longer present in the devel branch (which will be ansible 2.0).
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!
needs_info
This issue requires further information. Please answer any outstanding questions.
Priority 2 - Issue Blocks Release