Amneesh Singh f3e60fff71 check for nil maps
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-05-08 23:37:08 +05:30
2022-02-05 21:05:15 +05:30
2022-02-14 13:13:21 +05:30
2022-02-05 21:05:15 +05:30
2022-02-05 21:05:15 +05:30
2022-05-08 23:37:08 +05:30
2020-11-11 12:28:57 +01:00
2022-02-05 21:05:15 +05:30
2020-11-10 11:35:37 +01:00
2020-11-13 14:56:11 +01:00
2022-05-08 22:31:09 +05:30

Nomad Job Concourse Resource

A concurse resource for jobs on Hashicorp Nomad.

Source Configuration

resource_types:
  - name: nomad
    type: registry-image
    source:
      repository: natto1784/concourse-nomad-resource
      tag: latest

resources:
  - name: test-job
    type: nomad
    source:
      url: http://nomad-cluster.local:4646
      name: test
      token: XXXX
  • url: (required) URL of the nomad api on a node of your cluster
  • name: (required) name of the job
  • token: Nomad ACL token

Behavior

check: Check for new versions of the job

Checks if there are new versions of the job. It uses the nomad job history command of the nomad CLI and not all versions since the first deployment might be available.

in: noop

out: Run a new version of the job

Deploys a new version of the job to the cluster using nomad job run by reading a HCL job file. Golang template variables can be used to insert information like a version on the fly.

Parameters

  • job_path: (required) Path of the HCL job file to run
  • vars: { [key: string]: string } dictionary of variables to substitute in the job file. Each key should be represented in the job file as {{+.key+}}
  • var_files: { [key: string]: string } dictionary of paths to files to read to get variable values. Each key should be represented in the job file as {{+.key+}} and the values should be path to text files which content will be used as the variable value. Whitespace and trailing newlines will be trimmed from the value.
  • templating: { bool }: Whether to use templating or not. true by default
  • restart: { bool }: Whether to restart a job or not. false by default

NOTE: Restart just runs stop -purge against the job before running run against it

Example

resource_types:
  - name: nomad
    type: registry-image
    source:
      repository: natto1784/concourse-nomad-resource
      tag: latest

resources:
  - name: sample-job
    type: nomad
    source:
      url: http://10.4.0.4:4646
      name: sample
      token: ((nomad-cluster-token))

  - name: sample-repo
    type: git
    source:
      uri: git@github.com:cioplenu/sample.git
      branch: main
      private_key: ((private-repo-key))

jobs:
  - name: deploy
    plan:
      - get: sample-repo
      - put: sample-job
        params:
          job_path: sample-repo/sample.nomad
          vars:
            registry_token: ((registry-token))
          var_files:
            version: sample-repo/ci/version

with a job file like:

job "sample" {
  region      = "de"
  datacenters = ["dc1"]
  type        = "service"

  group "sample" {
    task "sample" {
      driver = "docker"

      config {
        image = "cioplenu/sample:{{+.version+}}"
        auth  = {
          username = "some-username"
          password = "{{+.registry_token+}}"
        }
        force_pull = true
      }

      resources {
        cpu    = 50
        memory = 50
        network {
          mbits = 1
        }
      }
    }
  }
}

and a version file like:

9.1.4
Description
Concourse CI resource to deploy jobs to a nomad cluster
Readme 103 KiB
Languages
Go 95.2%
Dockerfile 4.8%