diff options
author | Patrick Spek <p.spek@tyil.nl> | 2024-04-06 01:21:24 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2024-04-06 01:21:24 +0200 |
commit | 318702758950bc64f15dfc9df55e4b5062d9e792 (patch) | |
tree | 6ba3a9c00255cc678494fe634a8527096b38e548 /playbooks.d/k3s-node | |
parent | 17410fb0a3cead9f5cc7e8baffd6d52f5864d827 (diff) |
Update k3s playbooks to bind to a specific interface
Diffstat (limited to 'playbooks.d/k3s-node')
-rw-r--r-- | playbooks.d/k3s-node/playbook.bash | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/playbooks.d/k3s-node/playbook.bash b/playbooks.d/k3s-node/playbook.bash index e1d77b3..d5b9a76 100644 --- a/playbooks.d/k3s-node/playbook.bash +++ b/playbooks.d/k3s-node/playbook.bash @@ -12,18 +12,29 @@ playbook_add() { info "$BASHTARD_PLAYBOOK" "Writing config.yaml for k3s" mkdir -pv -- /etc/rancher/k3s - cat <<-EOF > /etc/rancher/k3s/config.yaml - node-name: "${BASHTARD_PLATFORM[fqdn]}" - node-ip: "$(config "$BASHTARD_PLAYBOOK.internal-ip" "127.0.0.1")" - server: "https://$(config "$BASHTARD_PLAYBOOK.entry.host"):$(config "$BASHTARD_PLAYBOOK.entry.port" "6443")" - token: "$(config "$BASHTARD_PLAYBOOK.entry.token")" - EOF - - if [[ -n "$(config "$BASHTARD_PLAYBOOK.external-ip" "")" ]] - then - printf "%s: %s\n" "node-external-ip" "$(config "$BASHTARD_PLAYBOOK.external-ip" "")"\ - >> /etc/rancher/k3s/config.yaml - fi + { + cat <<-EOF + node-name: "${BASHTARD_PLATFORM[fqdn]}" + node-ip: "$(config "$BASHTARD_PLAYBOOK.internal-ip" "127.0.0.1")" + server: "https://$(config "$BASHTARD_PLAYBOOK.entry.host"):$(config "$BASHTARD_PLAYBOOK.entry.port" "6443")" + token: "$(config "$BASHTARD_PLAYBOOK.entry.token")" + EOF + + if [[ -n "$(config_subkeys "$BASHTARD_PLAYBOOK.flannel.interfaces")" ]] + then + printf "flannel-iface:\n" + + while read -r iface + do + printf -- "- %s\n" "$(config "$BASHTARD_PLAYBOOK.flannel.interfaces.$iface")" + done < <( config_subkeys "$BASHTARD_PLAYBOOK.flannel.interfaces" ) + fi + + if [[ -n "$(config "$BASHTARD_PLAYBOOK.external-ip" "")" ]] + then + printf "%s: %s\n" "node-external-ip" "$(config "$BASHTARD_PLAYBOOK.external-ip" "")" + fi + } "$(config "fs.etcdir")/rancher/k3s/config.yaml" if [[ "$role" == "server" ]] then |