Re: [ansible-project] Ansible "failed_when" not working as desired

2020-03-06 Thread Dick Visser
Why not use the uri module instead of fragile shell + curl ?

On Fri, 6 Mar 2020 at 13:47, Rakesh Parida 
wrote:

> Hi,
>
> I have a task as follows:
>
> - hosts: nodes
>   gather_facts: true
>   tasks:
> - name: CurlCP Status
>   shell: "curl -Is -m 1 http://localhost:9113/cp/healthcheck;
>   register: cp_status
>   failed_when: "'200 OK' not in cp_status.stdout_lines"
>
> It fails even if 200 Ok is in o/p. I want to fail the job only when 200 OK
> is not in o/p
> Pls help here
>
> --
> 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-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6589d432-2ae7-4fcb-a7ba-926cfb3f2a17%40googlegroups.com
> 
> .
>


-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwPg1U9ZKz3YiDf%3Dra1ArqOYgnhFym7HxzXW2h2pYRYU0g%40mail.gmail.com.


Re: [ansible-project] Ansible "failed_when" not working as desired

2020-03-06 Thread Vladimir Botka
On Fri, 6 Mar 2020 04:46:58 -0800 (PST)
Rakesh Parida  wrote:

>   failed_when: "'200 OK' not in cp_status.stdout_lines"

Try

 failed_when: cp_status.stdout_lines|
  select('search', '200 OK')|
  list|
  length == 0

HTH,

-vlado

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200306142546.1469fcfc%40gmail.com.


pgpo_Gtp9BOB1.pgp
Description: OpenPGP digital signature