How to parameterize a job type system

Dear Nomad community,

I have a job like this

job "slurm-cn" {
  datacenters = ["dc1"]
  type = "system" 
  group "slurm-cn" {
    task "zypper" {
      lifecycle {
        hook = "prestart"
        sidecar = false
      }
      driver = "raw_exec"
      user = "root"
      config {
        command = "zypper"
        args = ["install", "-y", "slurm=${NOMAD_META_version}", "slurm-slurmctld=${NOMAD_META_version}", "slurm-perlapi=${NOMAD_META_version}", "slurm-slurmpmi=${NOMAD_META_version}", "slurm-devel=${NOMAD_META_version}"]
      }
    }
    task "slurmd" {
      driver = "raw_exec"
      user = "root"
      config {
        command = "/usr/sbin/slurmd"
        args = ["-D", "-Z", "--conf-server", "nid002584"]
      }
    }
    service {
      provider = "nomad"
      name = "slurmd"
      port = "slurmd"
      check {
        name = "slurmd"
        type = "tcp"
        interval = "9s"
        timeout = "3s"
      }
    }
    network {
      port "slurmd" {
        static = 6818 # host linked port to TCP 6818
      }
    }
  }
}

The goal is to have a job that installs and starts a service, the problem is I need to parameterize the version of the package to install, nomad documentation says only batch and sysbatch jobs have this feature.

How can I send params to a job like this?

thank you

Hi @masuberu, the parametarization only applies to job types that are expected to run to completion. For service type jobs that are expected to run “forever”, it makes more sense to set meta fields on the job if you need some kind of configuration. You could set these values using HCL2 vars, if you really need parameterization at job submit time.

(note: HCL2 vars are separate from Nomad Variables, which I describe in your other discuss question).

so, let’s say I have 2 tasks:

Task A - installs a daemon into a set of machines
Task B - runs the daemon

I want both tasks to be managed by nomad

Then I want to parametrize Task A because I want to choose which version to install

My understanding is that Task A should be a sysbatch and Task B a service.

My question is, is it possible to make Task A a prestart (lifecycle) of Task B within the same job?

If not how would you orchestrate this? through terraform?

thank you very much

They type of a job applies to all groups / tasks in the job. If you want the installation of the daemon to be separate from running the daemon, they’ll need to be in separate jobs.

However, if you don’t mind the installation of the daemon happening right before running the daemon, you could configure it as a prestart hook - that wouldn’t be so different from using an artifact block to download the thing you’re about to run, for example.