Is it possible to use if condition in a nomad job?

Hello.
I have some json-file with variables for a nomad job.
For example:

      "tasks": {
        "front_0": {
          "name": "front_0",
          "config": {
            "image": "example.com/front",
            "port": "http"
          },
          "service": {
            "name": "front-0",
            "port": "http",
            "check": {
              "port": "http"
            }
          }
        },
        "front_1": {
          "name": "front_1",
          "config": {
            "image": "example.com/front",
            "port": "http1"
          },
          "service": {
            "name": "front-1",
            "port": "http1",
            "check": {
              "port": "http1"
            }
          }
        }
      }

And I use this vars.json in my nomad.job template file:

      service {
        name = "[[ $task.service.name ]]"
        tags = ["service_[[ $task.service.name ]]"]
        port = "[[ $task.service.check.port ]]"
          check {
            name     = "HTTP Check"
            type     = "http"
            port     = "[[ $task.service.check.port ]]"
            path     = "/server-health"
            interval = "2m"
            timeout  = "10s"
          }
      }

If one of my services doesn’t need to do a check block, for example front_1, how can I skip it in the template? Can I use the if condition for that?

Take a look at nomad-pack, I think it might solve some of your problems. You can apply conditional logic with go-templates there.