-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multi-arch-builders/tofu: Add PowerVs configuration
* Add Tofu configuration for provisioning our ppc64le instance on PowerVs * Include supplementary documentation for our Tofu and PowerVs procedures
- Loading branch information
Showing
6 changed files
with
294 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# OpenTofu | ||
|
||
OpenTofu is a Terraform fork, is an open-source infrastructure as code (IaC) tool | ||
lets you define both cloud and on-prem resources in human-readable configuration files | ||
that you can version, reuse, and share. | ||
|
||
To proceed with the next steps, ensure that 'tofu' is installed on your system. | ||
See: https://github.com/opentofu/opentofu/releases | ||
|
||
## Before starting | ||
|
||
### PowerVS credentials | ||
|
||
- Ensure that you have access to our account. | ||
- Verify that the Fedora CoreOS image has been uploaded to the designated bucket. | ||
- See documetation in how to upload the image: | ||
https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-deploy-custom-image | ||
### PowerVs Issues | ||
|
||
- PowerVS seems to encounter a problem in creating the default local IP with the default route, | ||
resulting in issues to ssh to the server post-boot. | ||
To mitigate this, we've incorporated networking configurations into the Ignition file. However, | ||
we still with one issue during the Splunk Butane configuration, where the CA certification couldn't be | ||
downloaded during provisioning. If you encounter this issue, comment out the Red Hat CA download step | ||
and perform it manually on the machine after provisioning. | ||
|
||
- Additionally, it's important to note that PowerVS lacks the user data field in the interface for providing | ||
the Ignition config. | ||
|
||
### TF vars via environment variables | ||
|
||
If you'd like to override the target distro (defaults to `fcos`) you | ||
can: | ||
|
||
``` | ||
export TF_VAR_distro=rhcos | ||
``` | ||
|
||
If you are deploying RHCOS you'll need to define variables for splunk configuration: | ||
|
||
``` | ||
export TF_VAR_splunk_hostname=... | ||
export TF_VAR_splunk_sidecar_repo=... | ||
export TF_VAR_itpaas_splunk_repo=... | ||
``` | ||
|
||
## Running tofu | ||
```bash | ||
# To begin using it, run 'init' within this directory. | ||
tofu init | ||
# If you don't intend to make any changes to the code, simply run it: | ||
tofu apply | ||
# If you plan to make changes to the code as modules/plugins, go ahead and run it: | ||
tofu init -upgrade | ||
# To destroy it run: | ||
tofu destroy -target aws_instance.coreos-aarch64-builder | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
data "ibm_pi_network" "network" { | ||
pi_network_name = var.network | ||
pi_cloud_instance_id = var.power_instance_id | ||
} | ||
|
||
data "ibm_pi_image" "power_images" { | ||
pi_image_name = var.image_name | ||
pi_cloud_instance_id = var.power_instance_id | ||
} | ||
|
||
provider "ct" {} | ||
|
||
variable "project" { | ||
type = string | ||
default = "coreos-ppc64le-builder" | ||
} | ||
|
||
# Which distro are we deploying a builder for? Override the | ||
# default by setting the env var: TF_VAR_distro=rhcos | ||
variable "distro" { | ||
type = string | ||
default = "rhcos" | ||
} | ||
|
||
check "health_check_distro" { | ||
assert { | ||
condition = anytrue([ | ||
var.distro == "fcos", | ||
var.distro == "rhcos" | ||
]) | ||
error_message = "Distro must be 'fcos' or 'rhcos'" | ||
} | ||
} | ||
|
||
# Variables used for splunk deployment, which is only | ||
# for RHCOS builders. Define them in the environment with: | ||
# export TF_VAR_splunk_hostname=... | ||
# export TF_VAR_splunk_sidecar_repo=... | ||
# export TF_VAR_itpaas_splunk_repo=... | ||
variable "splunk_hostname" { | ||
type = string | ||
default = "" | ||
} | ||
variable "splunk_sidecar_repo" { | ||
type = string | ||
default = "" | ||
} | ||
variable "itpaas_splunk_repo" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
# Check that if we are deploying a RHCOS builder the splunk | ||
# variables have been defined. | ||
check "health_check_rhcos_splunk_vars" { | ||
assert { | ||
condition = !(var.distro == "rhcos" && anytrue([ | ||
var.splunk_hostname == "", | ||
var.splunk_sidecar_repo == "", | ||
var.itpaas_splunk_repo == "" | ||
])) | ||
error_message = "Must define splunk env vars for RCHOS builders" | ||
} | ||
} | ||
|
||
locals { | ||
fcos_snippets = [ | ||
file("../../coreos-ppc64le-builder.bu"), | ||
] | ||
rhcos_snippets = [ | ||
file("../../coreos-ppc64le-builder.bu"), | ||
templatefile("../../builder-splunk.bu", { | ||
SPLUNK_HOSTNAME = var.splunk_hostname | ||
SPLUNK_SIDECAR_REPO = var.splunk_sidecar_repo | ||
ITPAAS_SPLUNK_REPO = var.itpaas_splunk_repo | ||
}) | ||
] | ||
} | ||
data "ct_config" "butane" { | ||
strict = true | ||
content = file("../../builder-common.bu") | ||
snippets = var.distro == "rhcos" ? local.rhcos_snippets : local.fcos_snippets | ||
} | ||
|
||
|
||
|
||
resource "ibm_pi_instance" "pvminstance" { | ||
pi_memory = var.memory | ||
pi_processors = var.processors | ||
pi_instance_name = "${var.project}-${formatdate("YYYYMMDD", timestamp())}" | ||
pi_proc_type = var.proc_type | ||
pi_image_id = data.ibm_pi_image.power_images.id | ||
pi_network { | ||
network_id = data.ibm_pi_network.network.id | ||
} | ||
pi_key_pair_name = var.ssh_key_name | ||
pi_sys_type = var.system_type | ||
pi_cloud_instance_id = var.power_instance_id | ||
pi_user_data = base64encode(data.ct_config.butane.rendered) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
output "status" { | ||
value = ibm_pi_instance.pvminstance.status | ||
} | ||
|
||
output "min_proc" { | ||
value = ibm_pi_instance.pvminstance.min_processors | ||
} | ||
|
||
output "health_status" { | ||
value = ibm_pi_instance.pvminstance.health_status | ||
} | ||
|
||
output "addresses" { | ||
value = ibm_pi_instance.pvminstance.pi_network | ||
} | ||
|
||
output "progress" { | ||
value = ibm_pi_instance.pvminstance.pi_progress | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
terraform { | ||
required_providers { | ||
ct = { | ||
source = "poseidon/ct" | ||
version = "0.13.0" | ||
} | ||
ibm = { | ||
source = "IBM-Cloud/ibm" | ||
version = ">= 1.12.0" | ||
} | ||
} | ||
} | ||
|
||
provider "ibm" { | ||
ibmcloud_api_key = var.ibmcloud_api_key | ||
region = "us-south" | ||
zone = var.ibmcloud_zone | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
variable "ibmcloud_api_key" { | ||
description = "Denotes the IBM Cloud API key to use" | ||
default = "" | ||
} | ||
|
||
variable "ibmcloud_region" { | ||
description = "Denotes which IBM Cloud region to connect to" | ||
default = "us-south" | ||
} | ||
|
||
#INSERTED FOR MULTI-ZONE REGION SUCH AS FRANKFURT | ||
|
||
variable "ibmcloud_zone" { | ||
description = "Denotes which IBM Cloud zone to connect to - .i.e: eu-de-1 eu-de-2 us-south etc." | ||
default = "us-south" | ||
} | ||
|
||
# Got the ID from `ibmcloud resource service-instances --long field` command, refer GUID for the instance | ||
variable "power_instance_id" { | ||
description = "Power Virtual Server instance ID associated with your IBM Cloud account (note that this is NOT the API key)" | ||
default = "556eb201-32bf-4ae2-8ab5-dfd7bbe97789" | ||
} | ||
|
||
variable "memory" { | ||
description = "Amount of memory (GB) to be allocated to the VM" | ||
default = "50" | ||
} | ||
|
||
variable "processors" { | ||
description = "Number of virtual processors to allocate to the VM" | ||
default = "15" | ||
} | ||
|
||
variable "proc_type" { | ||
description = "Processor type for the LPAR - shared/dedicated" | ||
default = "dedicated" | ||
} | ||
|
||
variable "ssh_key_name" { | ||
description = "SSH key name in IBM Cloud to be used for SSH logins" | ||
default = "" | ||
} | ||
|
||
variable "shareable" { | ||
description = "Should the data volume be shared or not - true/false" | ||
default = "true" | ||
} | ||
|
||
variable "network" { | ||
description = "List of networks that should be attached to the VM - Create this network before running terraform" | ||
default = "redhat-internal-rhcos" | ||
} | ||
|
||
variable "system_type" { | ||
description = "Type of system on which the VM should be created - s922/e880" | ||
default = "e880" | ||
} | ||
|
||
variable "image_name" { | ||
description = "Name of the image from which the VM should be deployed - IBM i image name" | ||
default = "fedora-coreos-39-2023110110" | ||
} | ||
|
||
variable "replication_policy" { | ||
description = "Replication policy of the VM" | ||
default = "none" | ||
} | ||
|
||
variable "replication_scheme" { | ||
description = "Replication scheme for the VM" | ||
default = "suffix" | ||
} | ||
|
||
variable "replicants" { | ||
description = "Number of VM instances to deploy" | ||
default = "1" | ||
} |