I’m running a set of custom Ansible modules which are ment for local connections only.
I was trying to use Display() to print out some custom output - ideally in real time. I’m using Ansible 2.0.1.0 on Ubuntu 14.04.
This would be my (simplified) custom module:
`
# library/output.py
#!/usr/bin/python
from ansible.utils.display import Display
display = Display() # also tried Display(x) here - where x = 0..5
display.display(u"hello world")
display.vv(u"hello world")
display.banner(u"hello world")
print "{}"
`
This would be the playbook using the custom module (emphasis on the local connection):
`
# output.yml
- hosts: localhost
connection: local
tasks:
- output:
`
And these are the various ways I tried to run this:
`
ansible-playbook output.yml
ansible-playbook output.yml -vvv
ansible-playbook output.yml -f 1
PYTHONUNBUFFERED=1 ansible-playbook output.yml
`
I also tried combinations of these (one fork & verbose etc.)
I was expecting at least one the “hello world” messages to show up in the output, however none of the commands did print anything:
`
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [output] ******************************************************************
ok: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
`