-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow rendering userdata using jsonnet
- Loading branch information
Showing
6 changed files
with
110 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
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,14 @@ | ||
{ | ||
apiVersion: 'v1', | ||
kind: 'Secret', | ||
metadata: { | ||
name: 'cloudscale-user-data', | ||
namespace: 'openshift-machine-api', | ||
}, | ||
stringData: { | ||
ignitionHost: std.extVar('ignitionHost'), | ||
ignitionCA: std.extVar('ignitionCA'), | ||
userData: (importstr './userdata.jsonnet'), | ||
}, | ||
type: 'Opaque', | ||
} |
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,13 @@ | ||
#!/bin/bash | ||
# This script is used to generate the userdata file from the main.tf.json output by component openshift4-terraform | ||
# First optional positional argument is the path to the main.tf.json file | ||
|
||
set -euo pipefail | ||
|
||
maintf="${1:-main.tf.json}" | ||
sdir="$(dirname "$(readlink -f "$0")")" | ||
|
||
ignitionCA="$(jq -er '.module.cluster.ignition_ca' "$maintf")" | ||
ignitionHost="api-int.$(jq -er '.module.cluster.cluster_name' "$maintf").$(jq -er '.module.cluster.base_domain' "$maintf")" | ||
|
||
jsonnet "${sdir}/secret.jsonnet" --ext-str "ignitionHost=${ignitionHost}" --ext-str "ignitionCA=${ignitionCA}" |
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,36 @@ | ||
local context = std.extVar('context'); | ||
|
||
{ | ||
ignition: { | ||
version: '3.1.0', | ||
config: { | ||
merge: [ { | ||
source: 'https://%s:22623/config/%s' % [ context.data.ignitionHost, std.get(context.data, 'ignitionConfigName', 'worker') ], | ||
} ], | ||
}, | ||
security: { | ||
tls: { | ||
certificateAuthorities: [ { | ||
source: 'data:text/plain;charset=utf-8;base64,%s' % [ std.base64(context.data.ignitionCA) ], | ||
} ], | ||
}, | ||
}, | ||
}, | ||
systemd: { | ||
units: [ { | ||
name: 'cloudscale-hostkeys.service', | ||
enabled: true, | ||
contents: "[Unit]\nDescription=Print SSH Public Keys to tty\nAfter=sshd-keygen.target\n\n[Install]\nWantedBy=multi-user.target\n\n[Service]\nType=oneshot\nStandardOutput=tty\nTTYPath=/dev/ttyS0\nExecStart=/bin/sh -c \"echo '-----BEGIN SSH HOST KEY KEYS-----'; cat /etc/ssh/ssh_host_*key.pub; echo '-----END SSH HOST KEY KEYS-----'\"", | ||
} ], | ||
}, | ||
storage: { | ||
files: [ { | ||
filesystem: 'root', | ||
path: '/etc/hostname', | ||
mode: 420, | ||
contents: { | ||
source: 'data:,%s' % context.machine.metadata.name, | ||
}, | ||
} ], | ||
}, | ||
} |