├── .gitignore ├── schemas ├── Vault.dhall ├── Voume.dhall ├── DispatchPayload.dhall ├── SpreadTarget.dhall ├── VolumeMount.dhall ├── Logs.dhall ├── DockerConfigMount.dhall ├── Scaling.dhall ├── Periodic.dhall ├── EphemeralDisk.dhall ├── Port.dhall ├── Lifecycle.dhall ├── Spread.dhall ├── Docker │ ├── DockerDevice.dhall │ ├── DockerAuth.dhall │ └── DockerMount.dhall ├── Affinity.dhall ├── Constraint.dhall ├── DnsConfig.dhall ├── TaskConfig.dhall ├── Device.dhall ├── RawExec.dhall ├── Volume.dhall ├── Restart.dhall ├── Migrate.dhall ├── Resources.dhall ├── Parameterized.dhall ├── DockerConfig.dhall ├── Network.dhall ├── Artifact.dhall ├── Template.dhall ├── Update.dhall ├── Service.dhall ├── Reschedule.dhall ├── Template │ ├── FileNoop.dhall │ ├── InlineNoop.dhall │ ├── FileWithRestart.dhall │ ├── InlineWithRestart.dhall │ ├── FileWithSignal.dhall │ └── InlineWithSignal.dhall ├── Job.dhall ├── Group.dhall ├── Task.dhall ├── Check.dhall └── Docker.dhall ├── types ├── Docker │ ├── DockerTmpfsOptions.dhall │ ├── DockerBindType.dhall │ ├── DockerPIDMode.dhall │ ├── DockerTmpfsType.dhall │ ├── DockerVolumeType.dhall │ ├── DockerBindOptions.dhall │ ├── DockerVolumeDriverConfig.dhall │ ├── DockerNetworkMode.dhall │ ├── DockerDevice.dhall │ ├── DockerAuth.dhall │ ├── DockerVolumeOptions.dhall │ ├── DockerConfigMount.dhall │ └── DockerConfig.dhall ├── Constraint.dhall ├── JobType.dhall ├── VolumeType.dhall ├── ChangeModeNoop.dhall ├── ArtifactMode.dhall ├── ChangeModeRestart.dhall ├── ChangeModeSignal.dhall ├── CheckProtocol.dhall ├── DispatchPayload.dhall ├── RestartMode.dhall ├── ChangeMode.dhall ├── CheckType.dhall ├── NetworkMode.dhall ├── RawExec.dhall ├── Logs.dhall ├── MigrateCheck.dhall ├── AddressMode.dhall ├── HTTPMethod.dhall ├── LifecycleHook.dhall ├── UpdateCheck.dhall ├── Lifecycle.dhall ├── CheckInitialStatus.dhall ├── Periodic.dhall ├── SpreadTarget.dhall ├── DelayFunction.dhall ├── EphemeralDisk.dhall ├── ParameterizedPayload.dhall ├── VolumeMount.dhall ├── CheckRestart.dhall ├── Spread.dhall ├── Port.dhall ├── Affinity.dhall ├── Device.dhall ├── DnsConfig.dhall ├── Restart.dhall ├── Scaling.dhall ├── TaskConfig.dhall ├── Migrate.dhall ├── Parameterized.dhall ├── Vault.dhall ├── Volume.dhall ├── AffinityOperator.dhall ├── Network.dhall ├── Reschedule.dhall ├── Signal.dhall ├── ConstraintOperator.dhall ├── Artifact.dhall ├── Update.dhall ├── Service.dhall ├── Resources.dhall ├── Job.dhall ├── Check.dhall ├── Group.dhall ├── Task.dhall └── Template.dhall ├── examples ├── prometheus │ ├── prometheus_datasource.yml │ ├── file_provider.yml │ ├── README.md │ ├── prometheus.yml │ ├── prometheus.nomad │ ├── prometheus.dhall │ └── prometheus.json └── postgres │ ├── README.md │ ├── postgres.hcl │ ├── postgres.json │ └── postgres.dhall ├── LICENSE ├── package.dhall ├── Prelude.dhall └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .history 2 | -------------------------------------------------------------------------------- /schemas/Vault.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/SpreadTarget.dhall, default.percent = 0 } 2 | -------------------------------------------------------------------------------- /schemas/Voume.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/Volume.dhall, default.read_only = False } 2 | -------------------------------------------------------------------------------- /types/Docker/DockerTmpfsOptions.dhall: -------------------------------------------------------------------------------- 1 | { size : Natural, mode : Optional Text } 2 | -------------------------------------------------------------------------------- /schemas/DispatchPayload.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/DispatchPayload.dhall, default = {=} } 2 | -------------------------------------------------------------------------------- /schemas/SpreadTarget.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/SpreadTarget.dhall, default.percent = 0 } 2 | -------------------------------------------------------------------------------- /schemas/VolumeMount.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/VolumeMount.dhall, default.read_only = False } 2 | -------------------------------------------------------------------------------- /schemas/Logs.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/Logs.dhall, default = { max_files = 10, max_file_size = 10 } } 2 | -------------------------------------------------------------------------------- /types/Constraint.dhall: -------------------------------------------------------------------------------- 1 | { attribute : Text, operator : ./ConstraintOperator.dhall, value : Text } 2 | -------------------------------------------------------------------------------- /types/JobType.dhall: -------------------------------------------------------------------------------- 1 | {- Specifies the Nomad scheduler to use. -} 2 | < service | system | batch > 3 | -------------------------------------------------------------------------------- /schemas/DockerConfigMount.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/DockerConfigMount.dhall, default.readonly = False } 2 | -------------------------------------------------------------------------------- /types/Docker/DockerBindType.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker#mounts -} 2 | < bind > 3 | -------------------------------------------------------------------------------- /types/Docker/DockerPIDMode.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker#pid_mode -} 2 | < host > 3 | -------------------------------------------------------------------------------- /types/Docker/DockerTmpfsType.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker#mounts -} 2 | < tmpfs > 3 | -------------------------------------------------------------------------------- /types/Docker/DockerVolumeType.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker#mounts -} 2 | < volume > 3 | -------------------------------------------------------------------------------- /types/VolumeType.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/volume#type -} 2 | < host | csi > 3 | -------------------------------------------------------------------------------- /schemas/Scaling.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/Scaling.dhall 2 | , default = { min = None Natural, enabled = False } 3 | } 4 | -------------------------------------------------------------------------------- /types/ChangeModeNoop.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/template#change_mode -} 2 | < noop > 3 | -------------------------------------------------------------------------------- /types/ArtifactMode.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/artifact#mode -} 2 | < any | file | dir > 3 | -------------------------------------------------------------------------------- /types/ChangeModeRestart.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/template#change_mode -} 2 | < restart > 3 | -------------------------------------------------------------------------------- /types/ChangeModeSignal.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/template#change_mode -} 2 | < signal > 3 | -------------------------------------------------------------------------------- /types/CheckProtocol.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/service#protocol -} 2 | < http | https > 3 | -------------------------------------------------------------------------------- /types/DispatchPayload.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/dispatch_payload -} 2 | { file : Text } 3 | -------------------------------------------------------------------------------- /types/RestartMode.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/restart#mode-values -} 2 | < delay | fail > 3 | -------------------------------------------------------------------------------- /schemas/Periodic.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/Periodic.dhall 2 | , default = { prohibit_overlap = False, time_zone = "UTC" } 3 | } 4 | -------------------------------------------------------------------------------- /types/ChangeMode.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/vault#change_mode -} 2 | < noop | restart | signal > 3 | -------------------------------------------------------------------------------- /types/CheckType.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/service#type -} 2 | < grpc | http | script | tcp > 3 | -------------------------------------------------------------------------------- /types/NetworkMode.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/network#mode -} 2 | < none | bridge | java | host > 3 | -------------------------------------------------------------------------------- /types/RawExec.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/raw_exec -} 2 | { command : Text, args : Optional (List Text) } 3 | -------------------------------------------------------------------------------- /types/Logs.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/logs -} 2 | { max_files : Natural, max_file_size : Natural } 3 | -------------------------------------------------------------------------------- /types/MigrateCheck.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/migrate#health_check -} 2 | < checks | task_states > 3 | -------------------------------------------------------------------------------- /schemas/EphemeralDisk.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/EphemeralDisk.dhall 2 | , default = { migrate = False, size = 300, sticky = False } 3 | } 4 | -------------------------------------------------------------------------------- /schemas/Port.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/Port.dhall 2 | , default = { static = None Natural, to = None Text, host_network = None Text } 3 | } 4 | -------------------------------------------------------------------------------- /types/AddressMode.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/service#address_mode -} 2 | < alloc | auto | driver | host > 3 | -------------------------------------------------------------------------------- /types/HTTPMethod.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/service#method -} 2 | < GET | POST | PUT | PATCH | DELETE > 3 | -------------------------------------------------------------------------------- /types/LifecycleHook.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/lifecycle#hook -} 2 | < prestart | poststart | poststop > 3 | -------------------------------------------------------------------------------- /types/UpdateCheck.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/update#health_check -} 2 | < checks | task_states | manual > 3 | -------------------------------------------------------------------------------- /schemas/Lifecycle.dhall: -------------------------------------------------------------------------------- 1 | let Hook = ../types/LifecycleHook.dhall 2 | 3 | in { Type = ../types/Lifecycle.dhall, default.sidecar = False, Hook } 4 | -------------------------------------------------------------------------------- /schemas/Spread.dhall: -------------------------------------------------------------------------------- 1 | let Target = ./SpreadTarget.dhall 2 | 3 | in { Type = ../types/Spread.dhall, default.target = Target.default, Target } 4 | -------------------------------------------------------------------------------- /types/Docker/DockerBindOptions.dhall: -------------------------------------------------------------------------------- 1 | { propagation : Optional Text 2 | , consistency : Optional Text 3 | , non_recursive : Optional Bool 4 | } 5 | -------------------------------------------------------------------------------- /types/Lifecycle.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/lifecycle -} 2 | { hook : ./LifecycleHook.dhall, sidecar : Bool } 3 | -------------------------------------------------------------------------------- /types/CheckInitialStatus.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/service#initial_status -} 2 | < passing | warning | critical > 3 | -------------------------------------------------------------------------------- /types/Docker/DockerVolumeDriverConfig.dhall: -------------------------------------------------------------------------------- 1 | let Map = (../../Prelude.dhall).Map.Type 2 | 3 | in { name : Text, options : Optional (Map Text Text) } 4 | -------------------------------------------------------------------------------- /types/Periodic.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/periodic -} 2 | { cron : Text, prohibit_overlap : Bool, time_zone : Text } 3 | -------------------------------------------------------------------------------- /types/SpreadTarget.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/spread#target-parameters -} 2 | { value : Text, percent : Natural } 3 | -------------------------------------------------------------------------------- /types/DelayFunction.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/reschedule#delay_function -} 2 | < constant | exponential | fibonacci > 3 | -------------------------------------------------------------------------------- /types/EphemeralDisk.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/ephemeral_disk -} 2 | { migrate : Bool, size : Natural, sticky : Bool } 3 | -------------------------------------------------------------------------------- /types/ParameterizedPayload.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/parameterized#payload -} 2 | < optional | required | forbidden > 3 | -------------------------------------------------------------------------------- /types/VolumeMount.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/volume_mount -} 2 | { volume : Text, destination : Text, read_only : Bool } 3 | -------------------------------------------------------------------------------- /types/CheckRestart.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/check_restart -} 2 | { limit : Natural, grace : Text, ignore_warning : Bool } 3 | -------------------------------------------------------------------------------- /types/Spread.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/spread -} 2 | { attribute : Text, target : ./SpreadTarget.dhall, weight : Natural } 3 | -------------------------------------------------------------------------------- /types/Docker/DockerNetworkMode.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker#network_mode -} 2 | < default | bridge | host | node | container : Text > 3 | -------------------------------------------------------------------------------- /schemas/Docker/DockerDevice.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../../types/Docker/DockerDevice.dhall 2 | , default = { container_path = None Text, cgroup_permissions = None Text } 3 | } 4 | -------------------------------------------------------------------------------- /types/Port.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/network#port-parameters -} 2 | { static : Optional Natural, to : Optional Text, host_network : Optional Text } 3 | -------------------------------------------------------------------------------- /schemas/Affinity.dhall: -------------------------------------------------------------------------------- 1 | let operator = ../types/AffinityOperator.dhall 2 | 3 | in { Type = ../types/Affinity.dhall 4 | , default = { operator = operator.`=`, weight = 50 } 5 | } 6 | -------------------------------------------------------------------------------- /schemas/Constraint.dhall: -------------------------------------------------------------------------------- 1 | let Operator = ../types/ConstraintOperator.dhall 2 | 3 | in { Type = ../types/Constraint.dhall 4 | , default.operator = Operator.`=` 5 | , Operator 6 | } 7 | -------------------------------------------------------------------------------- /schemas/DnsConfig.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/DnsConfig.dhall 2 | , default = 3 | { servers = None (List Text) 4 | , searches = None (List Text) 5 | , options = None (List Text) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /schemas/TaskConfig.dhall: -------------------------------------------------------------------------------- 1 | let Taskconfig = ../types/TaskConfig.dhall 2 | 3 | in { Docker = ./Docker.dhall 4 | , RawExec = ./RawExec.dhall 5 | , Custom.new = Taskconfig.Custom 6 | } 7 | -------------------------------------------------------------------------------- /schemas/Device.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/Device.dhall 2 | , default = 3 | { count = 1 4 | , constraint = None ../types/Constraint.dhall 5 | , affinity = None ../types/Affinity.dhall 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /schemas/RawExec.dhall: -------------------------------------------------------------------------------- 1 | let TaskConfig = ../types/TaskConfig.dhall 2 | 3 | in { Type = ../types/RawExec.dhall 4 | , default.args = None (List Text) 5 | , new = TaskConfig.RawExec 6 | } 7 | -------------------------------------------------------------------------------- /types/Affinity.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/affinity -} 2 | { attribute : Text 3 | , operator : ./AffinityOperator.dhall 4 | , value : Text 5 | , weight : Natural 6 | } 7 | -------------------------------------------------------------------------------- /types/Device.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/device -} 2 | { count : Natural 3 | , constraint : Optional ./Constraint.dhall 4 | , affinity : Optional ./Affinity.dhall 5 | } 6 | -------------------------------------------------------------------------------- /types/Docker/DockerDevice.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker#devices -} 2 | { host_path : Text 3 | , container_path : Optional Text 4 | , cgroup_permissions : Optional Text 5 | } 6 | -------------------------------------------------------------------------------- /types/DnsConfig.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/network#mode -} 2 | { servers : Optional (List Text) 3 | , searches : Optional (List Text) 4 | , options : Optional (List Text) 5 | } 6 | -------------------------------------------------------------------------------- /types/Restart.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/restart -} 2 | { attempts : Optional Natural 3 | , delay : Text 4 | , interval : Optional Text 5 | , mode : ./RestartMode.dhall 6 | } 7 | -------------------------------------------------------------------------------- /types/Scaling.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/scaling -} 2 | let JSON = (../Prelude.dhall).JSON.Type 3 | 4 | in { min : Optional Natural, max : Natural, enabled : Bool, policy : JSON } 5 | -------------------------------------------------------------------------------- /types/TaskConfig.dhall: -------------------------------------------------------------------------------- 1 | let Prelude = ../Prelude.dhall 2 | 3 | let JSON = Prelude.JSON.Type 4 | 5 | in < Docker : ./Docker/DockerConfig.dhall 6 | | RawExec : ./RawExec.dhall 7 | | Custom : JSON 8 | > 9 | -------------------------------------------------------------------------------- /examples/prometheus/prometheus_datasource.yml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | 3 | datasources: 4 | - name: Prometheus 5 | type: prometheus 6 | access: proxy 7 | url: http://{{ env "NOMAD_ADDR_prometheus_ui" }} 8 | 9 | -------------------------------------------------------------------------------- /types/Docker/DockerAuth.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker#auth -} 2 | { username : Optional Text 3 | , password : Optional Text 4 | , email : Optional Text 5 | , server_address : Optional Text 6 | } 7 | -------------------------------------------------------------------------------- /types/Migrate.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/migrate -} 2 | { health_check : ./MigrateCheck.dhall 3 | , healthy_deadline : Text 4 | , max_parallel : Natural 5 | , min_healthy_time : Text 6 | } 7 | -------------------------------------------------------------------------------- /schemas/Docker/DockerAuth.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../../types/Docker/DockerAuth.dhall 2 | , default = 3 | { username = None Text 4 | , password = None Text 5 | , email = None Text 6 | , server_address = None Text 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /types/Parameterized.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/parameterized -} 2 | { meta_optional : Optional (List Text) 3 | , meta_required : Optional (List Text) 4 | , payload : ./ParameterizedPayload.dhall 5 | } 6 | -------------------------------------------------------------------------------- /types/Vault.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/vault -} 2 | { change_mode : ./ChangeMode.dhall 3 | , change_signal : ./Signal.dhall 4 | , env : Bool 5 | , namespace : Optional Text 6 | , policies : List Text 7 | } 8 | -------------------------------------------------------------------------------- /types/Docker/DockerVolumeOptions.dhall: -------------------------------------------------------------------------------- 1 | let Map = (../../Prelude.dhall).Map.Type 2 | 3 | in { no_copy : Optional Bool 4 | , labels : Optional (Map Text Text) 5 | , driver_config : Optional ./DockerVolumeDriverConfig.dhall 6 | } 7 | -------------------------------------------------------------------------------- /schemas/Volume.dhall: -------------------------------------------------------------------------------- 1 | let JSON = (../Prelude.dhall).JSON 2 | 3 | let VolumeType = ../types/VolumeType.dhall 4 | 5 | in { Type = ../types/Volume.dhall 6 | , default = { read_only = False, mount_options = JSON.null } 7 | , VolumeType 8 | } 9 | -------------------------------------------------------------------------------- /types/Volume.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/volume -} 2 | let JSON = (../Prelude.dhall).JSON.Type 3 | 4 | in { type : ./VolumeType.dhall 5 | , source : Text 6 | , read_only : Bool 7 | , mount_options : JSON 8 | } 9 | -------------------------------------------------------------------------------- /types/AffinityOperator.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/constraint#operator -} 2 | < `=` 3 | | `!=` 4 | | `>` 5 | | `>=` 6 | | `<` 7 | | `<=` 8 | | regexp 9 | | set_contains_all 10 | | set_contains_any 11 | | version 12 | > 13 | -------------------------------------------------------------------------------- /types/Network.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/network -} 2 | let Map = (../Prelude.dhall).Map.Type 3 | 4 | in { port : Optional (Map Text ./Port.dhall) 5 | , mode : ./NetworkMode.dhall 6 | , dns : Optional ./DnsConfig.dhall 7 | } 8 | -------------------------------------------------------------------------------- /types/Reschedule.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/reschedule -} 2 | { attempts : Optional Natural 3 | , interval : Optional Text 4 | , delay : Text 5 | , delay_function : Optional ./DelayFunction.dhall 6 | , max_delay : Optional Text 7 | , unlimited : Bool 8 | } 9 | -------------------------------------------------------------------------------- /types/Signal.dhall: -------------------------------------------------------------------------------- 1 | < SIGHUP 2 | | SIGINT 3 | | SIGQUIT 4 | | SIGTRAP 5 | | SIGKILL 6 | | SIGUSR1 7 | | SIGUSR2 8 | | SIGPIPE 9 | | SIGALRM 10 | | SIGTERM 11 | | SIGCHLD 12 | | SIGCONTv 13 | | SIGSTOP 14 | | SIGTSTP 15 | | SIGURG 16 | | SIGVTALRM 17 | | SIGIO 18 | | SIGPWR 19 | > 20 | -------------------------------------------------------------------------------- /schemas/Restart.dhall: -------------------------------------------------------------------------------- 1 | let Mode = ../types/RestartMode.dhall 2 | 3 | in { Type = ../types/Restart.dhall 4 | , default = 5 | { attempts = None Natural 6 | , delay = "15s" 7 | , interval = None Text 8 | , mode = Mode.fail 9 | } 10 | , Mode 11 | } 12 | -------------------------------------------------------------------------------- /schemas/Migrate.dhall: -------------------------------------------------------------------------------- 1 | let Check = ../types/MigrateCheck.dhall 2 | 3 | in { Type = ../types/Migrate.dhall 4 | , default = 5 | { health_check = Check.checks 6 | , healthy_deadline = "5m" 7 | , max_parallel = 1 8 | , min_healthy_time = "10s" 9 | } 10 | , Check 11 | } 12 | -------------------------------------------------------------------------------- /schemas/Resources.dhall: -------------------------------------------------------------------------------- 1 | let Map = (../Prelude.dhall).Map.Type 2 | 3 | in { Type = ../types/Resources.dhall 4 | , default = 5 | { cpu = 100 6 | , memory = 300 7 | , network = None ../types/Network.dhall 8 | , device = None (Map Text ../types/Device.dhall) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /schemas/Parameterized.dhall: -------------------------------------------------------------------------------- 1 | let Payload = ../types/ParameterizedPayload.dhall 2 | 3 | in { Type = ../types/Parameterized.dhall 4 | , default = 5 | { meta_optional = None (List Text) 6 | , meta_required = None (List Text) 7 | , payload = Payload.optional 8 | } 9 | , Payload 10 | } 11 | -------------------------------------------------------------------------------- /types/ConstraintOperator.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/constraint#operator -} 2 | < `=` 3 | | `!=` 4 | | `>` 5 | | `>=` 6 | | `<` 7 | | `<=` 8 | | distinct_hosts 9 | | distinct_property 10 | | regexp 11 | | set_contains 12 | | version 13 | | semver 14 | | is_set 15 | | is_not_set 16 | > 17 | -------------------------------------------------------------------------------- /types/Artifact.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/artifact -} 2 | let Map = (../Prelude.dhall).Map.Type 3 | 4 | in { destination : Optional Text 5 | , mode : ./ArtifactMode.dhall 6 | , options : Optional (Map Text Text) 7 | , headers : Optional (Map Text Text) 8 | , source : Text 9 | } 10 | -------------------------------------------------------------------------------- /schemas/DockerConfig.dhall: -------------------------------------------------------------------------------- 1 | { Type = ../types/Docker/DockerConfig.dhall 2 | , default = 3 | { command = None Text 4 | , entrypoint = None (List Text) 5 | , force_pull = None Bool 6 | , hostname = None Text 7 | , volumes = None (List Text) 8 | , mounts = None (List (../types/Docker/DockerConfigMount.dhall).Type) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/prometheus/file_provider.yml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | 3 | providers: 4 | - name: 'default' 5 | orgId: 1 6 | folder: '' 7 | type: file 8 | disableDeletion: false 9 | updateIntervalSeconds: 10 #how often Grafana will scan for changed dashboards 10 | options: 11 | path: {{ env "NOMAD_TASK_DIR" }}/provisioning/dashboards/dashs 12 | -------------------------------------------------------------------------------- /schemas/Network.dhall: -------------------------------------------------------------------------------- 1 | let Map = (../Prelude.dhall).Map.Type 2 | 3 | let Mode = ../types/NetworkMode.dhall 4 | 5 | in { Type = ../types/Network.dhall 6 | , default = 7 | { port = None (Map Text ../types/Port.dhall) 8 | , mode = Mode.host 9 | , dns = None ../types/DnsConfig.dhall 10 | } 11 | , Mode 12 | } 13 | -------------------------------------------------------------------------------- /types/Update.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/update -} 2 | { max_parallel : Natural 3 | , min_healthy_time : Text 4 | , healthy_deadline : Text 5 | , health_check : ./UpdateCheck.dhall 6 | , progress_deadline : Text 7 | , auto_revert : Bool 8 | , auto_promote : Bool 9 | , canary : Natural 10 | , stagger : Text 11 | } 12 | -------------------------------------------------------------------------------- /schemas/Artifact.dhall: -------------------------------------------------------------------------------- 1 | let Mode = ../types/ArtifactMode.dhall 2 | 3 | let Map = (../Prelude.dhall).Map.Type 4 | 5 | in { Type = ../types/Artifact.dhall 6 | , default = 7 | { destination = None Text 8 | , mode = Mode.any 9 | , options = None (Map Text Text) 10 | , headers = None (Map Text Text) 11 | } 12 | , Mode 13 | } 14 | -------------------------------------------------------------------------------- /examples/postgres/README.md: -------------------------------------------------------------------------------- 1 | # Example Postgres Nomad Config 2 | 3 | The `postgres.dhall` file in this folder is equivalent to the 4 | `postgres.nomad` reference file. 5 | 6 | The `postgres.json` file is generated with 7 | 8 | ```bash 9 | dhall-to-json --file postgres.dhall > postgres.json 10 | ``` 11 | 12 | The json file is equivalent to the nomad file and can be scheduled with: 13 | 14 | ```bash 15 | nomad job run postgres.json 16 | ``` 17 | 18 | -------------------------------------------------------------------------------- /schemas/Template.dhall: -------------------------------------------------------------------------------- 1 | { strategy = 2 | { noop = 3 | { File = ./Template/FileNoop.dhall, Inline = ./Template/InlineNoop.dhall } 4 | , restart = 5 | { File = ./Template/FileWithRestart.dhall 6 | , Inline = ./Template/InlineWithRestart.dhall 7 | } 8 | , notify = 9 | { File = ./Template/InlineWithSignal.dhall 10 | , Inline = ./Template/FileWithSignal.dhall 11 | } 12 | } 13 | , Type = (../types/Template.dhall).Type 14 | } 15 | -------------------------------------------------------------------------------- /examples/prometheus/README.md: -------------------------------------------------------------------------------- 1 | # Example Prometheus Nomad Config 2 | 3 | The `prometheus.dhall` file in this folder is equivalent to the 4 | `prometheus.nomad` reference file. 5 | 6 | The `prometheus.json` file is generated with 7 | 8 | ```bash 9 | dhall-to-json --file prometheus.dhall > prometheus.json 10 | ``` 11 | 12 | The json file is equivalent to the nomad file and can be scheduled with: 13 | 14 | ```bash 15 | nomad job run prometheus.json 16 | ``` 17 | -------------------------------------------------------------------------------- /schemas/Update.dhall: -------------------------------------------------------------------------------- 1 | let Check = ../types/UpdateCheck.dhall 2 | 3 | in { Type = ../types/Update.dhall 4 | , default = 5 | { max_parallel = 1 6 | , health_check = Check.checks 7 | , min_healthy_time = "10s" 8 | , healthy_deadline = "5m" 9 | , progress_deadline = "10m" 10 | , auto_revert = False 11 | , auto_promote = False 12 | , canary = 0 13 | , stagger = "30s" 14 | } 15 | , Check 16 | } 17 | -------------------------------------------------------------------------------- /types/Service.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/service -} 2 | let Map = (../Prelude.dhall).Map.Type 3 | 4 | in { check : Optional (List ./Check.dhall) 5 | , name : Text 6 | , port : Optional Text 7 | , tags : Optional (List Text) 8 | , canary_tags : Optional (List Text) 9 | , enable_tag_override : Bool 10 | , address_mode : ./AddressMode.dhall 11 | , task : Optional Text 12 | , meta : Optional (Map Text Text) 13 | , canary_meta : Optional (Map Text Text) 14 | } 15 | -------------------------------------------------------------------------------- /schemas/Service.dhall: -------------------------------------------------------------------------------- 1 | let addressMode = ../types/AddressMode.dhall 2 | 3 | let Map = (../Prelude.dhall).Map.Type 4 | 5 | in { Type = ../types/Service.dhall 6 | , default = 7 | { check = None (List ../types/Check.dhall) 8 | , port = None Text 9 | , tags = None (List Text) 10 | , canary_tags = None (List Text) 11 | , enable_tag_override = False 12 | , address_mode = addressMode.auto 13 | , meta = None (Map Text Text) 14 | , canary_meta = None (Map Text Text) 15 | , task = None Text 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /types/Resources.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/resources 2 | 3 | Had to include deprecated network property due to Nomad version < 0.12 4 | Due to the following issues: 5 | 6 | https://github.com/hashicorp/nomad/issues/8780 7 | https://github.com/hashicorp/nomad/issues/8770 8 | https://www.nomadproject.io/docs/drivers/docker#deprecated-port_map-syntax 9 | 10 | -} 11 | let Map = (../Prelude.dhall).Map.Type 12 | 13 | in { cpu : Natural 14 | , memory : Natural 15 | , network : Optional ./Network.dhall 16 | , device : Optional (Map Text ./Device.dhall) 17 | } 18 | -------------------------------------------------------------------------------- /examples/prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | --- 2 | global: 3 | scrape_interval: 15s 4 | scrape_configs: 5 | - job_name: 'prometheus' 6 | scrape_interval: 5s 7 | static_configs: 8 | - targets: ['localhost:9090'] 9 | 10 | - job_name: 'nomad' 11 | scrape_interval: 10s 12 | metrics_path: /v1/metrics 13 | params: 14 | format: ['prometheus'] 15 | consul_sd_configs: 16 | - server: '{{ env "NOMAD_IP_prometheus_ui" }}:8500' 17 | # token: "c62d8564-c0c5-8dfe-3e75-005debbd0e40" 18 | services: 19 | - "nomad" 20 | - "nomad-client" 21 | relabel_configs: 22 | - source_labels: ['__meta_consul_tags'] 23 | regex: .*,http,.* 24 | action: keep 25 | 26 | -------------------------------------------------------------------------------- /schemas/Reschedule.dhall: -------------------------------------------------------------------------------- 1 | let Function = ../types/DelayFunction.dhall 2 | 3 | let Reschedule = 4 | { Type = ../types/Reschedule.dhall 5 | , default = 6 | { attempts = None Natural 7 | , interval = None Text 8 | , delay_function = None Function 9 | , max_delay = None Text 10 | , unlimited = False 11 | } 12 | , Function 13 | } 14 | 15 | let example0 = 16 | assert 17 | : Reschedule::{ attempts = Some 0, unlimited = False, delay = "0s" } 18 | ≡ { attempts = Some 0 19 | , interval = None Text 20 | , delay = "0s" 21 | , delay_function = None Function 22 | , max_delay = None Text 23 | , unlimited = False 24 | } 25 | 26 | in Reschedule 27 | -------------------------------------------------------------------------------- /types/Job.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/job -} 2 | let Map = (../Prelude.dhall).Map.Type 3 | 4 | in { affinity : Optional (List ./Affinity.dhall) 5 | , all_at_once : Bool 6 | , constraint : Optional (List ./Constraint.dhall) 7 | , datacenters : List Text 8 | , group : Map Text ./Group.dhall 9 | , meta : Optional (Map Text Text) 10 | , name : Optional Text 11 | , migrate : Optional ./Migrate.dhall 12 | , namespace : Optional Text 13 | , parameterized : Optional ./Parameterized.dhall 14 | , periodic : Optional ./Periodic.dhall 15 | , priority : Natural 16 | , region : Text 17 | , reschedule : Optional ./Reschedule.dhall 18 | , type : ./JobType.dhall 19 | , spread : Optional (List ./Spread.dhall) 20 | , update : Optional ./Update.dhall 21 | , vault : Optional ./Vault.dhall 22 | } 23 | -------------------------------------------------------------------------------- /schemas/Template/FileNoop.dhall: -------------------------------------------------------------------------------- 1 | let changeMode = ../../types/ChangeModeNoop.dhall 2 | 3 | let Template = ../../types/Template.dhall 4 | 5 | let default = 6 | { change_mode = changeMode.noop 7 | , left_delimiter = None Text 8 | , perms = None Text 9 | , right_delimiter = None Text 10 | } 11 | 12 | let new = Template.Type.FileTemplateNoop 13 | 14 | let File = { Type = Template.NoopFileConfig, default, new } 15 | 16 | let example0 = 17 | assert 18 | : File.new File::{ source = "/my/file", destination = "/my/dest" } 19 | ≡ Template.Type.FileTemplateNoop 20 | { change_mode = changeMode.noop 21 | , left_delimiter = None Text 22 | , perms = None Text 23 | , right_delimiter = None Text 24 | , source = "/my/file" 25 | , destination = "/my/dest" 26 | } 27 | 28 | in File 29 | -------------------------------------------------------------------------------- /schemas/Job.dhall: -------------------------------------------------------------------------------- 1 | let Map = (../Prelude.dhall).Map.Type 2 | 3 | let JobType = ../types/JobType.dhall 4 | 5 | in { Type = ../types/Job.dhall 6 | , default = 7 | { affinity = None (List ../types/Affinity.dhall) 8 | , all_at_once = False 9 | , constraint = None (List ../types/Constraint.dhall) 10 | , meta = None (Map Text Text) 11 | , name = None Text 12 | , migrate = None ../types/Migrate.dhall 13 | , namespace = None Text 14 | , parameterized = None ../types/Parameterized.dhall 15 | , periodic = None ../types/Periodic.dhall 16 | , priority = 50 17 | , region = "global" 18 | , reschedule = None ../types/Reschedule.dhall 19 | , type = JobType.service 20 | , spread = None (List ../types/Spread.dhall) 21 | , update = None ../types/Update.dhall 22 | , vault = None ../types/Vault.dhall 23 | } 24 | , JobType 25 | } 26 | -------------------------------------------------------------------------------- /schemas/Template/InlineNoop.dhall: -------------------------------------------------------------------------------- 1 | let changeMode = ../../types/ChangeModeNoop.dhall 2 | 3 | let Template = ../../types/Template.dhall 4 | 5 | let default = 6 | { change_mode = changeMode.noop 7 | , left_delimiter = None Text 8 | , perms = None Text 9 | , right_delimiter = None Text 10 | } 11 | 12 | let new = Template.Type.InlineTemplateNoop 13 | 14 | let Inline = { Type = Template.NoopInlineConfig, default, new } 15 | 16 | let example0 = 17 | assert 18 | : Inline.new 19 | Inline::{ data = "file contents", destination = "/my/dest" } 20 | ≡ Template.Type.InlineTemplateNoop 21 | { change_mode = changeMode.noop 22 | , left_delimiter = None Text 23 | , right_delimiter = None Text 24 | , perms = None Text 25 | , data = "file contents" 26 | , destination = "/my/dest" 27 | } 28 | 29 | in Inline 30 | -------------------------------------------------------------------------------- /types/Check.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/service#check-parameters -} 2 | let Map = (../Prelude.dhall).Map.Type 3 | 4 | in { address_mode : ./AddressMode.dhall 5 | , args : Optional (List Text) 6 | , check_restart : Optional ./CheckRestart.dhall 7 | , command : Optional Text 8 | , grpc_service : Optional Text 9 | , grpc_use_tls : Bool 10 | , initial_status : ./CheckInitialStatus.dhall 11 | , success_before_passing : Optional Natural 12 | , failures_before_critical : Optional Natural 13 | , interval : Text 14 | , method : ./HTTPMethod.dhall 15 | , name : Optional Text 16 | , path : Optional Text 17 | , expose : Bool 18 | , port : Optional Text 19 | , protocol : Optional ./CheckProtocol.dhall 20 | , task : Optional Text 21 | , timeout : Text 22 | , type : ./CheckType.dhall 23 | , tls_skip_verify : Bool 24 | , header : Optional (Map Text (List Text)) 25 | } 26 | -------------------------------------------------------------------------------- /types/Group.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/group -} 2 | let Map = (../Prelude.dhall).Map.Type 3 | 4 | in { affinity : Optional (List ./Affinity.dhall) 5 | , constraint : Optional (List ./Constraint.dhall) 6 | , count : Optional Natural 7 | , ephemeral_disk : Optional ./EphemeralDisk.dhall 8 | , meta : Optional (Map Text Text) 9 | , migrate : Optional ./Migrate.dhall 10 | , network : Optional ./Network.dhall 11 | , restart : Optional ./Restart.dhall 12 | , reschedule : Optional ./Reschedule.dhall 13 | , service : Optional (List ./Service.dhall) 14 | , shutdown_delay : Text 15 | , scaling : Optional ./Scaling.dhall 16 | , spread : Optional (List ./Spread.dhall) 17 | , stop_after_client_disconnect : Optional Text 18 | , task : Map Text ./Task.dhall 19 | , update : Optional ./Update.dhall 20 | , vault : Optional ./Vault.dhall 21 | , volume : Optional (List ./Volume.dhall) 22 | } 23 | -------------------------------------------------------------------------------- /schemas/Group.dhall: -------------------------------------------------------------------------------- 1 | let Map = (../Prelude.dhall).Map.Type 2 | 3 | in { Type = ../types/Group.dhall 4 | , default = 5 | { affinity = None (List ../types/Affinity.dhall) 6 | , constraint = None (List ../types/Constraint.dhall) 7 | , count = None Natural 8 | , ephemeral_disk = None ../types/EphemeralDisk.dhall 9 | , meta = None (Map Text Text) 10 | , migrate = None ../types/Migrate.dhall 11 | , network = None ../types/Network.dhall 12 | , restart = None ../types/Restart.dhall 13 | , reschedule = None ../types/Reschedule.dhall 14 | , service = None (List ../types/Service.dhall) 15 | , shutdown_delay = "0s" 16 | , scaling = None ../types/Scaling.dhall 17 | , spread = None (List ../types/Spread.dhall) 18 | , stop_after_client_disconnect = None Text 19 | , update = None ../types/Update.dhall 20 | , vault = None ../types/Vault.dhall 21 | , volume = None (List ../types/Volume.dhall) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /schemas/Task.dhall: -------------------------------------------------------------------------------- 1 | let Map = (../Prelude.dhall).Map.Type 2 | 3 | let Template = (../types/Template.dhall).Type 4 | 5 | let default = 6 | { artifact = None (List ../types/Artifact.dhall) 7 | , constraint = None (List ../types/Constraint.dhall) 8 | , affinity = None (List ../types/Affinity.dhall) 9 | , dispatch_payload = None ../types/DispatchPayload.dhall 10 | , env = None (Map Text Text) 11 | , kill_signal = None Text 12 | , kill_timeout = None Text 13 | , leader = None Bool 14 | , lifecycle = None ../types/Lifecycle.dhall 15 | , logs = None ../types/Logs.dhall 16 | , meta = None (Map Text Text) 17 | , service = None (List ../types/Service.dhall) 18 | , shutdown_delay = None Text 19 | , user = None Text 20 | , template = None (List Template) 21 | , vault = None ../types/Vault.dhall 22 | , volume_mount = None ../types/VolumeMount.dhall 23 | } 24 | 25 | in { Type = ../types/Task.dhall, default, Config = ./TaskConfig.dhall } 26 | -------------------------------------------------------------------------------- /schemas/Template/FileWithRestart.dhall: -------------------------------------------------------------------------------- 1 | let changeMode = ../../types/ChangeModeRestart.dhall 2 | 3 | let Template = ../../types/Template.dhall 4 | 5 | let default = 6 | { change_mode = changeMode.restart 7 | , splay = None Text 8 | , left_delimiter = None Text 9 | , perms = None Text 10 | , right_delimiter = None Text 11 | , env = False 12 | } 13 | 14 | let new = Template.Type.FileTemplateWithRestart 15 | 16 | let File = { Type = Template.RestartFileConfig, default, new } 17 | 18 | let example0 = 19 | assert 20 | : File.new File::{ source = "/my/file", destination = "/my/dest" } 21 | ≡ Template.Type.FileTemplateWithRestart 22 | { change_mode = changeMode.restart 23 | , splay = None Text 24 | , left_delimiter = None Text 25 | , right_delimiter = None Text 26 | , perms = None Text 27 | , source = "/my/file" 28 | , destination = "/my/dest" 29 | , env = False 30 | } 31 | 32 | in File 33 | -------------------------------------------------------------------------------- /types/Task.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/task -} 2 | let Map = (../Prelude.dhall).Map.Type 3 | 4 | let Template = (./Template.dhall).Type 5 | 6 | in { artifact : Optional (List ./Artifact.dhall) 7 | , config : ./TaskConfig.dhall 8 | , constraint : Optional (List ./Constraint.dhall) 9 | , affinity : Optional (List ./Affinity.dhall) 10 | , dispatch_payload : Optional ./DispatchPayload.dhall 11 | , driver : Text 12 | , env : Optional (Map Text Text) 13 | , kill_timeout : Optional Text 14 | , kill_signal : Optional Text 15 | , leader : Optional Bool 16 | , lifecycle : Optional ./Lifecycle.dhall 17 | , logs : Optional ./Logs.dhall 18 | , meta : Optional (Map Text Text) 19 | , resources : ./Resources.dhall 20 | , service : Optional (List ./Service.dhall) 21 | , shutdown_delay : Optional Text 22 | , user : Optional Text 23 | , template : Optional (List Template) 24 | , vault : Optional ./Vault.dhall 25 | , volume_mount : Optional ./VolumeMount.dhall 26 | } 27 | -------------------------------------------------------------------------------- /schemas/Template/InlineWithRestart.dhall: -------------------------------------------------------------------------------- 1 | let changeMode = ../../types/ChangeModeRestart.dhall 2 | 3 | let Template = ../../types/Template.dhall 4 | 5 | let default = 6 | { change_mode = changeMode.restart 7 | , splay = None Text 8 | , left_delimiter = None Text 9 | , perms = None Text 10 | , right_delimiter = None Text 11 | , env = False 12 | } 13 | 14 | let new = Template.Type.InlineTemplateWithRestart 15 | 16 | let Inline = { Type = Template.RestartInlineConfig, default, new } 17 | 18 | let example0 = 19 | assert 20 | : Inline.new 21 | Inline::{ data = "file contents", destination = "/my/dest" } 22 | ≡ Template.Type.InlineTemplateWithRestart 23 | { change_mode = changeMode.restart 24 | , left_delimiter = None Text 25 | , right_delimiter = None Text 26 | , perms = None Text 27 | , data = "file contents" 28 | , destination = "/my/dest" 29 | , env = False 30 | , splay = None Text 31 | } 32 | 33 | in Inline 34 | -------------------------------------------------------------------------------- /schemas/Template/FileWithSignal.dhall: -------------------------------------------------------------------------------- 1 | let changeMode = ../../types/ChangeModeSignal.dhall 2 | 3 | let Template = ../../types/Template.dhall 4 | 5 | let default = 6 | { change_mode = changeMode.signal 7 | , splay = None Text 8 | , left_delimiter = None Text 9 | , perms = None Text 10 | , right_delimiter = None Text 11 | } 12 | 13 | let new = Template.Type.FileTemplateWithSignal 14 | 15 | let File = { Type = Template.SignalFileConfig, default, new } 16 | 17 | let example0 = 18 | assert 19 | : File.new 20 | File::{ 21 | , source = "/my/file" 22 | , destination = "/my/dest" 23 | , change_signal = "SIGHUP" 24 | } 25 | ≡ Template.Type.FileTemplateWithSignal 26 | { change_mode = changeMode.signal 27 | , splay = None Text 28 | , left_delimiter = None Text 29 | , right_delimiter = None Text 30 | , perms = None Text 31 | , source = "/my/file" 32 | , destination = "/my/dest" 33 | , change_signal = "SIGHUP" 34 | } 35 | 36 | in File 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Seatgeek, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /types/Docker/DockerConfigMount.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker#mounts -} 2 | let VolumeOptions = ./DockerVolumeOptions.dhall 3 | 4 | let BindOptions = ./DockerBindOptions.dhall 5 | 6 | let TmpfsOptions = ./DockerTmpfsOptions.dhall 7 | 8 | let VolumeConfig = 9 | { type : ./DockerVolumeType.dhall 10 | , target : Text 11 | , source : Text 12 | , readonly : Bool 13 | , volume_options : Optional VolumeOptions 14 | } 15 | 16 | let BindConfig = 17 | { type : ./DockerBindType.dhall 18 | , target : Text 19 | , source : Text 20 | , readonly : Bool 21 | , bind_options : Optional BindOptions 22 | } 23 | 24 | let TmpfsConfig = 25 | { type : ./DockerTmpfsType.dhall 26 | , target : Text 27 | , readonly : Bool 28 | , tmpfs_options : Optional TmpfsOptions 29 | } 30 | 31 | let Variants = 32 | < Volume : VolumeConfig | Bind : BindConfig | Tmpfs : TmpfsConfig > 33 | 34 | in { Type = Variants 35 | , VolumeConfig 36 | , BindConfig 37 | , TmpfsConfig 38 | , VolumeOptions 39 | , BindOptions 40 | , TmpfsOptions 41 | } 42 | -------------------------------------------------------------------------------- /schemas/Template/InlineWithSignal.dhall: -------------------------------------------------------------------------------- 1 | let changeMode = ../../types/ChangeModeSignal.dhall 2 | 3 | let Template = ../../types/Template.dhall 4 | 5 | let default = 6 | { change_mode = changeMode.signal 7 | , splay = None Text 8 | , left_delimiter = None Text 9 | , perms = None Text 10 | , right_delimiter = None Text 11 | } 12 | 13 | let new = Template.Type.InlineTemplateWithSignal 14 | 15 | let Inline = { Type = Template.SignalInlineConfig, default, new } 16 | 17 | let example0 = 18 | assert 19 | : Inline.new 20 | Inline::{ 21 | , data = "file contents" 22 | , destination = "/my/dest" 23 | , change_signal = "SIGHUP" 24 | } 25 | ≡ Template.Type.InlineTemplateWithSignal 26 | { change_mode = changeMode.signal 27 | , left_delimiter = None Text 28 | , right_delimiter = None Text 29 | , perms = None Text 30 | , data = "file contents" 31 | , destination = "/my/dest" 32 | , splay = None Text 33 | , change_signal = "SIGHUP" 34 | } 35 | 36 | in Inline 37 | -------------------------------------------------------------------------------- /examples/postgres/postgres.hcl: -------------------------------------------------------------------------------- 1 | job "postgres" { 2 | region = "us-east-1" 3 | datacenters = ["default"] 4 | type = "service" 5 | 6 | meta { 7 | version = "1" 8 | } 9 | 10 | group "db" { 11 | task "postgres" { 12 | driver = "docker" 13 | 14 | config { 15 | image = "postgres:12" 16 | volumes = [ 17 | "/postgres:/appdata/postgres", 18 | ] 19 | port_map { 20 | db = 5432 21 | } 22 | } 23 | 24 | env { 25 | POSTGRES_DB = "postgres" 26 | POSTGRES_USER = "postgres" 27 | POSTGRES_PASSWORD = "ChAnGeMe" 28 | PGDATA = "/appdata/postgres" 29 | } 30 | 31 | service { 32 | name = "${NOMAD_JOB_NAME}" 33 | tags = ["postgres"] 34 | 35 | port = "db" 36 | 37 | check { 38 | type = "tcp" 39 | port = "db" 40 | interval = "30s" 41 | timeout = "2s" 42 | } 43 | } 44 | 45 | resources { 46 | network { 47 | port "db" { 48 | static = "25432" 49 | } 50 | } 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /package.dhall: -------------------------------------------------------------------------------- 1 | { Affinity = ./schemas/Affinity.dhall 2 | , Artifact = ./schemas/Artifact.dhall 3 | , Check = ./schemas/Check.dhall 4 | , Constraint = ./schemas/Constraint.dhall 5 | , Device = ./schemas/Device.dhall 6 | , DispatchPayload = ./schemas/DispatchPayload.dhall 7 | , DnsConfig = ./schemas/DnsConfig.dhall 8 | , EphemeralDisk = ./schemas/EphemeralDisk.dhall 9 | , Group = ./schemas/Group.dhall 10 | , HTTPMethod = ./types/HTTPMethod.dhall 11 | , Job = ./schemas/Job.dhall 12 | , Lifecycle = ./schemas/Lifecycle.dhall 13 | , Logs = ./schemas/Logs.dhall 14 | , Migrate = ./schemas/Migrate.dhall 15 | , Network = ./schemas/Network.dhall 16 | , Parameterized = ./schemas/Parameterized.dhall 17 | , Periodic = ./schemas/Periodic.dhall 18 | , Port = ./schemas/Port.dhall 19 | , Reschedule = ./schemas/Reschedule.dhall 20 | , Resources = ./schemas/Resources.dhall 21 | , Restart = ./schemas/Restart.dhall 22 | , Scaling = ./schemas/Scaling.dhall 23 | , Service = ./schemas/Service.dhall 24 | , Signal = ./types/Signal.dhall 25 | , Spread = ./schemas/Spread.dhall 26 | , Task = ./schemas/Task.dhall 27 | , Template = ./schemas/Template.dhall 28 | , Update = ./schemas/Update.dhall 29 | , Vault = ./schemas/Vault.dhall 30 | , Volume = ./schemas/Volume.dhall 31 | } 32 | -------------------------------------------------------------------------------- /schemas/Check.dhall: -------------------------------------------------------------------------------- 1 | let AddressMode = ../types/AddressMode.dhall 2 | 3 | let Restart = ../types/CheckRestart.dhall 4 | 5 | let Status = ../types/CheckInitialStatus.dhall 6 | 7 | let Method = ../types/HTTPMethod.dhall 8 | 9 | let Protocol = ../types/CheckProtocol.dhall 10 | 11 | let CheckType = ../types/CheckType.dhall 12 | 13 | let Map = (../Prelude.dhall).Map.Type 14 | 15 | in { Type = ../types/Check.dhall 16 | , default = 17 | { address_mode = AddressMode.host 18 | , args = None (List Text) 19 | , check_restart = None Restart 20 | , command = None Text 21 | , grpc_service = None Text 22 | , grpc_use_tls = False 23 | , initial_status = Status.critical 24 | , success_before_passing = None Natural 25 | , failures_before_critical = None Natural 26 | , method = Method.GET 27 | , name = None Text 28 | , path = None Text 29 | , expose = False 30 | , port = None Text 31 | , protocol = None Protocol 32 | , task = None Text 33 | , timeout = Text 34 | , tls_skip_verify = False 35 | , header = None (Map Text (List Text)) 36 | } 37 | , CheckType 38 | , AddressMode 39 | , Restart 40 | , Status 41 | , Method 42 | , Protocol 43 | } 44 | -------------------------------------------------------------------------------- /Prelude.dhall: -------------------------------------------------------------------------------- 1 | {- This file provides a central `Prelude` import for the rest of the library to 2 | use so that the integrity check only needs to be updated in one place 3 | whenever upgrading the interpreter. 4 | This allows the user to provide their own Prelude import using the 5 | `DHALL_PRELUDE` environment variable, like this: 6 | ``` 7 | $ export DHALL_PRELUDE='https://prelude.dhall-lang.org/package.dhall sha256:...' 8 | ``` 9 | Note that overriding the Prelude in this way only works if this repository 10 | is imported locally. Remote imports do not have access to environment 11 | variables and any attempt to import one will fall back to the next available 12 | import. To learn more, read: 13 | * https://github.com/dhall-lang/dhall-lang/wiki/Safety-guarantees#cross-site-scripting-xss 14 | This file also provides an import without the integrity check as a slower 15 | fallback if the user is using a different version of the Dhall interpreter. 16 | 17 | This pattern is taken from the dhall-nethack repo: 18 | * https://github.com/dhall-lang/dhall-nethack/blob/master/Prelude.dhall 19 | -} 20 | env:DHALL_PRELUDE 21 | ? https://raw.githubusercontent.com/dhall-lang/dhall-lang/v20.0.0/Prelude/package.dhall sha256:21754b84b493b98682e73f64d9d57b18e1ca36a118b81b33d0a243de8455814b 22 | ? https://raw.githubusercontent.com/dhall-lang/dhall-lang/v20.0.0/Prelude/package.dhall 23 | -------------------------------------------------------------------------------- /types/Template.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/job-specification/template -} 2 | let CommonConfig = 3 | { destination : Text 4 | , left_delimiter : Optional Text 5 | , perms : Optional Text 6 | , right_delimiter : Optional Text 7 | } 8 | 9 | let SignalConfig = 10 | { change_signal : Text 11 | , change_mode : ./ChangeModeSignal.dhall 12 | , splay : Optional Text 13 | } 14 | 15 | let RestartConfig = 16 | { change_mode : ./ChangeModeRestart.dhall 17 | , env : Bool 18 | , splay : Optional Text 19 | } 20 | 21 | let NoopConfig = { change_mode : ./ChangeModeNoop.dhall } 22 | 23 | let FileConfig = { source : Text } ⩓ CommonConfig 24 | 25 | let InlineConfig = { data : Text } ⩓ CommonConfig 26 | 27 | let NoopFileConfig = NoopConfig ⩓ FileConfig 28 | 29 | let NoopInlineConfig = NoopConfig ⩓ InlineConfig 30 | 31 | let SignalFileConfig = SignalConfig ⩓ FileConfig 32 | 33 | let SignalInlineConfig = SignalConfig ⩓ InlineConfig 34 | 35 | let RestartFileConfig = RestartConfig ⩓ FileConfig 36 | 37 | let RestartInlineConfig = RestartConfig ⩓ InlineConfig 38 | 39 | let Variants = 40 | < FileTemplateNoop : NoopFileConfig 41 | | InlineTemplateNoop : NoopInlineConfig 42 | | FileTemplateWithSignal : SignalFileConfig 43 | | InlineTemplateWithSignal : SignalInlineConfig 44 | | FileTemplateWithRestart : RestartFileConfig 45 | | InlineTemplateWithRestart : RestartInlineConfig 46 | > 47 | 48 | in { Type = Variants 49 | , NoopFileConfig 50 | , NoopInlineConfig 51 | , SignalFileConfig 52 | , SignalInlineConfig 53 | , RestartFileConfig 54 | , RestartInlineConfig 55 | } 56 | -------------------------------------------------------------------------------- /schemas/Docker/DockerMount.dhall: -------------------------------------------------------------------------------- 1 | let Mount = ../../types/Docker/DockerConfigMount.dhall 2 | 3 | let VolumeType = ../../types/Docker/DockerVolumeType.dhall 4 | 5 | let BindType = ../../types/Docker/DockerBindType.dhall 6 | 7 | let TmpfsType = ../../types/Docker/DockerTmpfsType.dhall 8 | 9 | let VolumeDriverConfig = ../../types/Docker/DockerVolumeDriverConfig.dhall 10 | 11 | let Map = (../../Prelude.dhall).Map.Type 12 | 13 | let Volume = 14 | { Type = Mount.VolumeConfig 15 | , default = 16 | { type = VolumeType.volume 17 | , readonly = False 18 | , volume_options = None Mount.VolumeOptions 19 | } 20 | , Options = 21 | { Type = Mount.VolumeOptions 22 | , default = 23 | { no_copy = None Bool 24 | , labels = None (Map Text Text) 25 | , driver_config = None VolumeDriverConfig 26 | } 27 | , Config = 28 | { Type = VolumeDriverConfig, default.options = None (Map Text Text) } 29 | } 30 | , new = Mount.Type.Volume 31 | } 32 | 33 | let Bind = 34 | { Type = Mount.BindConfig 35 | , default = 36 | { type = BindType.bind 37 | , readonly = False 38 | , bind_options = None Mount.BindOptions 39 | } 40 | , Options = 41 | { Type = Mount.BindOptions 42 | , default = 43 | { propagation = None Text 44 | , consistency = None Text 45 | , non_recursive = None Bool 46 | } 47 | } 48 | , new = Mount.Type.Bind 49 | } 50 | 51 | let Tmpfs = 52 | { Type = Mount.TmpfsConfig 53 | , default = 54 | { type = TmpfsType.tmpfs 55 | , readonly = False 56 | , tmpfs_options = None Mount.TmpfsOptions 57 | } 58 | , Options = { Type = Mount.TmpfsOptions, default.mode = None Text } 59 | , new = Mount.Type.Tmpfs 60 | } 61 | 62 | in { Volume 63 | , Bind 64 | , Tmpfs 65 | , BindOptions = Mount.BindOptions 66 | , TmpfsOptions = Mount.TmpfsOptions 67 | } 68 | -------------------------------------------------------------------------------- /types/Docker/DockerConfig.dhall: -------------------------------------------------------------------------------- 1 | {- https://www.nomadproject.io/docs/drivers/docker -} 2 | let Prelude = ../../Prelude.dhall 3 | 4 | let Map = Prelude.Map.Type 5 | 6 | let JSON = Prelude.JSON.Type 7 | 8 | let MountConfig = (./DockerConfigMount.dhall).Type 9 | 10 | in { image : Text 11 | , image_pull_timeout : Optional Text 12 | , args : Optional (List Text) 13 | , auth : Optional ./DockerAuth.dhall 14 | , auth_soft_fail : Optional Bool 15 | , command : Optional Text 16 | , cpuset_cpus : Optional Text 17 | , dns_search_domains : Optional (List Text) 18 | , dns_options : Optional (List Text) 19 | , dns_servers : Optional (List Text) 20 | , entrypoint : Optional (List Text) 21 | , extra_hosts : Optional (List Text) 22 | , force_pull : Optional Bool 23 | , hostname : Optional Text 24 | , interactive : Optional Bool 25 | , sysctl : Optional (Map Text Text) 26 | , ulimit : Optional (Map Text Text) 27 | , privileged : Optional Bool 28 | , ipc_mode : Optional Text 29 | , ipv4_address : Optional Text 30 | , ipv6_address : Optional Text 31 | , labels : Optional (Map Text Text) 32 | , load : Optional Text 33 | , logging : Optional JSON 34 | , mac_address : Optional Text 35 | , memory_hard_limit : Optional Natural 36 | , network_aliases : Optional (List Text) 37 | , network_mode : Optional ./DockerNetworkMode.dhall 38 | , pid_mode : Optional ./DockerPIDMode.dhall 39 | , ports : Optional (List Text) 40 | , port_map : Optional (Map Text Natural) 41 | , security_opt : Optional (List Text) 42 | , shm_size : Optional Natural 43 | , storage_opt : Optional (Map Text Text) 44 | , tty : Optional Bool 45 | , uts_mode : Optional ./DockerPIDMode.dhall 46 | , userns_mode : Optional ./DockerPIDMode.dhall 47 | , volumes : Optional (List Text) 48 | , volume_driver : Optional Text 49 | , work_dir : Optional Text 50 | , mounts : Optional (List MountConfig) 51 | , devices : Optional (List ./DockerDevice.dhall) 52 | , cap_add : Optional (List Text) 53 | , cap_drop : Optional (List Text) 54 | , cpu_hard_limit : Optional Bool 55 | , cpu_cfs_period : Optional Natural 56 | , advertise_ipv6_address : Optional Bool 57 | , readonly_rootfs : Optional Bool 58 | , runtime : Optional Text 59 | , pids_limit : Optional Natural 60 | } 61 | -------------------------------------------------------------------------------- /examples/postgres/postgres.json: -------------------------------------------------------------------------------- 1 | { 2 | "job": { 3 | "postgres": { 4 | "all_at_once": false, 5 | "datacenters": [ 6 | "default" 7 | ], 8 | "group": { 9 | "db": { 10 | "shutdown_delay": "0s", 11 | "task": { 12 | "postgres": { 13 | "config": { 14 | "image": "postgres:12", 15 | "port_map": { 16 | "db": 5432 17 | }, 18 | "volumes": [ 19 | "/postgres:/data/postgres" 20 | ] 21 | }, 22 | "driver": "docker", 23 | "env": { 24 | "PGDATA": "/data/postgres", 25 | "POSTGRES_DB": "postgres", 26 | "POSTGRES_PASSWORD": "root", 27 | "POSTGRES_USER": "postgres" 28 | }, 29 | "resources": { 30 | "cpu": 100, 31 | "memory": 300, 32 | "network": { 33 | "mode": "host", 34 | "port": { 35 | "db": { 36 | "static": 25432 37 | } 38 | } 39 | } 40 | }, 41 | "service": [ 42 | { 43 | "address_mode": "auto", 44 | "check": [ 45 | { 46 | "address_mode": "host", 47 | "expose": false, 48 | "grpc_use_tls": false, 49 | "initial_status": "critical", 50 | "interval": "30s", 51 | "method": "GET", 52 | "port": "db", 53 | "timeout": "2s", 54 | "tls_skip_verify": false, 55 | "type": "tcp" 56 | } 57 | ], 58 | "enable_tag_override": false, 59 | "name": "${NOMAD_JOB_NAME}", 60 | "port": "db", 61 | "tags": [ 62 | "postgres" 63 | ] 64 | } 65 | ] 66 | } 67 | } 68 | } 69 | }, 70 | "meta": { 71 | "version": "1" 72 | }, 73 | "priority": 50, 74 | "region": "us-east-1", 75 | "type": "service" 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /examples/postgres/postgres.dhall: -------------------------------------------------------------------------------- 1 | let nomad = ../../package.dhall 2 | 3 | let port = { name = "db", from = 25432, to = 5432 } 4 | 5 | let postgres = 6 | nomad.Job::{ 7 | , region = "us-east-1" 8 | , datacenters = [ "default" ] 9 | , type = nomad.Job.JobType.service 10 | , meta = Some (toMap { version = "1" }) 11 | , group = toMap 12 | { db = nomad.Group::{ 13 | , task = toMap 14 | { postgres = nomad.Task::{ 15 | , driver = "docker" 16 | , config = 17 | nomad.Task.Config.Docker.new 18 | nomad.Task.Config.Docker::{ 19 | , image = "postgres:12" 20 | , volumes = Some [ "/postgres:/data/postgres" ] 21 | , port_map = Some 22 | [ { mapKey = port.name, mapValue = port.to } ] 23 | } 24 | , env = Some 25 | ( toMap 26 | { POSTGRES_DB = "postgres" 27 | , POSTGRES_USER = "postgres" 28 | , POSTGRES_PASSWORD = "root" 29 | , PGDATA = "/data/postgres" 30 | } 31 | ) 32 | , service = Some 33 | [ nomad.Service::{ 34 | , name = "\${NOMAD_JOB_NAME}" 35 | , tags = Some [ "postgres" ] 36 | , port = Some port.name 37 | , check = Some 38 | [ nomad.Check::{ 39 | , type = nomad.Check.CheckType.tcp 40 | , port = Some "db" 41 | , interval = "30s" 42 | , timeout = "2s" 43 | } 44 | ] 45 | } 46 | ] 47 | , resources = nomad.Resources::{ 48 | , network = Some nomad.Network::{ 49 | , port = Some 50 | [ { mapKey = port.name 51 | , mapValue = nomad.Port::{ static = Some port.from } 52 | } 53 | ] 54 | } 55 | } 56 | } 57 | } 58 | } 59 | } 60 | } 61 | 62 | in { job = toMap { postgres } } 63 | -------------------------------------------------------------------------------- /schemas/Docker.dhall: -------------------------------------------------------------------------------- 1 | let DockerConfig = ../types/Docker/DockerConfig.dhall 2 | 3 | let Auth = ../types/Docker/DockerAuth.dhall 4 | 5 | let NetworkMode = ../types/Docker/DockerNetworkMode.dhall 6 | 7 | let HostMode = ../types/Docker/DockerPIDMode.dhall 8 | 9 | let Device = ../types/Docker/DockerDevice.dhall 10 | 11 | let Mount = ../types/Docker/DockerConfigMount.dhall 12 | 13 | let Prelude = ../Prelude.dhall 14 | 15 | let Map = Prelude.Map.Type 16 | 17 | let JSON = Prelude.JSON.Type 18 | 19 | let default = 20 | { image_pull_timeout = None Text 21 | , args = None (List Text) 22 | , auth = None Auth 23 | , auth_soft_fail = None Bool 24 | , command = None Text 25 | , cpuset_cpus = None Text 26 | , dns_search_domains = None (List Text) 27 | , dns_options = None (List Text) 28 | , dns_servers = None (List Text) 29 | , entrypoint = None (List Text) 30 | , extra_hosts = None (List Text) 31 | , force_pull = None Bool 32 | , hostname = None Text 33 | , interactive = None Bool 34 | , sysctl = None (Map Text Text) 35 | , ulimit = None (Map Text Text) 36 | , privileged = None Bool 37 | , ipc_mode = None Text 38 | , ipv4_address = None Text 39 | , ipv6_address = None Text 40 | , labels = None (Map Text Text) 41 | , load = None Text 42 | , logging = None JSON 43 | , mac_address = None Text 44 | , memory_hard_limit = None Natural 45 | , network_aliases = None (List Text) 46 | , network_mode = None NetworkMode 47 | , pid_mode = None HostMode 48 | , ports = None (List Text) 49 | , port_map = None (Map Text Natural) 50 | , security_opt = None (List Text) 51 | , shm_size = None Natural 52 | , storage_opt = None (Map Text Text) 53 | , tty = None Bool 54 | , uts_mode = None HostMode 55 | , userns_mode = None HostMode 56 | , volumes = None (List Text) 57 | , volume_driver = None Text 58 | , work_dir = None Text 59 | , mounts = None (List Mount.Type) 60 | , devices = None (List Device) 61 | , cap_add = None (List Text) 62 | , cap_drop = None (List Text) 63 | , cpu_hard_limit = None Bool 64 | , cpu_cfs_period = None Natural 65 | , advertise_ipv6_address = None Bool 66 | , readonly_rootfs = None Bool 67 | , runtime = None Text 68 | , pids_limit = None Natural 69 | } 70 | 71 | let new = (../types/TaskConfig.dhall).Docker 72 | 73 | in { Type = DockerConfig 74 | , default 75 | , new 76 | , NetworkMode 77 | , HostMode 78 | , Auth = ./Docker/DockerAuth.dhall 79 | , Device = ./Docker/DockerDevice.dhall 80 | , Mount = ./Docker/DockerMount.dhall 81 | } 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dhall-nomad 2 | 3 | This package lets you create nomad job specifications, modularize them, compose 4 | specifications from smaller pieces, template attributes and have them statically 5 | checked for correctness. 6 | 7 | ## Why 8 | 9 | While writing nomad job files using HCL is simple and readable for most, these 10 | files quickly become "cargo-culted": When several teams in an organization are 11 | encouraged to take care of their service deployments, example nomad job files are 12 | copied verbatim without giving much thought to what they mean, making errors made 13 | at the beginning of the process replicate over multiple different job files. 14 | 15 | A consequence of copy-pasting example jobs is configuration drift. Whenever you 16 | want to make important changes to all job files, so that they conform to a 17 | specific policy or best-practice for your organization, you have to deal with 18 | manually changing each job file. This process is often done manually as the 19 | tools for mechanically transforming HCL files are lacking. 20 | 21 | A common solution to this problem is templating. Using a templating engine, or 22 | using HCL2, can solve some of these issues for simple cases. One problem with 23 | external templating engines is that they are not aware of what a valid nomad job 24 | file is, and therefore it is unergonomic to author and maintain these 25 | specifications with using lots of dynamically generated elements. 26 | 27 | Additionally, HCL2 has limitations on what stanzas can be 28 | treated as an expression. For instance, it is not possible to write with HCL2 29 | reusable expressions that can be shared by many job files. There is no concept 30 | of importing a library of custom expressions in HCL2. 31 | 32 | The other solution to tis problem is creating a small library or DSL for your 33 | organization that encodes the practices that best work for you. This packages 34 | can be used as the foundation for creating reusable functions or blocks to be 35 | used in the authoring of maintainable job specification files. 36 | 37 | ## How to use 38 | 39 | Some examples on how to compose job files with this package can be found in the 40 | [examples](/examples) folder. 41 | 42 | You can import this package from your custom `dhall` files and, for instance, 43 | create a function to create a service stanza that conforms to your organization 44 | standards: 45 | 46 | ```dhall 47 | let nomad = https://raw.githubusercontent.com/seatgeek/dhall-nomad/v1.0.0/package.dhall 48 | 49 | let Port = {name: Text, number: Natural} 50 | in 51 | \(serviceName: Text) -> 52 | \(port: Port) -> 53 | nomad.Service::{ 54 | , name = serviceName 55 | , tags = Some [ "urlprefix-/${serviceName} strip=/${serviceName}" ] 56 | , port = Some port.name 57 | , check = Some 58 | [ nomad.Check::{ 59 | , name = Some "${serviceName} port alive" 60 | , type = nomad.Check.CheckType.tcp 61 | , interval = "10s" 62 | , timeout = "2s" 63 | } 64 | ] 65 | } 66 | ``` 67 | -------------------------------------------------------------------------------- /examples/prometheus/prometheus.nomad: -------------------------------------------------------------------------------- 1 | job "prometheus" { 2 | datacenters = ["dc1"] 3 | type = "service" 4 | update { 5 | max_parallel = 1 6 | min_healthy_time = "10s" 7 | healthy_deadline = "3m" 8 | auto_revert = false 9 | canary = 0 10 | } 11 | group "monitoring" { 12 | count = 1 13 | restart { 14 | attempts = 10 15 | interval = "5m" 16 | delay = "25s" 17 | mode = "delay" 18 | } 19 | network { 20 | port "prometheus_ui" { 21 | to = 9090 22 | } 23 | port "grafana_ui" { 24 | to = 3000 25 | } 26 | } 27 | 28 | service { 29 | name = "prometheus-ui" 30 | tags = ["urlprefix-/prometheus strip=/prometheus"] 31 | port = "prometheus_ui" 32 | check { 33 | name = "prometheus_ui port alive" 34 | type = "tcp" 35 | interval = "10s" 36 | timeout = "2s" 37 | } 38 | } 39 | 40 | service { 41 | name = "grafana-ui" 42 | port = "grafana_ui" 43 | tags = ["urlprefix-/grafana strip=/grafana"] 44 | check { 45 | name = "grafana-ui port alive" 46 | type = "tcp" 47 | interval = "10s" 48 | timeout = "2s" 49 | } 50 | } 51 | ephemeral_disk { size = 1000 } 52 | task "grafana" { 53 | artifact { 54 | source = "https://example.com/prometheus_nomad.json" 55 | destination = "local/provisioning/dashboards/dashs" 56 | } 57 | template { 58 | change_mode = "noop" 59 | destination = "local/provisioning/dashboards/file_provider.yml" 60 | data = <