diff --git a/roles/deploy-xorg/files/nvidia-xconf-gen.py b/roles/deploy-xorg/files/nvidia-xconf-gen.py
index 7f25d86c2086d1873b25903d3f0ba5ad73b6ff46..e230bf4a4c9b9f83c08184a330e72983529983a0 100755
--- a/roles/deploy-xorg/files/nvidia-xconf-gen.py
+++ b/roles/deploy-xorg/files/nvidia-xconf-gen.py
@@ -1,4 +1,4 @@
-#!/bin/python -E
+#!/usr/bin/python3 -E
 from jinja2 import Template, Environment, FileSystemLoader
 import itertools
 import subprocess
@@ -13,18 +13,18 @@ import json
 
 def grab_card_ids():
     # This method runs nvidia-smi to grab the card ids, then returns a list
-    
+
     if not os.path.isfile("/bin/nvidia-smi"):
         print("nvidia-smi binary not found!")
         exit(1)
 
     cmd = ["/bin/nvidia-smi", "--query-gpu=pci.bus_id","--format=csv,noheader"]
     p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-    
+
     cards = []
 
     for line in p.stdout.readlines():
-        line = line.rstrip().split(":")[2]
+        line = line.decode().rstrip().split(":")[2]
         pcibus_num = int(re.sub('[.:]', '', line).rstrip("0"),16)
         card = "PCI:0:{}:0".format(str(pcibus_num))
         cards.append(card)
@@ -39,7 +39,7 @@ def grab_card_boardname():
     cards = []
     p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
     for line in p.stdout.readlines():
-        line = line.rstrip()
+        line = line.decode().rstrip()
         cards.append(line)
     return cards
 
@@ -68,5 +68,3 @@ if __name__ == "__main__":
 
     cards = grab_card_ids()
     write_xorg_conf(cards)
-
-
diff --git a/roles/deploy-xorg/tasks/main.yml b/roles/deploy-xorg/tasks/main.yml
index bc3ed9f174bd3bfdf1af5717d8f59632f124cbbb..95bfe1e623bf315ca9199820c39a7aa10283bede 100644
--- a/roles/deploy-xorg/tasks/main.yml
+++ b/roles/deploy-xorg/tasks/main.yml
@@ -37,3 +37,31 @@
   become: yes
   command: '/opt/generate-xorg/nvidia-xconf-gen.py'
   when: xorg_template.changed or gen.changed
+
+- name: deploy desktop related packages
+  package:
+    name:
+      - python-is-python2 # compatibility package for get-xorg.py
+      - python-tk #this is to get the Desktop Walltime script to work
+      - python-pexpect #this is to make the ansible expect module work
+    state: present
+  become: true
+  when: ansible_os_family=="Debian"
+
+- name: change allowed_user variable in Xwrapper.config
+  replace:
+    path: /etc/X11/Xwrapper.config
+    regexp:  'allowed_users=console'
+    replace: 'allowed_users=anybody'
+  become: true
+  register: xwrapperalloweduser
+  when: ansible_os_family=="Debian"
+
+- name: "Run `dpkg-reconfigure xserver-xorg-legacy` to make sure /etc/X11/Xwrapper.config doesn't get overridden during update"
+  expect:
+    command: 'dpkg-reconfigure -freadline xserver-xorg-legacy'
+    responses:
+      '(.*)Users allowed to start the X server(.*)': 3
+  when: xwrapperalloweduser.changed
+  become: true
+
diff --git a/roles/enable_modules/tasks/main.yml b/roles/enable_modules/tasks/main.yml
index 241c7420b41b48518719347539d9142649495c4a..1603920ada9eb397f76688b57943a20bcc026487 100644
--- a/roles/enable_modules/tasks/main.yml
+++ b/roles/enable_modules/tasks/main.yml
@@ -8,7 +8,7 @@
   when: default_modules == "modulecmd"
 
 - name: template lmod bash
-  template: src=lmod_{{ ansible_os_family }}.sh.j2 dest=/etc/profile.d/lmod.sh 
+  template: src=lmod_{{ ansible_os_family }}.sh.j2 dest=/etc/profile.d/lmod.sh
   become: true
   become_user: root
   when: default_modules == "lmod"
@@ -73,4 +73,12 @@
     state: link
     mode: u=rwx,g=rx,o=rx
   become: true
-  when: ansible_os_family == 'Debian' and default_modules == 'modulecmd'
\ No newline at end of file
+  when: ansible_os_family == 'Debian' and default_modules == 'modulecmd'
+
+- name: load modulecmd in /etc/bash.bashrc this is to get module command to work from terminal on the desktop
+  lineinfile:
+     path: /etc/bash.bashrc
+     line: 'if [ -f /etc/profile.d/modulecmd.sh ]; then source /etc/profile.d/modulecmd.sh; fi'
+  become: true
+  when: ansible_os_family=="Debian" and default_modules == 'modulecmd'
+