Last Updated: December 26, 2018
·
11.38K
· Lorin Hochstein

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

1 Response
Add your response

This is also useful if you want to run ansible in the background using nohup &

over 1 year ago ·