How to *not* print ansible diagnostic error messages?

45 views
Skip to first unread message

Frank Thommen

unread,
Jul 21, 2017, 10:35:33 AM7/21/17
to Ansible Project
Hi,

I have a playbook which executes a local task from which I need the exit
status in later steps:


- name: Get exit status of ./run.sh
local_action: command ./run.sh
register: ES
ignore_errors: yes

- name: Do something if ./run.sh failed
command:
....
when: ES.rc == 1


Unfortunately when "./run.sh" fails, ansible prints a whole bunch of
diagnostic output to the screen, which I am not interested in.

How can I tell ansible *not* to print diagnostic error output of a
specific step?

We are running ansible 2.3.0 0 on CentOS 7

Cheers
frank


Branko Majic

unread,
Jul 21, 2017, 11:17:03 AM7/21/17
to ansible...@googlegroups.com
You could use "failed_when: False" on the task. Although, keep in mind
that would make the task treated as successful for all other purposes
(e.g. ES.failed would be set to False).

Best regards

--
Branko Majic
XMPP: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
XMPP: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.

Frank Thommen

unread,
Jul 21, 2017, 11:42:04 AM7/21/17
to ansible...@googlegroups.com
Hi
This is perfect! Thanks a lot. Since I'm only interested in ES.rc and
not in ES.failed, this is exactly what I was looking for.

Cheers
frank


Mike Eriksson

unread,
Jul 25, 2017, 7:21:44 AM7/25/17
to Ansible Project
Frank,

Would adding the

no_log: True

bit do what you're after? That doesn't remove all the text, but it cuts it down quite markedly.

In your example:

<- Cut ->
   - name: Get exit status of ./run.sh
     local_action:  command ./run.sh
     register:      ES
     ignore_errors: yes 
     no_log: True
<- Cut -> 

Cheers, Mike 

--
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.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ce37e30a-aea4-8239-bc84-878917b6b15a%40drosera.ch.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages