Abort playbook execution when servers fail to deploy

0 votes

I have an ansible playbook that looks like the following:

-name: deploy web
  -hosts:
    -tag_Name_my_web_server
  user: ubuntu
  sudo: True
  sudo_user: app
  gather_facts: True
  roles:
    - role: "deploy/web"

-name: deploy job
  -hosts:
    -tag_Name_my_job_server
  user: ubuntu
  sudo: True
  sudo_user: app
  gather_facts: True
  roles:
    - role: "deploy/job"

I have two servers and would like to abort the playbook execution when the application deployment to web fails. How do I do this?

Feb 7, 2019 in Ansible by Peter
823 views

1 answer to this question.

0 votes

Het @Peter, try something like this:

- name: deploy web
  hosts: tag_Name_my_web_server
  user: ubuntu
  sudo: True
  sudo_user: app
  gather_facts: True
  roles:
  - { role: deploy, deploy_type: web }

- name: deploy job
  hosts: tag_Name_my_job_server
  user: ubuntu
  sudo: True
  sudo_user: app
  gather_facts: True
  roles:
  - { role: deploy, deploy_type: job }

In the deploy role, use the variable deploy_type to check for the conditions. 

answered Feb 7, 2019 by Pragati

Related Questions In Ansible

+1 vote
2 answers

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 14, 2018 in Ansible by DareDev
• 6,890 points
2,168 views
0 votes
2 answers
0 votes
0 answers
+1 vote
1 answer

How to deploy war file into the Websphere using ansible playbook

Hi@M, You can use the below-given example. - name: ...READ MORE

answered Jun 29, 2020 in Ansible by MD
• 95,440 points
2,059 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,517 views
+2 votes
1 answer
0 votes
1 answer

Playbook to wait for servers to come online - Ansible

Hey @Dipti, try something like this: - name: ...READ MORE

answered Mar 26, 2019 in Ansible by Jaz
569 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP