posted by 귀염둥이채원 2019. 1. 29. 18:14

when 조건에 만족하는 경우,

message에 정의된 내용을 출력해준다.


# example

# Example playbook using fail and when together

- fail:

    msg: "The system may not be provisioned according to the CMDB status."

  when: cmdb_status != "to-be-staged" 


- name: fail the play if the previous command did not succeed

  fail:

    msg: "the command failed"

  when: "'FAILED' in command_result.stderr" 


# 참고 사이트

https://docs.ansible.com/ansible/latest/modules/fail_module.html

https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html

https://ansible-manual.readthedocs.io/en/v1.8.4-doc/playbooks_error_handling.html

'Tool > ansible' 카테고리의 다른 글

ansible role template 생성하기  (0) 2019.02.01
ansible handler란?  (0) 2019.02.01
serial keyword를 이용한 rolling update  (0) 2019.01.29
ansible-vault를 이용한 암호화  (0) 2019.01.29
ansible source build  (0) 2019.01.29