Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Terraform Openstack
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Mitchell Moore
Terraform Openstack
Commits
adf01ba9
Commit
adf01ba9
authored
5 years ago
by
Ryan Randles Jones
Browse files
Options
Downloads
Patches
Plain Diff
added vars
parent
11437a97
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
instance/instances-main.tf
+46
-25
46 additions, 25 deletions
instance/instances-main.tf
with
46 additions
and
25 deletions
instance/instances-main.tf
+
46
−
25
View file @
adf01ba9
variable
"compute_node_count"
{
default
=
2
}
variable
"external_net"
{
default
=
"dmznet"
}
variable
"external_subnet_id"
{
default
=
"string"
}
variable
"flavor"
{
default
=
"m1.medium"
}
variable
"floating_ip_ohpc"
{
type
=
string
}
variable
"floating_ip_ood"
{
type
=
string
}
variable
"host_prefix"
{
default
=
"164.111.161.%s"
}
variable
"image_ohpc"
{
default
=
"CentOS-7-x86_64-GenericCloud-1905"
}
variable
"image_ood"
{
default
=
"CentOS-7-x86_64-GenericCloud-1905"
}
variable
"image_compute"
{
default
=
"CentOS-7-x86_64-GenericCloud-1905"
}
variable
"internal_net"
{
default
=
"clusternet"
}
variable
"internal_subnet_id"
{
default
=
"string"
}
variable
"keypair_name"
{
default
=
"os-gen-keypair"
}
variable
"ohpc_instance_name"
{
default
=
"ohpc"
}
variable
"ohpc_user"
{
default
=
"centos"
}
variable
"ood_instance_name"
{
default
=
"ood"
}
variable
"ood_user"
{
default
=
"centos"
}
variable
"ssh_private_key"
{
default
=
"~/.ssh/id_rsa"
}
variable
"ssh_public_key"
{
default
=
"~/.ssh/id_rsa.pub"
}
resource
"openstack_compute_keypair_v2"
"keypair"
{
name
=
var
.
keypair
-
name
public_key
=
file
(
var
.
ssh
-
public
-
key
)
name
=
var
.
keypair
_
name
public_key
=
file
(
var
.
ssh
_
public
_
key
)
}
# creates details for the OHPC instance
using variables defined in vars.tf
# creates details for the OHPC instance
resource
"openstack_compute_instance_v2"
"ohpc"
{
depends_on
=
[
var
.
external
-
subnet
-
id
]
name
=
var
.
ohpc
-
instance
-
name
depends_on
=
[
var
.
external
_
subnet
_
id
]
name
=
var
.
ohpc
_
instance
_
name
image_name
=
var
.
image_ohpc
flavor_name
=
var
.
flavor
key_pair
=
openstack_compute_keypair_v2
.
keypair
.
name
...
...
@@ -14,30 +35,30 @@ resource "openstack_compute_instance_v2" "ohpc" {
# defines the networks of the instance
network
{
name
=
var
.
external
-
net
name
=
var
.
external
_
net
}
network
{
name
=
var
.
internal
-
net
name
=
var
.
internal
_
net
}
}
# associates floating ip with the OHPC instance
and run the ansible playbook
# associates floating ip with the OHPC instance
resource
"openstack_compute_floatingip_associate_v2"
"ohpc"
{
floating_ip
=
var
.
floating
-
ip
-
ohpc
floating_ip
=
var
.
floating
_
ip
_
ohpc
instance_id
=
openstack_compute_instance_v2
.
ohpc
.
id
# defines ssh connection
connection
{
host
=
format
(
var
.
host
-
prefix
,
element
(
split
(
"."
,
var
.
floating
-
ip
-
ohpc
),
3
,),)
user
=
var
.
ohpc
-
user
private_key
=
file
(
var
.
ssh
-
private
-
key
)
host
=
format
(
var
.
host
_
prefix
,
element
(
split
(
"."
,
var
.
floating
_
ip
_
ohpc
),
3
,),)
user
=
var
.
ohpc
_
user
private_key
=
file
(
var
.
ssh
_
private
_
key
)
}
}
# creates details for the OOD instance
using variables defined in vars.tf
# creates details for the OOD instance
resource
"openstack_compute_instance_v2"
"ood"
{
depends_on
=
[
var
.
internal
-
subnet-id
]
name
=
var
.
ood
-
instance
-
name
depends_on
=
[
var
.
internal
_
subnet-id
]
name
=
var
.
ood
_
instance
_
name
image_name
=
var
.
image_ood
flavor_name
=
var
.
flavor
key_pair
=
openstack_compute_keypair_v2
.
keypair
.
name
...
...
@@ -45,29 +66,29 @@ resource "openstack_compute_instance_v2" "ood" {
# defines the networks of the instance
network
{
name
=
var
.
external
-
net
name
=
var
.
external
_
net
}
network
{
name
=
var
.
internal
-
net
name
=
var
.
internal
_
net
}
}
# associates floating ip with the OOD instance
and run the ansible playbook
# associates floating ip with the OOD instance
resource
"openstack_compute_floatingip_associate_v2"
"ood"
{
floating_ip
=
var
.
floating
-
ip
-
ood
floating_ip
=
var
.
floating
_
ip
_
ood
instance_id
=
openstack_compute_instance_v2
.
ood
.
id
# defines ssh connection
connection
{
host
=
format
(
var
.
host-prefix
,
element
(
split
(
"."
,
var
.
floating
-
ip
-
ood
),
3
,),)
user
=
var
.
ood
-
user
private_key
=
file
(
var
.
ssh
-
private
-
key
)
host
=
format
(
var
.
host-prefix
,
element
(
split
(
"."
,
var
.
floating
_
ip
_
ood
),
3
,),)
user
=
var
.
ood
_
user
private_key
=
file
(
var
.
ssh
_
private
_
key
)
}
}
# creates compute node
resource
"openstack_compute_instance_v2"
"c0"
{
depends_on
=
[
var
.
internal
-
subnet
-
id
]
depends_on
=
[
var
.
internal
_
subnet
_
id
]
name
=
"c
${
count
.
index
}
"
image_name
=
var
.
image_compute
flavor_name
=
var
.
flavor
...
...
@@ -77,10 +98,10 @@ resource "openstack_compute_instance_v2" "c0" {
# defines the networks of the instance
network
{
name
=
var
.
internal
-
net
name
=
var
.
internal
_
net
}
}
output
"ssh_host"
{
value
=
format
(
var
.
host
-
prefix
,
element
(
split
(
"."
,
var
.
floating
-
ip
-
ood
),
3
,),)
value
=
format
(
var
.
host
_
prefix
,
element
(
split
(
"."
,
var
.
floating
_
ip
_
ood
),
3
,),)
}
\ No newline at end of file
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