Hi,
I want to make a simple check after deploying an application with Ansible.
The task looks like this:
- name: Wait for application to listen
wait_for: host=localhost port={{ application_port }} state=started timeout=30
tags:
- check
I expect an HTTP server to listen on that port, and t check it myself I would use something like curl.
When I run it from my local machine, it works fine, but when it's run on the CI server, this last step breaks after the timeout.
I have also seen this thing wrapped in the "local_action" module, but since the above example works, I do not think that's the issue.
The only difference between CI run and me doing it locally is the remote_user, but I find it hard to image how that can possibly have anything to do with it., when only running the check.
There are probably many ways to solve the problem "Have Ansible exit with an error, if the deployment fails", though this one is probably the easiest, so any hint is appreciated.
The error I am getting:
failed: [162.13.11.115] => {"elapsed": 34, "failed": true}
msg: Timeout when waiting for localhost:8000
However, as stated before ssh'ing onto the machine and executing "curl localhost:8000" works just fine.
Regards,
Thomas