From 828d4a6ff43c8b9260d766a3e17b65feec502ba1 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Mon, 10 Jul 2023 15:41:26 +0100 Subject: [PATCH] add a common tf script, that can be used for all --- .../{stsstack_init/00-main.tf => 00-init.tf} | 0 openstack/init/00-base.tf | 8 +++ openstack/init/00-init.tf | 1 + openstack/init/00-main.tf | 51 ------------------- openstack/init/01-security_groups.tf | 23 +++++++++ openstack/multi-instances/00-init.tf | 1 + .../create-multiple-instances.tf | 14 ----- openstack/stsstack_init/00-init.tf | 1 + 8 files changed, 34 insertions(+), 65 deletions(-) rename openstack/{stsstack_init/00-main.tf => 00-init.tf} (100%) create mode 100644 openstack/init/00-base.tf create mode 120000 openstack/init/00-init.tf delete mode 100644 openstack/init/00-main.tf create mode 100644 openstack/init/01-security_groups.tf create mode 120000 openstack/multi-instances/00-init.tf create mode 120000 openstack/stsstack_init/00-init.tf diff --git a/openstack/stsstack_init/00-main.tf b/openstack/00-init.tf similarity index 100% rename from openstack/stsstack_init/00-main.tf rename to openstack/00-init.tf diff --git a/openstack/init/00-base.tf b/openstack/init/00-base.tf new file mode 100644 index 0000000..e704bac --- /dev/null +++ b/openstack/init/00-base.tf @@ -0,0 +1,8 @@ +resource "openstack_compute_keypair_v2" "arif-key" { + name = "arif-key" + public_key = file("/home/arif/.ssh/aarsa4096canonical.pub") +} + +resource "openstack_identity_role_v3" "tenantLead" { + name = "tenantLead" +} diff --git a/openstack/init/00-init.tf b/openstack/init/00-init.tf new file mode 120000 index 0000000..b015707 --- /dev/null +++ b/openstack/init/00-init.tf @@ -0,0 +1 @@ +../00-init.tf \ No newline at end of file diff --git a/openstack/init/00-main.tf b/openstack/init/00-main.tf deleted file mode 100644 index c4ba324..0000000 --- a/openstack/init/00-main.tf +++ /dev/null @@ -1,51 +0,0 @@ -terraform { - required_version = ">= 0.14.0" - required_providers { - openstack = { - source = "terraform-provider-openstack/openstack" - version = "1.49.0" - } - } -} - -provider "openstack" { - cloud = "arif-home" -} - -variable "domain_id" { - type = string - default = "3fd5a53e08e243b49ac3b171d57b4e4a" -} - -resource "openstack_compute_keypair_v2" "arif-key" { - name = "arif-key" - public_key = file("/home/arif/.ssh/aarsa4096canonical.pub") -} - -resource "openstack_identity_role_v3" "tenantLead" { - name = "tenantLead" -} - -resource "openstack_compute_secgroup_v2" "allow_ssh" { - name = "allow_ssh" - description = "Allow ssh" - - rule { - from_port = 22 - to_port = 22 - ip_protocol = "tcp" - cidr = "0.0.0.0/0" - } -} - -resource "openstack_compute_secgroup_v2" "allow_ping" { - name = "allow_ping" - description = "Allow ping" - - rule { - from_port = -1 - to_port = -1 - ip_protocol = "icmp" - cidr = "0.0.0.0/0" - } -} diff --git a/openstack/init/01-security_groups.tf b/openstack/init/01-security_groups.tf new file mode 100644 index 0000000..14e4749 --- /dev/null +++ b/openstack/init/01-security_groups.tf @@ -0,0 +1,23 @@ +resource "openstack_compute_secgroup_v2" "allow_ssh" { + name = "allow_ssh" + description = "Allow ssh" + + rule { + from_port = 22 + to_port = 22 + ip_protocol = "tcp" + cidr = "0.0.0.0/0" + } +} + +resource "openstack_compute_secgroup_v2" "allow_ping" { + name = "allow_ping" + description = "Allow ping" + + rule { + from_port = -1 + to_port = -1 + ip_protocol = "icmp" + cidr = "0.0.0.0/0" + } +} diff --git a/openstack/multi-instances/00-init.tf b/openstack/multi-instances/00-init.tf new file mode 120000 index 0000000..b015707 --- /dev/null +++ b/openstack/multi-instances/00-init.tf @@ -0,0 +1 @@ +../00-init.tf \ No newline at end of file diff --git a/openstack/multi-instances/create-multiple-instances.tf b/openstack/multi-instances/create-multiple-instances.tf index fab858f..868e254 100644 --- a/openstack/multi-instances/create-multiple-instances.tf +++ b/openstack/multi-instances/create-multiple-instances.tf @@ -1,17 +1,3 @@ -terraform { - required_version = ">= 0.14.0" - required_providers { - openstack = { - source = "terraform-provider-openstack/openstack" - version = "1.49.0" - } - } -} - -provider "openstack" { - cloud = "arif-home" -} - data "openstack_compute_flavor_v2" "m1_small" { name = "m1.small" } diff --git a/openstack/stsstack_init/00-init.tf b/openstack/stsstack_init/00-init.tf new file mode 120000 index 0000000..b015707 --- /dev/null +++ b/openstack/stsstack_init/00-init.tf @@ -0,0 +1 @@ +../00-init.tf \ No newline at end of file