Bash script and yml file output
I found this page (https://coderwall.com/p/d5zqla/unbuffered-output-with-ansible-in-jenkins) that shows how to force output to be unbuffered.
I modified my script to look like this:
export PYTHONUNBUFFERED=1
ansible-playbook -i inventory site.yml
and I now get ansible output as the script runs. Does that help?
Related videos on Youtube
nicoX
Updated on September 18, 2022Comments
-
nicoX over 1 year
I'm trying to catch the
stdout
of a script to a file, and at the same time have it display its ongoing summary:./RUN host-names ANSIBLE.yml 2>&1 | tee out.txt
What this does is that it displays and forwards the initial lines to
out.txt
, but from there on as it starts the actual host check, it stops displaying and forwarding toout.txt
:PLAY [all] ******************************************************************** GATHERING FACTS ********************************************************************
After the
PLAY
andGATHERING FACTS
it continues with its work, but only if I run the script without thetee
command:ok: [host.com] ok: [host.com] ok: [host.com] fatal: [host.com]
I would also be interested to only
grep
some of the output to theout.txt
file, asfatal
and leave out theok
hosts.-
FrustratedWithFormsDesigner about 9 yearsI've had a similar problem: I have a bash script which calls ansbible right at the end. The first part of the script displays on stdout immediately, but the ansible output doesn't appear until after ansible has completed. I'm guessing that ansible might not write directly to stdout where tee can capture it from, but I'm not sure...
-