Merge pull request #9538 from hashicorp/f-nomad-provider

provider/nomad: Nomad provider for managing jobs
This commit is contained in:
Mitchell Hashimoto
2016-11-09 18:34:55 -08:00
committed by GitHub
956 changed files with 177005 additions and 475 deletions

View File

@@ -0,0 +1,36 @@
---
layout: "nomad"
page_title: "Provider: Nomad"
sidebar_current: "docs-nomad-index"
description: |-
Nomad is a cluster scheduler. The Nomad provider exposes resources to interact with a Nomad cluster.
---
# Nomad Provider
[Nomad](https://www.nomadproject.io) is a cluster scheduler. The Nomad
provider exposes resources to interact with a Nomad cluster.
Use the navigation to the left to read about the available resources.
## Example Usage
```
# Configure the Nomad provider
provider "nomad" {
address = "nomad.mycompany.com"
region = "us-east-2"
}
# Register a job
resource "nomad_job" "monitoring" {
jobspec = "${file("${path.module}/jobspec.hcl")}"
}
```
## Argument Reference
The following arguments are supported:
* `address` - (Optional) The HTTP(S) API address of the Nomad agent to use. Defaults to `127.0.0.1:4646`. The `NOMAD_ADDR` environment variable can also be used.
* `region` - (Optional) The Nomad region to target. The `NOMAD_REGION` environment variable can also be used.

View File

@@ -0,0 +1,77 @@
---
layout: "nomad"
page_title: "Nomad: nomad_job"
sidebar_current: "docs-nomad-resource-job"
description: |-
Manages a job registered in Nomad.
---
# nomad\_job
Manages a job registered in Nomad.
This can be used to initialize your cluster with system jobs, common services,
and more. In day to day Nomad use it is common for developers to submit
jobs to Nomad directly, such as for general app deployment. In addition to
these apps, a Nomad cluster often runs core system services that are ideally
setup during infrastructure creation. This resource is ideal for the latter
type of job, but can be used to manage any job within Nomad.
## Example Usage
Registering a job from a jobspec file:
```
resource "nomad_job" "app" {
jobspec = "${file("${path.module}/job.hcl")}"
}
```
Registering a job from an inline jobspec. This is less realistic but
is an example of how it is possible. More likely, the contents will
be paired with something such as the
[template_file](https://www.terraform.io/docs/providers/template/d/file.html)
resource to render parameterized jobspecs.
```
resource "nomad_job" "app" {
jobspec = <<EOT
job "foo" {
datacenters = ["dc1"]
type = "service"
group "foo" {
task "foo" {
driver = "raw_exec"
config {
command = "/bin/sleep"
args = ["1"]
}
resources {
cpu = 20
memory = 10
disk = 100
}
logs {
max_files = 3
max_file_size = 10
}
}
}
}
EOT
}
```
## Argument Reference
The following arguments are supported:
* `jobspec` - (Required) The contents of the jobspec to register.
* `deregister_on_destroy` - (Optional) If true, the job will be deregistered
when this resource is destroyed in Terraform. Defaults to true.
* `deregister_on_id_change` - (Optional) If true, the job will be deregistered
if the ID of the job in the jobspec changes. Defaults to true.