I’m trying to run a simple Windows Powershell script from a Nomad job.
task "mytask" {
driver = "raw_exec"
config {
command = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
args = ["-File", "${var.service_root_dir}\\task.ps1"]
}
}
Then I simply do:
nomad job run -var="service_root_dir=C:\MyServiceRoot" myjob.nomad
This fails to execute and the alloc’s stderr shows the following:
The argument 'C:\MyServiceRoot\task.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
Of course that file exists and running powershell -File C:\MyServiceRoot\task.ps1
from the Run menu works properly.
I know this is not the main usage of Nomad but it should be plain simple to run a Windows Powershell script.
This is driving me crazy, I’ve spent an entire day trying to get this running.
Any help?
lgfa29
December 11, 2021, 1:25am
2
Oh hello again @dg-eparizzi
For reference to anyone that lands here in the future, there are further discussion on GitHub.
opened 08:02PM - 09 Dec 21 UTC
type/bug
theme/platform-windows
theme/driver/raw_exec
### Nomad version
Nomad v1.1.4 (acd3d7889328ad1df2895eb714e2cbe3dd9c6d82)
##… # Operating system and Environment details
Windows 10 Enterprise LTSC
Version 1809
OS build 17763.2061
### Issue
Nomad client can't seem to find any binaries. This is running in a single node acting as server and client, installed as a Windows Service and running as "Local System".
### Reproduction steps
Setup a single-node server/client Nomad on Windows 10 running as a Windows Service.
Try to run a binary using the raw_exec driver.
#### Expected Result
Binary is found and process executes.
#### Actual Result
Task fails. Allocation shows the following event:
```
Driver Failure | failed to launch command with executor: rpc error: code = Unknown desc = binary "C:\\Program Files\\nodejs\\node.exe" could not be found
```
### Job file (if appropriate)
```
variable "service_root_dir" {
type = string
}
job "logging-system" {
datacenters = ["dc1"]
type = "service"
group "data-logs-to-influxdb" {
reschedule {
attempts = 15
interval = "1h"
delay = "30s"
delay_function = "exponential"
max_delay = "60s"
unlimited = false
}
task "data-logs-to-influxdb" {
driver = "raw_exec"
config {
command = "C:\\Program Files\\nodejs\\node.exe"
args = ["${var.service_root_dir}\\dist\\apps\\data-logs-to-influxdb\\main.js"]
}
}
}
}
```
### Nomad Client logs (if appropriate)
```
2021-12-09T19:40:45.322Z [WARN] client.alloc_runner.task_runner: some environment variables not available for rendering: alloc_id=c46de00d-10d0-43dc-6b02-896582f6bf55 task=data-logs-to-influxdb keys=
2021-12-09T19:40:54.304Z [ERROR] client.driver_mgr.raw_exec: destroying executor failed: driver=raw_exec err="rpc error: code = Unknown desc = executor failed to find process: OpenProcess: The parameter is incorrect."
2021-12-09T19:40:54.305Z [ERROR] client.driver_mgr.raw_exec: error receiving stream from Stats executor RPC, closing stream: alloc_id=c46de00d-10d0-43dc-6b02-896582f6bf55 driver=raw_exec task_name=data-logs-to-influxdb error="rpc error: code = Unavailable desc = transport is closing"
```
Sorry, my bad. There was a another client and the job was being scheduled on that one where it didn’t have the file.
1 Like