unable to parse uri content in a handler

I have a handler of the following form:

  • name: reinit task_handler
    uri: url=some_url return_content=yes
    register: webpage
    delegate_to: localhost

Now I want to look for some string in webpage.content and mark this a pass or fail. However, I am not able to do this in any way. I tried adding a when in the handler, tried to add a notify in this handler and tried to examine webpage.content in there and a few more things.

Kindly help.

Hi Anuj, have you read the documentation page on “failed_when:”?

http://docs.ansible.com/playbooks_error_handling.html#controlling-what-defines-failure

I believe you’d want to do something like this:

  • name: reinit task_handler
    uri: url=some_url return_content=yes
    register: webpage
    failed_when: ‘“SOME ERROR STRING” in webpage.content’
    delegate_to: localhost

Hey James, thanks for your reply. Had found it. Forgot to update here.