Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Service module no longer works with async #5472

Closed
jhart1685 opened this issue Nov 3, 2016 · 5 comments
Closed

Service module no longer works with async #5472

jhart1685 opened this issue Nov 3, 2016 · 5 comments

Comments

@jhart1685
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

service module

ANSIBLE VERSION
ansible 2.2.0.0
  config file = /home/vagrant/source/GHE/ansible-playground/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION

N/A

OS / ENVIRONMENT

Ubuntu 14.04 (but probably many others)

SUMMARY

On Ansible 2.1 , async could be specified on tasks using the service module. This was extremely useful to avoid playbooks from hanging if a service start did not return in a reasonable amount of time.
At Ansible 2.2, this fails with async mode is not supported with the service module

STEPS TO REPRODUCE

Create a dummy service that is guaranteed to take a certain amount of time to start.
For this reproduce, create file /etc/init/testservice.conf , as root, with the following contents:

pre-start script
  #!/bin/bash
  i=0
  while [ "$i" -lt 10 ]
  do
    echo "Attempt $i"
    sleep 2
    i=$((i+1))
  done
  exit 0
end script

script
  echo "Started"
end script

This service is guaranteed to take 20 seconds to start.

Run the following playbook against localhost:


---
- hosts: all
  become: yes
  become_user: root
  become_method: sudo
  tasks:
  - name: upstart restart
    service: "name=testservice state=restarted sleep=1"
    async: 10
    poll: 5
    ignore_errors: yes
    register: restart_status
  - name: fail deploy if upstart restart failed
    fail: msg="The upstart restart step failed."
    when: restart_status | failed
EXPECTED RESULTS

At Ansible 2.1.2 restart timed out : async task did not complete within the requested time

PLAYBOOK: testservices.yml *****************************************************
1 plays in testservices.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1478188242.21-246358132149554 `" && echo ansible-tmp-1478188242.21-246358132149554="` echo $HOME/.ansible/tmp/ansible-tmp-1478188242.21-246358132149554 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpUugRdk TO /home/vagrant/.ansible/tmp/ansible-tmp-1478188242.21-246358132149554/setup
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1478188242.21-246358132149554/ /home/vagrant/.ansible/tmp/ansible-tmp-1478188242.21-246358132149554/setup && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-gpflpphtwddftzrfkoriswnuymaymkrl; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1478188242.21-246358132149554/setup; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1478188242.21-246358132149554/" > /dev/null 2>&1'"'"' && sleep 0'
ok: [127.0.0.1]

TASK [upstart restart] *********************************************************
task path: /home/vagrant/source/GHE/ansible-playground/testservices.yml:7
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988 `" && echo ansible-tmp-1478188244.41-125126621993988="` echo $HOME/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpUByg0S TO /home/vagrant/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988/service
<127.0.0.1> PUT /tmp/tmpw0Z12E TO /home/vagrant/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988/async_wrapper
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988/ /home/vagrant/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988/service /home/vagrant/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988/async_wrapper && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-yxjgpmoqcwfowpsyvbxridnwklvypoha; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /home/vagrant/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988/async_wrapper 164650715721 10 /home/vagrant/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988/service'"'"' && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1478188244.41-125126621993988/ > /dev/null 2>&1 && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1478188250.68-192180370745608 `" && echo ansible-tmp-1478188250.68-192180370745608="` echo $HOME/.ansible/tmp/ansible-tmp-1478188250.68-192180370745608 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmprydg9E TO /home/vagrant/.ansible/tmp/ansible-tmp-1478188250.68-192180370745608/async_status
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1478188250.68-192180370745608/ /home/vagrant/.ansible/tmp/ansible-tmp-1478188250.68-192180370745608/async_status && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-gepyxugizyhafzmhsvczcvexlulqhfgw; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1478188250.68-192180370745608/async_status; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1478188250.68-192180370745608/" > /dev/null 2>&1'"'"' && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1478188255.79-182646281999246 `" && echo ansible-tmp-1478188255.79-182646281999246="` echo $HOME/.ansible/tmp/ansible-tmp-1478188255.79-182646281999246 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpiswcWa TO /home/vagrant/.ansible/tmp/ansible-tmp-1478188255.79-182646281999246/async_status
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1478188255.79-182646281999246/ /home/vagrant/.ansible/tmp/ansible-tmp-1478188255.79-182646281999246/async_status && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-ynrcmnmeylrhanlnoauwffgvwlzuwbgq; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1478188255.79-182646281999246/async_status; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1478188255.79-182646281999246/" > /dev/null 2>&1'"'"' && sleep 0'
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "async task did not complete within the requested time"}
...ignoring

TASK [fail deploy if upstart restart failed] ***********************************
task path: /home/vagrant/source/GHE/ansible-playground/testservices.yml:13
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"msg": "The upstart restart step failed."}, "module_name": "fail"}, "msg": "The upstart restart step failed."}

NO MORE HOSTS LEFT *************************************************************
	to retry, use: --limit @/home/vagrant/source/GHE/ansible-playground/testservices.retry

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=1 
ACTUAL RESULTS

At Ansible 2.2 : async mode is not supported with the service module

PLAYBOOK: testservices.yml *****************************************************
1 plays in testservices.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1478188095.18-113784857458696 `" && echo ansible-tmp-1478188095.18-113784857458696="` echo $HOME/.ansible/tmp/ansible-tmp-1478188095.18-113784857458696 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmphWWy6b TO /home/vagrant/.ansible/tmp/ansible-tmp-1478188095.18-113784857458696/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1478188095.18-113784857458696/ /home/vagrant/.ansible/tmp/ansible-tmp-1478188095.18-113784857458696/setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-bulczgwqvdnbjvnyovwlypoyymqngdvk; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1478188095.18-113784857458696/setup.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1478188095.18-113784857458696/" > /dev/null 2>&1'"'"' && sleep 0'
ok: [127.0.0.1]

TASK [upstart restart] *********************************************************
task path: /home/vagrant/source/GHE/ansible-playground/testservices.yml:7
fatal: [127.0.0.1]: FAILED! => {
    "failed": true, 
    "msg": "async mode is not supported with the service module"
}
...ignoring

TASK [fail deploy if upstart restart failed] ***********************************
task path: /home/vagrant/source/GHE/ansible-playground/testservices.yml:13
fatal: [127.0.0.1]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "msg": "The upstart restart step failed."
        }, 
        "module_name": "fail"
    }, 
    "msg": "The upstart restart step failed."
}
	to retry, use: --limit @/home/vagrant/source/GHE/ansible-playground/testservices.retry

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=1
@ansibot
Copy link

ansibot commented Nov 3, 2016

@ansible ping, this issue is waiting for your response.
click here for bot help

@ansibot
Copy link

ansibot commented Nov 19, 2016

@ansible, ping. This issue is still waiting on your response.
click here for bot help

@holms
Copy link

holms commented Dec 1, 2016

Can we fix it? my couple of playbook died because of this. it's not really fun to rewrite tons of playbook because Ansible lacking backward compatibility.

@ansibot
Copy link

ansibot commented Dec 7, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

@jhart1685
Copy link
Author

This issue was moved to ansible/ansible#18965

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants