답변1
콜백 사용커뮤니티.일반.선택적. 바라보다
shell> ansible-doc -t callback selective
인용하다:
이 콜백은
print_action
표시되거나 실패한 작업만 인쇄합니다.
예를 들어, 스크립트
shell> cat pb.yml
- hosts: web
gather_facts: false
tasks:
- getent:
database: passwd
- assert:
that:
- getent_passwd._apt.5 == '/usr/sbin/nologin'
- getent_passwd._rpc.5 == '/usr/sbin/nologin'
- getent_passwd._chrony.5 == '/usr/sbin/nologin'
success_msg: "[PASSED] - Ensure system accounts are non-login"
tags: [print_action]
모든 작업의 출력 표시기본콜백 사용
shell> ANSIBLE_STDOUT_CALLBACK=default ansible-playbook pb.yml
PLAY [web] ***********************************************************************************
TASK [getent] ********************************************************************************
ok: [web]
TASK [assert] ********************************************************************************
ok: [web] => {
"changed": false,
"msg": "[PASSED] - Ensure system accounts are non-login"
}
PLAY RECAP ***********************************************************************************
web: ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
출력이 활성화된 작업으로 제한되는 경우선택 과목콜백 사용
shell> ANSIBLE_STDOUT_CALLBACK=selective ansible-playbook pb.yml
.
# assert ******************************************************************************************************************
* web - changed=False --------------------------------------------------
[PASSED] - Ensure system accounts are non-login
# STATS *******************************************************************************************************************
web: ok=2 changed=0 failed=0 unreachable=0 rescued=0 ignored=0