add ssh utils following the same scheme as k8s-create...

This commit is contained in:
jerger 2022-03-14 16:42:27 +01:00
parent 1836b9efdb
commit a3fbd13474
4 changed files with 59 additions and 31 deletions

View file

@ -59,32 +59,33 @@ fun Prov.installKubectlAndTools(): ProvResult = def {
} }
} }
task("install tunnel alias") { task("install ssh helper") {
val tunnelAliasFile = "~/.bashrc.d/ssh_alias.sh" createFileFromResource(
if (!fileExists(tunnelAliasFile)) { "/usr/local/bin/sshu.sh",
val tunnelAlias = """ "sshu.sh",
alias sshu='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' resourcePath,
alias ssht='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -L 8002:localhost:8002 -L 6443:192.168.5.1:6443' "555",
""".trimIndent() sudo = true
createFile(tunnelAliasFile, tunnelAlias, "640") )
} else { createFileFromResource(
ProvResult(true, out = "tunnel alias already installed") "/usr/local/bin/ssht.sh",
} "ssht.sh",
resourcePath,
"555",
sudo = true
)
} }
task("install k8sCreateContext") { task("install k8sCreateContext") {
val k8sContextFile = "/usr/local/bin/k8s-create-context.sh" val k8sContextFile = "/usr/local/bin/k8s-create-context.sh"
if (!fileExists(k8sContextFile)) { createFileFromResource(
createFileFromResource( k8sContextFile,
k8sContextFile, "k8s-create-context.sh",
"k8s-create-context.sh", resourcePath,
resourcePath, "555",
"555", sudo = true
sudo = true )
)
} else {
ProvResult(true)
}
} }
} }
@ -104,17 +105,18 @@ fun Prov.installTerraform(): ProvResult = def {
// -------------------------------------------- AWS credentials file ----------------------------------------------- // -------------------------------------------- AWS credentials file -----------------------------------------------
fun Prov.installAwsCredentials(id: String = "REPLACE_WITH_YOUR_ID", key: String = "REPLACE_WITH_YOUR_KEY"): ProvResult = def { fun Prov.installAwsCredentials(id: String = "REPLACE_WITH_YOUR_ID", key: String = "REPLACE_WITH_YOUR_KEY"): ProvResult =
val dir = "~/.aws" def {
val dir = "~/.aws"
if (!dirExists(dir)) { if (!dirExists(dir)) {
createDirs(dir) createDirs(dir)
createFile("~/.aws/config", awsConfig()) createFile("~/.aws/config", awsConfig())
createFile("~/.aws/credentials", awsCredentials(id, key)) createFile("~/.aws/credentials", awsCredentials(id, key))
} else { } else {
ProvResult(true, "aws credential folder already installed") ProvResult(true, "aws credential folder already installed")
}
} }
}
fun awsConfig(): String { fun awsConfig(): String {
return """ return """

View file

@ -1,3 +1,7 @@
#!/bin/sh
set -e
set -o noglob
function main() { function main() {
local cluster_name="${1}"; shift local cluster_name="${1}"; shift

View file

@ -0,0 +1,11 @@
#!/bin/bash
set -e
set -o noglob
function main() {
local cluster_name="${1}"; shift
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.meissa-gmbh.de -L 8002:localhost:8002 -L 6443:192.168.5.1:6443
}
main $1

View file

@ -0,0 +1,11 @@
#!/bin/bash
set -e
set -o noglob
function main() {
local cluster_name="${1}"; shift
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${cluster_name}.meissa-gmbh.de
}
main $1