Ansible can not run apps with GUI! Is it ok?

Hello.
I have faced with an issue that after provisioning of vagrant vm with installed docker there and HA proxy i can not start this vagrant VM from ansible playbook (last step).
Vagrant file is ok with proper parameters with GUI enabled just to inform you that it is not the case (point of failure or possible root cause of this).
Even more: i have tried to run AD-HOC ansible command locally and faced with the next errors:

[root@co1 ~]# ansible co1 -m shell -a “xclock”
co1 | FAILED | rc=1 >>
Error: Can’t open display:

[root@co1 ~]# ansible co1 -m shell -a “firefox”
co1 | FAILED | rc=1 >>
Error: GDK_BACKEND does not match available displays

[root@co1 ~]# ansible co1 -m shell -a “virtualbox”
co1 | FAILED | rc=-6 >>
Qt FATAL: QXcbConnection: Could not connect to display

[root@co1 ~]# ansible co1 -m shell -a “gedit”
co1 | FAILED | rc=1 >>

(gedit:11838): Gtk-WARNING **: cannot open display:

[root@cloud ~]# ansible all -m shell -a “gparted”
cloud | FAILED | rc=1 >>
Failed to execute operation: Access denied

(gpartedbin:66756): Gtk-WARNING **: cannot open display:
Failed to execute operation: Access denied

and so on.

The question is why Ansible can not run simple command end redirect output to screen?

The errors are telling you why, it needs the DISPLAY env var to point
at your Xserver, which is probably not set because Ansible uses non
interactive logins.

Hello Brian,
Thanks for the tip but as i can see i have DISPLAY variable:

[root@co1 admin]# echo $DISPLAY
:0

That’s your own session. Ansible will execute in a different context. Check the DISPLAY variable in that seesion with this;

ansible localhost -m shell -a 'echo $DISPLAY';

[root@cloud admin]# echo $DISPLAY
:0
[root@cloud admin]# ansible localhost -m shell -a ‘echo $DISPLAY’;
127.0.0.1 | SUCCESS | rc=0 >>

[root@cloud admin]# ansible cloud -m shell -a ‘echo $DISPLAY’;
192.168.176.130 | SUCCESS | rc=0 >>

So this should work:

ansible co1 -m shell -a "DISPLAY=':0' xclock"

It is working.
Thanks.)