Skip to content

Scheduling GUI Apps

stagrlee edited this page Jan 13, 2013 · 7 revisions

Background

The standard way of managing windows apps with Rundeck is to invoke jobs over Windows Remote Management or "WinRM". Lots of rundeck users use WinRM with great success. Issues have come up with the approach on later patch releases of Windows 2008, Vista, 7, and Windows 8 due to Session 0 Isolation as jobs that require GUI interactivity or devices traditionally managed by the graphics system of Windows will fail when starting. This problem is effecting newer style cloud applications that leverage the amazing processing capability of the graphics cards. This Isolation issue will also effect automated jobs using powershell to automate GUI applications through the COM programmatic interface.

Solution Overview

There are several approaches to working around Session 0 Isolation posted in numerous blogs. This solution uses Rundeck installed locally on the Windows machine to manage (start/stop/status) the Windows application suffering from Session 0 isolation. A typical topology would implement a spoke and hub command distribution model where the local Windows Rundeck installation will be a spoke to central (hub) enterprise workflow Rundeck server(s). The hub Rundeck workflows would access the remote Rundeck installs through the Rundeck REST APIs. The Windows machine is configured to automatically login at bootup so that the graphics and GUI subsystem of windows are available to rundeck jobs.

Implementation

At time of writting this, no native windows packaging exists for Rundeck so setup for this solution will take some time. The outline is as follows

  1. Install Powershell if it isn't there already
  2. Install the Java Runtime Environment (JRE)
  3. Install the Rundeck launcher jar
  4. Create a sheduled task to run Rundeck at login
  5. Create a test powershell script
  6. Set machine to auto login
  7. Create Rundeck job to invoke test powershell script
  8. Create firewall rule to open Rundeck's port 4440
  9. Test solution

Install Powershell

This solution was developed on Windows 8 largely because the scheduling and configuration of Windows 8 is more complex than prior versions of Windows due to the inclusion of the tile based start screen (Metro) user interface. Windows 8 and Windows Server 2012 comes with Powershell 3.0. Older versions of Windows can install Windows Management Framework which will include either Powershell 3.0 or PowerShell 2.0. Either version should work.

Optional Powershell setup

Powershell is not configured to run by default. This solution does not require the system policy to be modified to work, but Powershell is a very nice way to setup machines. If you are on a development machine, this will be useful to have. From the "cmd.exe" prompt, you can start the interactive powershell environment by typing "powershell_ise", then you can type in the following commands...

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
mkdir $HOME/Documents/WindowsPowerShell

Install the Java Runtime Environment

Java is packaged for Windows and is available at Java.COM. If you are going to be using PowerShell, optionally extend your path to the new JRE directory by creating $(HOME)/Documents/WindowsPowerShell/profile.ps1. profile.ps1 will get run when your PowerShell session starts. PowerShell_ISE has a File->New menu to create files.

# Write-Host "Setting up profile"
$env:Path = "C:\Program Files (x86)\Java\jre7\bin;" + $env:Path
# java -version

Install the Rundeck Launcher jar

Create a $(HOME)/Documents/rundeck directory and downlaod the rundeck launcher jar into the new directory from the Rundeck project download page. You can run this powershell do do the work for you...

mkdir $HOME/Documents/rundeck
$client = new-object System.Net.WebClient
$client.DownloadFile( http://download.rundeck.org/jar/rundeck-launcher-1.4.5.jar, $HOME/Documents/rundeck )

Create a test rundeck powershell startup script by doing File->New $HOME/Documents/rundeck/rundeck.ps1

Get-ExecutionPolicy
java -jar $HOME\Documents\rundeck\rundeck-launcher-1.4.5.jar

After you save the file you can hit the green triangle "play" icon to run the script. If you are getting privilege issues, you may need to restart/reboot. Check the Get-ExecutionPolicy settings... If all works, you can use a browser to navigate to http://localhost:4440 where Rundeck is running.

Workflow

Use the