Skip to content

Commit

Permalink
Merge pull request #3 from mutablelogic/dev
Browse files Browse the repository at this point in the history
Added service parameters for coredns and openldap
  • Loading branch information
djthorpe authored Jan 25, 2024
2 parents 56ea102 + 9bbd8b0 commit dfbe5ac
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 26 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ provider "nomad" {
DNS server which could be used to resolve nomad services into dns records

* [Documentation](https://coredns.io/)
* [Terraform Example](examples/coredns.tf)
* [Terraform Example](_examples/coredns.tf)
* [Nomad Job](coredns/nomad/coredns.hcl)

TODO:
Expand All @@ -36,7 +36,7 @@ TODO:
grafana is a database server

* [Documentation](https://grafana.com/docs/grafana/latest/)
* [Terraform Example](examples/grafana.tf)
* [Terraform Example](_examples/grafana.tf)
* [Nomad Job](grafana/nomad/grafana.hcl)

TODO:
Expand All @@ -50,7 +50,7 @@ TODO:
Time-series database, which can be placed on several nodes

* [Documentation](https://docs.influxdata.com/influxdb/v2/)
* [Terraform Example](examples/influxdb.tf)
* [Terraform Example](_examples/influxdb.tf)
* [Nomad Job](influxdb/nomad/influxdb.hcl)

TODO:
Expand All @@ -61,7 +61,7 @@ TODO:
MQTT broker, which can be placed on several nodes

* [Documentation](https://mosquitto.org/)
* [Terraform Example](examples/mosquitto.tf)
* [Terraform Example](_examples/mosquitto.tf)
* [Nomad Job](mosquitto/nomad/mosquitto.hcl)

TODO:
Expand All @@ -72,7 +72,7 @@ TODO:
Web server and reverse proxy, which can be placed on several nodes

* [Documentation](https://nginx.org/en/)
* [Terraform Example](examples/nginx.tf)
* [Terraform Example](_examples/nginx.tf)
* [Nomad Job](nginx/nomad/nginx.hcl)

TODO:
Expand All @@ -85,7 +85,7 @@ TODO:
OpenLDAP server, which can be placed on several nodes

* [Documentation](https://www.openldap.org/)
* [Terraform Example](examples/openldap.tf)
* [Terraform Example](_examples/openldap.tf)
* [Nomad Job](openldap/nomad/openldap.hcl)

TODO:
Expand All @@ -99,7 +99,7 @@ TODO:
PostgreSQL is a database server

* [Documentation](https://www.postgresql.org/)
* [Terraform Example](examples/postgresql.tf)
* [Terraform Example](_examples/postgresql.tf)
* [Nomad Job](postgresql/nomad/postgresql.hcl)

TODO:
Expand All @@ -110,7 +110,7 @@ TODO:
Cluster filesystem, which can be spread across multiple nodes.

* [Documentation](https://github.com/seaweedfs/seaweedfs)
* [Terraform Example](examples/seaweedfs.tf)
* [Terraform Example](_examples/seaweedfs.tf)
* [Nomad Job](seaweedfs/nomad/seaweedfs.hcl)

TODO:
Expand All @@ -122,7 +122,7 @@ TODO:
Semaphore is a Ansible front-end

* [Documentation](https://www.semui.co/)
* [Terraform Example](examples/semaphore.tf)
* [Terraform Example](_examples/semaphore.tf)
* [Nomad Job](semaphore/nomad/semaphore.hcl)

TODO:
Expand All @@ -134,7 +134,7 @@ TODO:
Time-series metrics collector, which can be placed on several nodes

* [Documentation](https://docs.influxdata.com/telegraf/v1/)
* [Terraform Example](examples/telegraf.tf)
* [Terraform Example](_examples/telegraf.tf)
* [Nomad Job](telegraf/nomad/telegraf.hcl)

When setting up your configuration with inputs and outputs, each value needs
Expand Down
2 changes: 1 addition & 1 deletion _examples/influxdb.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Example InfluxDB time-series database
module "influxdb" {
source = "github.com/mutablelogic/tf-nomad/influxdb"
source = "github.com/mutablelogic/tf-nomad//influxdb"

// Required parameters
dc = "datacenter" // Nomad datacenter for the cluster
Expand Down
2 changes: 1 addition & 1 deletion _examples/mosquitto.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Example MQTT broker, using the eclipse-mosquitto docker image
module "mqtt" {
source = "github.com/mutablelogic/tf-nomad/mosquitto"
source = "github.com/mutablelogic/tf-nomad//mosquitto"

// Required parameters
dc = "datacenter" // Nomad datacenter for the cluster
Expand Down
2 changes: 1 addition & 1 deletion _examples/nginx.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Example nginx reverse proxy module
module "nginx" {
source = "github.com/mutablelogic/tf-nomad/nginx"
source = "github.com/mutablelogic/tf-nomad//nginx"

// Required parameters
dc = "datacenter" // Nomad datacenter for the cluster
Expand Down
2 changes: 1 addition & 1 deletion _examples/openldap.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Example LDAP server, using the bitnami/openldap docker image
module "openldap" {
source = "github.com/mutablelogic/tf-nomad/openldap"
source = "github.com/mutablelogic/tf-nomad//openldap"

// Required parameters
dc = "datacenter" // Nomad datacenter for the cluster
Expand Down
2 changes: 1 addition & 1 deletion _examples/postgresql.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

module "postgresql" {
source = "github.com/mutablelogic/tf-nomad/postgresql"
source = "github.com/mutablelogic/tf-nomad//postgresql"

// Required parameters
dc = local.datacenter // Nomad datacenter for the cluster
Expand Down
2 changes: 1 addition & 1 deletion _examples/seaweedfs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Example Cluster filesystem using seaweedfs, with one master, two volumes and three filers
module "clusterfs" {
source = "github.com/mutablelogic/tf-nomad/seaweedfs"
source = "github.com/mutablelogic/tf-nomad//seaweedfs"
enabled = true // If false, no-op
dc = "datacenter" // Nomad datacenter for the cluster
namespace = "clusterfs" // Nomad namespace for the cluster
Expand Down
2 changes: 1 addition & 1 deletion _examples/telegraf.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Example telegraf time-series metrics collector
module "telegraf" {
source = "github.com/mutablelogic/tf-nomad/telegraf"
source = "github.com/mutablelogic/tf-nomad//telegraf"

// Required parameters
dc = local.datacenter // Nomad datacenter for the cluster
Expand Down
18 changes: 18 additions & 0 deletions coredns/input.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ variable "docker_tag" {
default = "v1.11.1"
}

variable "service_provider" {
description = "Service provider, either consul or nomad"
type = string
default = "nomad"
}

variable "service_name" {
description = "Service name"
type = string
default = "coredns-dns"
}

variable "service_dns" {
description = "Service discovery DNS"
type = list(string)
default = []
}

variable "hosts" {
type = list(string)
description = "List of hosts to deploy on. If empty, one allocation will be created"
Expand Down
3 changes: 3 additions & 0 deletions coredns/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ resource "nomad_job" "coredns" {
namespace = var.namespace
docker_image = local.docker_image
docker_always_pull = jsonencode(local.docker_always_pull)
service_provider = var.service_provider
service_name = var.service_name
service_dns = jsonencode(var.service_dns)
hosts = jsonencode(var.hosts)
port = var.port
corefile = file("${path.module}/config/Corefile")
Expand Down
29 changes: 24 additions & 5 deletions coredns/nomad/coredns.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ variable "service_provider" {
default = "nomad"
}

variable "service_name" {
description = "Service name"
type = string
default = "coredns-dns"
}

variable "service_dns" {
description = "Service discovery DNS"
type = list(string)
default = []
}

variable "dns_servers" {
description = "Task DNS servers"
type = list(string)
default = []
}

variable "docker_image" {
description = "Docker image"
type = string
Expand Down Expand Up @@ -117,7 +135,7 @@ job "coredns" {

service {
tags = ["dns"]
name = "coredns-dns"
name = var.service_name
port = "dns"
provider = var.service_provider
}
Expand All @@ -142,10 +160,11 @@ job "coredns" {
}

config {
image = var.docker_image
force_pull = var.docker_always_pull
ports = ["dns"]
args = ["coredns", "-conf", local.core_file]
image = var.docker_image
force_pull = var.docker_always_pull
ports = ["dns"]
args = ["coredns", "-conf", local.core_file]
dns_servers = var.service_dns
}

} // task "daemon"
Expand Down
18 changes: 18 additions & 0 deletions openldap/input.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ variable "enabled" {
default = true
}

variable "service_provider" {
description = "Service provider, either consul or nomad"
type = string
default = "nomad"
}

variable "service_name" {
description = "Service name"
type = string
default = "openldap-ldap"
}

variable "service_dns" {
description = "Service discovery DNS"
type = list(string)
default = []
}

variable "docker_tag" {
type = string
description = "Version of the docker image to use, defaults to latest"
Expand Down
3 changes: 3 additions & 0 deletions openldap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ resource "nomad_job" "ldap" {
namespace = var.namespace
docker_image = local.docker_image
docker_always_pull = jsonencode(local.docker_always_pull)
service_provider = var.service_provider
service_name = var.service_name
service_dns = jsonencode(var.service_dns)
hosts = jsonencode(var.hosts)
port = var.port
data = var.data
Expand Down
21 changes: 17 additions & 4 deletions openldap/nomad/openldap.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ variable "service_provider" {
default = "nomad"
}

variable "service_name" {
description = "Service name"
type = string
default = "openldap-ldap"
}

variable "service_dns" {
description = "Service discovery DNS"
type = list(string)
default = []
}

variable "docker_image" {
description = "Docker image"
type = string
Expand Down Expand Up @@ -126,10 +138,10 @@ job "openldap" {
}

service {
tags = ["ldap"]
name = "ldap"
port = "ldap"
tags = ["openldap", "ldap"]
name = var.service_name
provider = var.service_provider
port = "ldap"
}

ephemeral_disk {
Expand Down Expand Up @@ -184,7 +196,8 @@ job "openldap" {
volumes = compact([
var.data == "" ? "" : format("%s:/bitnami/openldap/", var.data),
])
ports = ["ldap"]
ports = ["ldap"]
dns_servers = var.service_dns
}

} // task "daemon"
Expand Down

0 comments on commit dfbe5ac

Please sign in to comment.