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

76 views
Skip to first unread message

Костя Хомко

unread,
Sep 25, 2017, 10:51:05 PM9/25/17
to Ansible Project
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?

Brian Coca

unread,
Sep 25, 2017, 11:08:37 PM9/25/17
to Ansible Project
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.



--
----------
Brian Coca

Костя Хомко

unread,
Sep 26, 2017, 1:24:56 AM9/26/17
to Ansible Project
Hello Brian, 
Thanks for the tip but as i can see i have DISPLAY variable: 

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


вторник, 26 сентября 2017 г., 6:08:37 UTC+3 пользователь Brian Coca написал:

rhys.jame...@googlemail.com

unread,
Sep 26, 2017, 3:05:21 AM9/26/17
to Ansible Project
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';


Костя Хомко

unread,
Sep 26, 2017, 11:28:38 AM9/26/17
to Ansible Project
[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 >>


вторник, 26 сентября 2017 г., 10:05:21 UTC+3 пользователь rhys.jame...@googlemail.com написал:

Brian Coca

unread,
Sep 26, 2017, 11:32:27 AM9/26/17
to Ansible Project
So this should work:

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


----------
Brian Coca

Костя Хомко

unread,
Sep 26, 2017, 4:36:23 PM9/26/17
to Ansible Project
It is working.
Thanks.)

вторник, 26 сентября 2017 г., 18:32:27 UTC+3 пользователь Brian Coca написал:
Reply all
Reply to author
Forward
0 new messages