Thanks for this fix! I ran into this issue when running ansible-playbook as 
part of a shell provisioning script in Vagrant. In other words, Vagrant is 
just running a shell script, and the shell script is running "sudo 
ansible-playbook" in local mode. However, I just wanted to point out that 
in this case, the following doesn't work as I expected:

export PYTHONUNBUFFERED=1
sudo ansible-playbook /vagrant/provisioning/playbook.yml --connection=local 
-i "[database]127.0.0.1,"

Of course, I'm a Linux noobie, and it took me a while to realize I needed 
to do this instead:
sudo PYTHONUNBUFFERED=1 ansible-playbook ...

Or this:
sudo python -u `which ansible-playbook` ...

The "PYTHONUNBUFFERED" env variable didn't survive the call to sudo, which 
makes sense in hindsight. Anyway, in case anyone else is running into this 
instead of using Vagrant's built-in Ansible provisioner, I wanted to post 
the solution here since this thread is a likely place to stumble.

Taylor


On Thursday, September 26, 2013 9:27:26 AM UTC-3, Michael DeHaan wrote:
>
> Thanks very much!
>
> We have lots of vagrant users so this will definitely continue to keep 
> them happy.
>
>
>
>
> On Thu, Sep 26, 2013 at 5:19 AM, Jake Clarkson <
> [email protected] <javascript:>> wrote:
>
>> Have submitted a PR to Vagrant for this:
>>
>> https://github.com/mitchellh/vagrant/pull/2275
>>
>> Thanks all for your help :-)
>>
>>
>> On Thursday, 26 September 2013 08:59:01 UTC+1, Jake Clarkson wrote:
>>>
>>> Thanks Dmitry, that solved the problem :-)
>>>
>>> On Wednesday, 25 September 2013 21:28:35 UTC+1, Dmitry Horbach wrote:
>>>>
>>>> Yes I noticed the same after upgrade to 1.3 Ansible.
>>>>  export PYTHONUNBUFFERED=1
>>>> This fixes the issue if ansible execution is wrapped with some other 
>>>> process
>>>>
>>>> On Wednesday, September 25, 2013 4:12:56 PM UTC+3, Jake Clarkson wrote:
>>>>>
>>>>> Hey guys,
>>>>>
>>>>> Since using Ansible >= 1.3.0 I've noticed that when provisioning a 
>>>>> Vagrant VM the output of `ansible-playbook` is not shown until it has 
>>>>> finished (whether it be an error or a successful provision).
>>>>>
>>>>> I've had a look in the Vagrant source code and in https://github.com/
>>>>> mitchellh/vagrant/blob/master/plugins/provisioners/ansible/
>>>>> provisioner.rb the following can be seen:
>>>>>
>>>>>
>>>>> result = Vagrant::Util::Subprocess.execute(*command) do |type, data|
>>>>>   if type == :stdout || type == :stderr
>>>>>     @machine.env.ui.info(data, :new_line => false, :prefix => false)
>>>>>   end
>>>>> end
>>>>>
>>>>>
>>>>> This looks to me like it's just redirecting stdout/err from 
>>>>> `ansible-playbook` to the host machine's terminal. I have raised a ticket 
>>>>> with Vagrant (https://github.com/mitchellh/vagrant/issues/2194).
>>>>>
>>>>> If I run `ansible-playbook` by hand in the terminal I get 'realtime' 
>>>>> feedback of task execution rather than solely at the end of the run, e.g.
>>>>>
>>>>> ansible-playbook \
>>>>>   ~/Development/playbook.yml \
>>>>>   -i ~/Development/inventory \
>>>>>   -u vagrant \
>>>>>   --private-key=~/.vagrant.d/insecure_private_key
>>>>>
>>>>> My question is, when does Ansible write to stdout? Did this change at 
>>>>> all between 1.2.x -> 1.3?
>>>>>
>>>>> Many thanks :-)
>>>>>
>>>>> Everyone Advertises
>>>>>
>>>>> http://www.digitalanimal.com
>>>>>
>>>>> *Digital Animal Limited is registered in England and Wales under 
>>>>> company number: 07757607. Registered office 47 Castle Street Reading RG1 
>>>>> 7SR. VAT No: GB 121 1672 57*
>>>>>
>>>>> This electronic message contains information from Digital Animal Ltd 
>>>>> which may be privileged or confidential. The information is intended to 
>>>>> be 
>>>>> for the use of the individuals or entity named above. If you are not the 
>>>>> intended recipient be aware that any disclosure, copying, distribution or 
>>>>> use of the contents of this information is prohibited. If you have 
>>>>> received 
>>>>> this electronic message in error, please notify us by telephone or email 
>>>>> (to the numbers or address above) immediately.
>>>>>
>>>>
>> Everyone Advertises
>>
>> http://www.digitalanimal.com
>>
>> *Digital Animal Limited is registered in England and Wales under company 
>> number: 07757607. Registered office 47 Castle Street Reading RG1 7SR. VAT 
>> No: GB 121 1672 57*
>>
>> This electronic message contains information from Digital Animal Ltd 
>> which may be privileged or confidential. The information is intended to be 
>> for the use of the individuals or entity named above. If you are not the 
>> intended recipient be aware that any disclosure, copying, distribution or 
>> use of the contents of this information is prohibited. If you have received 
>> this electronic message in error, please notify us by telephone or email 
>> (to the numbers or address above) immediately.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Michael DeHaan <[email protected] <javascript:>>
> CTO, AnsibleWorks, Inc.
> http://www.ansibleworks.com/
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to