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
a85dc324
Commit
a85dc324
authored
6 years ago
by
Ryan Randles Jones
Browse files
Options
Downloads
Patches
Plain Diff
Delete old_main
parent
61b1317d
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
old_main
+0
-146
0 additions, 146 deletions
old_main
with
0 additions
and
146 deletions
old_main
deleted
100644 → 0
+
0
−
146
View file @
61b1317d
# creates public and private keypair
resource "openstack_compute_keypair_v2" "test-keypair" {
name = "my-keypair"
}
# creates dmznet
resource "openstack_networking_network_v2" "terraform" {
name = "dmznet"
admin_state_up = "true"
}
# creates dmzsubnet using the floating ip defined in datasources.tf to get the network id
# cidr is the subnet range (that subnet range and dns nameservers from the network create file in feat-openstack)
resource "openstack_networking_subnet_v2" "terraform" {
name = "dmzsubnet"
network_id = "${openstack_networking_network_v2.terraform.id}"
cidr = "192.168.100.0/24"
ip_version = 4
dns_nameservers = ["8.8.8.8"]
}
# defines the router borderrouter using floating ip defined in datasources.tf to create the external network id
resource "openstack_networking_router_v2" "terraform" {
name = "borderrouter"
admin_state_up = "true"
external_network_id = "${data.openstack_networking_network_v2.terraform.id}"
}
# creates the router and subnet id using info defined above
resource "openstack_networking_router_interface_v2" "terraform" {
router_id = "${openstack_networking_router_v2.terraform.id}"
subnet_id = "${openstack_networking_subnet_v2.terraform.id}"
}
# creates a security group
resource "openstack_networking_secgroup_v2" "terraform" {
name = "terraform"
description = "Security group for the Terraform example instances"
}
# creates details of security group fir port 22 and creates security group id
resource "openstack_networking_secgroup_rule_v2" "terraform_22" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 22
port_range_max = 22
remote_ip_prefix = "0.0.0.0/0"
security_group_id = "${openstack_networking_secgroup_v2.terraform.id}"
}
# creates details of security group fir port 80 and creates security group id
resource "openstack_networking_secgroup_rule_v2" "terraform_80" {
direction = "ingress"
ethertype = "IPv4"
protocol = "tcp"
port_range_min = 80
port_range_max = 80
remote_ip_prefix = "0.0.0.0/0"
security_group_id = "${openstack_networking_secgroup_v2.terraform.id}"
}
# creates details of security group fir protocol icmp and creates security group id
resource "openstack_networking_secgroup_rule_v2" "terraform" {
direction = "ingress"
ethertype = "IPv4"
protocol = "icmp"
remote_ip_prefix = "0.0.0.0/0"
security_group_id = "${openstack_networking_secgroup_v2.terraform.id}"
}
# defines where floating ip will come from using variable from vars.tf
resource "openstack_networking_floatingip_v2" "terraform" {
pool = "${var.pool}"
}
# creates details for the instance using variables defined in vars.tf and resource for security groups
resource "openstack_compute_instance_v2" "terraform" {
name = "ohpc"
image_name = "${var.image}"
flavor_name = "${var.flavor}"
key_pair = "${openstack_compute_keypair_v2.test-keypair.name}"
security_groups = ["${openstack_networking_secgroup_v2.terraform.name}"]
# defines the instance id using info from datasources.tf
network {
uuid = "${openstack_networking_network_v2.terraform.id}"
}
}
# associates floating ip with the instance
resource "openstack_compute_floatingip_associate_v2" "terraform" {
floating_ip = "${openstack_networking_floatingip_v2.terraform.address}"
instance_id = "${openstack_compute_instance_v2.terraform.id}"
}
# creates clusternet
resource "openstack_networking_network_v2" "terraform2" {
name = "clusternet"
admin_state_up = "true"
}
# 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" "terraform2" {
name = "clustersubnet"
network_id = "${openstack_networking_network_v2.terraform2.id}"
cidr = "10.1.1.0/24"
ip_version = 4
}
# defines the instance and network id using info defined above
resource "openstack_compute_interface_attach_v2" "terraform2" {
instance_id = "${openstack_compute_instance_v2.terraform.id}"
network_id = "${openstack_networking_network_v2.terraform2.id}"
}
provisioner "remote-exec" {
inline = [
"hostnamectl set-hostname ohpc",
"yum install -y epel-release",
"yum install -y ansible git vim bash-completion",
"yum install -y NetworkManager",
"systemctl restart NetworkManager",
"nmcli con mod 'Wired connection 1' connection.id 'eth1'",
]
connection {
host = "${self.ipv4_address}" # The `self` variable is like `this` in many programming languages
type = "ssh" # in this case, `self` is the resource (the server).
user = "root"
private_key = "${file("~/.ssh/id_rsa")}"
}
}
provisioner "local-exec" {
environment {
PUBLIC_IP = "${self.ipv4_address}"
PRIVATE_IP = "${self.ipv4_address_private}"
}
working_dir = "$HOME/terraform-first-instance/terraform-openstack/CRI_XCBC/"
command = "ansible-playbook -c local -i hosts -l `hostname` site.yaml -b,"
}
}
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