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
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/23967/5cedd9785afd24f27b018289e077a552.jpeg)
julianchurchill
43.73K
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/43435/92e51ec70e264ab14e7e4606f79464ef.jpeg)
denver
12.2K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#