d5zqla
Last Updated: February 25, 2016
·
6.671K
· lorin
Me pixel

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
Say Thanks
Respond

1 Response
Add your response

13272

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

over 1 year ago ·
Filed Under