Skip to content

Commit

Permalink
generate file to setup provider networking
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstudarus committed Apr 22, 2020
1 parent 4d77661 commit a6aee92
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 12 deletions.
12 changes: 0 additions & 12 deletions ExternalNetwork.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
resource "null_resource" "controller-external-network" {

connection {
host = packet_device.controller.access_public_ipv4
private_key = file(var.cloud_ssh_key_path)
}

provisioner "file" {
source = "ExternalNetwork.sh"
destination = "ExternalNetwork.sh"
}
}

23 changes: 23 additions & 0 deletions ProviderNetwork.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,26 @@ resource "packet_ip_attachment" "controller_public_ipv6" {
cidr_notation = cidrsubnet(data.packet_precreated_ip_block.public_ipv6.cidr_notation,8,1)

}

data "template_file" "provider-networks" {

template = file("templates/ProviderNetworks.sh")

vars = {
provider_ipv4_cidr = packet_ip_attachment.controller_private_ipv4.cidr_notation
provider_ipv6_cidr = packet_ip_attachment.controller_public_ipv6.cidr_notation
}
}

resource "null_resource" "controller-provider-networks" {

connection {
host = packet_device.controller.access_public_ipv4
private_key = file(var.cloud_ssh_key_path)
}

provisioner "file" {
content = data.template_file.provider-networks.rendered
destination = "ProviderNetworks.sh"
}
}
35 changes: 35 additions & 0 deletions templates/ProviderNetworks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
#
# associate elastic IP subnet with the controller node via the Packet Web GUI
#
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3

PROVIDER_4_CIDR="${provider_ipv4_cidr}"
PROVIDER_6_CIDR="${provider_ipv6_cidr}"

export PROVIDER_4_ID=`openstack network create --share \
--provider-physical-network provider \
--provider-network-type flat provider \
--external \
-f value -c id`

echo "Provider 4 ID is $PROVIDER_4_ID"

export SUBNET_4_ID=`openstack subnet create \
--network $PROVIDER_4_ID \
--subnet-range $PROVIDER_4_CIDR \
$PROVIDER_4_CIDR -f value -c id`

echo "Subnet 4 ID is $SUBNET_4_ID"

# assign this gateway to all routers
for ROUTER_ID in `openstack router list -f value -c ID`
do
openstack router set --external-gateway $PROVIDER_4_ID $ROUTER_ID
done

0 comments on commit a6aee92

Please sign in to comment.