remove root from ssh_args...

because scp does not take the username via -l, so we just re-add
it to the commands themselves.
This commit is contained in:
phaer 2022-02-07 13:19:06 +01:00
parent a5914f81e6
commit 1a50ace0d3
4 changed files with 8 additions and 8 deletions

View File

@ -45,12 +45,12 @@ resource "hcloud_server" "agents" {
# Issue a reboot command # Issue a reboot command
provisioner "local-exec" { provisioner "local-exec" {
command = "ssh ${local.ssh_args} ${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3" command = "ssh ${local.ssh_args} root@${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3"
} }
# Wait for MicroOS to reboot and be ready # Wait for MicroOS to reboot and be ready
provisioner "local-exec" { provisioner "local-exec" {
command = "until ssh ${local.ssh_args} -o ConnectTimeout=2 ${self.ipv4_address} true; do sleep 1; done" command = "until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true; do sleep 1; done"
} }
# Generating and uploading the angent.conf file # Generating and uploading the angent.conf file

View File

@ -12,7 +12,7 @@ locals {
ssh_identity_file = var.private_key == null ? var.public_key : var.private_key ssh_identity_file = var.private_key == null ? var.public_key : var.private_key
# shared flags for ssh to ignore host keys, to use root and our ssh identity file for all connections during provisioning. # shared flags for ssh to ignore host keys, to use root and our ssh identity file for all connections during provisioning.
ssh_args = "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root -i ${local.ssh_identity_file}" ssh_args = "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${local.ssh_identity_file}"
MicroOS_install_commands = [ MicroOS_install_commands = [
"set -ex", "set -ex",

View File

@ -43,12 +43,12 @@ resource "hcloud_server" "first_control_plane" {
# Issue a reboot command # Issue a reboot command
provisioner "local-exec" { provisioner "local-exec" {
command = "ssh ${local.ssh_args} ${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3" command = "ssh ${local.ssh_args} root@${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3"
} }
# Wait for MicroOS to reboot and be ready # Wait for MicroOS to reboot and be ready
provisioner "local-exec" { provisioner "local-exec" {
command = "until ssh ${local.ssh_args} -o ConnectTimeout=2 ${self.ipv4_address} true; do sleep 1; done" command = "until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true; do sleep 1; done"
} }
# Generating k3s master config file # Generating k3s master config file
@ -90,7 +90,7 @@ resource "hcloud_server" "first_control_plane" {
command = <<-EOT command = <<-EOT
set -ex set -ex
sleep 30 sleep 30
scp ${local.ssh_args} ${self.ipv4_address}:/etc/rancher/k3s/k3s.yaml ${path.module}/kubeconfig.yaml scp ${local.ssh_args} root@${self.ipv4_address}:/etc/rancher/k3s/k3s.yaml ${path.module}/kubeconfig.yaml
sed -i -e 's/127.0.0.1/${self.ipv4_address}/g' ${path.module}/kubeconfig.yaml sed -i -e 's/127.0.0.1/${self.ipv4_address}/g' ${path.module}/kubeconfig.yaml
sleep 10 && until kubectl get node ${self.name}; do sleep 5; done sleep 10 && until kubectl get node ${self.name}; do sleep 5; done
EOT EOT

View File

@ -44,12 +44,12 @@ resource "hcloud_server" "control_planes" {
# Issue a reboot command # Issue a reboot command
provisioner "local-exec" { provisioner "local-exec" {
command = "ssh ${local.ssh_args} ${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3" command = "ssh ${local.ssh_args} root@${self.ipv4_address} '(sleep 2; reboot)&'; sleep 3"
} }
# Wait for MicroOS to reboot and be ready # Wait for MicroOS to reboot and be ready
provisioner "local-exec" { provisioner "local-exec" {
command = "until ssh ${local.ssh_args} -o ConnectTimeout=2 ${self.ipv4_address} true; do sleep 1; done" command = "until ssh ${local.ssh_args} -o ConnectTimeout=2 root@${self.ipv4_address} true; do sleep 1; done"
} }
# Generating k3s server config file # Generating k3s server config file