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
Good day Guys
Is there a way I can ansible to exit and print a custom error message if a bash / shell variable is not set.
If anyone can assist, it would be appreciated.
Thanks Brent
Brian Coca
unread,
Aug 21, 2015, 10:00:41 AM8/21/15
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
- hosts: localhost
gather_facts: false
tasks:
- fail: msg="lola is not set"
when: lookup('env', 'lola') == ''
This fails the play
#>ansible-playbook play.yml
PLAY ***************************************************************************
TASK [fail msg=lola is not set] ************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true,
"msg": "lola is not set"}
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1
And this continues play
#>lola=is ansible-playbook play.yml
PLAY ***************************************************************************
TASK [fail msg=lola is not set] ************************************************
skipping: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=0