This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from hashicorp/tf12-upgrade
Tf12 upgrade
- Loading branch information
Showing
21 changed files
with
1,487 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
workspace_root: &workspace_root | ||
/go/src/github.com/hashicorp/terraform-google-nomad | ||
|
||
defaults: &defaults | ||
working_directory: *workspace_root | ||
docker: | ||
- image: gruntwork/circle-ci-test-image-base:go1.11 | ||
|
||
version: 2 | ||
jobs: | ||
build: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- attach_workspace: | ||
at: *workspace_root | ||
- restore_cache: | ||
keys: | ||
- dep-{{ checksum "test/Gopkg.lock" }} | ||
- run: configure-environment-for-gruntwork-module --go-src-path test --use-go-dep --circle-ci-2 | ||
- save_cache: | ||
key: dep-{{ checksum "test/Gopkg.lock" }} | ||
paths: | ||
- /go/src/github.com/hashicorp/terraform-google-nomad/test/vendor | ||
- persist_to_workspace: | ||
root: *workspace_root | ||
paths: test/vendor | ||
test: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- run: echo 'export PATH=$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV | ||
- attach_workspace: | ||
at: *workspace_root | ||
# Write service account creds to disk where the API expects them | ||
- run: mkdir -p /tmp/logs | ||
- run: | | ||
export GOOGLE_APPLICATION_CREDENTIALS="/tmp/gcloud.json" && \ | ||
echo $GCLOUD_SERVICE_KEY > /tmp/gcloud.json && \ | ||
run-go-tests --circle-ci-2 --path test | tee /tmp/logs/all.log | ||
- run: | ||
command: terratest_log_parser --testlog /tmp/logs/all.log --outputdir /tmp/logs | ||
when: always | ||
- store_artifacts: | ||
path: /tmp/logs | ||
- store_test_results: | ||
path: /tmp/logs | ||
|
||
workflows: | ||
version: 2 | ||
build-and-test: | ||
jobs: | ||
- build | ||
- test: | ||
requires: | ||
- build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
terraform.tfstate | ||
terraform.tfvars | ||
*.tfstate* | ||
*.test-data | ||
|
||
# OS X files | ||
.history | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,14 @@ | |
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
provider "google" { | ||
project = "${var.gcp_project}" | ||
region = "${var.gcp_region}" | ||
project = var.gcp_project | ||
region = var.gcp_region | ||
} | ||
|
||
# Use Terraform 0.10.x so that we can take advantage of Terraform GCP functionality as a separate provider via | ||
# https://github.com/terraform-providers/terraform-provider-google | ||
terraform { | ||
required_version = ">= 0.10.3" | ||
# The modules used in this example have been updated with 0.12 syntax, which means the example is no longer | ||
# compatible with any versions below 0.12. | ||
required_version = ">= 0.12" | ||
} | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
@@ -33,15 +33,15 @@ module "nomad_servers" { | |
# source = "git::[email protected]:hashicorp/terraform-google-nomad.git//modules/nomad-cluster?ref=v0.0.1" | ||
source = "../../modules/nomad-cluster" | ||
|
||
gcp_zone = "${var.gcp_zone}" | ||
gcp_region = var.gcp_region | ||
|
||
cluster_name = "${var.nomad_server_cluster_name}" | ||
cluster_size = "${var.nomad_server_cluster_size}" | ||
cluster_tag_name = "${var.nomad_server_cluster_name}" | ||
machine_type = "${var.nomad_server_cluster_machine_type}" | ||
cluster_name = var.nomad_server_cluster_name | ||
cluster_size = var.nomad_server_cluster_size | ||
cluster_tag_name = var.nomad_server_cluster_name | ||
machine_type = var.nomad_server_cluster_machine_type | ||
|
||
source_image = "${var.nomad_server_source_image}" | ||
startup_script = "${data.template_file.startup_script_nomad_server.rendered}" | ||
source_image = var.nomad_server_source_image | ||
startup_script = data.template_file.startup_script_nomad_server.rendered | ||
|
||
# WARNING! | ||
# In a production setting, we strongly recommend only launching a Nomad Server cluster as private nodes. | ||
|
@@ -52,18 +52,18 @@ module "nomad_servers" { | |
allowed_inbound_cidr_blocks_http = ["0.0.0.0/0"] | ||
|
||
# Enable the Consul Cluster to reach the Nomad Cluster | ||
allowed_inbound_tags_http = ["${var.consul_server_cluster_name}", "${var.nomad_client_cluster_name}"] | ||
allowed_inbound_tags_rpc = ["${var.consul_server_cluster_name}", "${var.nomad_client_cluster_name}"] | ||
allowed_inbound_tags_serf = ["${var.consul_server_cluster_name}", "${var.nomad_client_cluster_name}"] | ||
allowed_inbound_tags_http = [var.consul_server_cluster_name, var.nomad_client_cluster_name] | ||
allowed_inbound_tags_rpc = [var.consul_server_cluster_name, var.nomad_client_cluster_name] | ||
allowed_inbound_tags_serf = [var.consul_server_cluster_name, var.nomad_client_cluster_name] | ||
} | ||
|
||
# Render the Startup Script that will run on each Nomad Instance on boot. This script will configure and start Nomad. | ||
data "template_file" "startup_script_nomad_server" { | ||
template = "${file("${path.module}/startup-script-nomad-server.sh")}" | ||
template = file("${path.module}/startup-script-nomad-server.sh") | ||
|
||
vars { | ||
num_servers = "${var.nomad_server_cluster_size}" | ||
consul_server_cluster_tag_name = "${var.consul_server_cluster_name}" | ||
vars = { | ||
num_servers = var.nomad_server_cluster_size | ||
consul_server_cluster_tag_name = var.consul_server_cluster_name | ||
} | ||
} | ||
|
||
|
@@ -72,33 +72,35 @@ data "template_file" "startup_script_nomad_server" { | |
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
module "consul_cluster" { | ||
source = "git::[email protected]:gruntwork-io/terraform-google-consul.git//modules/consul-cluster?ref=v0.0.2" | ||
source = "git::[email protected]:hashicorp/terraform-google-consul.git//modules/consul-cluster?ref=v0.4.0" | ||
|
||
gcp_zone = "${var.gcp_zone}" | ||
cluster_name = "${var.consul_server_cluster_name}" | ||
cluster_tag_name = "${var.consul_server_cluster_name}" | ||
cluster_size = "${var.consul_server_cluster_size}" | ||
gcp_project_id = var.gcp_project | ||
gcp_region = var.gcp_region | ||
|
||
source_image = "${var.consul_server_source_image}" | ||
machine_type = "${var.consul_server_machine_type}" | ||
cluster_name = var.consul_server_cluster_name | ||
cluster_tag_name = var.consul_server_cluster_name | ||
cluster_size = var.consul_server_cluster_size | ||
|
||
startup_script = "${data.template_file.startup_script_consul.rendered}" | ||
source_image = var.consul_server_source_image | ||
machine_type = var.consul_server_machine_type | ||
|
||
startup_script = data.template_file.startup_script_consul.rendered | ||
|
||
# WARNING! | ||
# In a production setting, we strongly recommend only launching a Consul Server cluster as private nodes. | ||
# Note that the only way to reach private nodes via SSH is to first SSH into another node that is not private. | ||
assign_public_ip_addresses = true | ||
|
||
allowed_inbound_tags_dns = ["${var.nomad_server_cluster_name}", "${var.nomad_client_cluster_name}"] | ||
allowed_inbound_tags_http_api = ["${var.nomad_server_cluster_name}", "${var.nomad_client_cluster_name}"] | ||
allowed_inbound_tags_dns = [var.nomad_server_cluster_name, var.nomad_client_cluster_name] | ||
allowed_inbound_tags_http_api = [var.nomad_server_cluster_name, var.nomad_client_cluster_name] | ||
} | ||
|
||
# This Startup Script will run at boot configure and start Consul on the Consul Server cluster nodes | ||
data "template_file" "startup_script_consul" { | ||
template = "${file("${path.module}/startup-script-consul-server.sh")}" | ||
template = file("${path.module}/startup-script-consul-server.sh") | ||
|
||
vars { | ||
consul_server_cluster_tag_name = "${var.consul_server_cluster_name}" | ||
vars = { | ||
consul_server_cluster_tag_name = var.consul_server_cluster_name | ||
} | ||
} | ||
|
||
|
@@ -112,15 +114,15 @@ module "nomad_clients" { | |
# source = "git::[email protected]:hashicorp/terraform-google-nomad.git//modules/nomad-cluster?ref=v0.0.1" | ||
source = "../../modules/nomad-cluster" | ||
|
||
gcp_zone = "${var.gcp_zone}" | ||
gcp_region = var.gcp_region | ||
|
||
cluster_name = "${var.nomad_client_cluster_name}" | ||
cluster_size = "${var.nomad_client_cluster_size}" | ||
cluster_tag_name = "${var.nomad_client_cluster_name}" | ||
machine_type = "${var.nomad_client_machine_type}" | ||
cluster_name = var.nomad_client_cluster_name | ||
cluster_size = var.nomad_client_cluster_size | ||
cluster_tag_name = var.nomad_client_cluster_name | ||
machine_type = var.nomad_client_machine_type | ||
|
||
source_image = "${var.nomad_client_source_image}" | ||
startup_script = "${data.template_file.startup_script_nomad_client.rendered}" | ||
source_image = var.nomad_client_source_image | ||
startup_script = data.template_file.startup_script_nomad_client.rendered | ||
|
||
# We strongly recommend setting this to "false" in a production setting. Your Nomad cluster has no reason to be | ||
# publicly accessible! However, for testing and demo purposes, it is more convenient to launch a publicly accessible | ||
|
@@ -129,17 +131,16 @@ module "nomad_clients" { | |
|
||
# These inbound clients need only receive requests from Nomad Server and Consul | ||
allowed_inbound_cidr_blocks_http = [] | ||
allowed_inbound_tags_http = ["${var.nomad_server_cluster_name}", "${var.consul_server_cluster_name}"] | ||
allowed_inbound_tags_rpc = ["${var.nomad_server_cluster_name}"] | ||
allowed_inbound_tags_serf = ["${var.nomad_server_cluster_name}"] | ||
allowed_inbound_tags_http = [var.nomad_server_cluster_name, var.consul_server_cluster_name] | ||
allowed_inbound_tags_rpc = [var.nomad_server_cluster_name] | ||
allowed_inbound_tags_serf = [var.nomad_server_cluster_name] | ||
} | ||
|
||
# Render the Startup Script that will configure and run both Consul and Nomad in client mode. | ||
data "template_file" "startup_script_nomad_client" { | ||
template = "${file("${path.module}/startup-script-nomad-client.sh")}" | ||
template = file("${path.module}/startup-script-nomad-client.sh") | ||
|
||
vars { | ||
consul_server_cluster_tag_name = "${var.consul_server_cluster_name}" | ||
vars = { | ||
consul_server_cluster_tag_name = var.consul_server_cluster_name | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,59 @@ | ||
output "gcp_project" { | ||
value = "${var.gcp_project}" | ||
value = var.gcp_project | ||
} | ||
|
||
output "gcp_zone" { | ||
value = "${var.gcp_zone}" | ||
output "gcp_region" { | ||
value = var.gcp_region | ||
} | ||
|
||
output "nomad_server_cluster_size" { | ||
value = "${var.nomad_server_cluster_size}" | ||
value = var.nomad_server_cluster_size | ||
} | ||
|
||
output "nomad_client_cluster_size" { | ||
value = "${var.nomad_client_cluster_size}" | ||
value = var.nomad_client_cluster_size | ||
} | ||
|
||
output "nomad_server_cluster_tag_name" { | ||
value = "${var.nomad_server_cluster_name}" | ||
value = var.nomad_server_cluster_name | ||
} | ||
|
||
output "nomad_client_cluster_tag_name" { | ||
value = "${var.nomad_client_cluster_name}" | ||
value = var.nomad_client_cluster_name | ||
} | ||
|
||
output "consul_server_cluster_tag_name" { | ||
value = "${var.consul_server_cluster_name}" | ||
value = var.consul_server_cluster_name | ||
} | ||
|
||
output "nomad_server_instance_group_id" { | ||
value = "${module.nomad_servers.instance_group_id}" | ||
value = module.nomad_servers.instance_group_id | ||
} | ||
|
||
output "nomad_server_instance_group_name" { | ||
value = module.nomad_servers.instance_group_name | ||
} | ||
|
||
output "nomad_server_instance_group_url" { | ||
value = "${module.nomad_servers.instance_group_url}" | ||
value = module.nomad_servers.instance_group_url | ||
} | ||
|
||
output "nomad_client_instance_group_id" { | ||
value = "${module.nomad_clients.instance_group_id}" | ||
value = module.nomad_clients.instance_group_id | ||
} | ||
|
||
output "nomad_client_instance_group_name" { | ||
value = module.nomad_clients.instance_group_name | ||
} | ||
|
||
output "nomad_client_instance_group_url" { | ||
value = "${module.nomad_clients.instance_group_url}" | ||
value = module.nomad_clients.instance_group_url | ||
} | ||
|
||
output "consul_server_instance_group_id" { | ||
value = "${module.consul_cluster.instance_group_name}" | ||
output "consul_server_instance_group_name" { | ||
value = module.consul_cluster.instance_group_name | ||
} | ||
|
||
output "consul_server_instance_group_url" { | ||
value = "${module.consul_cluster.instance_group_url}" | ||
} | ||
value = module.consul_cluster.instance_group_url | ||
} |
Oops, something went wrong.