Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bo-Chun Chen
Terraform Openstack
Commits
2cc174a6
Commit
2cc174a6
authored
Jun 27, 2019
by
Ryan Randles Jones
Browse files
Add new file
parent
9754be2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.tf
0 → 100644
View file @
2cc174a6
# defines where floating ip will come from using variable from vars.tf
resource
"openstack_networking_floatingip_v2"
"ohpc"
{
pool
=
"
${
var
.
pool
}
"
}
# creates details for the instance using variables defined in vars.tf and resource for security groups
resource
"openstack_compute_instance_v2"
"ohpc"
{
name
=
"ohpc"
image_name
=
"
${
var
.
image
}
"
flavor_name
=
"
${
var
.
flavor
}
"
key_pair
=
"
${
var
.
key_pair
}
"
security_groups
=
[
"default"
]
# defines the networks of the instance
network
{
name
=
"dmznet"
}
network
{
name
=
"clusternet"
}
}
# associates floating ip with the instance
resource
"openstack_compute_floatingip_associate_v2"
"ohpc"
{
floating_ip
=
"
${
openstack_networking_floatingip_v2
.
ohpc
.
address
}
"
instance_id
=
"
${
openstack_compute_instance_v2
.
ohpc
.
id
}
"
provisioner
"remote-exec"
{
connection
{
host
=
"
${
format
(
"164.111.161.%s"
,
element
(
split
(
"."
,
openstack_networking_floatingip_v2
.
ohpc
.
address
),
3
))
}
"
#host = "${openstack_networking_floatingip_v2.ohpc.address}"
user
=
"centos"
private_key
=
"
${
file
(
var
.
ssh_key_private
)
}
"
}
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'"
]
}
provisioner
"file"
{
source
=
"CRI_XCBC/"
destination
=
"/CRI_XCBC/"
connection
{
host
=
"
${
format
(
"164.111.161.%s"
,
element
(
split
(
"."
,
openstack_networking_floatingip_v2
.
ohpc
.
address
),
3
))
}
"
#host = "${openstack_networking_floatingip_v2.terraform.address}"
user
=
"centos"
private_key
=
"
${
file
(
var
.
ssh_key_private
)
}
"
}
}
provisioner
"remote-exec"
{
connection
{
host
=
"
${
format
(
"164.111.161.%s"
,
element
(
split
(
"."
,
openstack_networking_floatingip_v2
.
ohpc
.
address
),
3
))
}
"
#host = "${openstack_networking_floatingip_v2.ohpc.address}"
user
=
"centos"
private_key
=
"
${
file
(
var
.
ssh_key_private
)
}
"
}
inline
=
[
"sudo ansible-playbook -c local -i /CRI_XCBC/hosts -l ohpc /CRI_XCBC/site.yaml -b"
]
}
}
# creates details for the instance using variables defined in vars.tf
resource
"openstack_compute_instance_v2"
"ohpc"
{
name
=
"ohpc"
image_name
=
"
${
var
.
image
}
"
flavor_name
=
"
${
var
.
flavor
}
"
key_pair
=
"
${
var
.
key_pair
}
"
security_groups
=
[
"default"
]
# defines the networks of the instance
network
{
name
=
"dmznet"
}
network
{
name
=
"clusternet"
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment