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,22 +59,25 @@ fun Prov.installKubectlAndTools(): ProvResult = def {
}
}
task("install tunnel alias") {
val tunnelAliasFile = "~/.bashrc.d/ssh_alias.sh"
if (!fileExists(tunnelAliasFile)) {
val tunnelAlias = """
alias sshu='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
alias ssht='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -L 8002:localhost:8002 -L 6443:192.168.5.1:6443'
""".trimIndent()
createFile(tunnelAliasFile, tunnelAlias, "640")
} else {
ProvResult(true, out = "tunnel alias already installed")
}
task("install ssh helper") {
createFileFromResource(
"/usr/local/bin/sshu.sh",
"sshu.sh",
resourcePath,
"555",
sudo = true
)
createFileFromResource(
"/usr/local/bin/ssht.sh",
"ssht.sh",
resourcePath,
"555",
sudo = true
)
}
task("install k8sCreateContext") {
val k8sContextFile = "/usr/local/bin/k8s-create-context.sh"
if (!fileExists(k8sContextFile)) {
createFileFromResource(
k8sContextFile,
"k8s-create-context.sh",
@ -82,9 +85,7 @@ fun Prov.installKubectlAndTools(): ProvResult = def {
"555",
sudo = true
)
} else {
ProvResult(true)
}
}
}
@ -104,7 +105,8 @@ fun Prov.installTerraform(): ProvResult = def {
// -------------------------------------------- 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 =
def {
val dir = "~/.aws"
if (!dirExists(dir)) {
@ -114,7 +116,7 @@ fun Prov.installAwsCredentials(id: String = "REPLACE_WITH_YOUR_ID", key: String
} else {
ProvResult(true, "aws credential folder already installed")
}
}
}
fun awsConfig(): String {
return """

View file

@ -1,3 +1,7 @@
#!/bin/sh
set -e
set -o noglob
function main() {
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