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 in Ansible by Peter
11 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

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 by Pragati

Related Questions In Ansible

0 votes
1 answer

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 13, 2018 in Ansible by DareDev
• 6,520 points
75 views
0 votes
1 answer

Running to plays in one playbook

The inventory file is loaded before a ...READ MORE

answered Jun 25, 2018 in Ansible by ajs3033
• 7,000 points
21 views
0 votes
1 answer

Permission denied when running ansible playbook through jenkins

Jenkins uses it's own user to execute ...READ MORE

answered Jun 25, 2018 in Ansible by DareDev
• 6,520 points
456 views
+13 votes
2 answers
0 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 25 in Ansible by Jaz
37 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.