Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tls-san handling in rke2 config #96

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions modules/userdata/files/rke2-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ append_config() {
echo "$1" >> "/etc/rancher/rke2/config.yaml"
}

append_config_san() {
grep "^tls-san:$" /etc/rancher/rke2/config.yaml > /dev/null
if [ $? -eq 0 ]; then
sed -i "/^tls-san:$/a \ \ - ${server_url}" /etc/rancher/rke2/config.yaml
return
fi
echo "tls-san:" >> /etc/rancher/rke2/config.yaml
echo " - ${server_url}" >> /etc/rancher/rke2/config.yaml
}

# The most simple "leader election" you've ever seen in your life
elect_leader() {
# Fetch other running instances in ASG
Expand Down Expand Up @@ -168,10 +178,7 @@ upload() {
# Initialize server
identify

cat <<EOF >> "/etc/rancher/rke2/config.yaml"
tls-san:
- ${server_url}
EOF
append_config_san

if [ $SERVER_TYPE = "server" ]; then # additional server joining an existing cluster
append_config 'server: https://${server_url}:9345'
Expand Down
Loading