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
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
- 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
note that the fail is 'per host'