我正在编写一个简单的Ansible
剧本来RHEL
在混合发行版的 Linux 机器上运行闰秒检测器。
这是剧本
---
- hosts: Linux
vars_files:
- ../group_vars/Linux.yml
tasks:
- name: Running RHEL leap second detector (will skip if distirubtion is not RHEL)
when: ansible_distribution == "RedHat"
script: ../scripts/leap_vulnerability.sh
register: result
changed_when: false
- name: RHEL Lead second detector result
when: ansible_distribution == "RedHat"
fail: msg="Kernel {{ansible_kernel}} is vulnerable"
failed_when: "'kernel is vulnerable' in result.stdout"
Run Code Online (Sandbox Code Playgroud)
它工作正常,这是一个输出示例
TASK: [Running RHEL leap second detector (will skip if distirubtion is not RHEL)] ***
skipping: [UTIL02]
skipping: [UTIL01]
ok: [SERV01]
ok: [SERV02]
TASK: [RHEL Lead second detector result] **************************************
skipping: [UTIL02]
skipping: [UTIL01]
failed: [SERV01] => {"failed": true, "failed_when_result": true}
msg: Kernel 2.6.18-53.el5 is vulnerable
failed: [SERV02] => {"failed": true, "failed_when_result": true}
msg: Kernel 2.6.18-53.el5 is vulnerable
PLAY RECAP ********************************************************************
UTIL01 : ok=1 changed=0 unreachable=0 failed=0
UTIL02 : ok=1 changed=0 unreachable=0 failed=0
SERV01 : ok=2 changed=0 unreachable=0 failed=1
SERV02 : ok=2 changed=0 unreachable=0 failed=1
Run Code Online (Sandbox Code Playgroud)
如您所见,还有一行我并不真正想要的消息。
failed: [SERV01] => {"failed": true, "failed_when_result": true}
是否可以不打印该条件评估消息而只打印我定义的错误消息?像下面这样的东西
failed: Kernel 2.6.18-53.el5 is vulnerable
归档时间: |
|
查看次数: |
20087 次 |
最近记录: |