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
16 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 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,810 points
125 views
0 votes
2 answers
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,240 points
24 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,810 points
554 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
46 views