Re: [ansible-project] Do-until seems not to work with delegate

138 views
Skip to first unread message

Michael DeHaan

unread,
Aug 29, 2014, 2:43:46 PM8/29/14
to ansible...@googlegroups.com

This doesn't seem to be a do/until problem, since the command is failing because a binary is not present.


Example:


- hosts: all

  tasks:

    - shell: /usr/bin/wrong

      register: blip

      delay: 1

      retries: 4

      until: blip.stdout.find("3")


However, it's also not apparently true that ignore_errors is used when deciding to retry, so this is a buglet, which I'll file because we need to deal with it:


- hosts: all

  tasks:

    - shell: /usr/bin/false

      register: blip

      delay: 1

      ignore_errors: True

      retries: 4

      until: blip.stdout.find("3")

      ignore_errors: True






On Fri, Aug 29, 2014 at 2:02 PM, Steven Truong <djatl...@gmail.com> wrote:
Hi all,

I have this task:

  - name: wait for http port 80 return ok for 1 minutes
    shell: /usr/local/bin/check_health /health 80 {{ inventory_hostname }} 
    delegate_to: "{{ item }}"
    with_items: groups.sc2_docker_lb
    register: output
    until: output.stdout.find("Ready to go") != -1
    retries: 6
    delay: 10
    tags: web_war_deploy

And then when it came to this task, my run failed with the following errors:

< TASK: wait for http port 80 return ok for 1 minutes >
 -----------------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||


changed: [sc2-dock3-web1 -> {{ item }}] => (item=sc2-dock1-lb)
changed: [sc2-dock3-web3 -> {{ item }}] => (item=sc2-dock1-lb)
failed: [sc2-dock3-web1 -> {{ item }}] => (item=sc2-dock2-lb) => {"attempts": 6, "changed": true, "cmd": "/usr/local/bin/check_health /health 80 sc2-dock3-web1", "delta": "0:00:00.009735", "end": "2014-08-29 13:54:27.691545", "failed": true, "item": "sc2-dock2-lb", "rc": 127, "start": "2014-08-29 13:54:27.681810"}
stderr: /bin/sh: /usr/local/bin/check_health: No such file or directory
msg: Task failed as maximum retries was encountered
failed: [sc2-dock3-web3 -> {{ item }}] => (item=sc2-dock2-lb) => {"attempts": 6, "changed": true, "cmd": "/usr/local/bin/check_health /health 80 sc2-dock3-web3", "delta": "0:00:00.011236", "end": "2014-08-29 13:54:27.843791", "failed": true, "item": "sc2-dock2-lb", "rc": 127, "start": "2014-08-29 13:54:27.832555"}
stderr: /bin/sh: /usr/local/bin/check_health: No such file or directory
msg: Task failed as maximum retries was encountered
failed: [sc2-dock3-web1 -> {{ item }}] => (item=sc2-dock3-lb) => {"attempts": 6, "changed": true, "cmd": "/usr/local/bin/check_health /health 80 sc2-dock3-web1", "delta": "0:00:00.144995", "end": "2014-08-29 13:55:35.073634", "failed": true, "item": "sc2-dock3-lb", "rc": 127, "start": "2014-08-29 13:55:34.928639"}
stderr: /bin/sh: /usr/local/bin/check_health: No such file or directory
msg: Task failed as maximum retries was encountered
failed: [sc2-dock3-web3 -> {{ item }}] => (item=sc2-dock3-lb) => {"attempts": 6, "changed": true, "cmd": "/usr/local/bin/check_health /health 80 sc2-dock3-web3", "delta": "0:00:00.147576", "end": "2014-08-29 13:55:35.685953", "failed": true, "item": "sc2-dock3-lb", "rc": 127, "start": "2014-08-29 13:55:35.538377"}
stderr: /bin/sh: /usr/local/bin/check_health: No such file or directory
msg: Task failed as maximum retries was encountered

FATAL: all hosts have already failed -- aborting

----

sc2-dock*-lb are my Haproxy servers and I certainly want to have these servers checking the web servers before adding them back to the load balancers.

Did I use this do-unitl loop correctly?  Was it intended for other purposes?

Thanks,
Steven.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/99c84bcf-8e09-4e4d-91b0-36b120907ac7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael DeHaan

unread,
Aug 29, 2014, 4:21:49 PM8/29/14
to ansible...@googlegroups.com
What happened here is you had a task failure on several of the machines, and the do/until is not ignoring errors (because it's not told to)

failed: [sc2-dock3-web3 -> {{ item }}] => (item=sc2-dock3-lb) => {"attempts": 6, "changed": true, "cmd": "/usr/local/bin/check_health /health 80 sc2-dock3-web3", "delta": "0:00:00.147576", "end": "2014-08-29 13:55:35.685953", "failed": true, "item": "sc2-dock3-lb", "rc": 127, "start": "2014-08-29 13:55:35.538377"}
stderr: /bin/sh: /usr/local/bin/check_health: No such file or directory

So this is not a delegation issue.

However, it's also true that "ignore_errors" can't be used with do/until, and for this I'll file a small bug because I want to make that work for your use case, if you added ignore_errors: True, which right now does not seem to help.




Reply all
Reply to author
Forward
0 new messages