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

**URL:** <https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593>\
**Category:** Ansible Project\
**Created:** [September 26, 2017, 2:51am UTC](https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593 "2017-09-26T02:51:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![user65](https://avatars.discourse-cdn.com/v4/letter/u/ea5d25/32.png) [@user65](https://forum.ansible.com/u/user65)\
**Post date:** [September 26, 2017, 2:51am UTC](https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593/1 "2017-09-26T02:51:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 26, 2017, 3:08am UTC](https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593/2 "2017-09-26T03:08:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![user65](https://avatars.discourse-cdn.com/v4/letter/u/ea5d25/32.png) [@user65](https://forum.ansible.com/u/user65)\
**Post date:** [September 26, 2017, 5:24am UTC](https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593/3 "2017-09-26T05:24:55Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![rhysmeister](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/rhysmeister/32/10599_2.png) [@rhysmeister](https://forum.ansible.com/u/rhysmeister)\
**Post date:** [September 26, 2017, 7:05am UTC](https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593/4 "2017-09-26T07:05:21Z")

</div>

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';`

---

<div class="post-metadata">

**Author:** ![user65](https://avatars.discourse-cdn.com/v4/letter/u/ea5d25/32.png) [@user65](https://forum.ansible.com/u/user65)\
**Post date:** [September 26, 2017, 3:28pm UTC](https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593/5 "2017-09-26T15:28:38Z")

</div>

[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 \>\>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 26, 2017, 3:32pm UTC](https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593/6 "2017-09-26T15:32:09Z")

</div>

So this should work:

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

---

<div class="post-metadata">

**Author:** ![user65](https://avatars.discourse-cdn.com/v4/letter/u/ea5d25/32.png) [@user65](https://forum.ansible.com/u/user65)\
**Post date:** [September 26, 2017, 8:36pm UTC](https://forum.ansible.com/t/ansible-can-not-run-apps-with-gui-is-it-ok/25593/7 "2017-09-26T20:36:23Z")

</div>

It is working.  
Thanks.)
