I am writing a simple Ansible
playbook to run RHEL
leap second detector on Linux boxes with mixed distribution.
here is the playbook
---
- 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"
it is working fine and here is an example of output
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
As you can see, there is an extra line of message I don't really want.
failed: [SERV01] => {"failed": true, "failed_when_result": true}
Is it possible not to print that condition evaluation message just print the error message I defined ? something like following
failed: Kernel 2.6.18-53.el5 is vulnerable