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
2
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
Ryan Randles Jones
Terraform Openstack
Commits
265d0488
Commit
265d0488
authored
6 years ago
by
Mitchell Moore
Committed by
Ryan Randles Jones
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Feat ood instantiate
parent
46693062
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.tf
+64
-3
64 additions, 3 deletions
main.tf
output.tf
+6
-2
6 additions, 2 deletions
output.tf
vars.tf
+8
-0
8 additions, 0 deletions
vars.tf
with
78 additions
and
5 deletions
main.tf
+
64
−
3
View file @
265d0488
...
@@ -48,7 +48,11 @@ resource "openstack_networking_subnet_v2" "internal_subnet" {
...
@@ -48,7 +48,11 @@ resource "openstack_networking_subnet_v2" "internal_subnet" {
# defines where floating ip will come from using variable from vars.tf
# defines where floating ip will come from using variable from vars.tf
resource
"openstack_networking_floatingip_v2"
"ip_pool"
{
resource
"openstack_networking_floatingip_v2"
"ohpc_ip"
{
pool
=
"
${
var
.
public-network-name
}
"
}
resource
"openstack_networking_floatingip_v2"
"ood_ip"
{
pool
=
"
${
var
.
public-network-name
}
"
pool
=
"
${
var
.
public-network-name
}
"
}
}
...
@@ -72,12 +76,12 @@ depends_on = ["openstack_networking_subnet_v2.external_subnet"]
...
@@ -72,12 +76,12 @@ depends_on = ["openstack_networking_subnet_v2.external_subnet"]
# associates floating ip with the OHPC instance and run the ansible playbook
# associates floating ip with the OHPC instance and run the ansible playbook
resource
"openstack_compute_floatingip_associate_v2"
"ohpc"
{
resource
"openstack_compute_floatingip_associate_v2"
"ohpc"
{
floating_ip
=
"
${
openstack_networking_floatingip_v2
.
ip_pool
.
address
}
"
floating_ip
=
"
${
openstack_networking_floatingip_v2
.
ohpc_ip
.
address
}
"
instance_id
=
"
${
openstack_compute_instance_v2
.
ohpc
.
id
}
"
instance_id
=
"
${
openstack_compute_instance_v2
.
ohpc
.
id
}
"
# defines ssh connection
# defines ssh connection
connection
{
connection
{
host
=
"
${
format
(
"
${
var
.
host-prefix
}
"
,
element
(
split
(
"."
,
openstack_networking_floatingip_v2
.
ip_pool
.
address
),
3
))
}
"
host
=
"
${
format
(
"
${
var
.
host-prefix
}
"
,
element
(
split
(
"."
,
openstack_networking_floatingip_v2
.
ohpc_ip
.
address
),
3
))
}
"
user
=
"
${
var
.
ohpc-user
}
"
user
=
"
${
var
.
ohpc-user
}
"
private_key
=
"
${
file
(
var
.
ssh-private-key
)
}
"
private_key
=
"
${
file
(
var
.
ssh-private-key
)
}
"
}
}
...
@@ -107,3 +111,60 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" {
...
@@ -107,3 +111,60 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" {
]
]
}
}
}
}
# creates details for the OOD instance using variables defined in vars.tf
resource
"openstack_compute_instance_v2"
"ood"
{
depends_on
=
[
"openstack_networking_subnet_v2.external_subnet"
]
name
=
"
${
var
.
ood-instance-name
}
"
image_name
=
"
${
var
.
image
}
"
flavor_name
=
"
${
var
.
flavor
}
"
key_pair
=
"
${
openstack_compute_keypair_v2
.
keypair
.
name
}
"
security_groups
=
[
"default"
]
# defines the networks of the instance
network
{
name
=
"
${
var
.
external-net
}
"
}
network
{
name
=
"
${
var
.
internal-net
}
"
}
}
# associates floating ip with the OOD instance and run the ansible playbook
resource
"openstack_compute_floatingip_associate_v2"
"ood"
{
floating_ip
=
"
${
openstack_networking_floatingip_v2
.
ood_ip
.
address
}
"
instance_id
=
"
${
openstack_compute_instance_v2
.
ood
.
id
}
"
# defines ssh connection
connection
{
host
=
"
${
format
(
"
${
var
.
host-prefix
}
"
,
element
(
split
(
"."
,
openstack_networking_floatingip_v2
.
ood_ip
.
address
),
3
))
}
"
user
=
"
${
var
.
ood-user
}
"
private_key
=
"
${
file
(
var
.
ssh-private-key
)
}
"
}
# installs programs
provisioner
"remote-exec"
{
inline
=
[
"sudo mkdir -p /CRI_XCBC && sudo chown centos: /CRI_XCBC"
,
"sudo yum install -y epel-release"
,
"sudo yum install -y ansible git vim bash-completion"
,
"sudo yum install -y NetworkManager"
,
"sudo systemctl restart NetworkManager"
,
"sudo nmcli con mod 'Wired connection 1' connection.id 'eth1'"
]
}
# moves CRI_XCBC file into directory made above
provisioner
"file"
{
source
=
"CRI_XCBC/"
destination
=
"/CRI_XCBC/"
}
# runs ansible playbook
provisioner
"remote-exec"
{
inline
=
[
"sudo ansible-playbook -c local -i /CRI_XCBC/hosts -l `hostname -s` /CRI_XCBC/site.yaml -b"
]
}
}
This diff is collapsed.
Click to expand it.
output.tf
+
6
−
2
View file @
265d0488
output
"address"
{
output
"ohpc_address"
{
value
=
"
${
openstack_networking_floatingip_v2
.
ip_pool
.
address
}
"
value
=
"
${
openstack_networking_floatingip_v2
.
ohpc_ip
.
address
}
"
}
output
"ood_address"
{
value
=
"
${
openstack_networking_floatingip_v2
.
ood_ip
.
address
}
"
}
}
output
"external_network_id"
{
output
"external_network_id"
{
...
...
This diff is collapsed.
Click to expand it.
vars.tf
+
8
−
0
View file @
265d0488
...
@@ -49,6 +49,14 @@ variable "ohpc-user" {
...
@@ -49,6 +49,14 @@ variable "ohpc-user" {
default
=
"centos"
default
=
"centos"
}
}
variable
"ood-instance-name"
{
default
=
"ood"
}
variable
"ood-user"
{
default
=
"centos"
}
variable
"public-network-name"
{
variable
"public-network-name"
{
default
=
"bright-external-flat-externalnet"
default
=
"bright-external-flat-externalnet"
}
}
...
...
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