Check Application Status Using Ansible Play – wait_for moudle

I have an application running on port 8080. I want to check if the port is open and the application is successfully running on the port. How can i do this using ansible wait_for module?

Check Application Status Using waif_for module

There are two things,

  1. If a port is opened, it doesn’t mean your application has started.
  2. You need to check the response code for a specific URL to make sure that your application is running.
  3. Download the page content and check for a specific string in your application to make sure you are getting the right application page.

Let’s look at each scenario.

Check for Port

You can check for a specific port using the following code.

The above code will check for port 80 connectivity for 900 seconds. If the port doesn’t come up within 900 seconds, then ansible will throw a timeout error. You can change the parameter based on your needs.

Check based on HTTP response code

You can make sure the application is up using the following code which loops until a particular response code is retrieved.

The status code might change depend on the application. Some applications might respond with 401. Test the response code with a REST client before you implement the ansible code.

Check based on page content

You can use the following content to check the application status based on a string in the web page.

You can replace “user” with a string that is available in your application web page.

Related

Installing and Setting up a WordPress on RHEL 7 / CentOS 7

Basic Requirements Step 1: Connect to the server using key or…

Read more

How do I install the latest mongoDB database server and components in Redhat 7 or a centos 7 box? There are no…

Read more

Issue: I have my Jenkins master and slave setup on AWS instance. I am build i have a maven deploy task to upload a…

Read more
About

The Best Tutorials & Tips to Speedup Your DevOps Workflow.

Created by Bibin Wilson.