Ansible "failed_when" not working as desired

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

Try

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

HTH,

  -vlado

Why not use the uri module instead of fragile shell + curl ?