How do I exit Ansible playbook without error on a condition
17 views
Skip to first unread message
Pandu jh
unread,
Nov 24, 2018, 12:19:26 PM11/24/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
I have 3 plays in a playbook. In a task in 1st play, If the desired value is not set to variable, the execution should exist with success status and remaining plays also should not get executed.
Kai Stian Olstad
unread,
Nov 24, 2018, 12:35:12 PM11/24/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
You could put play 2 and 3 in it's own file and use import_playbook: in play 1 with a when statement.
Because import is static all the task in the plays will be imported and executed but because of the when they will all be skipped.
--
Kai Stian Olstad
Uwe Sauter
unread,
Nov 24, 2018, 12:54:29 PM11/24/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Thanks for your update. But I have multiple plays in my playbook and those plays are being executed on hosts using add_hosts module.
"end_play" is terminated only that particular play and the following plays are being executed.
Pandu jh
unread,
Nov 26, 2018, 4:59:54 AM11/26/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Thanks for your response. my playbook has multiple plays and hosts value will be passed between plays through add_host module. output of a task of one play is the host value of the next play.
So, Please let me know how to pass host from one playbook to playbook.