Skip to content

Commit 9f635a6

Browse files
committed
ENH: add cloud variable for clouds.yaml
When deploying in different clouds we need separate credentials. I've added a variable called cloud which will tell terraform which entry in clouds.yaml to use for authentication.
1 parent 4e70ad9 commit 9f635a6

File tree

9 files changed

+19
-7
lines changed

9 files changed

+19
-7
lines changed

chatops_deployment/ansible/dev/host_vars/localhost/vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ terraform_deployment: chatops-development
33
terraform_external_network_id: 0dc30001-edfb-4137-be76-8e51f38fd650
44
terraform_stack_volume_id: f8d37290-598e-4dc7-a8d6-e771a64c549f
55
bastion_key_passphrase: "{{ vault_bastion_key_passphrase }}"
6+
cloud: "scratch-dev"

chatops_deployment/ansible/prod/host_vars/localhost/vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ terraform_deployment: chatops-production
33
terraform_external_network_id: 5283f642-8bd8-48b6-8608-fa3006ff4539
44
terraform_stack_volume_id: df3fdff2-30fc-4aca-b8e5-03412a507607
55
bastion_key_passphrase: "{{ vault_bastion_key_passphrase }}"
6+
cloud: "cloud-microservices"

chatops_deployment/ansible/roles/terraform/templates/terraform.tfvars.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ deployment="{{ terraform_deployment }}"
22
external_network_id="{{ terraform_external_network_id }}"
33
floating_ip="{{ terraform_floating_ip }}"
44
stack_volume_id="{{ terraform_stack_volume_id }}"
5-
environment="{{ env }}"
5+
environment="{{ env }}"
6+
cloud="{{ cloud }}"

chatops_deployment/terraform/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ terraform {
99
}
1010

1111
provider "openstack" {
12-
cloud = "openstack"
12+
cloud = var.cloud
1313
}
1414

1515
module "networking" {
1616
source = "./modules/networking"
1717

1818
deployment = var.deployment
1919
external_network_id = var.external_network_id
20+
cloud = var.cloud
2021
}
2122

2223
module "compute" {
@@ -28,4 +29,5 @@ module "compute" {
2829
deployment = var.deployment
2930
stack_volume_id = var.stack_volume_id
3031
environment = var.environment
31-
}
32+
cloud = var.cloud
33+
}

chatops_deployment/terraform/modules/compute/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ terraform {
99
}
1010

1111
provider "openstack" {
12-
cloud = "openstack"
12+
cloud = var.cloud
1313
}
1414

1515
resource "openstack_compute_keypair_v2" "bastion_keypair" {

chatops_deployment/terraform/modules/compute/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ variable "floating_ip" {}
44
variable "private_subnet" {}
55
variable "stack_volume_id" {}
66
variable "environment" {}
7-
variable "stack_secgroup" {}
7+
variable "stack_secgroup" {}
8+
variable "cloud" {}

chatops_deployment/terraform/modules/networking/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ terraform {
99
}
1010

1111
provider "openstack" {
12-
cloud = "openstack"
12+
cloud = var.cloud
1313
}
1414

1515
resource "openstack_networking_network_v2" "private_network" {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
variable "deployment" {}
2-
variable "external_network_id" {}
2+
variable "external_network_id" {}
3+
variable "cloud" {}

chatops_deployment/terraform/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ variable "environment" {
2222
type = string
2323
description = "The environment being deployed into. E.g. dev, staging, prod"
2424
}
25+
26+
variable "cloud" {
27+
type = string
28+
description = "clouds.yaml entry to use for authentication."
29+
}

0 commit comments

Comments
 (0)