Skip to content

Commit da55bb5

Browse files
committed
multi-arch-builders/tofu: use poseidon/ct tf module for rendering butane/ignition
poseidon/ct has support for "snippets" which is an alternative for the include files concept in butane, so we'll use that. Also plumb through the splunk configuration to TF vars set via environment variables.
1 parent 266309c commit da55bb5

File tree

6 files changed

+57
-25
lines changed

6 files changed

+57
-25
lines changed

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

Lines changed: 0 additions & 4 deletions
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

multi-arch-builders/coreos-aarch64-rhcos-builder.bu

Lines changed: 0 additions & 12 deletions
This file was deleted.

multi-arch-builders/provisioning/aarch64/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ can:
4444
export TF_VAR_distro=rhcos
4545
```
4646

47+
If you are deploying RHCOS you'll need to define variables for splunk configuration:
48+
49+
```
50+
export TF_VAR_splunk_hostname=...
51+
export TF_VAR_splunk_sidecar_repo=...
52+
export TF_VAR_itpaas_splunk_repo=...
53+
```
54+
4755
## Running tofu
4856
```bash
4957
# To begin using it, run 'init' within this directory.

multi-arch-builders/provisioning/aarch64/butane.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

multi-arch-builders/provisioning/aarch64/coreos-aarch64-builder.ign

Whitespace-only changes.

multi-arch-builders/provisioning/aarch64/main.tf

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,57 @@ check "health_check_distro" {
4040
}
4141
}
4242

43-
# Get ignition created for the multiarch builder
44-
resource "null_resource" "butane" {
45-
provisioner "local-exec" {
46-
command = "bash -x ./butane.sh"
43+
44+
# Variables used for splunk deployment, which is only
45+
# for RHCOS builders. Define them in the environment with:
46+
# export TF_VAR_splunk_hostname=...
47+
# export TF_VAR_splunk_sidecar_repo=...
48+
# export TF_VAR_itpaas_splunk_repo=...
49+
variable "splunk_hostname" {
50+
type = string
51+
default = ""
52+
}
53+
variable "splunk_sidecar_repo" {
54+
type = string
55+
default = ""
56+
}
57+
variable "itpaas_splunk_repo" {
58+
type = string
59+
default = ""
60+
}
61+
# Check that if we are deploying a RHCOS builder the splunk
62+
# variables have been defined.
63+
check "health_check_rhcos_splunk_vars" {
64+
assert {
65+
condition = !(var.distro == "rhcos" && anytrue([
66+
var.splunk_hostname == "",
67+
var.splunk_sidecar_repo == "",
68+
var.itpaas_splunk_repo == ""
69+
]))
70+
error_message = "Must define splunk env vars for RCHOS builders"
4771
}
4872
}
4973

74+
75+
locals {
76+
fcos_snippets = [
77+
file("../../coreos-aarch64-builder.bu"),
78+
]
79+
rhcos_snippets = [
80+
file("../../coreos-aarch64-builder.bu"),
81+
templatefile("../../builder-splunk.bu", {
82+
SPLUNK_HOSTNAME = var.splunk_hostname
83+
SPLUNK_SIDECAR_REPO = var.splunk_sidecar_repo
84+
ITPAAS_SPLUNK_REPO = var.itpaas_splunk_repo
85+
})
86+
]
87+
}
88+
data "ct_config" "butane" {
89+
strict = true
90+
content = file("../../builder-common.bu")
91+
snippets = var.distro == "rhcos" ? local.rhcos_snippets : local.fcos_snippets
92+
}
93+
5094
data "aws_region" "aws_region" {}
5195

5296
# Gather information about the AWS image for the current region
@@ -83,7 +127,7 @@ resource "aws_instance" "coreos-aarch64-builder" {
83127
Name = "${var.project}-${formatdate("YYYYMMDD", timestamp())}"
84128
}
85129
ami = local.ami
86-
user_data = file("coreos-aarch64-builder.ign")
130+
user_data = data.ct_config.butane.rendered
87131
instance_type = "m6g.metal"
88132
vpc_security_group_ids = [aws_security_group.sg.id]
89133
subnet_id = local.aws_subnet_id

0 commit comments

Comments
 (0)