Skip to content

Commit 5999748

Browse files
chore: powervs_instances
1 parent e6a21cd commit 5999748

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

ibm_catalog.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@
691691
],
692692
"custom_config": {}
693693
},
694+
{
695+
"key": "powervs_instance_count",
696+
"default_value": "",
697+
"required": true
698+
},
694699
{
695700
"key": "tshirt_size",
696701
"type": "object",

solutions/standard-plus-vsi/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ This example sets up the following infrastructure:
9191
| <a name="input_network_services_vsi_profile"></a> [network\_services\_vsi\_profile](#input\_network\_services\_vsi\_profile) | Compute profile configuration of the network services vsi (cpu and memory configuration). Must be one of the supported profiles. See [here](https://cloud.ibm.com/docs/vpc?topic=vpc-profiles&interface=ui). | `string` | `"cx2-2x4"` | no |
9292
| <a name="input_nfs_server_config"></a> [nfs\_server\_config](#input\_nfs\_server\_config) | Configuration for the NFS server. 'size' is in GB, 'iops' is maximum input/output operation performance bandwidth per second, 'mount\_path' defines the target mount point on os. Set 'configure\_nfs\_server' to false to ignore creating file storage share. | <pre>object({<br/> size = number<br/> iops = number<br/> mount_path = string<br/> })</pre> | <pre>{<br/> "iops": 600,<br/> "mount_path": "/nfs",<br/> "size": 200<br/>}</pre> | no |
9393
| <a name="input_powervs_backup_network"></a> [powervs\_backup\_network](#input\_powervs\_backup\_network) | Name of the IBM Cloud PowerVS backup network and CIDR to create. | <pre>object({<br/> name = string<br/> cidr = string<br/> })</pre> | <pre>{<br/> "cidr": "10.52.0.0/24",<br/> "name": "bkp_net"<br/>}</pre> | no |
94+
| <a name="input_powervs_instance_count"></a> [powervs\_instance\_count](#input\_powervs\_instance\_count) | Number of PowerVS instances to create. | `number` | `1` | no |
9495
| <a name="input_powervs_management_network"></a> [powervs\_management\_network](#input\_powervs\_management\_network) | Name of the IBM Cloud PowerVS management subnet and CIDR to create. | <pre>object({<br/> name = string<br/> cidr = string<br/> })</pre> | <pre>{<br/> "cidr": "10.51.0.0/24",<br/> "name": "mgmt_net"<br/>}</pre> | no |
9596
| <a name="input_powervs_resource_group_name"></a> [powervs\_resource\_group\_name](#input\_powervs\_resource\_group\_name) | Existing IBM Cloud resource group name. | `string` | `"Default"` | no |
9697
| <a name="input_powervs_zone"></a> [powervs\_zone](#input\_powervs\_zone) | IBM Cloud data center location where IBM PowerVS infrastructure will be created. | `string` | n/a | yes |

solutions/standard-plus-vsi/main.tf

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ module "powervs_instance" {
4747
source = "terraform-ibm-modules/powervs-instance/ibm"
4848
version = "2.6.2"
4949
providers = { ibm = ibm.ibm-pi }
50+
count = var.powervs_instance_count
5051
depends_on = [time_sleep.wait_for_dependencies]
5152

5253
pi_workspace_guid = module.standard.powervs_workspace_guid
5354
pi_ssh_public_key_name = module.standard.powervs_ssh_public_key.name
5455

5556
pi_image_id = local.pi_instance.pi_image_id
5657
pi_networks = local.pi_instance.pi_networks
57-
pi_instance_name = local.pi_instance.pi_instance_name
58+
pi_instance_name = "${local.pi_instance.pi_instance_name}-${count.index + 1}"
5859
pi_sap_profile_id = local.pi_instance.pi_sap_profile_id
5960
pi_server_type = local.pi_instance.pi_server_type
6061
pi_number_of_processors = local.pi_instance.pi_number_of_processors
@@ -82,18 +83,18 @@ module "powervs_instance" {
8283
######################################################
8384
resource "terraform_data" "aix_init" {
8485

85-
count = local.pi_instance_os_type == "aix" ? 1 : 0
86+
count = local.pi_instance_os_type == "aix" ? var.powervs_instance_count : 0
8687
depends_on = [module.standard, module.powervs_instance]
8788

8889
triggers_replace = {
8990
"network_services_config" = local.network_services_config,
90-
"pi_storage_configuration" = module.powervs_instance.pi_storage_configuration
91+
"pi_storage_configuration" = module.powervs_instance[count.index].pi_storage_configuration
9192
}
9293
connection {
9394
type = "ssh"
9495
user = "root"
9596
bastion_host = module.standard.access_host_or_ip
96-
host = module.powervs_instance.pi_instance_primary_ip
97+
host = module.powervs_instance[count.index].pi_instance_primary_ip
9798
private_key = var.ssh_private_key
9899
agent = false
99100
timeout = "10m"
@@ -109,17 +110,17 @@ resource "terraform_data" "aix_init" {
109110
content = templatefile("./aix-init/aix_init.sh.tftpl",
110111
merge(
111112
{ "network_services_config" = local.network_services_config },
112-
{ "pi_storage_configuration" = module.powervs_instance.pi_storage_configuration }
113+
{ "pi_storage_configuration" = module.powervs_instance[count.index].pi_storage_configuration }
113114
)
114115
)
115-
destination = "/root/terraform_files/aix_init.sh"
116+
destination = "/root/terraform_files/aix_init-${count.index + 1}.sh"
116117
}
117118

118119
# Execute aix_ini.sh shell script to configure management services and create filesystem
119120
provisioner "remote-exec" {
120121
inline = [
121-
"chmod +x /root/terraform_files/aix_init.sh",
122-
"/root/terraform_files/aix_init.sh",
122+
"chmod +x /root/terraform_files/aix_init-${count.index + 1}.sh",
123+
"/root/terraform_files/aix_init-${count.index + 1}.sh",
123124
]
124125
}
125126

@@ -130,7 +131,7 @@ module "pi_scc_wp_agent" {
130131

131132
source = "../../modules/powervs-vpc-landing-zone/submodules/ansible"
132133
depends_on = [module.standard, module.powervs_instance, terraform_data.aix_init]
133-
count = var.enable_scc_wp && contains(["aix", "linux"], local.pi_instance_os_type) ? 1 : 0
134+
count = var.enable_scc_wp && contains(["aix", "linux"], local.pi_instance_os_type) ? var.powervs_instance_count : 0
134135

135136
bastion_host_ip = module.standard.access_host_or_ip
136137
ansible_host_or_ip = module.standard.ansible_host_or_ip
@@ -139,16 +140,16 @@ module "pi_scc_wp_agent" {
139140
configure_ansible_host = false
140141

141142
src_script_template_name = "configure-scc-wp-agent/ansible_configure_scc_wp_agent.sh.tftpl"
142-
dst_script_file_name = "${var.prefix}-configure_scc_wp_agent_pi_${local.pi_instance_os_type}.sh"
143+
dst_script_file_name = "${var.prefix}-configure_scc_wp_agent_pi_${local.pi_instance_os_type}-${count.index}.sh"
143144

144145
src_playbook_template_name = "configure-scc-wp-agent/playbook-configure-scc-wp-agent-${local.pi_instance_os_type}.yml.tftpl"
145-
dst_playbook_file_name = "${var.prefix}-playbook-configure-scc-wp-agent-pi-${local.pi_instance_os_type}.yml"
146+
dst_playbook_file_name = "${var.prefix}-playbook-configure-scc-wp-agent-pi-${local.pi_instance_os_type}-${count.index}.yml"
146147
playbook_template_vars = {
147148
COLLECTOR_ENDPOINT : module.standard.scc_wp_instance.ingestion_endpoint,
148149
API_ENDPOINT : module.standard.scc_wp_instance.api_endpoint,
149150
ACCESS_KEY : module.standard.scc_wp_instance.access_key
150151
}
151152
src_inventory_template_name = "inventory.tftpl"
152-
dst_inventory_file_name = "${var.prefix}-scc-wp-inventory-pi-${local.pi_instance_os_type}"
153-
inventory_template_vars = { "host_or_ip" : module.powervs_instance.pi_instance_primary_ip }
153+
dst_inventory_file_name = "${var.prefix}-scc-wp-inventory-pi-${local.pi_instance_os_type}-${count.index}"
154+
inventory_template_vars = { "host_or_ip" : module.powervs_instance[count.index].pi_instance_primary_ip }
154155
}

solutions/standard-plus-vsi/outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ output "powervs_images" {
170170

171171
output "powervs_instance_management_ip" {
172172
description = "IP address of the primary network interface of IBM PowerVS instance."
173-
value = module.powervs_instance.pi_instance_primary_ip
173+
value = module.powervs_instance[*].pi_instance_primary_ip
174174
}
175175

176176
output "powervs_instance_private_ips" {
177177
description = "All private IP addresses (as a list) of IBM PowerVS instance."
178-
value = module.powervs_instance.pi_instance_private_ips
178+
value = module.powervs_instance[*].pi_instance_private_ips
179179
}
180180

181181
output "powervs_storage_configuration" {
182182
description = "Storage configuration of PowerVS instance."
183-
value = module.powervs_instance.pi_storage_configuration
183+
value = module.powervs_instance[*].pi_storage_configuration
184184
}
185185

186186
output "schematics_workspace_id" {

solutions/standard-plus-vsi/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ variable "prefix" {
88
type = string
99
}
1010

11+
variable "powervs_instance_count" {
12+
description = "Number of PowerVS instances to create."
13+
type = number
14+
default = 1
15+
validation {
16+
condition = var.powervs_instance_count > 0
17+
error_message = "The number of PowerVS instances must be a positive integer."
18+
}
19+
}
20+
1121
variable "tshirt_size" {
1222
description = "PowerVS instance profiles. These profiles can be overridden by specifying 'custom_profile_instance_boot_image' and 'custom_profile' values in optional parameters."
1323
type = object({

0 commit comments

Comments
 (0)