Facing Issue Ansible Summary

18 views
Skip to first unread message

Jitender J

unread,
Dec 20, 2021, 9:34:02 AM12/20/21
to Ansible Project
Hi Team, 

Facing a very strange issue, my failed task output getting swapped with another task, in summary, we have done some modification in the callback module but never saw like this before, any suggestion 

tt.PNG

Antony Stone

unread,
Dec 20, 2021, 9:37:06 AM12/20/21
to ansible...@googlegroups.com
On Monday 20 December 2021 at 15:34:02, 'Jitender J' via Ansible Project
wrote:
My suggestion is to show us your playbook which can do this.

Antony.

--
What do you call a dinosaur with only one eye? A Doyouthinkesaurus.

Please reply to the list;
please *don't* CC me.

Jitender J

unread,
Dec 20, 2021, 9:45:02 AM12/20/21
to ansible...@googlegroups.com
Hi Antony,

Thanks for the mail, below is the playbook code snippet 

##############################
- hosts: "{{ UI }}"
  gather_facts: no
  user: ops
  tasks:
   - name: Check total CPU cores
     shell: |
       cpu=`sysctl hw.model hw.machine hw.ncpu|grep  hw.ncpu:`
       echo "$cpu"|awk -F':' '{
       if ($2 >= 5)
        print "\033[32mOK:\033[0m" $0;
       else
        print $0,  echo -e "\033[31m CRITICAL\033[0m" }'
     register: err_cpu
     failed_when: '"CRITICAL" in err_cpu.stdout'
     args:
      executable: /bin/bash
     ignore_errors: true

   - name: Check total memory
     shell: |
       mem=`echo "$(sysctl -n hw.physmem)/1024/1024/1024"|bc`
       echo "$mem"|awk '{
       if ($NF >= 48)
        print "\033[32mOK:\033[0m" $0
       else
         print  $0,  echo -e "\033[31m CRITICAL\033[0m" }'
     register: err_mem
     failed_when: '"CRITICAL" in err_mem.stdout'
     args:
      executable: /bin/bash
     ignore_errors: true
#############################
--
Regards,
Jitender

Stefan Hornburg (Racke)

unread,
Dec 20, 2021, 9:59:00 AM12/20/21
to ansible...@googlegroups.com
Why don't use ansible_facts instead of these horrible shell hacks?

Regards
Racke

>
> On Mon, Dec 20, 2021 at 8:06 PM Antony Stone <Antony...@ansible.open.source.it <mailto:Antony...@ansible.open.source.it>> wrote:
>
> On Monday 20 December 2021 at 15:34:02, 'Jitender J' via Ansible Project
> wrote:
>
> > Hi Team,
> >
> > Facing a very strange issue, my failed task output getting swapped with
> > another task, in summary, we have done some modification in the callback
> > module but never saw like this before, any suggestion
>
> My suggestion is to show us your playbook which can do this.
>
> Antony.
>
> --
> What do you call a dinosaur with only one eye?  A Doyouthinkesaurus.
>
>                                                    Please reply to the list;
>                                                          please *don't* CC me.
>
>
>
> --
> *Regards,
> *
> *Jitender*
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAMO4JZs_XPhYKoHNqmjTYzLVWzCo%3Dr2v4o9VWYAomquz5nNXsA%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CAMO4JZs_XPhYKoHNqmjTYzLVWzCo%3Dr2v4o9VWYAomquz5nNXsA%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages