From 1e895c25497109bbfc3cde0c9babd0a355bf3563 Mon Sep 17 00:00:00 2001 From: Jeff Loughridge Date: Fri, 22 Feb 2019 12:28:04 +0000 Subject: [PATCH 1/6] First attempt at global_ipv4 support --- instance.tf | 15 ++++++--------- vars.tf | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/instance.tf b/instance.tf index 254ce77..3dba451 100644 --- a/instance.tf +++ b/instance.tf @@ -1,4 +1,3 @@ - resource "packet_ssh_key" "ssh-key" { name = "mykey" public_key = "${file("mykey.pub")}" @@ -6,23 +5,21 @@ resource "packet_ssh_key" "ssh-key" { resource "packet_reserved_ip_block" "elastic_ip" { project_id = "${var.packet_project_id}" + type = "global_ipv4" quantity = 1 - facility = "${var.packet_facility}" } -# Create a device at the first facility resource "packet_device" "hosts" { + depends_on = ["packet_ssh_key.ssh-key"] - depends_on = ["packet_ssh_key.ssh-key"] - - hostname = "${format("%s-%02d", var.packet_facility, count.index)}" - + # hostname = "${format("%s-%02d", ${var.packet_facilities_global_ipv4[count.index]}, 1)}" + hostname = "test" plan = "t1.small.x86" - facility = "${var.packet_facility}" + facilities = ["${var.ewr1_facility}", "${var.sjc1_facility}"] operating_system = "ubuntu_18_04" billing_cycle = "hourly" project_id = "${var.packet_project_id}" - count = "${var.host-count}" + count = 2 connection { user = "root" diff --git a/vars.tf b/vars.tf index 2765c4f..599ecfb 100644 --- a/vars.tf +++ b/vars.tf @@ -4,11 +4,20 @@ variable "packet_project_id" {} variable "bgp_md5" {} -# spin up hosts across two different facilities to test load balancing -variable "packet_facility" { - default = "ewr1" +# sites that currently support global_ip4 - MS1, EWR1, NRT1, and SJC1 + +# ewr facility ID - e1e9c52e-a0bc-4117-b996-0fc94843ea09 +# sjc1 facility ID - 2b70eb8f-fa18-47c0-aba7-222a842362fd + +variable "ewr1_facility" { + default = "e1e9c52e-a0bc-4117-b996-0fc94843ea09" +} + +variable "sjc1_facility" { + default = "2b70eb8f-fa18-47c0-aba7-222a842362fd" } +# host count must equal the length of the packet_facility list (refactor later?) variable "host-count" { default = "2" } From 440716c3283df5e2f83d9dd5b815508d84c0e8ee Mon Sep 17 00:00:00 2001 From: Jeff Loughridge Date: Fri, 22 Feb 2019 15:00:14 +0000 Subject: [PATCH 2/6] Minor fixes to facility handling --- instance.tf | 2 +- vars.tf | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/instance.tf b/instance.tf index 3dba451..03409b1 100644 --- a/instance.tf +++ b/instance.tf @@ -15,7 +15,7 @@ resource "packet_device" "hosts" { # hostname = "${format("%s-%02d", ${var.packet_facilities_global_ipv4[count.index]}, 1)}" hostname = "test" plan = "t1.small.x86" - facilities = ["${var.ewr1_facility}", "${var.sjc1_facility}"] + facilities = [ "${var.sites[count.index]}" ] operating_system = "ubuntu_18_04" billing_cycle = "hourly" project_id = "${var.packet_project_id}" diff --git a/vars.tf b/vars.tf index 599ecfb..bc03ead 100644 --- a/vars.tf +++ b/vars.tf @@ -6,18 +6,11 @@ variable "bgp_md5" {} # sites that currently support global_ip4 - MS1, EWR1, NRT1, and SJC1 -# ewr facility ID - e1e9c52e-a0bc-4117-b996-0fc94843ea09 -# sjc1 facility ID - 2b70eb8f-fa18-47c0-aba7-222a842362fd - -variable "ewr1_facility" { - default = "e1e9c52e-a0bc-4117-b996-0fc94843ea09" -} - -variable "sjc1_facility" { - default = "2b70eb8f-fa18-47c0-aba7-222a842362fd" +variable "sites" { + default = [ "ewr1", "sjc1" ] } -# host count must equal the length of the packet_facility list (refactor later?) +# host count must equal the length of the sites list (refactor later?) variable "host-count" { default = "2" } From 7c70a57bdb4fe00af2405f453af7c9a11f619610 Mon Sep 17 00:00:00 2001 From: Jeff Loughridge Date: Fri, 22 Feb 2019 15:08:19 +0000 Subject: [PATCH 3/6] Set hostname based on site --- instance.tf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/instance.tf b/instance.tf index 03409b1..f937183 100644 --- a/instance.tf +++ b/instance.tf @@ -12,8 +12,7 @@ resource "packet_reserved_ip_block" "elastic_ip" { resource "packet_device" "hosts" { depends_on = ["packet_ssh_key.ssh-key"] - # hostname = "${format("%s-%02d", ${var.packet_facilities_global_ipv4[count.index]}, 1)}" - hostname = "test" + hostname = "${format("%s-%02d", "${var.sites[count.index]}", 1)}" plan = "t1.small.x86" facilities = [ "${var.sites[count.index]}" ] operating_system = "ubuntu_18_04" From 5581a16f289e25a6c15bb7640b24cebcd900a10e Mon Sep 17 00:00:00 2001 From: Jeff Loughridge Date: Fri, 22 Feb 2019 16:18:34 +0000 Subject: [PATCH 4/6] Fix count to be dynamic based on number of sites --- apache.tf | 2 +- configure_bird.tf | 2 +- enable_bgp_device_session.tf | 2 +- instance.tf | 4 ++-- vars.tf | 6 +----- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/apache.tf b/apache.tf index 43e4fe3..13c5c47 100644 --- a/apache.tf +++ b/apache.tf @@ -3,7 +3,7 @@ resource "null_resource" "apache" { depends_on = ["null_resource.configure_bird"] - count = "${var.host-count}" + count = "${length(var.sites)}" connection { type = "ssh" diff --git a/configure_bird.tf b/configure_bird.tf index 04332e5..3828a83 100644 --- a/configure_bird.tf +++ b/configure_bird.tf @@ -13,7 +13,7 @@ data "template_file" "enable_bgp" { resource "null_resource" "configure_bird" { - count = "${var.host-count}" + count = "${length(var.sites)}" triggers = { template = "${data.template_file.enable_bgp.rendered}" diff --git a/enable_bgp_device_session.tf b/enable_bgp_device_session.tf index fc7f279..7876e32 100644 --- a/enable_bgp_device_session.tf +++ b/enable_bgp_device_session.tf @@ -1,7 +1,7 @@ resource "null_resource" "enable_bgp_device_session" { - count = "${var.host-count}" + count = "${length(var.sites)}" provisioner "local-exec" { command = "curl -X POST -H \"X-Auth-Token: ${var.packet_auth_token}\" https://api.packet.net/devices/${element(packet_device.hosts.*.id,count.index)}/bgp/sessions?address_family=ipv4" diff --git a/instance.tf b/instance.tf index f937183..b1158fe 100644 --- a/instance.tf +++ b/instance.tf @@ -12,13 +12,13 @@ resource "packet_reserved_ip_block" "elastic_ip" { resource "packet_device" "hosts" { depends_on = ["packet_ssh_key.ssh-key"] - hostname = "${format("%s-%02d", "${var.sites[count.index]}", 1)}" + hostname = "${format("%s-%02d", var.sites[count.index], 1)}" plan = "t1.small.x86" facilities = [ "${var.sites[count.index]}" ] operating_system = "ubuntu_18_04" billing_cycle = "hourly" project_id = "${var.packet_project_id}" - count = 2 + count = "${length(var.sites)}" connection { user = "root" diff --git a/vars.tf b/vars.tf index bc03ead..f89e0d8 100644 --- a/vars.tf +++ b/vars.tf @@ -7,10 +7,6 @@ variable "bgp_md5" {} # sites that currently support global_ip4 - MS1, EWR1, NRT1, and SJC1 variable "sites" { - default = [ "ewr1", "sjc1" ] + default = [ "ewr1", "sjc1", "nrt1" ] } -# host count must equal the length of the sites list (refactor later?) -variable "host-count" { - default = "2" -} From 412cbca9b7f243ee5f60f0785c6d4a483412408b Mon Sep 17 00:00:00 2001 From: K Rain Leander Date: Fri, 13 Nov 2020 15:41:06 +0100 Subject: [PATCH 5/6] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 25f4d49..b20f9cb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ +![](https://img.shields.io/badge/Stability-Experimental-red.svg) + This terraform code configures a Ubuntu virtual machine on packet and configures BIRD for BGP routing. +This repository is [Experimental](https://github.com/packethost/standards/blob/master/experimental-statement.md) meaning that it's based on untested ideas or techniques and not yet established or finalized or involves a radically new and innovative style! This means that support is best effort (at best!) and we strongly encourage you to NOT use this in production. ### Requirements From 7c9dcec87321dc38d9b386ed71221f668989381f Mon Sep 17 00:00:00 2001 From: K Rain Leander Date: Fri, 13 Nov 2020 15:41:26 +0100 Subject: [PATCH 6/6] Add .circleci/config.yml --- .circleci/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6f98693 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,13 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference +version: 2.1 +# Use a package of configuration called an orb. +orbs: + # Declare a dependency on the welcome-orb + welcome: circleci/welcome-orb@0.4.1 +# Orchestrate or schedule a set of jobs +workflows: + # Name the workflow "welcome" + welcome: + # Run the welcome/run job in its own container + jobs: + - welcome/run