Unbuffered output with ansible in jenkins
When I run an Ansible playbook inside a Jenkins task, I like to turn off stdout buffering so that I can see the next output line immediately in the Jenkins console view.
This is particularly helpful when ansible blocks on a task, since buffering can suppress the output.
Since ansible-playbook
is a Python script, the simplest way to disable buffering is to set the PYTHONUNBUFFERED environment variable in your Jenkins script before running your playbook:
#!/bin/bash
...
export PYTHONUNBUFFERED=1
ansible-playbook myplaybook.yaml
Written by Lorin Hochstein
Related protips
1 Response
This is also useful if you want to run ansible in the background using nohup &
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jenkins
Authors
julianchurchill
43.93K
denver
12.34K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#