Skip to content

Commit

Permalink
Terraform pass more data to Ansible for AWS native fencing (#200)
Browse files Browse the repository at this point in the history
Deprecate aws_cluster_data.yaml and move everything to the inventory.
Add variable to pass the name of the tag applied to the hana machines.
  • Loading branch information
mpagot authored Jan 17, 2024
1 parent 30dfd49 commit 22ac510
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
4 changes: 0 additions & 4 deletions ansible/playbooks/sap-hana-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@


tasks:
- name: Include AWS variables
ansible.builtin.include_vars: ../../terraform/aws/aws_cluster_data.yaml
when: cloud_platform_is_aws

- name: Base Cluster Configuration [azure]
ansible.builtin.include_tasks: ./tasks/azure-cluster-bootstrap.yaml
when: cloud_platform_is_azure
Expand Down
3 changes: 0 additions & 3 deletions terraform/aws/aws_cluster_data.tftpl

This file was deleted.

3 changes: 3 additions & 0 deletions terraform/aws/inventory.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
all:
vars:
use_sbd: ${use_sbd}
aws_route_table: ${routetable_id}
aws_cluster_ip: ${virtual_ip}
aws_stonith_tag: ${stonith_tag}
children:
hana:
hosts:
Expand Down
7 changes: 4 additions & 3 deletions terraform/aws/modules/hana_node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ locals {
create_scale_out = var.hana_count > 1 && var.common_variables["hana"]["scale_out_enabled"] ? 1 : 0
create_ha_infra = var.hana_count > 1 && var.common_variables["hana"]["ha_enabled"] ? 1 : 0
hostname = var.common_variables["deployment_name_in_hostname"] ? format("%s-%s", var.common_variables["deployment_name"], var.name) : var.name
hana_stonith_tag = "${var.common_variables["deployment_name"]}-cluster"
}

# Network resources: subnets, routes, etc
Expand Down Expand Up @@ -84,8 +85,8 @@ resource "aws_instance" "hana" {
#}

tags = {
Name = "${var.common_variables["deployment_name"]}-${var.name}${format("%02d", count.index + 1)}"
Workspace = var.common_variables["deployment_name"]
"${var.common_variables["deployment_name"]}-cluster" = "${var.name}${format("%02d", count.index + 1)}"
Name = "${var.common_variables["deployment_name"]}-${var.name}${format("%02d", count.index + 1)}"
Workspace = var.common_variables["deployment_name"]
"${local.hana_stonith_tag}" = "${var.name}${format("%02d", count.index + 1)}"
}
}
4 changes: 4 additions & 0 deletions terraform/aws/modules/hana_node/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ output "hana_public_name" {
value = data.aws_instance.hana.*.public_dns
}

output "stonith_tag" {
value = local.hana_stonith_tag
}

14 changes: 4 additions & 10 deletions terraform/aws/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,11 @@ resource "local_file" "ansible_inventory" {
iscsi_pip = module.iscsi_server.iscsisrv_public_ip,
iscsi_enabled = local.iscsi_enabled,
iscsi_remote_python = var.iscsi_remote_python,
use_sbd = local.use_sbd
use_sbd = local.use_sbd,
routetable_id = aws_route_table.route-table.id,
virtual_ip = local.hana_cluster_vip,
stonith_tag = module.hana_node.stonith_tag
})
filename = "inventory.yaml"
}

# Additional cluster information
resource "local_file" "cluster_data" {
content = templatefile("aws_cluster_data.tftpl",
{
routetable_id = aws_route_table.route-table.id,
virtual_ip = local.hana_cluster_vip
})
filename = "aws_cluster_data.yaml"
}

0 comments on commit 22ac510

Please sign in to comment.