Testing server response with timeout using ansible

0 votes

I have 2 servers hosting a website. I want to do a rolling upgrade with Ansible like the following:

I want roll out updates to my two servers with ansible. I want them to upgrade one at a time-> then take the building node off the load balancer-> run the tasks. Over here I want to wait it for server start up and send a request to a test URL 5 seconds periodically till there's a valid response. Here it fails the tasks because a timeout occurs after 3 minutes. I want these tasks to complete successfully and then build the next node.

I can do the timeout part with a custom script but isn't there some ansible functionality that does it automatically.

Aug 7, 2018 in Ansible by Atul
• 10,220 points
164 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Got it working using wait_for and until statement together:

 - name: "wait for port to be available"
    wait_for:
      host: "127.0.0.1"
      port: "{{port}}"
      timeout: 30
  - name: "wait for web app to start up"
    shell: curl -XGET --head --silent http://127.0.0.1:{{port}}/test
    register: result
    until: result.stdout.find("200 OK") != -1
    retries: 60
    delay: 3
answered Aug 7, 2018 by Atul
• 10,220 points

Related Questions In Ansible

0 votes
1 answer

Mention Kubernetes version while using it with ansible

Hey @Dustin, The default value for roles is kube_version: ...READ MORE

answered Jan 22 in Ansible by Anushri
12 views
0 votes
1 answer
0 votes
2 answers

Issue creating AWS VPC with Ansible

You can use the details given in ...READ MORE

answered Aug 16, 2018 in Ansible by Priyaj
• 56,140 points
126 views
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
841 views
+13 votes
2 answers
0 votes
1 answer

How to use Ansible git module pull a branch with local changes?

You cannot achieve it using the git ...READ MORE

answered Jul 9, 2018 in Ansible by Atul
• 10,220 points
863 views
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,220 points
1,598 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.