Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

ansible - How to fail a task and exit the playbook

I'm having some trouble with executing this one task on my host. Basically i used a shell module and i want the playbook to exit when that task reports an error. Here is my code, basically it will show a json type of data like "name":"connector1","connector":{"state":"RUNNING:} etc. I want the task to fail when i see error in the out or 404. I tried executing this and the task is actually passing when it should be failing, any ideas? I'm using register and failed when

- name: 'Verify if the kafka instance is up and running'
  shell: curl -X GET  localhost:8080/Connector/status
  args:
    executable: /bin/bas
  register: command_result
  failed_when: "'error' in command_result.stderr" or "'404' in command_result.stderr" or "'fail' in command_result.stderr"
question from:https://stackoverflow.com/questions/65927506/how-to-fail-a-task-and-exit-the-playbook

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...