Suppress output of task?

885 views
Skip to first unread message

John Oliver

unread,
Nov 7, 2014, 1:14:19 PM11/7/14
to ansible...@googlegroups.com
There are some tasks I run to collect info, and if they fail, oh well... I have ignore_errors: true in there.  But sometimes there could be a lot of output from a "failed" task that I just don't want to see.  How can I tell my task to not echo back any output to stdout?

Hakisho Nukama

unread,
Nov 7, 2014, 1:58:02 PM11/7/14
to ansible...@googlegroups.com
Could this example [1] work?

- name: secret task
shell: /usr/bin/do_something --value={{ secret_value }}
no_log: True

# Maybe conditional, when an error arises?
register: result
no_log: True
when: result|failed

[1] http://docs.ansible.com/faq.html#how-do-i-keep-secret-data-in-my-playbook

John Oliver

unread,
Nov 7, 2014, 2:07:22 PM11/7/14
to ansible...@googlegroups.com
No, no_log just suppresses logging.  Already found and tried it :-)

John Oliver

unread,
Nov 24, 2014, 5:56:27 PM11/24/14
to ansible...@googlegroups.com
Anyone?

Michael DeHaan

unread,
Nov 24, 2014, 6:16:32 PM11/24/14
to ansible...@googlegroups.com
no_log in 1.8 does in fact block output to the callbacks in general.

Have you tried on 1.8 (devel -- releasing VERY soon now), and if so, can you clarify more about what you are looking for?



On Mon, Nov 24, 2014 at 5:56 PM, John Oliver <jno...@gmail.com> wrote:
Anyone?

--
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/e388b069-1cda-47df-8c11-d9ef7c4cbf07%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

John Oliver

unread,
Nov 24, 2014, 7:40:35 PM11/24/14
to ansible...@googlegroups.com
Awesome!  No, I have not tried it, as I get my ansible from MacPorts.  Hopefully as soon as 1.8 is out the port maintainer will release there.

Basically, when I'm executing a task simply to get some output, I don't want to see:

TASK: [postfix | Check if SMTP submission is already allowed via IPv6] ******** 
failed: [jedis-test] => {"changed": true, "cmd": "grep '^-A\\ INPUT\\ -p\\ tcp\\ -m\\ state\\ --state\\ NEW\\ -m\\ tcp\\ --dport\\ 587\\ -j\\ ACCEPT' /etc/sysconfig/ip6tables >/dev/null 2>&1", "delta": "0:00:00.002819", "end": "2014-11-24 16:35:55.098774", "rc": 1, "start": "2014-11-24 16:35:55.095955"}
...ignoring

And some tasks, like checking to see if our McAfee is there, can generate a page of angry red text.  Since I really don't care what stdout is, I'd rather just see:

TASK: [postfix | Check if SMTP submission is already allowed via IPv6] ******** 

and then move on to the next task :-)

Thanks yet again, and thanks for such an awesome piece of software!  I'm using ansible for more and more tasks, and loving it!
Reply all
Reply to author
Forward
0 new messages