Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Terraform Openstack
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
Terraform Openstack
Commits
c36bacd1
Commit
c36bacd1
authored
1 year ago
by
Eesaan Atluri
Committed by
Ravi Tripathi
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Create an internal network and use it for each deploy
parent
54099053
No related branches found
Branches containing commit
No related tags found
1 merge request
!12
Create an internal network and use it for each deploy
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
internal-network/main.tf
+4
-4
4 additions, 4 deletions
internal-network/main.tf
main.tf
+16
-3
16 additions, 3 deletions
main.tf
nodes/main.tf
+4
-0
4 additions, 0 deletions
nodes/main.tf
with
25 additions
and
8 deletions
.gitlab-ci.yml
+
1
−
1
View file @
c36bacd1
...
...
@@ -8,7 +8,6 @@ variables:
OS_AUTH_TYPE
:
"
v3applicationcredential"
OS_AUTH_URL
:
"
https://keystone.cloud.rc.uab.edu:5000/v3"
TF_ROOT
:
${CI_PROJECT_DIR}/
TF_VAR_internal_network
:
"
xdmod-packer-clusternet"
TF_VAR_external_network
:
"
xdmod-packer-dmznet"
TF_VAR_flavor
:
"
m1.medium"
GIT_SUBMODULE_STRATEGY
:
"
recursive"
...
...
@@ -46,6 +45,7 @@ tf-apply:
tags
:
[
build
]
script
:
-
export BUILD_DATE=$(TZ=America/Chicago date +%Y%m%d%H%M%S)
-
export TF_VAR_internal_network="xdmod-packer-clusternet-$BUILD_DATE"
-
|
if [ -z $TF_VAR_image_ohpc ];
then
...
...
This diff is collapsed.
Click to expand it.
internal-network/main.tf
+
4
−
4
View file @
c36bacd1
variable
"
name
"
{
default
=
"
cluster
"
}
variable
"
internal_net
"
{
default
=
""
}
variable
"admin_state_up"
{
}
variable
"enable_dhcp"
{}
...
...
@@ -21,21 +21,21 @@ provider "openstack" {
# creates clusternet
resource
"openstack_networking_network_v2"
"internal_network"
{
name
=
"
${
var
.
name
}
net
"
name
=
var
.
internal_
net
admin_state_up
=
var
.
admin_state_up
}
# creates clustersubnet
# cidr is the subnet range (that subnet range and dns nameservers from the network create file in feat-openstack)
resource
"openstack_networking_subnet_v2"
"internal_subnet"
{
name
=
"
${
var
.
name
}
subnet"
name
=
"
${
var
.
internal_net
}
_
subnet"
network_id
=
openstack_networking_network_v2
.
internal_network
.
id
cidr
=
"10.1.1.0/24"
ip_version
=
4
enable_dhcp
=
var
.
enable_dhcp
}
output
"id"
{
output
"
internal_network_
id"
{
value
=
openstack_networking_network_v2
.
internal_network
.
id
depends_on
=
[
openstack_networking_subnet_v2
.
internal_subnet
]
}
...
...
This diff is collapsed.
Click to expand it.
main.tf
+
16
−
3
View file @
c36bacd1
...
...
@@ -14,6 +14,19 @@ provider "openstack" {
}
}
# runs the internal-network module
module
"cluster-network"
{
internal_net
=
var
.
internal_network
source
=
"./internal-network"
# Default name var is in the module main file
admin_state_up
=
var
.
admin_state_up
enable_dhcp
=
var
.
enable_dhcp
}
# calls the outputs defined in the internal-network module
output
"internal_network_id"
{
value
=
"
${module
.
cluster-network
.
internal_network_id
}
"
}
# runs the floating-ip module - uses public network name defined above
module
"floating-ip-address"
{
source
=
"./floating-ip"
...
...
@@ -42,7 +55,6 @@ output "keypair_name" {
}
data
"openstack_networking_network_v2"
"external_net"
{
name
=
var
.
external_network
}
data
"openstack_networking_network_v2"
"internal_net"
{
name
=
var
.
internal_network
}
# runs the ohpc-instance module - creates ohpc instance using variables defined above
# calls functions from dmz-network, import-keypair, and floating-ip-address modules to get values created there for use
...
...
@@ -53,7 +65,7 @@ module "create-ohpc-instance" {
flavor
=
var
.
flavor
key_pair
=
module
.
import-keypair
.
keypair_name
external_network
=
data
.
openstack_networking_network_v2
.
external_net
.
id
internal_network
=
data
.
openstack_networking_
network
_v2
.
internal_net
.
id
internal_network
=
"
${module
.
cluster-
network
.
internal_net
work_id
}
"
internal_ip
=
var
.
ohpc_private_ip
floating_ip_ohpc
=
module
.
floating-ip-address
.
ohpc_address
ohpc_user
=
var
.
ohpc_user
...
...
@@ -80,12 +92,13 @@ module "create-ohpc-instance" {
# runs the nodes module - creates nodes using variables defined above
# calls functions from cluster-network and import-keypair modules to get values created there for use
module
"nodes"
{
internal_subnet_id
=
"
${module
.
cluster-network
.
internal_subnet_id
}
"
source
=
"./nodes"
image_compute
=
var
.
image_compute
flavor
=
var
.
flavor
key_pair
=
module
.
import-keypair
.
keypair_name
compute_node_count
=
var
.
compute_node_count
internal_network
=
data
.
openstack_networking_
network
_v2
.
internal_net
.
id
internal_network
=
"
${module
.
cluster-
network
.
internal_net
work_id
}
"
}
# calls the outputs defined in the ohpc-instance module
...
...
This diff is collapsed.
Click to expand it.
nodes/main.tf
+
4
−
0
View file @
c36bacd1
# is created in internal-network module and called in root module
variable
"internal_subnet_id"
{
type
=
string
}
variable
"image_compute"
{}
variable
"flavor"
{}
...
...
@@ -31,6 +34,7 @@ data "openstack_images_image_v2" "compute" {
# creates compute node
resource
"openstack_compute_instance_v2"
"compute"
{
depends_on
=
[
var
.
internal_subnet_id
]
name
=
"c
${
count
.
index
}
"
image_id
=
data
.
openstack_images_image_v2
.
compute
.
id
flavor_name
=
var
.
flavor
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment