Skip to content

Commit 579e514

Browse files
committed
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
1 parent 0a519b2 commit 579e514

File tree

6 files changed

+300
-4
lines changed

6 files changed

+300
-4
lines changed

multi-arch-builders/coreos-ppc64le-builder.bu

+16-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
#
77
variant: fcos
88
version: 1.4.0
9-
ignition:
10-
config:
11-
merge:
12-
- local: builder-common.ign
139
passwd:
1410
users:
1511
- name: builder
@@ -23,3 +19,19 @@ storage:
2319
overwrite: true
2420
contents:
2521
inline: coreos-ppc64le-builder
22+
# It is a workaround due the IP/Route issue in PowerVs
23+
# See more in the ppc64le README
24+
- path: /etc/NetworkManager/system-connections/env2.nmconnection
25+
mode: 0600
26+
contents:
27+
inline: |
28+
[connection]
29+
id=en
30+
type=ethernet
31+
interface-name=env2
32+
[ipv4]
33+
address1=10.130.1.149/25,10.130.1.129
34+
dns=127.0.0.53;
35+
dns-search=
36+
may-fail=false
37+
method=manual
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# OpenTofu
2+
3+
OpenTofu, a Terraform fork, is an open-source infrastructure as code (IaC) tool
4+
lets you define both cloud and on-prem resources in human-readable configuration files
5+
that you can version, reuse, and share.
6+
7+
To proceed with the next steps, ensure that 'tofu' is installed on your system.
8+
See: https://github.com/opentofu/opentofu/releases
9+
10+
## Before starting
11+
12+
### PowerVS credentials
13+
14+
- Ensure that you have access to our account.
15+
- Verify that the Fedora CoreOS image has been uploaded to the designated bucket.
16+
- TODO: Add bucket creation and image upload to tofu
17+
- See documetation in how to upload the image manually:
18+
https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-deploy-custom-image
19+
### PowerVs Issues
20+
21+
- PowerVS seems to encounter a problem in creating the default local IP with the default route,
22+
resulting in issues to ssh to the server post-boot.
23+
To mitigate this, we've incorporated networking configurations into the Ignition file. However,
24+
we still with one issue during the Splunk Butane configuration, where the CA certification couldn't be
25+
downloaded during provisioning. If you encounter this issue, comment out the Red Hat CA download step
26+
and perform it manually on the machine after provisioning.
27+
28+
- Additionally, it's important to note that PowerVS lacks the user data field in the web interface for providing
29+
the Ignition config.
30+
31+
### TF vars via environment variables
32+
33+
If you'd like to override the target distro (defaults to `fcos`) you
34+
can:
35+
36+
```
37+
export TF_VAR_distro=rhcos
38+
```
39+
40+
If you are deploying RHCOS you'll need to define variables for splunk configuration:
41+
42+
```
43+
export TF_VAR_splunk_hostname=...
44+
export TF_VAR_splunk_sidecar_repo=...
45+
export TF_VAR_itpaas_splunk_repo=...
46+
```
47+
48+
## Running tofu
49+
```bash
50+
# To begin using it, run 'init' within this directory.
51+
tofu init
52+
# If you don't intend to make any changes to the code, simply run it:
53+
tofu apply
54+
# If you plan to make changes to the code as modules/plugins, go ahead and run it:
55+
tofu init -upgrade
56+
# To destroy it run:
57+
tofu destroy -target aws_instance.coreos-aarch64-builder
58+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
data "ibm_pi_network" "network" {
2+
pi_network_name = var.network
3+
pi_cloud_instance_id = var.power_instance_id
4+
}
5+
6+
data "ibm_pi_image" "power_images" {
7+
pi_image_name = var.image_name
8+
pi_cloud_instance_id = var.power_instance_id
9+
}
10+
11+
provider "ct" {}
12+
13+
variable "project" {
14+
type = string
15+
default = "coreos-ppc64le-builder"
16+
}
17+
18+
# Which distro are we deploying a builder for? Override the
19+
# default by setting the env var: TF_VAR_distro=rhcos
20+
variable "distro" {
21+
type = string
22+
default = "fcos"
23+
}
24+
25+
check "health_check_distro" {
26+
assert {
27+
condition = anytrue([
28+
var.distro == "fcos",
29+
var.distro == "rhcos"
30+
])
31+
error_message = "Distro must be 'fcos' or 'rhcos'"
32+
}
33+
}
34+
35+
# Variables used for splunk deployment, which is only
36+
# for RHCOS builders. Define them in the environment with:
37+
# export TF_VAR_splunk_hostname=...
38+
# export TF_VAR_splunk_sidecar_repo=...
39+
# export TF_VAR_itpaas_splunk_repo=...
40+
variable "splunk_hostname" {
41+
type = string
42+
default = ""
43+
}
44+
variable "splunk_sidecar_repo" {
45+
type = string
46+
default = ""
47+
}
48+
variable "itpaas_splunk_repo" {
49+
type = string
50+
default = ""
51+
}
52+
53+
# Check that if we are deploying a RHCOS builder the splunk
54+
# variables have been defined.
55+
check "health_check_rhcos_splunk_vars" {
56+
assert {
57+
condition = !(var.distro == "rhcos" && anytrue([
58+
var.splunk_hostname == "",
59+
var.splunk_sidecar_repo == "",
60+
var.itpaas_splunk_repo == ""
61+
]))
62+
error_message = "Must define splunk env vars for RCHOS builders"
63+
}
64+
}
65+
66+
locals {
67+
fcos_snippets = [
68+
file("../../coreos-ppc64le-builder.bu"),
69+
]
70+
rhcos_snippets = [
71+
file("../../coreos-ppc64le-builder.bu"),
72+
templatefile("../../builder-splunk.bu", {
73+
SPLUNK_HOSTNAME = var.splunk_hostname
74+
SPLUNK_SIDECAR_REPO = var.splunk_sidecar_repo
75+
ITPAAS_SPLUNK_REPO = var.itpaas_splunk_repo
76+
})
77+
]
78+
}
79+
data "ct_config" "butane" {
80+
strict = true
81+
content = file("../../builder-common.bu")
82+
snippets = var.distro == "rhcos" ? local.rhcos_snippets : local.fcos_snippets
83+
}
84+
85+
86+
87+
resource "ibm_pi_instance" "pvminstance" {
88+
pi_memory = var.memory
89+
pi_processors = var.processors
90+
pi_instance_name = "${var.project}-${formatdate("YYYYMMDD", timestamp())}"
91+
pi_proc_type = var.proc_type
92+
pi_image_id = data.ibm_pi_image.power_images.id
93+
pi_network {
94+
network_id = data.ibm_pi_network.network.id
95+
}
96+
pi_key_pair_name = var.ssh_key_name
97+
pi_sys_type = var.system_type
98+
pi_cloud_instance_id = var.power_instance_id
99+
pi_user_data = base64encode(data.ct_config.butane.rendered)
100+
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
output "status" {
3+
value = ibm_pi_instance.pvminstance.status
4+
}
5+
6+
output "min_proc" {
7+
value = ibm_pi_instance.pvminstance.min_processors
8+
}
9+
10+
output "health_status" {
11+
value = ibm_pi_instance.pvminstance.health_status
12+
}
13+
14+
output "addresses" {
15+
value = ibm_pi_instance.pvminstance.pi_network
16+
}
17+
18+
output "progress" {
19+
value = ibm_pi_instance.pvminstance.pi_progress
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
terraform {
2+
required_providers {
3+
ct = {
4+
source = "poseidon/ct"
5+
version = "0.13.0"
6+
}
7+
ibm = {
8+
source = "IBM-Cloud/ibm"
9+
version = ">= 1.12.0"
10+
}
11+
}
12+
}
13+
14+
provider "ibm" {
15+
ibmcloud_api_key = var.ibmcloud_api_key
16+
region = "us-south"
17+
zone = var.ibmcloud_zone
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
variable "ibmcloud_api_key" {
3+
description = "Denotes the IBM Cloud API key to use"
4+
default = ""
5+
}
6+
7+
variable "ibmcloud_region" {
8+
description = "Denotes which IBM Cloud region to connect to"
9+
default = "us-south"
10+
}
11+
12+
#INSERTED FOR MULTI-ZONE REGION SUCH AS FRANKFURT
13+
14+
variable "ibmcloud_zone" {
15+
description = "Denotes which IBM Cloud zone to connect to - .i.e: eu-de-1 eu-de-2 us-south etc."
16+
default = "us-south"
17+
}
18+
19+
# Got the ID from `ibmcloud resource service-instances --long field` command, refer GUID for the instance
20+
variable "power_instance_id" {
21+
description = "Power Virtual Server instance ID associated with your IBM Cloud account (note that this is NOT the API key)"
22+
default = "556eb201-32bf-4ae2-8ab5-dfd7bbe97789"
23+
}
24+
25+
26+
# The PowerVs cost are high, check the price before adding
27+
# more processors and memory. This number may change
28+
# due the PowerVs availability.
29+
30+
variable "memory" {
31+
description = "Amount of memory (GB) to be allocated to the VM"
32+
default = "50"
33+
}
34+
35+
variable "processors" {
36+
description = "Number of virtual processors to allocate to the VM"
37+
default = "15"
38+
}
39+
40+
# The s922 model is the cheapest model
41+
variable "system_type" {
42+
description = "Type of system on which the VM should be created - s922/e880/e980"
43+
default = "s922"
44+
}
45+
46+
variable "proc_type" {
47+
description = "Processor type for the LPAR - shared/dedicated"
48+
default = "capped"
49+
}
50+
51+
variable "ssh_key_name" {
52+
description = "SSH key name in IBM Cloud to be used for SSH logins"
53+
default = ""
54+
}
55+
56+
variable "shareable" {
57+
description = "Should the data volume be shared or not - true/false"
58+
default = "true"
59+
}
60+
61+
# TODO: We need to add the network creation via tofu for fcos
62+
# This config is for rhcos only
63+
variable "network" {
64+
description = "List of networks that should be attached to the VM - Create this network before running terraform"
65+
default = "redhat-internal-rhcos"
66+
}
67+
68+
69+
variable "image_name" {
70+
description = "Name of the image from which the VM should be deployed - IBM image name"
71+
default = "fedora-coreos-39-2023110110"
72+
}
73+
74+
variable "replication_policy" {
75+
description = "Replication policy of the VM"
76+
default = "none"
77+
}
78+
79+
variable "replication_scheme" {
80+
description = "Replication scheme for the VM"
81+
default = "suffix"
82+
}
83+
84+
variable "replicants" {
85+
description = "Number of VM instances to deploy"
86+
default = "1"
87+
}

0 commit comments

Comments
 (0)