Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Terraform Openstack
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Code
Merge requests
3
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
John-Paul Robinson
Terraform Openstack
Commits
899f30ea
Commit
899f30ea
authored
5 years ago
by
John-Paul Robinson
Browse files
Options
Downloads
Plain Diff
Merge branch 'feat-compute-ops-provision-rebase'
parents
6a0a1e36
1753acb9
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
main.tf
+25
-1
25 additions, 1 deletion
main.tf
nodes/main.tf
+28
-4
28 additions, 4 deletions
nodes/main.tf
ohpc-instance/main.tf
+7
-1
7 additions, 1 deletion
ohpc-instance/main.tf
ood-instance/main.tf
+2
-0
2 additions, 0 deletions
ood-instance/main.tf
vars.tf
+2
-0
2 additions, 0 deletions
vars.tf
with
64 additions
and
6 deletions
main.tf
+
25
−
1
View file @
899f30ea
...
...
@@ -65,6 +65,7 @@ module "create-ohpc-instance" {
key_pair
=
"
${module
.
import-keypair
.
keypair_name
}
"
external_network
=
var
.
external_network
internal_network
=
var
.
internal_network
internal_ip
=
var
.
ohpc_private_ip
floating_ip_ohpc
=
"
${module
.
floating-ip-address
.
ohpc_address
}
"
host_prefix
=
var
.
host_prefix
ohpc_user
=
var
.
ohpc_user
...
...
@@ -81,6 +82,7 @@ module "create-ood-instance" {
flavor
=
var
.
flavor
key_pair
=
"
${module
.
import-keypair
.
keypair_name
}
"
internal_network
=
var
.
internal_network
internal_ip
=
var
.
ood_private_ip
external_network
=
var
.
external_network
floating_ip_ood
=
"
${module
.
floating-ip-address
.
ood_address
}
"
host_prefix
=
var
.
host_prefix
...
...
@@ -108,4 +110,26 @@ output "ohpc-ssh_host" {
# calls the outputs defined in the ood-instance module
output
"ood-ssh_host"
{
value
=
"
${module
.
create-ood-instance
.
ssh_host
}
"
}
\ No newline at end of file
}
# compute node post provision
resource
"null_resource"
"compute_ops"
{
triggers
=
{
ohpc_instance
=
module
.
create-ohpc-instance
.
id
compute_instances
=
join
(
","
,
module
.
nodes
.
id
)
}
connection
{
host
=
module
.
create-ohpc-instance
.
ssh_host
user
=
var
.
ohpc_user
private_key
=
file
(
var
.
ssh_private_key
)
}
# compute node
provisioner
"remote-exec"
{
inline
=
[
for
node
,
net
in
module
.
nodes
.
network
:
"ansible-playbook -i /CRI_XCBC/hosts -l `hostname -s` -e
\"
{'node_name':'
${
node
}
', 'node_ip_v4':'
${
net
[
0
].
fixed_ip_v4
}
', 'node_mac':'
${
net
[
0
].
mac
}
'}
\"
/CRI_XCBC/site-ops.yaml -b -v"
]
}
}
This diff is collapsed.
Click to expand it.
nodes/main.tf
+
28
−
4
View file @
899f30ea
...
...
@@ -10,20 +10,44 @@ variable "key_pair" {type = "string"}
variable
"compute_node_count"
{
}
variable
"internal_network"
{}
data
"openstack_images_image_v2"
"compute"
{
name
=
var
.
image_compute
most_recent
=
true
}
# creates compute node
resource
"openstack_compute_instance_v2"
"c
0
"
{
resource
"openstack_compute_instance_v2"
"c
ompute
"
{
depends_on
=
[
var
.
internal_subnet_id
]
name
=
"c
${
count
.
index
}
"
image_
name
=
var
.
image_
compute
image_
id
=
data
.
openstack_images_image_v2
.
compute
.
id
flavor_name
=
var
.
flavor
key_pair
=
var
.
key_pair
security_groups
=
[
"default"
]
count
=
var
.
compute_node_count
user_data
=
<<-
EOF
#cloud-config
runcmd
:
-
[
bash
,
-
xc
,
'ethernet=
$
(cat /sys/class/net/eth0/address); nodename=
$
(hostname -s); sed -e "s/MY_HWADDR/
$
ethernet/" -e "s/MY_NODENAME/
$
nodename/" -i /warewulf/config;'
]
-
[
bash
,
-
xc
,
"echo
$
(date) ': hello world!'; until WWGETFILES_INTERVAL=0 bash -x /warewulf/bin/wwgetfiles; do echo waiting ; rm -f /tmp/.wwgetfile.lock ; sleep 10; done;"
]
-
[
bash
,
-
xc
,
"systemctl restart munge"
]
-
[
bash
,
-
xc
,
"systemctl restart slurmd"
]
EOF
# defines the networks of the instance
network
{
name
=
var
.
internal_network
}
}
\ No newline at end of file
}
# output
output
"id"
{
value
=
openstack_compute_instance_v2
.
compute
.*.
id
}
output
"image_id"
{
value
=
data
.
openstack_images_image_v2
.
compute
.
id
}
output
"network"
{
value
=
zipmap
(
openstack_compute_instance_v2
.
compute
.*.
name
,
openstack_compute_instance_v2
.
compute
.*.
network
)
}
This diff is collapsed.
Click to expand it.
ohpc-instance/main.tf
+
7
−
1
View file @
899f30ea
...
...
@@ -9,6 +9,7 @@ variable "flavor" {}
variable
"key_pair"
{
type
=
"string"
}
variable
"internal_network"
{}
variable
"internal_ip"
{}
variable
"external_network"
{}
# is created in floating-ip module and called in root module
...
...
@@ -34,6 +35,7 @@ resource "openstack_compute_instance_v2" "ohpc" {
}
network
{
name
=
var
.
internal_network
fixed_ip_v4
=
var
.
internal_ip
}
}
...
...
@@ -50,6 +52,10 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" {
}
}
output
"id"
{
value
=
openstack_compute_instance_v2
.
ohpc
.
id
}
output
"ssh_host"
{
value
=
format
(
var
.
host_prefix
,
element
(
split
(
"."
,
var
.
floating_ip_ohpc
),
3
,),)
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
ood-instance/main.tf
+
2
−
0
View file @
899f30ea
...
...
@@ -9,6 +9,7 @@ variable "flavor" {}
variable
"key_pair"
{
type
=
"string"
}
variable
"internal_network"
{}
variable
"internal_ip"
{}
variable
"external_network"
{}
# is created in floating-ip module and called in root module
...
...
@@ -34,6 +35,7 @@ resource "openstack_compute_instance_v2" "ood" {
}
network
{
name
=
var
.
internal_network
fixed_ip_v4
=
var
.
internal_ip
}
}
...
...
This diff is collapsed.
Click to expand it.
vars.tf
+
2
−
0
View file @
899f30ea
...
...
@@ -14,9 +14,11 @@ variable "ssh_public_key" {default = "~/.ssh/id_rsa.pub"}
# variables for instance modules
variable
"ohpc_instance_name"
{
default
=
"ohpc"
}
variable
"ohpc_private_ip"
{
default
=
"10.1.1.10"
}
variable
"ood_instance_name"
{
default
=
"ood"
}
variable
"image_ohpc"
{
default
=
"CentOS-7-x86_64-GenericCloud-1905"
}
variable
"image_ood"
{
default
=
"CentOS-7-x86_64-GenericCloud-1905"
}
variable
"ood_private_ip"
{
default
=
"10.1.1.11"
}
variable
"flavor"
{
default
=
"m1.medium"
}
variable
"internal_network"
{
default
=
"clusternet"
}
variable
"external_network"
{
default
=
"dmznet"
}
...
...
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